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.web.repository.SiteAwareAmetysObject;
023import org.ametys.web.repository.sitemap.Sitemap;
024
025/**
026 * {@link TraversableAmetysObject} containing pages and which knows about its current site and sitemap.
027 */
028public interface PagesContainer extends TraversableAmetysObject, SiteAwareAmetysObject
029{
030    /**
031     * Retrieves the sitemap containing the current sitemap.
032     * @return the sitemap containing the current sitemap.
033     * @throws AmetysRepositoryException if an error occurs.
034     */
035    Sitemap getSitemap() throws AmetysRepositoryException;
036    
037    /**
038     * Returns this page's sitemap name
039     * @return this page's sitemap name
040     * @throws AmetysRepositoryException if an error occurs.
041     */
042    public String getSitemapName() throws AmetysRepositoryException;
043    
044    /**
045     * Computes the path relative to the current sitemap.
046     * @return the path relative to the current sitemap.
047     * @throws AmetysRepositoryException if an error occurs.
048     */
049    String getPathInSitemap() throws AmetysRepositoryException;
050    
051    /**
052     * Retrieves child pages.
053     * @return the child pages.
054     * @throws AmetysRepositoryException if an error occurs.
055     */
056    AmetysObjectIterable<? extends Page> getChildrenPages() throws AmetysRepositoryException;
057 
058    /**
059     * Retrieves child pages.
060     * @param includeInvisiblePages true to include invisible pages
061     * @return the child pages.
062     * @throws AmetysRepositoryException if an error occurs.
063     */
064    AmetysObjectIterable<? extends Page> getChildrenPages(boolean includeInvisiblePages) throws AmetysRepositoryException;
065    
066    /**
067     * Gets the child {@link Page} at the given position
068     * @param index the position of the {@link Page} within the ordered set of its sibling objects.
069     * @return the {@link Page} if found
070     * @throws AmetysRepositoryException if an error occurs
071     * @throws UnknownAmetysObjectException if no child page was found at this position
072     */
073    Page getChildPageAt(int index) throws UnknownAmetysObjectException, AmetysRepositoryException;
074}