001/*
002 *  Copyright 2010 Anyware Services
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 */
016package org.ametys.web.repository.page;
017
018import java.util.Set;
019
020import org.ametys.plugins.explorer.resources.ResourceCollection;
021import org.ametys.plugins.repository.AmetysObject;
022import org.ametys.plugins.repository.AmetysObjectIterable;
023import org.ametys.plugins.repository.AmetysRepositoryException;
024import org.ametys.plugins.repository.data.holder.ModelAwareDataHolder;
025import org.ametys.plugins.repository.tag.TagAwareAmetysObject;
026
027/**
028 * {@link AmetysObject} for reading page informations.<p>
029 */
030public interface Page extends MetadataAwarePagesContainer, TagAwareAmetysObject
031{
032    /** Type of a page. */
033    public enum PageType
034    {
035        /** Empty page (no zone, nor link) */
036        NODE,
037        /** Link page. */
038        LINK,
039        /** Multiple zone (content, service) page. */
040        CONTAINER
041    }
042
043    /** Type of a link page. */
044    public enum LinkType
045    {
046        /** External page */
047        WEB,
048        /** Internal page */
049        PAGE
050    }
051
052    /**
053     * Retrieves the title.
054     * @return the title.
055     * @throws AmetysRepositoryException if an error occurs.
056     */
057    String getTitle() throws AmetysRepositoryException;
058
059    /**
060     * Retrieves the long title.
061     * @return the title.
062     * @throws AmetysRepositoryException if an error occurs.
063     */
064    String getLongTitle() throws AmetysRepositoryException;
065
066    /**
067     * Retrieves the type.<br>
068     * @return the type.
069     * @throws AmetysRepositoryException if an error occurs.
070     * @see PageType
071     */
072    PageType getType() throws AmetysRepositoryException;
073
074    /**
075     * Retrieves the linked URL.
076     * @return the linked URL.
077     * @throws AmetysRepositoryException if an error occurs.
078     */
079    String getURL() throws AmetysRepositoryException;
080
081    /**
082     * Retrieves the linked URL type.
083     * @return the linked URL type.
084     * @throws AmetysRepositoryException if an error occurs.
085     */
086    LinkType getURLType() throws AmetysRepositoryException;
087
088    /**
089     * Get the page depth
090     * @return the page depth
091     * @throws AmetysRepositoryException if an error occurs.
092     */
093    int getDepth () throws AmetysRepositoryException;
094    
095    /**
096     * Retrieves the template name.
097     * @return the template name or <code>null</code> if none has
098     *         been set.
099     * @throws AmetysRepositoryException if an error occurs.
100     */
101    String getTemplate() throws AmetysRepositoryException;
102
103    /**
104     * Retrieves the zones.
105     * @return the zones.
106     * @throws AmetysRepositoryException if an error occurs.
107     */
108    AmetysObjectIterable<? extends Zone> getZones() throws AmetysRepositoryException;
109    
110    /**
111     * Determine if a zone exists
112     * @param name The name of the zone
113     * @return true if the zone exists
114     * @throws AmetysRepositoryException If an error occured
115     */
116    boolean hasZone(String name) throws AmetysRepositoryException;
117    
118    /**
119     * Retrieves a given zone.
120     * @param name the name of the zone.
121     * @return the given zone.
122     * @throws UnknownZoneException if there is no zone for the given name.
123     * @throws AmetysRepositoryException if an error occurs.
124     */
125    Zone getZone(String name) throws UnknownZoneException, AmetysRepositoryException;
126
127    /**
128     * Retrieves the attachments root node
129     * @return The the attachments root node
130     * @throws AmetysRepositoryException if an error occurs.
131     */
132    ResourceCollection getRootAttachments()  throws AmetysRepositoryException;
133    
134    /**
135     * Retrieves all {@link AmetysObject} ids referencing this page.
136     * @return the {@link AmetysObject} ids referencing this page.
137     * @throws AmetysRepositoryException if an error occurs.
138     */
139    Set<String> getReferers() throws AmetysRepositoryException;
140    
141    /**
142     * Determine if the page is visible into navigation elements
143     * @return true if the page is visible.
144     * @throws AmetysRepositoryException if an error occurs.
145     */
146    boolean isVisible() throws AmetysRepositoryException;
147    
148    /**
149     * Get the view parameters
150     * @return the view parameters
151     * @throws AmetysRepositoryException if an error occurs.
152     */
153    ModelAwareDataHolder getTemplateParametersHolder() throws AmetysRepositoryException;
154}