Class SimpleAmetysObject<F extends SimpleAmetysObjectFactory>
java.lang.Object
org.ametys.plugins.repository.AbstractAmetysObject
org.ametys.plugins.repository.jcr.SimpleAmetysObject<F>
- Type Parameters:
F- the actual type of factory.
- All Implemented Interfaces:
AmetysObject,DataHolder,ModifiableDataHolder,JCRAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableAmetysObject,RemovableAmetysObject
- Direct Known Subclasses:
Activity,AmetysObjectCollection,CacheContentVersionChunk,DefaultAlias,DefaultDefinition,DefaultTheme,DefaultTheme,DefaultTraversableAmetysObject,DefaultZoneItem,SimpleModelAwareAmetysObject,Subscription,VersionAmetysObject
public class SimpleAmetysObject<F extends SimpleAmetysObjectFactory>
extends AbstractAmetysObject
implements JCRAmetysObject
Default implementation of an
This implementation heavily relies on its
AmetysObject, backed by a JCR node.This implementation heavily relies on its
SimpleAmetysObjectFactory counterpart.-
Constructor Summary
ConstructorsConstructorDescriptionSimpleAmetysObject(javax.jcr.Node node, String parentPath, F factory) Creates anSimpleAmetysObject. -
Method Summary
Modifier and TypeMethodDescriptionprotected FRetrieves the factory.protected voidRecompute the name from the Node.
To be used when the node name changesd internally.protected voidInvalidates cached parent path.getComposite(String compositePath) Retrieves the composite at the given pathgetComposite(String compositePath, boolean createNew) Retrieves the composite at the given pathprotected ModifiableDataHolderReturns theDataHolderof thisAmetysObject.getId()Retrieves the unique identifier of this AmetysObject.
It must be unique in the whole repository and must never be null.
It must conform to the URI syntax:
<protocol>://<protocol-specific-part>Deprecated.use getRepositoryData insteadgetName()Retrieves the name of the current object.javax.jcr.NodegetNode()Gives access to the underlying JCR node.<A extends AmetysObject>
AReturns the parent object in the Ametys hierarchy.Optional<? extends ModifiableDataHolder> Retrieves the optional parent of the currentDataHolderThere can be no parent if the currentDataHolderis the rootReturns the path of the parent object in the Ametys hierarchy.getPath()Retrieves the path of the current object.Retrieves the repository data used by thisDataHolderRetrieves theDataHolderthat is the root of the current onebooleanReturns true if there is pending changes.voidremove()Removes thisAmetysObjectfrom the Ametys tree.voidremoveValue(String dataPath) Removes the stored value of the data at the given pathvoidRename theAmetysObjectvoidDiscard pending changes and revert to the currently persisted version.voidPersists pending changes.
If the underlying Node is new, the Session is globally saved.voidSets the value of the data at the given pathvoidSets the value of the data at the given path<T extends SynchronizationResult>
TsynchronizeValues(Map<String, Object> values) Synchronizes the given values with the current onesMethods inherited from class org.ametys.plugins.repository.AbstractAmetysObject
dataToJSON, dataToJSON, dataToSAX, dataToSAX, equals, getDataNames, getModelItemTypeExtensionPoint, getType, getValue, getValueOfType, getValueOfTypeOrDefault, getValueOrDefault, hasDifferences, hashCode, hasValue, hasValue, hasValueOrEmpty, isMultiple, isMultiple, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.ametys.plugins.repository.AmetysObject
equals, hashCodeMethods inherited from interface org.ametys.plugins.repository.data.holder.DataHolder
copyTo, copyTo, dataToJSON, dataToJSON, dataToJSON, dataToJSON, dataToSAX, dataToSAX, dataToSAX, dataToSAX, getDataNames, getModelItemTypeExtensionPoint, getType, getValue, getValueOfType, getValueOfTypeOrDefault, getValueOrDefault, hasDifferences, hasValue, hasValue, hasValueOrEmpty, isMultiple, isMultiple
-
Constructor Details
-
SimpleAmetysObject
Creates anSimpleAmetysObject.- Parameters:
node- the node backing thisAmetysObjectparentPath- the parentPath in the Ametys hierarchyfactory- theSimpleAmetysObjectFactorywhich created the AmetysObject
-
-
Method Details
-
_getFactory
Retrieves the factory.- Returns:
- the factory.
-
getName
Description copied from interface:AmetysObjectRetrieves the name of the current object.- Specified by:
getNamein interfaceAmetysObject- Returns:
- the name.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getMetadataHolder
Deprecated.use getRepositoryData insteadReturns the rootCompositeMetadataof thisAmetysObject.- Specified by:
getMetadataHolderin interfaceMetadataAwareAmetysObject- Specified by:
getMetadataHolderin interfaceModifiableMetadataAwareAmetysObject- Returns:
- the root
CompositeMetadataof thisAmetysObject
-
getParentPath
Description copied from interface:AmetysObjectReturns the path of the parent object in the Ametys hierarchy.- Specified by:
getParentPathin interfaceAmetysObject- Returns:
- the path of the parent object.
- Throws:
AmetysRepositoryException- if an error occurs.
-
_invalidateParentPath
Invalidates cached parent path. -
_invalidateName
Recompute the name from the Node.
To be used when the node name changesd internally. -
getPath
Description copied from interface:AmetysObjectRetrieves the path of the current object.- Specified by:
getPathin interfaceAmetysObject- Returns:
- the path.
- Throws:
AmetysRepositoryException- if an error occurs.
-
getNode
Description copied from interface:JCRAmetysObjectGives access to the underlying JCR node.- Specified by:
getNodein interfaceJCRAmetysObject- Returns:
- the JCR node backing this AmetysObject.
-
getId
Description copied from interface:AmetysObjectRetrieves the unique identifier of this AmetysObject.
It must be unique in the whole repository and must never be null.
It must conform to the URI syntax:
<protocol>://<protocol-specific-part>- Specified by:
getIdin interfaceAmetysObject- Returns:
- the unique identifier of this AmetysObject
-
rename
Description copied from interface:ModifiableAmetysObjectRename theAmetysObject- Specified by:
renamein interfaceModifiableAmetysObject- Parameters:
newName- the new name of the ametys object- Throws:
AmetysRepositoryException- if an error occurs.
-
remove
Description copied from interface:RemovableAmetysObjectRemoves thisAmetysObjectfrom the Ametys tree.- Specified by:
removein interfaceRemovableAmetysObject- Throws:
AmetysRepositoryException- if an error occurs.RepositoryIntegrityViolationException- if thisAmetysObjectis referenced by another objects.
-
getParent
Description copied from interface:AmetysObjectReturns the parent object in the Ametys hierarchy.- Specified by:
getParentin interfaceAmetysObject- Type Parameters:
A- the type of the parentAmetysObject.- Returns:
- the parent object or
nullif current object is the root. - Throws:
AmetysRepositoryException- if an error occurs.
-
needsSave
Description copied from interface:ModifiableAmetysObjectReturns true if there is pending changes.- Specified by:
needsSavein interfaceModifiableAmetysObject- Returns:
- true if there is pending changes.
- Throws:
AmetysRepositoryException- if an error occurs.
-
saveChanges
Description copied from interface:ModifiableAmetysObjectPersists pending changes.
If the underlying Node is new, the Session is globally saved.- Specified by:
saveChangesin interfaceModifiableAmetysObject- Throws:
AmetysRepositoryException- if an error occurs.
-
revertChanges
Description copied from interface:ModifiableAmetysObjectDiscard pending changes and revert to the currently persisted version.- Specified by:
revertChangesin interfaceModifiableAmetysObject- Throws:
AmetysRepositoryException- if an error occurs.
-
getDataHolder
Description copied from class:AbstractAmetysObjectReturns theDataHolderof thisAmetysObject.- Specified by:
getDataHolderin classAbstractAmetysObject- Returns:
- the
DataHolderof thisAmetysObject
-
getComposite
public ModifiableComposite getComposite(String compositePath) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:DataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceDataHolder- Specified by:
getCompositein interfaceModifiableDataHolder- Overrides:
getCompositein classAbstractAmetysObject- Parameters:
compositePath- path of the composite to retrieve- Returns:
- the composite or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyUnknownTypeException- if the type composite is not available for this data holderBadItemTypeException- if the stored value at the given path is not a compositeUndefinedItemPathException- if the data holder has a model and the given composite path is not defined by this modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
getComposite
public ModifiableComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModifiableDataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceModifiableDataHolder- Parameters:
compositePath- path of the composite to retrievecreateNew-trueto create the composite if it does not exist,falseotherwise- Returns:
- the composite or
nullif createNew isfalseand value not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyUnknownTypeException- if the type composite is not available for this data holderBadItemTypeException- if the stored value at the given path is not a compositeUndefinedItemPathException- if the data holder has a model and the given composite path is not defined by this modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
synchronizeValues
public <T extends SynchronizationResult> T synchronizeValues(Map<String, Object> values) throws UnknownTypeException, NotUniqueTypeException, BadItemTypeException, UndefinedItemPathExceptionDescription copied from interface:ModifiableDataHolderSynchronizes the given values with the current ones- Specified by:
synchronizeValuesin interfaceModifiableDataHolder- Type Parameters:
T- the type of theSynchronizationResult- Parameters:
values- the values to synchronize- Returns:
- the
SynchronizationResult - Throws:
UnknownTypeException- if there is no available type compatible with a given value for this data holder's type extension pointNotUniqueTypeException- if there is more than one available types compatibles with the a value for this data holder's type extension pointBadItemTypeException- if type of the a data doesn't match the corresponding given value to setUndefinedItemPathException- if the data holder has a model and a key in the given Map refers to a data that is not defined by the model
-
setValue
public void setValue(String dataPath, Object value) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, NotUniqueTypeException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModifiableDataHolderSets the value of the data at the given path- Specified by:
setValuein interfaceModifiableDataHolder- Parameters:
dataPath- path of the datavalue- the value to set. To empty a value, useModifiableDataHolder.setValue(String, Object, String)with anullvalue- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownDataException- if the given the data path is composed of an non existing groupUnknownTypeException- if there is no available type compatible with the given value for this data holder's type extension pointNotUniqueTypeException- if there is more than one available types compatibles with the given value for this data holder's type extension pointBadItemTypeException- if type of the data at the given path doesn't match the given value to setUndefinedItemPathException- if the data holder has a model and the given data path is not defined by the modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
setValue
public void setValue(String dataPath, Object value, String dataType) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModifiableDataHolderSets the value of the data at the given path- Specified by:
setValuein interfaceModifiableDataHolder- Parameters:
dataPath- path of the datavalue- the value to set. Givenullto empty the value.dataType- type identifier of the data- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownDataException- if the given data path is composed of an non existing groupUnknownTypeException- if the given type is not available for this data holder's type extension pointBadItemTypeException- if the given type doesn't match the given value to setUndefinedItemPathException- if the data holder has a model and the given data path is not defined by the modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
removeValue
public void removeValue(String dataPath) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModifiableDataHolderRemoves the stored value of the data at the given path- Specified by:
removeValuein interfaceModifiableDataHolder- Parameters:
dataPath- path of the data- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownTypeException- if the the data to remove is in a group and there is no available type compatible with this groupBadItemTypeException- if the value of the parent of the given path is not an item containerUndefinedItemPathException- if the data holder has a model and the given data path is not defined by the modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
getRepositoryData
Description copied from interface:DataHolderRetrieves the repository data used by thisDataHolder- Specified by:
getRepositoryDatain interfaceDataHolder- Specified by:
getRepositoryDatain interfaceModifiableDataHolder- Overrides:
getRepositoryDatain classAbstractAmetysObject- Returns:
- the repository data used by this
DataHolder
-
getParentDataHolder
Description copied from interface:DataHolderRetrieves the optional parent of the currentDataHolderThere can be no parent if the currentDataHolderis the root- Specified by:
getParentDataHolderin interfaceDataHolder- Specified by:
getParentDataHolderin interfaceModifiableDataHolder- Overrides:
getParentDataHolderin classAbstractAmetysObject- Returns:
- the parent of the current
DataHolder
-
getRootDataHolder
Description copied from interface:DataHolderRetrieves theDataHolderthat is the root of the current one- Specified by:
getRootDataHolderin interfaceDataHolder- Specified by:
getRootDataHolderin interfaceModifiableDataHolder- Overrides:
getRootDataHolderin classAbstractAmetysObject- Returns:
- the root
DataHolder
-