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 a
ModifiableZoneItem.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.web.repository.page.ZoneItem
ZoneItem.ZoneType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant for content metadata.static final StringConstant for service metadata.static final StringConstant for title metadata.static final StringConstant for view name metadata.static final StringConstant service parameters node type.Fields inherited from interface org.ametys.web.repository.page.ZoneItem
SERVICE_PARAMETERS_DATA_NAME -
Constructor Summary
ConstructorsConstructorDescriptionDefaultZoneItem(javax.jcr.Node node, String parentPath, DefaultZoneItemFactory factory) Creates aDefaultZoneItem. -
Method Summary
Modifier and TypeMethodDescriptionprotected ModifiableRepositoryDataRetrieves 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.copyTo(ModifiableTraversableAmetysObject parent, String name) Copy the currentAmetysObjectto the given object.copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) Copy the currentAmetysObjectto the given object if it is not in the restriction list.dataToJSON(String dataPath, DataContext context) Convert the data at the given path into a JSON objectdataToJSON(DataContext context) Convert the data contained in thisDataHoldervoiddataToSAX(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>
CRetrieves the content reference.getContentViewParametersHolder(String contentViewName) Get the content view parameters for a given viewReturns theDataHolderof thisAmetysObject.Returns the rootCompositeMetadataof thisAmetysObject.Retrieves the service id.Get the service parametersgetServiceViewParametersHolder(String serviceViewName) Get the service view parameters for a given viewgetType()Retrieves the type.Get the name of the view to render the Content with.getZone()Get the parent zone.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, saveChangesMethods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
equals, hashCode, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, getId, getName, getParent, getParentPath, getPath, hashCodeMethods inherited from interface org.ametys.plugins.repository.data.ametysobject.DataAwareAmetysObject
copyTo, copyTo, dataToJSON, dataToSAX, getDataNames, getRepositoryDataMethods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelLessDataAwareAmetysObject
getComposite, getModelItemTypeExtensionPoint, getParentDataHolder, getRootDataHolder, getType, getValue, getValue, getValueOfType, getValueOfType, hasDifferences, hasValue, hasValue, hasValueOrEmpty, isMultiple, isMultipleMethods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToJSON, dataToSAX, hasValue, hasValueOrEmptyMethods inherited from interface org.ametys.plugins.repository.ModifiableAmetysObject
needsSave, rename, revertChanges, saveChangesMethods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModifiableModelLessDataAwareAmetysObject
getComposite, getComposite, getParentDataHolder, getRepositoryData, getRootDataHolder, removeValue, setValue, setValue, synchronizeValuesMethods inherited from interface org.ametys.plugins.repository.RemovableAmetysObject
remove
-
Field Details
-
METADATA_TYPE
Constant for title metadata.- See Also:
-
METADATA_SERVICE
Constant for service metadata.- See Also:
-
METADATA_CONTENT
Constant for content metadata.- See Also:
-
SERVICE_PARAM_NODETYPE
Constant service parameters node type.- See Also:
-
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:
-
-
Constructor Details
-
DefaultZoneItem
Creates aDefaultZoneItem.- Parameters:
node- the node backing thisAmetysObject.parentPath- the parent path in the Ametys hierarchy.factory- theDefaultZoneItemFactorywhich creates the AmetysObject.
-
-
Method Details
-
getType
Description copied from interface:ZoneItemRetrieves the type.- Specified by:
getTypein interfaceZoneItem- Returns:
- the type.
- Throws:
AmetysRepositoryException- if an error occurs.- See Also:
-
setType
Description copied from interface:ModifiableZoneItemSet the type.- Specified by:
setTypein interfaceModifiableZoneItem- Parameters:
type- the type.- Throws:
AmetysRepositoryException- if an error occurs.- See Also:
-
getContent
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
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
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
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
Description copied from interface:ZoneItemRetrieves the service id.- Specified by:
getServiceIdin interfaceZoneItem- Returns:
- the service id.
- Throws:
AmetysRepositoryException- if an error occurs.
-
setServiceId
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, IllegalStateExceptionGet 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
Retrieves theModifiableRepositoryDatacontaining the service parameters of this zone item- Returns:
- the
ModifiableRepositoryDatacontaining the service parameters of this zone item
-
getZoneItemParametersHolder
public ModifiableModelAwareDataHolder getZoneItemParametersHolder() throws AmetysRepositoryExceptionDescription 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
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
-
dataToJSON
public Map<String,Object> dataToJSON(DataContext context) throws UnknownTypeException, NotUniqueTypeException Description copied from interface:ModelLessDataHolderConvert the data contained in thisDataHolder- Specified by:
dataToJSONin interfaceModelLessDataAwareAmetysObject- Specified by:
dataToJSONin interfaceModelLessDataHolder- Parameters:
context- The context of the data to convert- Returns:
- The data of the current
DataHolderas JSON - Throws:
UnknownTypeException- if there is no compatible type with the value to convertNotUniqueTypeException- if there are many compatible types (there is no way to determine which type is the good one) with the value to convert
-
dataToJSON
Description copied from interface:DataHolderConvert the data at the given path into a JSON object- Specified by:
dataToJSONin interfaceDataAwareAmetysObject- Specified by:
dataToJSONin interfaceDataHolder- Parameters:
dataPath- the path of the data to convertcontext- The context of the data to convert- Returns:
- The value as JSON
-
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
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
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.
-
getZone
Description copied from interface:ZoneItemGet the parent zone. -
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.
-