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.cms.repository.Content;
019import org.ametys.plugins.repository.AmetysRepositoryException;
020import org.ametys.plugins.repository.metadata.CompositeMetadata;
021import org.ametys.plugins.repository.metadata.MetadataAwareAmetysObject;
022
023/**
024 * A {@link ZoneItem} is an ordered part of {@link Zone}
025 * It can be a content ref or a service  
026 */
027public interface ZoneItem extends MetadataAwareAmetysObject
028{
029    /** Type of an zone. */
030    public enum ZoneType
031    {
032        /** Content zone. */
033        CONTENT,
034        /** Service zone. */
035        SERVICE
036    }
037    
038    /**
039     * Retrieves the type.<br>
040     * @return the type.
041     * @throws AmetysRepositoryException if an error occurs.
042     * @see ZoneType
043     */
044    public ZoneType getType() throws AmetysRepositoryException;
045
046    /**
047     * Retrieves the content reference.
048     * @param <C> the actual type of {@link Content}.
049     * @return the service id.
050     * @throws AmetysRepositoryException if an error occurs.
051     */
052    public <C extends Content> C getContent() throws AmetysRepositoryException;
053
054    /**
055     * Get the name of the metadata set to render the Content with. It only makes sense if the ZoneItem is a Content reference.<br>
056     * If null is returned, in most cases, "main" should be assumed.
057     * @return the metadata set name, or null if not set.
058     * @throws AmetysRepositoryException if an error occurs.
059     */
060    public String getMetadataSetName() throws AmetysRepositoryException;
061    
062    /**
063     * Retrieves the service id.
064     * @return the service id.
065     * @throws AmetysRepositoryException if an error occurs.
066     */
067    public String getServiceId() throws AmetysRepositoryException;
068
069    /**
070     * Get the service parameters
071     * @return the service parameters
072     * @throws AmetysRepositoryException if an error occurs.
073     */
074    public CompositeMetadata getServiceParameters () throws AmetysRepositoryException;
075    
076    /**
077     * Get the parent zone.
078     * @return the parent zone of the zone item. cannot be null
079     */
080    public Zone getZone();
081}