001/*
002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     bstefanescu
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.webengine.model;
021
022import java.text.ParseException;
023import java.util.List;
024import java.util.Set;
025
026import javax.ws.rs.core.Response;
027
028import org.nuxeo.runtime.model.Adaptable;
029
030/**
031 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
032 */
033public interface Resource extends Adaptable {
034
035    Resource initialize(WebContext ctx, ResourceType type, Object... args);
036
037    void dispose();
038
039    WebContext getContext();
040
041    Module getModule();
042
043    ResourceType getType();
044
045    boolean isInstanceOf(String type);
046
047    String getName();
048
049    String getPath();
050
051    String getTrailingPath();
052
053    String getNextSegment();
054
055    String getURL();
056
057    Resource getPrevious();
058
059    Resource getNext();
060
061    void setNext(Resource next);
062
063    void setPrevious(Resource previous);
064
065    boolean isAdapter();
066
067    boolean isRoot();
068
069    void setRoot(boolean isRoot);
070
071    Set<String> getFacets();
072
073    boolean hasFacet(String facet);
074
075    List<LinkDescriptor> getLinks(String category);
076
077    Resource newObject(String type, Object... args);
078
079    AdapterResource newAdapter(String type, Object... args);
080
081    Template getView(String viewId);
082
083    Template getTemplate(String fileName);
084
085    Response redirect(String uri);
086
087    /**
088     * Returns the active Adapter on this object if any in the current request.
089     *
090     * @return the service instance or null
091     */
092    AdapterResource getActiveAdapter();
093
094    /**
095     * Checks the given guard expression in the context of this resource.
096     */
097    boolean checkGuard(String guard) throws ParseException;
098
099    // Response getEntries();
100
101}