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 itsSimpleAmetysObjectFactory
counterpart.
-
-
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.String
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>
ModifiableCompositeMetadata
getMetadataHolder()
Deprecated.use getRepositoryData insteadString
getName()
Retrieves the name of the current object.Node
getNode()
Gives access to the underlying JCR node.<A extends AmetysObject>
AgetParent()
Returns the parent object in the Ametys hierarchy.String
getParentPath()
Returns the path of the parent object in the Ametys hierarchy.String
getPath()
Retrieves the path of the current object.boolean
needsSave()
Returns true if there is pending changes.void
remove()
Removes thisAmetysObject
from the Ametys tree.void
rename(String newName)
Rename theAmetysObject
void
revertChanges()
Discard pending changes and revert to the currently persisted version.void
saveChanges()
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 thisAmetysObject
parentPath
- 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:AmetysObject
Retrieves the name of the current object.- Specified by:
getName
in interfaceAmetysObject
- Returns:
- the name.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getMetadataHolder
@Deprecated public ModifiableCompositeMetadata getMetadataHolder()
Deprecated.use getRepositoryData insteadReturns the rootCompositeMetadata
of thisAmetysObject
.- Specified by:
getMetadataHolder
in interfaceMetadataAwareAmetysObject
- Specified by:
getMetadataHolder
in interfaceModifiableMetadataAwareAmetysObject
- Returns:
- the root
CompositeMetadata
of thisAmetysObject
-
getParentPath
public String getParentPath() throws AmetysRepositoryException
Description copied from interface:AmetysObject
Returns the path of the parent object in the Ametys hierarchy.- Specified by:
getParentPath
in 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:AmetysObject
Retrieves the path of the current object.- Specified by:
getPath
in interfaceAmetysObject
- Returns:
- the path.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
getNode
public Node getNode()
Description copied from interface:JCRAmetysObject
Gives access to the underlying JCR node.- Specified by:
getNode
in interfaceJCRAmetysObject
- Returns:
- the JCR node backing this AmetysObject.
-
getId
public String getId()
Description copied from interface:AmetysObject
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>
- Specified by:
getId
in interfaceAmetysObject
- Returns:
- the unique identifier of this AmetysObject
-
rename
public void rename(String newName) throws AmetysRepositoryException
Description copied from interface:ModifiableAmetysObject
Rename theAmetysObject
- Specified by:
rename
in 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:RemovableAmetysObject
Removes thisAmetysObject
from the Ametys tree.- Specified by:
remove
in interfaceRemovableAmetysObject
- Throws:
AmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if thisAmetysObject
is referenced by another objects.
-
getParent
public <A extends AmetysObject> A getParent() throws AmetysRepositoryException
Description copied from interface:AmetysObject
Returns the parent object in the Ametys hierarchy.- Specified by:
getParent
in interfaceAmetysObject
- Type Parameters:
A
- the type of the parentAmetysObject
.- Returns:
- the parent object or
null
if current object is the root. - Throws:
AmetysRepositoryException
- if an error occurs.
-
needsSave
public boolean needsSave() throws AmetysRepositoryException
Description copied from interface:ModifiableAmetysObject
Returns true if there is pending changes.- Specified by:
needsSave
in interfaceModifiableAmetysObject
- Returns:
- true if there is pending changes.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
saveChanges
public void saveChanges() throws AmetysRepositoryException
Description copied from interface:ModifiableAmetysObject
Persists pending changes.
If the underlying Node is new, the Session is globally saved.- Specified by:
saveChanges
in interfaceModifiableAmetysObject
- Throws:
AmetysRepositoryException
- if an error occurs.
-
revertChanges
public void revertChanges() throws AmetysRepositoryException
Description copied from interface:ModifiableAmetysObject
Discard pending changes and revert to the currently persisted version.- Specified by:
revertChanges
in interfaceModifiableAmetysObject
- Throws:
AmetysRepositoryException
- if an error occurs.
-
-