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,JCRAmetysObject,MetadataAwareAmetysObject,ModifiableMetadataAwareAmetysObject,ModifiableAmetysObject,RemovableAmetysObject
- Direct Known Subclasses:
AmetysObjectCollection,Catalog,ContentBackupAmetysObject,DefaultAlias,DefaultAmetysObject,DefaultDefinition,DefaultTheme,DefaultTraversableAmetysObject,DefaultZoneItem,VersionAmetysObject
public class SimpleAmetysObject<F extends SimpleAmetysObjectFactory> extends AbstractAmetysObject implements JCRAmetysObject
Default implementation of anAmetysObject, backed by a JCR node.
This implementation heavily relies on itsSimpleAmetysObjectFactorycounterpart.
-
-
Constructor Summary
Constructors Constructor Description SimpleAmetysObject(Node node, String parentPath, F factory)Creates anSimpleAmetysObject.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected F_getFactory()Retrieves the factory.protected void_invalidateName()Recompute the name from the Node.
To be used when the node name changesd internally.protected void_invalidateParentPath()Invalidates cached parent path.StringgetId()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>ModifiableCompositeMetadatagetMetadataHolder()Deprecated.use getRepositoryData insteadStringgetName()Retrieves the name of the current object.NodegetNode()Gives access to the underlying JCR node.<A extends AmetysObject>
AgetParent()Returns the parent object in the Ametys hierarchy.StringgetParentPath()Returns the path of the parent object in the Ametys hierarchy.StringgetPath()Retrieves the path of the current object.booleanneedsSave()Returns true if there is pending changes.voidremove()Removes thisAmetysObjectfrom the Ametys tree.voidrename(String newName)Rename theAmetysObjectvoidrevertChanges()Discard pending changes and revert to the currently persisted version.voidsaveChanges()Persists pending changes.
If the underlying Node is new, the Session is globally saved.-
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, hashCode
-
-
-
-
Constructor Detail
-
SimpleAmetysObject
public SimpleAmetysObject(Node node, String parentPath, F factory)
Creates anSimpleAmetysObject.- Parameters:
node- the node backing thisAmetysObjectparentPath- the parentPath in the Ametys hierarchyfactory- the DefaultTraversableAmetysObjectFactory which created the AmetysObject
-
-
Method Detail
-
_getFactory
protected F _getFactory()
Retrieves the factory.- Returns:
- the factory.
-
getName
public String getName() throws AmetysRepositoryException
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 public ModifiableCompositeMetadata getMetadataHolder()
Deprecated.use getRepositoryData insteadReturns the rootCompositeMetadataof thisAmetysObject.- Specified by:
getMetadataHolderin interfaceMetadataAwareAmetysObject- Specified by:
getMetadataHolderin interfaceModifiableMetadataAwareAmetysObject- Returns:
- the root
CompositeMetadataof thisAmetysObject
-
getParentPath
public String getParentPath() throws AmetysRepositoryException
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
protected void _invalidateParentPath()
Invalidates cached parent path.
-
_invalidateName
protected void _invalidateName()
Recompute the name from the Node.
To be used when the node name changesd internally.
-
getPath
public String getPath() throws AmetysRepositoryException
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
public Node getNode()
Description copied from interface:JCRAmetysObjectGives access to the underlying JCR node.- Specified by:
getNodein interfaceJCRAmetysObject- Returns:
- the JCR node backing this AmetysObject.
-
getId
public String 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
public void rename(String newName) throws AmetysRepositoryException
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
public void remove() throws AmetysRepositoryException, RepositoryIntegrityViolationException
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
public <A extends AmetysObject> A getParent() throws AmetysRepositoryException
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
public boolean needsSave() throws AmetysRepositoryException
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
public void saveChanges() throws AmetysRepositoryException
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
public void revertChanges() throws AmetysRepositoryException
Description copied from interface:ModifiableAmetysObjectDiscard pending changes and revert to the currently persisted version.- Specified by:
revertChangesin interfaceModifiableAmetysObject- Throws:
AmetysRepositoryException- if an error occurs.
-
-