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:
Activity
,AmetysObjectCollection
,Catalog
,ContentBackupAmetysObject
,ContentConsistencyResult
,DefaultAlias
,DefaultAmetysObject
,DefaultDefinition
,DefaultTheme
,DefaultTraversableAmetysObject
,DefaultZoneItem
,FormEntry
,FormPageRule
,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
ConstructorDescriptionSimpleAmetysObject
(javax.jcr.Node node, String parentPath, F factory) Creates anSimpleAmetysObject
. -
Method Summary
Modifier and TypeMethodDescriptionprotected F
Retrieves the factory.protected void
Recompute the name from the Node.
To be used when the node name changesd internally.protected void
Invalidates cached parent path.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.Node
getNode()
Gives access to the underlying JCR node.<A extends AmetysObject>
AReturns the parent object in the Ametys hierarchy.Returns the path of the parent object in the Ametys hierarchy.getPath()
Retrieves the path of the current object.boolean
Returns true if there is pending changes.void
remove()
Removes thisAmetysObject
from the Ametys tree.void
Rename theAmetysObject
void
Discard pending changes and revert to the currently persisted version.void
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 Details
-
SimpleAmetysObject
Creates anSimpleAmetysObject
.- Parameters:
node
- the node backing thisAmetysObject
parentPath
- the parentPath in the Ametys hierarchyfactory
- the DefaultTraversableAmetysObjectFactory which created the AmetysObject
-
-
Method Details
-
_getFactory
Retrieves the factory.- Returns:
- the factory.
-
getName
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.use getRepositoryData insteadReturns the rootCompositeMetadata
of thisAmetysObject
.- Specified by:
getMetadataHolder
in interfaceMetadataAwareAmetysObject
- Specified by:
getMetadataHolder
in interfaceModifiableMetadataAwareAmetysObject
- Returns:
- the root
CompositeMetadata
of thisAmetysObject
-
getParentPath
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
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:AmetysObject
Retrieves the path of the current object.- Specified by:
getPath
in interfaceAmetysObject
- Returns:
- the path.
- Throws:
AmetysRepositoryException
- if an error occurs.
-
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
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
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
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
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
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
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
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.
-