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 private static org.slf4j.Logger
__LOGGER
static String
METADATA_CONTENT
Constant for content metadata.static String
METADATA_METADATASET_NAME
Deprecated.UseMETADATA_VIEW_NAME
insteadstatic String
METADATA_SERVICE
Constant for service metadata.static String
METADATA_TYPE
Constant for title metadata.static String
METADATA_VIEW_NAME
Constant for view name metadata.static String
SERVICE_PARAM_NODETYPE
Constant 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 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.ModifiableZoneItem
copyTo(ModifiableTraversableAmetysObject parent, String name)
Copy the currentAmetysObject
to the given object.ModifiableZoneItem
copyTo(ModifiableTraversableAmetysObject parent, String name, List<String> restrictTo)
Copy the currentAmetysObject
to the given object if it is not in the restriction list.void
dataToSAX(ContentHandler contentHandler, String dataPath, Locale locale)
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, Locale locale)
Generates SAX events for data contained in thisDataHolder
<C extends Content>
CgetContent()
Retrieves the content reference.ModifiableModelAwareDataHolder
getContentViewParametersHolder(String contentViewName)
Get the content view parameters for a given viewModifiableModelLessDataHolder
getDataHolder()
Returns theDataHolder
of thisAmetysObject
.ModifiableCompositeMetadata
getMetadataHolder()
Returns the rootCompositeMetadata
of thisAmetysObject
.String
getServiceId()
Retrieves the service id.ModifiableModelAwareDataHolder
getServiceParameters()
Get the service parametersModifiableModelAwareDataHolder
getServiceViewParametersHolder(String serviceViewName)
Get the service view parameters for a given viewZoneItem.ZoneType
getType()
Retrieves the type.String
getViewName()
Get the name of the view to render the Content with.Zone
getZone()
Get the parent zone.ModifiableModelAwareDataHolder
getZoneItemParametersHolder()
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, getDataNames, getRepositoryData
-
Methods inherited from interface org.ametys.plugins.repository.data.holder.DataHolder
dataToSAX
-
Methods inherited from interface org.ametys.plugins.repository.data.ametysobject.ModelLessDataAwareAmetysObject
getComposite, getType, getValue, getValue, getValueOfType, getValueOfType, hasValue, isMultiple
-
Methods inherited from interface org.ametys.plugins.repository.data.holder.ModelLessDataHolder
dataToSAX, hasValue
-
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, getRepositoryData, 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_NAME
insteadConstant 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
-
__LOGGER
private static final org.slf4j.Logger __LOGGER
-
-
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
- theDefaultZoneItemFactory
which creates the AmetysObject.
-
-
Method Detail
-
getType
public ZoneItem.ZoneType getType() throws AmetysRepositoryException
Description copied from interface:ZoneItem
Retrieves the type.- Specified by:
getType
in 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:ModifiableZoneItem
Set the type.- Specified by:
setType
in 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: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
public <C extends Content> void setContent(C content) throws AmetysRepositoryException
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
public String getViewName() throws AmetysRepositoryException
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
public void setViewName(String viewName) throws AmetysRepositoryException
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
public String getServiceId() throws AmetysRepositoryException
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
public void setServiceId(String serviceId) throws AmetysRepositoryException
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, IllegalStateException
Get 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
protected ModifiableRepositoryData _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 AmetysRepositoryException
Description 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
public ModifiableModelLessDataHolder 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, Locale locale) throws SAXException, IOException, 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 eventslocale
- The locale to use for localized data, such asMultilingualString
. Can benull
to generate SAX events for all existingLocale
s.- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O APIUnknownTypeException
- 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, Locale locale) throws SAXException, IOException
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 SAXlocale
- The locale to use for localized data, such asMultilingualString
. Can benull
to generate SAX events for all existingLocale
s.- Throws:
SAXException
- if an error occurs during the SAX events generationIOException
- if an error occurs while reading a value using the I/O API
-
getMetadataHolder
public ModifiableCompositeMetadata 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
public boolean canMoveTo(AmetysObject newParent) throws AmetysRepositoryException
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
public void orderBefore(AmetysObject siblingObject) throws AmetysRepositoryException
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.
-
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.
-
-