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