Class DefaultZoneItem
- java.lang.Object
-
- org.ametys.plugins.repository.AbstractAmetysObject
-
- org.ametys.plugins.repository.jcr.SimpleAmetysObject<DefaultZoneItemFactory>
-
- org.ametys.web.repository.page.jcr.DefaultZoneItem
-
- All Implemented Interfaces:
AmetysObject,CopiableAmetysObject,DataAwareAmetysObject,ModelLessDataAwareAmetysObject,ModifiableModelLessDataAwareAmetysObject,DataHolder,ModelLessDataHolder,ModifiableDataHolder,ModifiableModelLessDataHolder,JCRAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableAmetysObject,MovableAmetysObject,RemovableAmetysObject,ModifiableZoneItem,ZoneItem
public class DefaultZoneItem extends SimpleAmetysObject<DefaultZoneItemFactory> implements ModifiableZoneItem, CopiableAmetysObject
implementation of aModifiableZoneItem.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.web.repository.page.ZoneItem
ZoneItem.ZoneType
-
-
Field Summary
Fields Modifier and Type Field Description static StringMETADATA_CONTENTConstant for content metadata.static StringMETADATA_METADATASET_NAMEDeprecated.UseMETADATA_VIEW_NAMEinsteadstatic StringMETADATA_SERVICEConstant for service metadata.static StringMETADATA_TYPEConstant for title metadata.static StringMETADATA_VIEW_NAMEConstant for view name metadata.static StringSERVICE_PARAM_NODETYPEConstant service parameters node type.-
Fields inherited from interface org.ametys.web.repository.page.ZoneItem
SERVICE_PARAMETERS_DATA_NAME
-
-
Constructor Summary
Constructors Constructor Description DefaultZoneItem(Node node, String parentPath, DefaultZoneItemFactory factory)Creates aDefaultZoneItem.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ModifiableRepositoryData_getServiceParametersRepositoryData()Retrieves theModifiableRepositoryDatacontaining the service parameters of this zone itembooleancanMoveTo(AmetysObject newParent)Test if a move can be a success or if it is impossible (e.g.ModifiableZoneItemcopyTo(ModifiableTraversableAmetysObject parent, String name)Copy the currentAmetysObjectto the given object.ModifiableZoneItemcopyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo)Copy the currentAmetysObjectto the given object if it is not in the restriction list.voiddataToSAX(ContentHandler contentHandler, String dataPath, DataContext context)Generates SAX events for the data at the given data path in the currentDataHolderDo not generate any event if there is no values at the given pathvoiddataToSAX(ContentHandler contentHandler, DataContext context)Generates SAX events for data contained in thisDataHolder<C extends Content>
CgetContent()Retrieves the content reference.ModifiableModelAwareDataHoldergetContentViewParametersHolder(String contentViewName)Get the content view parameters for a given viewModifiableModelLessDataHoldergetDataHolder()Returns theDataHolderof thisAmetysObject.ModifiableCompositeMetadatagetMetadataHolder()Returns the rootCompositeMetadataof thisAmetysObject.StringgetServiceId()Retrieves the service id.ModifiableModelAwareDataHoldergetServiceParameters()Get the service parametersModifiableModelAwareDataHoldergetServiceViewParametersHolder(String serviceViewName)Get the service view parameters for a given viewZoneItem.ZoneTypegetType()Retrieves the type.StringgetViewName()Get the name of the view to render the Content with.ZonegetZone()Get the parent zone.ModifiableModelAwareDataHoldergetZoneItemParametersHolder()Get the view parametersvoidmoveTo(AmetysObject newParent, boolean renameIfExist)Move the current object as a new child of the given object.voidorderBefore(AmetysObject siblingObject)Order a node before another sibling node (or as the last node)<C extends Content>
voidsetContent(C content)Set the content reference.voidsetServiceId(String serviceId)Set the service id.voidsetType(ZoneItem.ZoneType type)Set the type.voidsetViewName(String viewName)Set the Content view name.-
Methods inherited from class org.ametys.plugins.repository.jcr.SimpleAmetysObject
_getFactory, _invalidateName, _invalidateParentPath, getId, getName, getNode, getParent, getParentPath, getPath, needsSave, remove, rename, revertChanges, saveChanges
-
Methods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCode
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.DataAwareAmetysObject
copyTo, dataToSAX, getDataNames, getRepositoryData
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelLessDataAwareAmetysObject
getComposite, getParentDataHolder, getRootDataHolder, getType, getValue, getValue, getValueOfType, getValueOfType, hasValue, hasValueOrEmpty, isMultiple
-
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToSAX, hasValue, hasValueOrEmpty
-
Methods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChanges
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModifiableModelLessDataAwareAmetysObject
getComposite, getComposite, getParentDataHolder, getRepositoryData, getRootDataHolder, removeValue, setValue, setValue, synchronizeValues
-
Methods inherited from interface org.ametys.plugins.repository.RemovableAmetysObject
remove
-
-
-
-
Field Detail
-
METADATA_TYPE
public static final String METADATA_TYPE
Constant for title metadata.- See Also:
- Constant Field Values
-
METADATA_SERVICE
public static final String METADATA_SERVICE
Constant for service metadata.- See Also:
- Constant Field Values
-
METADATA_CONTENT
public static final String METADATA_CONTENT
Constant for content metadata.- See Also:
- Constant Field Values
-
SERVICE_PARAM_NODETYPE
public static final String SERVICE_PARAM_NODETYPE
Constant service parameters node type.- See Also:
- Constant Field Values
-
METADATA_METADATASET_NAME
@Deprecated public static final String METADATA_METADATASET_NAME
Deprecated.UseMETADATA_VIEW_NAMEinsteadConstant for "metadata set name" metadata.- See Also:
- Constant Field Values
-
METADATA_VIEW_NAME
public static final String METADATA_VIEW_NAME
Constant for view name metadata. TODO NEWATTRIBUTEAPI_SERVICE: Change the name of this metadata to viewName (there may be a lot of impacts..)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultZoneItem
public DefaultZoneItem(Node node, String parentPath, DefaultZoneItemFactory factory)
Creates aDefaultZoneItem.- Parameters:
node- the node backing thisAmetysObject.parentPath- the parent path in the Ametys hierarchy.factory- theDefaultZoneItemFactorywhich creates the AmetysObject.
-
-
Method Detail
-
getType
public ZoneItem.ZoneType getType() throws AmetysRepositoryException
Description copied from interface:ZoneItemRetrieves the type.- Specified by:
getTypein interfaceZoneItem- Returns:
- the type.
- Throws:
AmetysRepositoryException- if an error occurs.- See Also:
ZoneItem.ZoneType
-
setType
public void setType(ZoneItem.ZoneType type) throws AmetysRepositoryException
Description copied from interface:ModifiableZoneItemSet the type.- Specified by:
setTypein interfaceModifiableZoneItem- Parameters:
type- the type.- Throws:
AmetysRepositoryException- if an error occurs.- See Also:
ZoneItem.ZoneType
-
getContent
public <C extends Content> C getContent() throws AmetysRepositoryException
Description copied from interface:ZoneItemRetrieves the content reference.- Specified by:
getContentin interfaceZoneItem- Type Parameters:
C- the actual type ofContent.- Returns:
- the service id.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setContent
public <C extends Content> void setContent(C content) throws AmetysRepositoryException
Description copied from interface:ModifiableZoneItemSet the content reference.- Specified by:
setContentin interfaceModifiableZoneItem- Type Parameters:
C- the actual type ofContent.- Parameters:
content- the content.- Throws:
AmetysRepositoryException- if an error occurs.
-
getViewName
public String getViewName() throws AmetysRepositoryException
Description copied from interface:ZoneItemGet the name of the view to render the Content with. It only makes sense if the ZoneItem is a Content reference.
If null is returned, in most cases, "main" should be assumed.- Specified by:
getViewNamein interfaceZoneItem- Returns:
- the view name, or null if not set.
- Throws:
AmetysRepositoryException- if an error occurs. TODO NEWATTRIBUTEAPI_SERVICE: remove the default implementation when all zone items implement the method
-
setViewName
public void setViewName(String viewName) throws AmetysRepositoryException
Description copied from interface:ModifiableZoneItemSet the Content view name.- Specified by:
setViewNamein interfaceModifiableZoneItem- Parameters:
viewName- the view name.- Throws:
AmetysRepositoryException- if an error occurs.
-
getServiceId
public String getServiceId() throws AmetysRepositoryException
Description copied from interface:ZoneItemRetrieves the service id.- Specified by:
getServiceIdin interfaceZoneItem- Returns:
- the service id.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setServiceId
public void setServiceId(String serviceId) throws AmetysRepositoryException
Description copied from interface:ModifiableZoneItemSet the service id.- Specified by:
setServiceIdin interfaceModifiableZoneItem- Parameters:
serviceId- the service id.- Throws:
AmetysRepositoryException- if an error occurs.
-
getServiceParameters
public ModifiableModelAwareDataHolder getServiceParameters() throws AmetysRepositoryException, IllegalStateException
Get the service parameters- Specified by:
getServiceParametersin interfaceModifiableZoneItem- Specified by:
getServiceParametersin interfaceZoneItem- Returns:
- the service parameters
- Throws:
IllegalStateException- if the service referenced by this zone item does not existAmetysRepositoryException- if an error occurs.
-
_getServiceParametersRepositoryData
protected ModifiableRepositoryData _getServiceParametersRepositoryData()
Retrieves theModifiableRepositoryDatacontaining the service parameters of this zone item- Returns:
- the
ModifiableRepositoryDatacontaining the service parameters of this zone item
-
getZoneItemParametersHolder
public ModifiableModelAwareDataHolder getZoneItemParametersHolder() throws AmetysRepositoryException
Description copied from interface:ZoneItemGet the view parameters- Specified by:
getZoneItemParametersHolderin interfaceModifiableZoneItem- Specified by:
getZoneItemParametersHolderin interfaceZoneItem- Returns:
- the view parameters
- Throws:
AmetysRepositoryException- if an error occurs.
-
getDataHolder
public ModifiableModelLessDataHolder getDataHolder()
Description copied from interface:DataAwareAmetysObjectReturns theDataHolderof thisAmetysObject.- Specified by:
getDataHolderin interfaceDataAwareAmetysObject- Specified by:
getDataHolderin interfaceModelLessDataAwareAmetysObject- Specified by:
getDataHolderin interfaceModifiableModelLessDataAwareAmetysObject- Returns:
- the
DataHolderof thisAmetysObject
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, DataContext context) throws SAXException, UnknownTypeException, NotUniqueTypeException
Description copied from interface:ModelLessDataHolderGenerates SAX events for data contained in thisDataHolder- Specified by:
dataToSAXin interfaceModelLessDataAwareAmetysObject- Specified by:
dataToSAXin interfaceModelLessDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventscontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationUnknownTypeException- if there is no compatible type with the saxed valueNotUniqueTypeException- if there are many compatible types (there is no way to determine which type is the good one) with the saxed value
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) throws SAXException
Description copied from interface:DataHolderGenerates SAX events for the data at the given data path in the currentDataHolderDo not generate any event if there is no values at the given path- Specified by:
dataToSAXin interfaceDataAwareAmetysObject- Specified by:
dataToSAXin interfaceDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsdataPath- the path of the data to SAXcontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generation
-
getMetadataHolder
public ModifiableCompositeMetadata getMetadataHolder()
Description copied from class:SimpleAmetysObjectReturns the rootCompositeMetadataof thisAmetysObject.- Specified by:
getMetadataHolderin interfaceMetadataAwareAmetysObject- Specified by:
getMetadataHolderin interfaceModifiableMetadataAwareAmetysObject- Overrides:
getMetadataHolderin classSimpleAmetysObject<DefaultZoneItemFactory>- Returns:
- the root
CompositeMetadataof thisAmetysObject
-
copyTo
public ModifiableZoneItem copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObjectCopy the currentAmetysObjectto the given object if it is not in the restriction list. Be careful, this method save changes.- Specified by:
copyToin interfaceCopiableAmetysObject- Parameters:
parent- The parent of the new object. Can not be null.name- Name of the new object. Can be null. If null, the new name will be get from the copied objectrestrictTo- A restrict list ofCopiableAmetysObjectauthorized to be copied- Returns:
- the created object
- Throws:
AmetysRepositoryException- if an error occurs.
-
copyTo
public ModifiableZoneItem copyTo(ModifiableTraversableAmetysObject parent, String name) throws AmetysRepositoryException
Description copied from interface:CopiableAmetysObjectCopy the currentAmetysObjectto the given object. Be careful, this method save changes.- Specified by:
copyToin interfaceCopiableAmetysObject- Parameters:
parent- The parent of the new object. Can not be null.name- Name of the new object. Can be null. If null, the new name will be get from the copied object- Returns:
- the created object
- Throws:
AmetysRepositoryException- if an error occurs.
-
canMoveTo
public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObjectTest if a move can be a success or if it is impossible (e.g. due to the implementation of the target)- Specified by:
canMoveToin interfaceMovableAmetysObject- Parameters:
newParent- See moveTo.- Returns:
- true if the move operation may succeed. If false is returned and you call moveTo anyway, you may encontered a RuntimeException (such as UnsupportedOperationException)
- Throws:
AmetysRepositoryException- if an error occurs.
-
moveTo
public void moveTo(AmetysObject newParent, boolean renameIfExist) throws AmetysRepositoryException, RepositoryIntegrityViolationException
Description copied from interface:MovableAmetysObjectMove the current object as a new child of the given object. This node will be the last child. You should call canMoveTo to know if this is a supported operation.- Specified by:
moveToin interfaceMovableAmetysObject- Parameters:
newParent- The new parent for the current object. Can not be null. Can not be a child of the current node. Must be a TraversableAmetyObject.renameIfExist- true to rename moved page if a page with same name already exist- Throws:
AmetysRepositoryException- if an error occurs.RepositoryIntegrityViolationException- if a page with the same name already exists.
-
orderBefore
public void orderBefore(AmetysObject siblingObject) throws AmetysRepositoryException
Description copied from interface:MovableAmetysObjectOrder a node before another sibling node (or as the last node)- Specified by:
orderBeforein interfaceMovableAmetysObject- Parameters:
siblingObject- The node that will be the next sibling node of the current node. Must have the same parent as the current node. Can be null to set the current node as the last node.- Throws:
AmetysRepositoryException- if an error occurs.
-
getContentViewParametersHolder
public ModifiableModelAwareDataHolder getContentViewParametersHolder(String contentViewName) throws AmetysRepositoryException
Description copied from interface:ZoneItemGet the content view parameters for a given view- Specified by:
getContentViewParametersHolderin interfaceModifiableZoneItem- Specified by:
getContentViewParametersHolderin interfaceZoneItem- Parameters:
contentViewName- the view name- Returns:
- the content view parameters
- Throws:
AmetysRepositoryException- if an error occurs.
-
getServiceViewParametersHolder
public ModifiableModelAwareDataHolder getServiceViewParametersHolder(String serviceViewName) throws AmetysRepositoryException
Description copied from interface:ZoneItemGet the service view parameters for a given view- Specified by:
getServiceViewParametersHolderin interfaceModifiableZoneItem- Specified by:
getServiceViewParametersHolderin interfaceZoneItem- Parameters:
serviceViewName- the view name- Returns:
- the service view parameters
- Throws:
AmetysRepositoryException- if an error occurs.
-
-