F
- the actual type of factory.public class SimpleAmetysObject<F extends SimpleAmetysObjectFactory> extends AbstractAmetysObject implements JCRAmetysObject
AmetysObject
, backed by a JCR node.SimpleAmetysObjectFactory
counterpart.Modifier and Type | Field and Description |
---|---|
private F |
_factory
The corresponding
SimpleAmetysObjectFactory |
private String |
_name |
private Node |
_node |
private String |
_parentPath |
Constructor and Description |
---|
SimpleAmetysObject(Node node,
String parentPath,
F factory)
Creates an
SimpleAmetysObject . |
Modifier and Type | Method and 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()
Returns the root
CompositeMetadata of this AmetysObject . |
String |
getName()
Retrieves the name of the current object.
|
Node |
getNode()
Gives access to the underlying JCR node.
|
<A extends AmetysObject> |
getParent()
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 this
AmetysObject from the Ametys tree. |
void |
rename(String newName)
Rename the
AmetysObject |
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. |
equals, hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
equals, hashCode
private F extends SimpleAmetysObjectFactory _factory
SimpleAmetysObjectFactory
private String _parentPath
public SimpleAmetysObject(Node node, String parentPath, F factory)
SimpleAmetysObject
.node
- the node backing this AmetysObject
parentPath
- the parentPath in the Ametys hierarchyfactory
- the DefaultTraversableAmetysObjectFactory which created the AmetysObjectprotected F _getFactory()
public String getName() throws AmetysRepositoryException
AmetysObject
getName
in interface AmetysObject
AmetysRepositoryException
- if an error occurs.public ModifiableCompositeMetadata getMetadataHolder()
MetadataAwareAmetysObject
CompositeMetadata
of this AmetysObject
.getMetadataHolder
in interface MetadataAwareAmetysObject
getMetadataHolder
in interface ModifiableMetadataAwareAmetysObject
CompositeMetadata
of this AmetysObject
public String getParentPath() throws AmetysRepositoryException
AmetysObject
getParentPath
in interface AmetysObject
AmetysRepositoryException
- if an error occurs.protected void _invalidateParentPath()
protected void _invalidateName()
public String getPath() throws AmetysRepositoryException
AmetysObject
getPath
in interface AmetysObject
AmetysRepositoryException
- if an error occurs.public Node getNode()
JCRAmetysObject
getNode
in interface JCRAmetysObject
public String getId()
AmetysObject
<protocol>://<protocol-specific-part>
getId
in interface AmetysObject
public void rename(String newName) throws AmetysRepositoryException
ModifiableAmetysObject
AmetysObject
rename
in interface ModifiableAmetysObject
newName
- the new name of the ametys objectAmetysRepositoryException
- if an error occurs.public void remove() throws AmetysRepositoryException, RepositoryIntegrityViolationException
RemovableAmetysObject
AmetysObject
from the Ametys tree.remove
in interface RemovableAmetysObject
AmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if this AmetysObject
is referenced by another objects.public <A extends AmetysObject> A getParent() throws AmetysRepositoryException
AmetysObject
getParent
in interface AmetysObject
A
- the type of the parent AmetysObject
.null
if current object
is the root.AmetysRepositoryException
- if an error occurs.public boolean needsSave() throws AmetysRepositoryException
ModifiableAmetysObject
needsSave
in interface ModifiableAmetysObject
AmetysRepositoryException
- if an error occurs.public void saveChanges() throws AmetysRepositoryException
ModifiableAmetysObject
saveChanges
in interface ModifiableAmetysObject
AmetysRepositoryException
- if an error occurs.public void revertChanges() throws AmetysRepositoryException
ModifiableAmetysObject
revertChanges
in interface ModifiableAmetysObject
AmetysRepositoryException
- if an error occurs.