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 org.ametys.plugins.repository.AmetysObjectIterable;
019import org.ametys.plugins.repository.AmetysRepositoryException;
020import org.ametys.plugins.repository.TraversableAmetysObject;
021import org.ametys.plugins.repository.UnknownAmetysObjectException;
022import org.ametys.plugins.repository.data.holder.ModelAwareDataHolder;
023import org.ametys.web.repository.SiteAwareAmetysObject;
024import org.ametys.web.repository.sitemap.Sitemap;
025
026/**
027 * {@link TraversableAmetysObject} containing pages and which knows about its current site and sitemap, template, zones...
028 */
029public interface SitemapElement extends TraversableAmetysObject, SiteAwareAmetysObject
030{
031    /**
032     * Retrieves the title.
033     * @return the title.
034     * @throws AmetysRepositoryException if an error occurs.
035     */
036    String getTitle() throws AmetysRepositoryException;
037
038    /**
039     * Retrieves the sitemap containing the current sitemap.
040     * @return the sitemap containing the current sitemap.
041     * @throws AmetysRepositoryException if an error occurs.
042     */
043    Sitemap getSitemap() throws AmetysRepositoryException;
044    
045    /**
046     * Returns this page's sitemap name
047     * @return this page's sitemap name
048     * @throws AmetysRepositoryException if an error occurs.
049     */
050    public String getSitemapName() throws AmetysRepositoryException;
051    
052    /**
053     * Computes the path relative to the current sitemap.
054     * @return the path relative to the current sitemap.
055     * @throws AmetysRepositoryException if an error occurs.
056     */
057    String getPathInSitemap() throws AmetysRepositoryException;
058    
059    /**
060     * Retrieves child pages.
061     * @return the child pages.
062     * @throws AmetysRepositoryException if an error occurs.
063     */
064    AmetysObjectIterable<? extends Page> getChildrenPages() throws AmetysRepositoryException;
065 
066    /**
067     * Retrieves child pages.
068     * @param includeInvisiblePages true to include invisible pages
069     * @return the child pages.
070     * @throws AmetysRepositoryException if an error occurs.
071     */
072    AmetysObjectIterable<? extends Page> getChildrenPages(boolean includeInvisiblePages) throws AmetysRepositoryException;
073    
074    /**
075     * Gets the child {@link Page} at the given position
076     * @param index the position of the {@link Page} within the ordered set of its sibling objects.
077     * @return the {@link Page} if found
078     * @throws AmetysRepositoryException if an error occurs
079     * @throws UnknownAmetysObjectException if no child page was found at this position
080     */
081    Page getChildPageAt(int index) throws UnknownAmetysObjectException, AmetysRepositoryException;
082    
083    /**
084     * Retrieves the template name.
085     * @return the template name or <code>null</code> if none has
086     *         been set or if the type is not container.
087     * @throws AmetysRepositoryException if an error occurs.
088     */
089    String getTemplate() throws AmetysRepositoryException;    
090    
091    /**
092     * Get the view parameters
093     * @return the view parameters. Can be null.
094     * @throws AmetysRepositoryException if an error occurs.
095     */
096    ModelAwareDataHolder getTemplateParametersHolder() throws AmetysRepositoryException;
097
098    /**
099     * Retrieves the zones.
100     * @return the zones.
101     * @throws AmetysRepositoryException if an error occurs.
102     */
103    AmetysObjectIterable<? extends Zone> getZones() throws AmetysRepositoryException;
104    
105    /**
106     * Determine if a zone exists
107     * @param name The name of the zone
108     * @return true if the zone exists
109     * @throws AmetysRepositoryException If an error occured
110     */
111    boolean hasZone(String name) throws AmetysRepositoryException;
112    
113    /**
114     * Retrieves a given zone.
115     * @param name the name of the zone.
116     * @return the given zone.
117     * @throws UnknownZoneException if there is no zone for the given name.
118     * @throws AmetysRepositoryException if an error occurs.
119     */
120    Zone getZone(String name) throws UnknownZoneException, AmetysRepositoryException;
121}