001/*
002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     bstefanescu
018 *
019 * $Id$
020 */
021
022package org.nuxeo.ecm.webengine.model;
023
024import java.text.ParseException;
025import java.util.List;
026import java.util.Set;
027
028import javax.ws.rs.core.Response;
029
030import org.nuxeo.runtime.model.Adaptable;
031
032/**
033 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
034 */
035public interface Resource extends Adaptable {
036
037    Resource initialize(WebContext ctx, ResourceType type, Object... args);
038
039    void dispose();
040
041    WebContext getContext();
042
043    Module getModule();
044
045    ResourceType getType();
046
047    boolean isInstanceOf(String type);
048
049    String getName();
050
051    String getPath();
052
053    String getTrailingPath();
054
055    String getNextSegment();
056
057    String getURL();
058
059    Resource getPrevious();
060
061    Resource getNext();
062
063    void setNext(Resource next);
064
065    void setPrevious(Resource previous);
066
067    boolean isAdapter();
068
069    boolean isRoot();
070
071    void setRoot(boolean isRoot);
072
073    Set<String> getFacets();
074
075    boolean hasFacet(String facet);
076
077    List<LinkDescriptor> getLinks(String category);
078
079    Resource newObject(String type, Object... args);
080
081    AdapterResource newAdapter(String type, Object... args);
082
083    Template getView(String viewId);
084
085    Template getTemplate(String fileName);
086
087    Response redirect(String uri);
088
089    /**
090     * Returns the active Adapter on this object if any in the current request.
091     *
092     * @return the service instance or null
093     */
094    AdapterResource getActiveAdapter();
095
096    /**
097     * Checks the given guard expression in the context of this resource.
098     */
099    boolean checkGuard(String guard) throws ParseException;
100
101    // Response getEntries();
102
103}