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
Modifier and TypeFieldDescriptionstatic final String
Constant for content metadata.static final String
Deprecated.static final String
Constant for service metadata.static final String
Constant for title metadata.static final String
Constant for view name metadata.static final String
Constant service parameters node type.Fields inherited from interface org.ametys.web.repository.page.ZoneItem
SERVICE_PARAMETERS_DATA_NAME
-
Constructor Summary
ConstructorDescriptionDefaultZoneItem
(javax.jcr.Node node, String parentPath, DefaultZoneItemFactory factory) Creates aDefaultZoneItem
. -
Method Summary
Modifier and TypeMethodDescriptionprotected ModifiableRepositoryData
Retrieves theModifiableRepositoryData
containing the service parameters of this zone itemboolean
canMoveTo
(AmetysObject newParent) Test if a move can be a success or if it is impossible (e.g.copyTo
(ModifiableTraversableAmetysObject parent, String name) Copy the currentAmetysObject
to the given object.copyTo
(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) Copy the currentAmetysObject
to 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 thisDataHolder
void
dataToSAX
(ContentHandler contentHandler, String dataPath, DataContext context) Generates SAX events for the data at the given data path in the currentDataHolder
Do not generate any event if there is no values at the given pathvoid
dataToSAX
(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 theDataHolder
of thisAmetysObject
.Returns the rootCompositeMetadata
of 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 parametersvoid
moveTo
(AmetysObject newParent, boolean renameIfExist) Move the current object as a new child of the given object.void
orderBefore
(AmetysObject siblingObject) Order a node before another sibling node (or as the last node)<C extends Content>
voidsetContent
(C content) Set the content reference.void
setServiceId
(String serviceId) Set the service id.void
setType
(ZoneItem.ZoneType type) Set the type.void
setViewName
(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, copyTo, dataToJSON, dataToSAX, getDataNames, getRepositoryData
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelLessDataAwareAmetysObject
getComposite, getModelItemTypeExtensionPoint, getParentDataHolder, getRootDataHolder, getType, getValue, getValue, getValueOfType, getValueOfType, hasDifferences, hasValue, hasValue, hasValueOrEmpty, isMultiple, isMultiple
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToJSON, 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 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_METADATASET_NAME
Deprecated.UseMETADATA_VIEW_NAME
insteadConstant for "metadata set name" metadata.- 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
- theDefaultZoneItemFactory
which creates the AmetysObject.
-
-
Method Details
-
getType
Description copied from interface:ZoneItem
Retrieves the type.- Specified by:
getType
in interfaceZoneItem
- Returns:
- the type.
- Throws:
AmetysRepositoryException
- if an error occurs.- See Also:
-
setType
Description copied from interface:ModifiableZoneItem
Set the type.- Specified by:
setType
in interfaceModifiableZoneItem
- Parameters:
type
- the type.- Throws:
AmetysRepositoryException
- if an error occurs.- See Also:
-
getContent
Description copied from interface:ZoneItem
Retrieves the content reference.- Specified by:
getContent
in interfaceZoneItem
- Type Parameters:
C
- the actual type ofContent
.- Returns:
- the service id.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setContent
Description copied from interface:ModifiableZoneItem
Set the content reference.- Specified by:
setContent
in interfaceModifiableZoneItem
- Type Parameters:
C
- the actual type ofContent
.- Parameters:
content
- the content.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getViewName
Description copied from interface:ZoneItem
Get 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:
getViewName
in 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:ModifiableZoneItem
Set the Content view name.- Specified by:
setViewName
in interfaceModifiableZoneItem
- Parameters:
viewName
- the view name.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getServiceId
Description copied from interface:ZoneItem
Retrieves the service id.- Specified by:
getServiceId
in interfaceZoneItem
- Returns:
- the service id.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
setServiceId
Description copied from interface:ModifiableZoneItem
Set the service id.- Specified by:
setServiceId
in interfaceModifiableZoneItem
- Parameters:
serviceId
- the service id.- Throws:
AmetysRepositoryException
- if an error occurs.
-
getServiceParameters
public ModifiableModelAwareDataHolder getServiceParameters() throws AmetysRepositoryException, IllegalStateExceptionGet the service parameters- Specified by:
getServiceParameters
in interfaceModifiableZoneItem
- Specified by:
getServiceParameters
in interfaceZoneItem
- Returns:
- the service parameters
- Throws:
IllegalStateException
- if the service referenced by this zone item does not existAmetysRepositoryException
- if an error occurs.
-
_getServiceParametersRepositoryData
Retrieves theModifiableRepositoryData
containing the service parameters of this zone item- Returns:
- the
ModifiableRepositoryData
containing the service parameters of this zone item
-
getZoneItemParametersHolder
public ModifiableModelAwareDataHolder getZoneItemParametersHolder() throws AmetysRepositoryExceptionDescription copied from interface:ZoneItem
Get the view parameters- Specified by:
getZoneItemParametersHolder
in interfaceModifiableZoneItem
- Specified by:
getZoneItemParametersHolder
in interfaceZoneItem
- Returns:
- the view parameters
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getDataHolder
Description copied from interface:DataAwareAmetysObject
Returns theDataHolder
of thisAmetysObject
.- Specified by:
getDataHolder
in interfaceDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModelLessDataAwareAmetysObject
- Specified by:
getDataHolder
in interfaceModifiableModelLessDataAwareAmetysObject
- Returns:
- the
DataHolder
of thisAmetysObject
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, DataContext context) throws SAXException, UnknownTypeException, NotUniqueTypeException Description copied from interface:ModelLessDataHolder
Generates SAX events for data contained in thisDataHolder
- Specified by:
dataToSAX
in interfaceModelLessDataAwareAmetysObject
- Specified by:
dataToSAX
in interfaceModelLessDataHolder
- Parameters:
contentHandler
- theContentHandler
that 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:DataHolder
Generates SAX events for the data at the given data path in the currentDataHolder
Do not generate any event if there is no values at the given path- Specified by:
dataToSAX
in interfaceDataAwareAmetysObject
- Specified by:
dataToSAX
in interfaceDataHolder
- Parameters:
contentHandler
- theContentHandler
that 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:ModelLessDataHolder
Convert the data contained in thisDataHolder
- Specified by:
dataToJSON
in interfaceModelLessDataAwareAmetysObject
- Specified by:
dataToJSON
in interfaceModelLessDataHolder
- Parameters:
context
- The context of the data to convert- Returns:
- The data of the current
DataHolder
as 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:DataHolder
Convert the data at the given path into a JSON object- Specified by:
dataToJSON
in interfaceDataAwareAmetysObject
- Specified by:
dataToJSON
in 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:SimpleAmetysObject
Returns the rootCompositeMetadata
of thisAmetysObject
.- Specified by:
getMetadataHolder
in interfaceMetadataAwareAmetysObject
- Specified by:
getMetadataHolder
in interfaceModifiableMetadataAwareAmetysObject
- Overrides:
getMetadataHolder
in classSimpleAmetysObject<DefaultZoneItemFactory>
- Returns:
- the root
CompositeMetadata
of thisAmetysObject
-
copyTo
public ModifiableZoneItem copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo) throws AmetysRepositoryException Description copied from interface:CopiableAmetysObject
Copy the currentAmetysObject
to the given object if it is not in the restriction list. Be careful, this method save changes.- Specified by:
copyTo
in 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 ofCopiableAmetysObject
authorized 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:CopiableAmetysObject
Copy the currentAmetysObject
to the given object. Be careful, this method save changes.- Specified by:
copyTo
in 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:MovableAmetysObject
Test if a move can be a success or if it is impossible (e.g. due to the implementation of the target)- Specified by:
canMoveTo
in 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:MovableAmetysObject
Move 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:
moveTo
in 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:MovableAmetysObject
Order a node before another sibling node (or as the last node)- Specified by:
orderBefore
in 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:ZoneItem
Get the parent zone. -
getContentViewParametersHolder
public ModifiableModelAwareDataHolder getContentViewParametersHolder(String contentViewName) throws AmetysRepositoryException Description copied from interface:ZoneItem
Get the content view parameters for a given view- Specified by:
getContentViewParametersHolder
in interfaceModifiableZoneItem
- Specified by:
getContentViewParametersHolder
in 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:ZoneItem
Get the service view parameters for a given view- Specified by:
getServiceViewParametersHolder
in interfaceModifiableZoneItem
- Specified by:
getServiceViewParametersHolder
in interfaceZoneItem
- Parameters:
serviceViewName
- the view name- Returns:
- the service view parameters
- Throws:
AmetysRepositoryException
- if an error occurs.
-
METADATA_VIEW_NAME
instead