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.data.ametysobject.ModelLessDataAwareAmetysObject; 021import org.ametys.plugins.repository.data.holder.ModelAwareDataHolder; 022import org.ametys.plugins.repository.data.holder.ModifiableModelAwareDataHolder; 023 024/** 025 * A {@link ZoneItem} is an ordered part of {@link Zone} 026 * It can be a content ref or a service 027 */ 028public interface ZoneItem extends ModelLessDataAwareAmetysObject 029{ 030 /** Constant for the name of the data containing the service parameters. */ 031 public static final String SERVICE_PARAMETERS_DATA_NAME = "service_parameters"; 032 033 /** Type of an zone. */ 034 public enum ZoneType 035 { 036 /** Content zone. */ 037 CONTENT, 038 /** Service zone. */ 039 SERVICE 040 } 041 042 /** 043 * Retrieves the type.<br> 044 * @return the type. 045 * @throws AmetysRepositoryException if an error occurs. 046 * @see ZoneType 047 */ 048 public ZoneType getType() throws AmetysRepositoryException; 049 050 /** 051 * Retrieves the content reference. 052 * @param <C> the actual type of {@link Content}. 053 * @return the service id. 054 * @throws AmetysRepositoryException if an error occurs. 055 */ 056 public <C extends Content> C getContent() throws AmetysRepositoryException; 057 058 /** 059 * Get the name of the view to render the Content with. It only makes sense if the ZoneItem is a Content reference.<br> 060 * If null is returned, in most cases, "main" should be assumed. 061 * @return the view name, or null if not set. 062 * @throws AmetysRepositoryException if an error occurs. 063 * TODO NEWATTRIBUTEAPI_SERVICE: remove the default implementation when all zone items implement the method 064 */ 065 public default String getViewName() throws AmetysRepositoryException 066 { 067 throw new UnsupportedOperationException(); 068 } 069 070 /** 071 * Retrieves the service id. 072 * @return the service id. 073 * @throws AmetysRepositoryException if an error occurs. 074 */ 075 public String getServiceId() throws AmetysRepositoryException; 076 077 /** 078 * Get the service parameters 079 * @return the service parameters 080 * @throws AmetysRepositoryException if an error occurs. 081 */ 082 public ModelAwareDataHolder getServiceParameters() throws AmetysRepositoryException; 083 084 /** 085 * Get the view parameters 086 * @return the view parameters 087 * @throws AmetysRepositoryException if an error occurs. 088 */ 089 public ModelAwareDataHolder getZoneItemParametersHolder() throws AmetysRepositoryException; 090 091 /** 092 * Get the parent zone. 093 * @return the parent zone of the zone item. cannot be null 094 */ 095 public Zone getZone(); 096 097 /** 098 * Get the content view parameters for a given view 099 * @param contentViewName the view name 100 * @return the content view parameters 101 * @throws AmetysRepositoryException if an error occurs. 102 */ 103 public ModelAwareDataHolder getContentViewParametersHolder(String contentViewName) throws AmetysRepositoryException; 104 105 /** 106 * Get the service view parameters for a given view 107 * @param serviceViewName the view name 108 * @return the service view parameters 109 * @throws AmetysRepositoryException if an error occurs. 110 */ 111 public ModelAwareDataHolder getServiceViewParametersHolder(String serviceViewName) throws AmetysRepositoryException; 112}