org.apache.jackrabbit.core
Class NodeImpl

java.lang.Object
  extended by org.apache.jackrabbit.core.ItemImpl
      extended by org.apache.jackrabbit.core.NodeImpl
All Implemented Interfaces:
Item, Node
Direct Known Subclasses:
VersionHistoryImpl, VersionImpl

public class NodeImpl
extends ItemImpl
implements Node

NodeImpl implements the Node interface.


Field Summary
protected static short CREATED
           
 
Fields inherited from class org.apache.jackrabbit.core.ItemImpl
id, itemMgr, rep, session, stateMgr, STATUS_DESTROYED, STATUS_INVALIDATED, STATUS_MODIFIED, STATUS_NORMAL
 
Fields inherited from interface javax.jcr.Node
JCR_CHILD_NODE_DEFINITION, JCR_CONTENT, JCR_FROZEN_NODE, JCR_PROPERTY_DEFINITION, JCR_ROOT_VERSION, JCR_VERSION_LABELS
 
Constructor Summary
protected NodeImpl(ItemManager itemMgr, SessionImpl session, AbstractNodeData data)
          Protected constructor.
 
Method Summary
 void accept(ItemVisitor visitor)
          
 void addMixin(Name mixinName)
          Same as Node.addMixin(String) except that it takes a Name instead of a String.
 void addMixin(String mixinName)
          
 NodeImpl addNode(Name nodeName, Name nodeTypeName, NodeId id)
          Same as Node.addNode(String, String) except that this method takes Name arguments instead of Strings and has an additional uuid argument.
 Node addNode(String relPath)
          
 Node addNode(String relPath, String nodeTypeName)
          
 Node addNodeWithUuid(String relPath, String uuid)
          Adds a node with the given UUID.
 Node addNodeWithUuid(String relPath, String nodeTypeName, String uuid)
          Adds a node with the given node type and UUID.
 void assignLifecyclePolicy(Node policy, String state)
          Assigns the given lifecycle policy to this node and sets the current state to the one given.
 boolean canAddMixin(String mixinName)
          
 void cancelMerge(Version version)
          Deprecated. 
 Version checkin()
          Deprecated. 
 Version checkin(Calendar created)
          Deprecated. 
protected  void checkLock()
          Deprecated.  
 void checkout()
          Deprecated. 
protected  void checkSetProperty()
          Checks various pre-conditions that are common to all setProperty() methods.
 NodeImpl clone(NodeImpl src, Name name)
          Create a child node that is a clone of a shareable node.
protected  NodeImpl createChildNode(Name name, NodeTypeImpl nodeType, NodeId id)
           
protected  PropertyImpl createChildProperty(Name name, int type, PropertyDefinitionImpl def)
          Creates a new property with the given name and type hint and property definition.
 void doneMerge(Version version)
          Deprecated. 
 void followLifecycleTransition(String transition)
          Transitions this node through its lifecycle to the given target state.
 String[] getAllowedLifecycleTransistions()
          Returns all allowed transitions from the current lifecycle state of this node.
protected  NodeDefinitionImpl getApplicableChildNodeDefinition(Name nodeName, Name nodeTypeName)
          Returns the applicable child node definition for a child node with the specified name and node type.
protected  PropertyDefinitionImpl getApplicablePropertyDefinition(Name propertyName, int type, boolean multiValued, boolean exactTypeMatch)
          Returns the applicable property definition for a property with the specified name and type.
 Version getBaseVersion()
          Deprecated. 
 String getCorrespondingNodePath(String workspaceName)
          
 NodeDefinition getDefinition()
          
 EffectiveNodeType getEffectiveNodeType()
          Returns the effective (i.e.
 String getIdentifier()
          
 int getIndex()
          
 Lock getLock()
          
 NodeType[] getMixinNodeTypes()
          
 Set<Name> getMixinTypeNames()
          Returns the Names of this node's mixin types.
 String getName()
          
 NodeImpl getNode(Name name)
          Returns the child node of this node with the specified name.
 NodeImpl getNode(Name name, int index)
          Returns the child node of this node with the specified name.
 Node getNode(String relPath)
          
 NodeId getNodeId()
          Returns the identifier of this Node.
 NodeIterator getNodes()
          
 NodeIterator getNodes(String namePattern)
          
 NodeIterator getNodes(String[] nameGlobs)
          
protected  PropertyImpl getOrCreateProperty(Name name, int type, boolean multiValued, boolean exactTypeMatch, BitSet status)
           
protected  PropertyImpl getOrCreateProperty(String name, int type, boolean multiValued, boolean exactTypeMatch, BitSet status)
           
protected  ItemState getOrCreateTransientItemState()
           
 Node getParent()
          
 Item getPrimaryItem()
          
 NodeType getPrimaryNodeType()
          
 Path getPrimaryPath()
          Returns the primary path to this Item.
 PropertyIterator getProperties()
          
 PropertyIterator getProperties(String namePattern)
          
 PropertyIterator getProperties(String[] nameGlobs)
          
 PropertyImpl getProperty(Name name)
          Returns the property of this node with the specified name.
 Property getProperty(String relPath)
          
 Name getQName()
          Same as Item.getName() except that this method returns a Name instead of a String.
 PropertyIterator getReferences()
          
 PropertyIterator getReferences(String name)
          
 NodeIterator getSharedSet()
          Returns an iterator over all nodes that are in the shared set of this node.
 String getUUID()
          
 VersionHistory getVersionHistory()
          Deprecated. 
 PropertyIterator getWeakReferences()
          
 PropertyIterator getWeakReferences(String name)
          
 boolean hasNode(Name name)
          Indicates whether a child node with the specified name exists.
 boolean hasNode(Name name, int index)
          Indicates whether a child node with the specified name exists.
 boolean hasNode(String relPath)
          
 boolean hasNodes()
          
protected  boolean hasPendingChanges()
          Determines if there are pending unsaved changes either on this node or on any node or property in the subtree below it.
 boolean hasProperties()
          
 boolean hasProperty(Name name)
          Indicates whether a property with the specified name exists.
 boolean hasProperty(String relPath)
          
 boolean holdsLock()
          
protected  Property internalSetProperty(Name name, InternalValue value)
          Sets the internal value of a property without checking any constraints.
protected  Property internalSetProperty(Name name, InternalValue[] values)
          Sets the internal value of a property without checking any constraints.
protected  Property internalSetProperty(Name name, InternalValue[] values, int type)
          Sets the internal value of a property without checking any constraints.
 boolean isCheckedOut()
          
 boolean isLocked()
          
 boolean isNode()
          
 boolean isNodeType(Name ntName)
          Same as Node.isNodeType(String) except that it takes a Name instead of a String.
 boolean isNodeType(String nodeTypeName)
          
 Lock lock(boolean isDeep, boolean isSessionScoped)
          
protected  void makePersistent()
           
 NodeIterator merge(String srcWorkspace, boolean bestEffort)
          Deprecated. 
protected  void onRedefine(QNodeDefinition def)
           
protected  void onRemove(NodeId parentId)
           
 void orderBefore(Path.Element srcName, Path.Element dstName)
          Same as Node.orderBefore(String, String) except that this method takes a Path.Element arguments instead of Strings.
 void orderBefore(String srcName, String destName)
          
protected  void removeChildNode(Name nodeName, int index)
           
protected  void removeChildProperty(Name propName)
           
protected  void removeChildProperty(String propName)
           
 void removeMixin(Name mixinName)
          Same as Node.removeMixin(String) except that it takes a Name instead of a String.
 void removeMixin(String mixinName)
          
 void removeShare()
          A special kind of remove() that removes this node, but does not remove any other node in the shared set of this node.
 void removeSharedSet()
          A special kind of remove() that removes this node and every other node in the shared set of this node.
protected  void renameChildNode(Name oldName, int index, NodeId id, Name newName)
           
 NodeImpl replaceChildNode(NodeId id, Name nodeName, Name nodeTypeName, Name[] mixinNames)
          Replaces the child node with the specified id by a new child node with the same id and specified nodeName, nodeTypeName and mixinNames.
protected  NodeId resolveRelativeNodePath(String relPath)
          Returns the id of the node at relPath or null if no node exists at relPath.
protected  PropertyId resolveRelativePropertyPath(String relPath)
          Returns the id of the property at relPath or null if no property exists at relPath.
 void restore(String versionName, boolean removeExisting)
          Deprecated. 
 void restore(Version version, boolean removeExisting)
          Deprecated. 
 void restore(Version version, String relPath, boolean removeExisting)
          Deprecated. 
 void restoreByLabel(String versionLabel, boolean removeExisting)
          Deprecated. 
protected  void restoreTransient(NodeState transientState)
           
 void setPrimaryType(String nodeTypeName)
          
 PropertyImpl setProperty(Name name, Value value)
          Same as Node.setProperty(String, Value) except that this method takes a Name name argument instead of a String.
 PropertyImpl setProperty(Name name, Value[] values)
          Same as Node.setProperty(String, Value[]) except that this method takes a Name name argument instead of a String.
 PropertyImpl setProperty(Name name, Value[] values, int type)
          Same as Node.setProperty(String, Value[], int) except that this method takes a Name name argument instead of a String.
protected  PropertyImpl setProperty(Name name, Value[] values, int type, boolean enforceType)
          Implementation for setProperty() using a Value array.
protected  PropertyImpl setProperty(Name name, Value value, boolean enforceType)
          Implementation for setProperty() using a single Value.
 Property setProperty(String name, BigDecimal value)
          
 Property setProperty(String name, Binary value)
          
 Property setProperty(String name, boolean value)
          
 Property setProperty(String name, Calendar value)
          
 Property setProperty(String name, double value)
          
 Property setProperty(String name, InputStream value)
          
 Property setProperty(String name, long value)
          
 Property setProperty(String name, Node value)
          
 Property setProperty(String name, String value)
          
 Property setProperty(String name, String[] values)
          
 Property setProperty(String name, String[] values, int type)
          
 Property setProperty(String name, String value, int type)
          
 Property setProperty(String name, Value value)
          
 Property setProperty(String name, Value[] values)
          
 Property setProperty(String name, Value[] values, int type)
          
 Property setProperty(String name, Value value, int type)
          
 String toString()
          Return a string representation of this node for diagnostic purposes.
 void unlock()
          
 void update(String srcWorkspaceName)
          
 
Methods inherited from class org.apache.jackrabbit.core.ItemImpl
getAncestor, getDepth, getId, getPath, getSession, internalRemove, isModified, isNew, isSame, isTransactionalNew, isTransient, refresh, remove, safeGetJCRPath, sanityCheck, save, setRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.jcr.Item
getAncestor, getDepth, getPath, getSession, isModified, isNew, isSame, refresh, remove, save
 

Field Detail

CREATED

protected static final short CREATED
See Also:
Constant Field Values
Constructor Detail

NodeImpl

protected NodeImpl(ItemManager itemMgr,
                   SessionImpl session,
                   AbstractNodeData data)
Protected constructor.

Parameters:
itemMgr - the ItemManager that created this Node instance
session - the Session through which this Node is acquired
data - the node data
Method Detail

resolveRelativePropertyPath

protected PropertyId resolveRelativePropertyPath(String relPath)
                                          throws RepositoryException
Returns the id of the property at relPath or null if no property exists at relPath.

Note that access rights are not checked.

Parameters:
relPath - relative path of a (possible) property
Returns:
the id of the property at relPath or null if no property exists at relPath
Throws:
RepositoryException - if relPath is not a valid relative path

resolveRelativeNodePath

protected NodeId resolveRelativeNodePath(String relPath)
                                  throws RepositoryException
Returns the id of the node at relPath or null if no node exists at relPath.

Note that access rights are not checked.

Parameters:
relPath - relative path of a (possible) node
Returns:
the id of the node at relPath or null if no node exists at relPath
Throws:
RepositoryException - if relPath is not a valid relative path

hasPendingChanges

protected boolean hasPendingChanges()
                             throws RepositoryException
Determines if there are pending unsaved changes either on this node or on any node or property in the subtree below it.

Returns:
true if there are pending unsaved changes, false otherwise.
Throws:
RepositoryException - if an error occurred

getOrCreateTransientItemState

protected ItemState getOrCreateTransientItemState()
                                           throws RepositoryException
Specified by:
getOrCreateTransientItemState in class ItemImpl
Throws:
RepositoryException

getOrCreateProperty

protected PropertyImpl getOrCreateProperty(String name,
                                           int type,
                                           boolean multiValued,
                                           boolean exactTypeMatch,
                                           BitSet status)
                                    throws ConstraintViolationException,
                                           RepositoryException
Parameters:
name -
type -
multiValued -
exactTypeMatch -
status -
Returns:
Throws:
ConstraintViolationException - if no applicable property definition could be found
RepositoryException - if another error occurs

getOrCreateProperty

protected PropertyImpl getOrCreateProperty(Name name,
                                           int type,
                                           boolean multiValued,
                                           boolean exactTypeMatch,
                                           BitSet status)
                                    throws ConstraintViolationException,
                                           RepositoryException
Parameters:
name -
type -
multiValued -
exactTypeMatch -
status -
Returns:
Throws:
ConstraintViolationException - if no applicable property definition could be found
RepositoryException - if another error occurs

createChildProperty

protected PropertyImpl createChildProperty(Name name,
                                           int type,
                                           PropertyDefinitionImpl def)
                                    throws RepositoryException
Creates a new property with the given name and type hint and property definition. If the given property definition is not of type UNDEFINED, then it takes precendence over the type hint.

Parameters:
name - the name of the property to create.
type - the type hint.
def - the associated property definition.
Returns:
the property instance.
Throws:
RepositoryException - if the property cannot be created.

createChildNode

protected NodeImpl createChildNode(Name name,
                                   NodeTypeImpl nodeType,
                                   NodeId id)
                            throws RepositoryException
Throws:
RepositoryException

renameChildNode

protected void renameChildNode(Name oldName,
                               int index,
                               NodeId id,
                               Name newName)
                        throws RepositoryException
Throws:
RepositoryException

removeChildProperty

protected void removeChildProperty(String propName)
                            throws RepositoryException
Throws:
RepositoryException

removeChildProperty

protected void removeChildProperty(Name propName)
                            throws RepositoryException
Throws:
RepositoryException

removeChildNode

protected void removeChildNode(Name nodeName,
                               int index)
                        throws RepositoryException
Throws:
RepositoryException

onRedefine

protected void onRedefine(QNodeDefinition def)
                   throws RepositoryException
Throws:
RepositoryException

onRemove

protected void onRemove(NodeId parentId)
                 throws RepositoryException
Throws:
RepositoryException

getMixinTypeNames

public Set<Name> getMixinTypeNames()
Returns the Names of this node's mixin types.

Returns:
a set of the Names of this node's mixin types.

getEffectiveNodeType

public EffectiveNodeType getEffectiveNodeType()
                                       throws RepositoryException
Returns the effective (i.e. merged and resolved) node type representation of this node's primary and mixin node types.

Returns:
the effective node type
Throws:
RepositoryException - if an error occurs

getApplicableChildNodeDefinition

protected NodeDefinitionImpl getApplicableChildNodeDefinition(Name nodeName,
                                                              Name nodeTypeName)
                                                       throws ConstraintViolationException,
                                                              RepositoryException
Returns the applicable child node definition for a child node with the specified name and node type.

Parameters:
nodeName -
nodeTypeName -
Returns:
Throws:
ConstraintViolationException - if no applicable child node definition could be found
RepositoryException - if another error occurs

getApplicablePropertyDefinition

protected PropertyDefinitionImpl getApplicablePropertyDefinition(Name propertyName,
                                                                 int type,
                                                                 boolean multiValued,
                                                                 boolean exactTypeMatch)
                                                          throws ConstraintViolationException,
                                                                 RepositoryException
Returns the applicable property definition for a property with the specified name and type.

Parameters:
propertyName -
type -
multiValued -
exactTypeMatch -
Returns:
Throws:
ConstraintViolationException - if no applicable property definition could be found
RepositoryException - if another error occurs

makePersistent

protected void makePersistent()
                       throws InvalidItemStateException
Specified by:
makePersistent in class ItemImpl
Throws:
InvalidItemStateException

restoreTransient

protected void restoreTransient(NodeState transientState)
                         throws RepositoryException
Throws:
RepositoryException

addMixin

public void addMixin(Name mixinName)
              throws NoSuchNodeTypeException,
                     VersionException,
                     ConstraintViolationException,
                     LockException,
                     RepositoryException
Same as Node.addMixin(String) except that it takes a Name instead of a String.

Throws:
NoSuchNodeTypeException
VersionException
ConstraintViolationException
LockException
RepositoryException
See Also:
Node.addMixin(String)

removeMixin

public void removeMixin(Name mixinName)
                 throws NoSuchNodeTypeException,
                        VersionException,
                        ConstraintViolationException,
                        LockException,
                        RepositoryException
Same as Node.removeMixin(String) except that it takes a Name instead of a String.

Throws:
NoSuchNodeTypeException
VersionException
ConstraintViolationException
LockException
RepositoryException
See Also:
Node.removeMixin(String)

isNodeType

public boolean isNodeType(Name ntName)
                   throws RepositoryException
Same as Node.isNodeType(String) except that it takes a Name instead of a String.

Parameters:
ntName - name of node type
Returns:
true if this node is of the specified node type; otherwise false
Throws:
RepositoryException

checkSetProperty

protected void checkSetProperty()
                         throws VersionException,
                                LockException,
                                RepositoryException
Checks various pre-conditions that are common to all setProperty() methods. The checks performed are: Note that certain checks are performed by the respective Property.setValue() methods.

Throws:
VersionException - if this node is not checked-out
LockException - if this node is locked by somebody else
RepositoryException - if another error occurs
See Also:
Node.setProperty(java.lang.String, javax.jcr.Value)

internalSetProperty

protected Property internalSetProperty(Name name,
                                       InternalValue value)
                                throws ValueFormatException,
                                       RepositoryException
Sets the internal value of a property without checking any constraints.

Note that no type conversion is being performed, i.e. it's the caller's responsibility to make sure that the type of the given value is compatible with the specified property's definition.

Parameters:
name -
value -
Returns:
Throws:
ValueFormatException
RepositoryException

internalSetProperty

protected Property internalSetProperty(Name name,
                                       InternalValue[] values)
                                throws ValueFormatException,
                                       RepositoryException
Sets the internal value of a property without checking any constraints.

Note that no type conversion is being performed, i.e. it's the caller's responsibility to make sure that the type of the given values is compatible with the specified property's definition.

Parameters:
name -
values -
Returns:
Throws:
ValueFormatException
RepositoryException

internalSetProperty

protected Property internalSetProperty(Name name,
                                       InternalValue[] values,
                                       int type)
                                throws ValueFormatException,
                                       RepositoryException
Sets the internal value of a property without checking any constraints.

Note that no type conversion is being performed, i.e. it's the caller's responsibility to make sure that the type of the given values is compatible with the specified property's definition.

Parameters:
name -
values -
type -
Returns:
Throws:
ValueFormatException
RepositoryException

getNode

public NodeImpl getNode(Name name)
                 throws ItemNotFoundException,
                        RepositoryException
Returns the child node of this node with the specified name.

Parameters:
name - The name of the child node to retrieve.
Returns:
The child node with the specified name.
Throws:
ItemNotFoundException - If no child node exists with the specified name.
RepositoryException - If another error occurs.

getNode

public NodeImpl getNode(Name name,
                        int index)
                 throws ItemNotFoundException,
                        RepositoryException
Returns the child node of this node with the specified name.

Parameters:
name - The name of the child node to retrieve.
index - The index of the child node to retrieve (in the case of same-name siblings).
Returns:
The child node with the specified name.
Throws:
ItemNotFoundException - If no child node exists with the specified name.
RepositoryException - If another error occurs.

hasNode

public boolean hasNode(Name name)
                throws RepositoryException
Indicates whether a child node with the specified name exists. Returns true if the child node exists and false otherwise.

Parameters:
name - The name of the child node.
Returns:
true if the child node exists; false otherwise.
Throws:
RepositoryException - If an unspecified error occurs.

hasNode

public boolean hasNode(Name name,
                       int index)
                throws RepositoryException
Indicates whether a child node with the specified name exists. Returns true if the child node exists and false otherwise.

Parameters:
name - The name of the child node.
index - The index of the child node (in the case of same-name siblings).
Returns:
true if the child node exists; false otherwise.
Throws:
RepositoryException - If an unspecified error occurs.

getProperty

public PropertyImpl getProperty(Name name)
                         throws ItemNotFoundException,
                                RepositoryException
Returns the property of this node with the specified name.

Parameters:
name - The name of the property to retrieve.
Returns:
The property with the specified name.
Throws:
ItemNotFoundException - If no property exists with the specified name.
RepositoryException - If another error occurs.

hasProperty

public boolean hasProperty(Name name)
                    throws RepositoryException
Indicates whether a property with the specified name exists. Returns true if the property exists and false otherwise.

Parameters:
name - The name of the property.
Returns:
true if the property exists; false otherwise.
Throws:
RepositoryException - If an unspecified error occurs.

addNode

public NodeImpl addNode(Name nodeName,
                        Name nodeTypeName,
                        NodeId id)
                 throws RepositoryException
Same as Node.addNode(String, String) except that this method takes Name arguments instead of Strings and has an additional uuid argument.

Important Notice: This method is for internal use only! Passing already assigned uuid's might lead to unexpected results and data corruption in the worst case.

Parameters:
nodeName - name of the new node
nodeTypeName - name of the new node's node type or null if it should be determined automatically
id - id of the new node or null if a new id should be assigned
Returns:
the newly added node
Throws:
RepositoryException - if the node can not added

setProperty

public PropertyImpl setProperty(Name name,
                                Value[] values)
                         throws ValueFormatException,
                                VersionException,
                                LockException,
                                ConstraintViolationException,
                                RepositoryException
Same as Node.setProperty(String, Value[]) except that this method takes a Name name argument instead of a String.

Parameters:
name -
values -
Returns:
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public PropertyImpl setProperty(Name name,
                                Value[] values,
                                int type)
                         throws ValueFormatException,
                                VersionException,
                                LockException,
                                ConstraintViolationException,
                                RepositoryException
Same as Node.setProperty(String, Value[], int) except that this method takes a Name name argument instead of a String.

Parameters:
name -
values -
type -
Returns:
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public PropertyImpl setProperty(Name name,
                                Value value)
                         throws ValueFormatException,
                                VersionException,
                                LockException,
                                ConstraintViolationException,
                                RepositoryException
Same as Node.setProperty(String, Value) except that this method takes a Name name argument instead of a String.

Parameters:
name -
value -
Returns:
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

getQName

public Name getQName()
              throws RepositoryException
Description copied from class: ItemImpl
Same as Item.getName() except that this method returns a Name instead of a String.

Specified by:
getQName in class ItemImpl
Returns:
the name of this item as Name
Throws:
RepositoryException - if an error occurs.
See Also:
ItemImpl.getQName()

getNodeId

public NodeId getNodeId()
Returns the identifier of this Node.

Returns:
the id of this Node

orderBefore

public void orderBefore(Path.Element srcName,
                        Path.Element dstName)
                 throws UnsupportedRepositoryOperationException,
                        VersionException,
                        ConstraintViolationException,
                        ItemNotFoundException,
                        LockException,
                        RepositoryException
Same as Node.orderBefore(String, String) except that this method takes a Path.Element arguments instead of Strings.

Parameters:
srcName -
dstName -
Throws:
UnsupportedRepositoryOperationException
VersionException
ConstraintViolationException
ItemNotFoundException
LockException
RepositoryException

replaceChildNode

public NodeImpl replaceChildNode(NodeId id,
                                 Name nodeName,
                                 Name nodeTypeName,
                                 Name[] mixinNames)
                          throws ItemNotFoundException,
                                 NoSuchNodeTypeException,
                                 VersionException,
                                 ConstraintViolationException,
                                 LockException,
                                 RepositoryException
Replaces the child node with the specified id by a new child node with the same id and specified nodeName, nodeTypeName and mixinNames.

Parameters:
id - id of the child node to be replaced
nodeName - name of the new node
nodeTypeName - name of the new node's node type
mixinNames - name of the new node's mixin types
Returns:
the new child node replacing the existing child
Throws:
ItemNotFoundException
NoSuchNodeTypeException
VersionException
ConstraintViolationException
LockException
RepositoryException

clone

public NodeImpl clone(NodeImpl src,
                      Name name)
               throws ItemExistsException,
                      VersionException,
                      ConstraintViolationException,
                      LockException,
                      RepositoryException
Create a child node that is a clone of a shareable node.

Parameters:
src - shareable source node
name - name of new node
Returns:
child node
Throws:
ItemExistsException - if there already is a child node with the name given and the definition does not allow creating another one
VersionException - if this node is not checked out
ConstraintViolationException - if no definition is found in this node that would allow creating the child node
LockException - if this node is locked
RepositoryException - if some other error occurs

isNode

public boolean isNode()

Specified by:
isNode in interface Item
Specified by:
isNode in class ItemImpl

getName

public String getName()
               throws RepositoryException

Specified by:
getName in interface Item
Specified by:
getName in class ItemImpl
Throws:
RepositoryException

accept

public void accept(ItemVisitor visitor)
            throws RepositoryException

Specified by:
accept in interface Item
Specified by:
accept in class ItemImpl
Throws:
RepositoryException

getParent

public Node getParent()
               throws ItemNotFoundException,
                      AccessDeniedException,
                      RepositoryException

Specified by:
getParent in interface Item
Specified by:
getParent in class ItemImpl
Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException

addNode

public Node addNode(String relPath)
             throws RepositoryException

Specified by:
addNode in interface Node
Throws:
RepositoryException

addNode

public Node addNode(String relPath,
                    String nodeTypeName)
             throws RepositoryException

Specified by:
addNode in interface Node
Throws:
RepositoryException

addNodeWithUuid

public Node addNodeWithUuid(String relPath,
                            String uuid)
                     throws RepositoryException
Adds a node with the given UUID. You can only add a node with a UUID that is not already assigned to another node in this workspace.

Parameters:
relPath - path of the new node
uuid - UUID of the new node, or null for a random new UUID
Returns:
the newly added node
Throws:
RepositoryException - if the node can not be added
Since:
Apache Jackrabbit 1.6
See Also:
JCR-1972, Node.addNode(String)

addNodeWithUuid

public Node addNodeWithUuid(String relPath,
                            String nodeTypeName,
                            String uuid)
                     throws RepositoryException
Adds a node with the given node type and UUID. You can only add a node with a UUID that is not already assigned to another node in this workspace.

Parameters:
relPath - path of the new node
nodeTypeName - name of the new node's node type, or null for automatic type assignment
uuid - UUID of the new node, or null for a random new UUID
Returns:
the newly added node
Throws:
RepositoryException - if the node can not be added
Since:
Apache Jackrabbit 1.6
See Also:
JCR-1972, Node.addNode(String, String)

orderBefore

public void orderBefore(String srcName,
                        String destName)
                 throws UnsupportedRepositoryOperationException,
                        VersionException,
                        ConstraintViolationException,
                        ItemNotFoundException,
                        LockException,
                        RepositoryException

Specified by:
orderBefore in interface Node
Throws:
UnsupportedRepositoryOperationException
VersionException
ConstraintViolationException
ItemNotFoundException
LockException
RepositoryException

setProperty

public Property setProperty(String name,
                            Value[] values)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            Value[] values,
                            int type)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            String[] values)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            String[] values,
                            int type)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            String value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            String value,
                            int type)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            Value value,
                            int type)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            Value value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            InputStream value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            boolean value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            double value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            long value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            Calendar value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            Node value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

protected PropertyImpl setProperty(Name name,
                                   Value value,
                                   boolean enforceType)
                            throws ValueFormatException,
                                   VersionException,
                                   LockException,
                                   ConstraintViolationException,
                                   RepositoryException
Implementation for setProperty() using a single Value. The type of the returned property is enforced based on the enforceType flag. If set to true, the returned property is of the passed type if it didn't exist before. If set to false, then the returned property may be of some other type, but still must be based on an existing property definition for the given name and single-valued flag. The resulting type is taken from that definition and the implementation tries to convert the passed value to that type. If that fails, then a ValueFormatException is thrown.

Parameters:
name - the name of the property to set.
value - the value to set. If null the property is removed.
enforceType - if the type of value is enforced.
Returns:
the Property object set, or null if this method was used to remove a property (by setting its value to null).
Throws:
ValueFormatException - if value cannot be converted to the specified type or if the property already exists and is multi-valued.
VersionException - if this node is read-only due to a checked-in node and this implementation performs this validation immediately.
LockException - if a lock prevents the setting of the property and this implementation performs this validation immediately.
ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
RepositoryException - if another error occurs.

setProperty

protected PropertyImpl setProperty(Name name,
                                   Value[] values,
                                   int type,
                                   boolean enforceType)
                            throws ValueFormatException,
                                   VersionException,
                                   LockException,
                                   ConstraintViolationException,
                                   RepositoryException
Implementation for setProperty() using a Value array. The type of the returned property is enforced based on the enforceType flag. If set to true, the returned property is of the passed type if it didn't exist before. If set to false, then the returned property may be of some other type, but still must be based on an existing property definition for the given name and multi-valued flag. The resulting type is taken from that definition and the implementation tries to convert the passed values to that type. If that fails, then a ValueFormatException is thrown.

Parameters:
name - the name of the property to set.
values - the values to set. If null the property is removed.
type - the target type of the values to set.
enforceType - if the target type is enforced.
Returns:
the Property object set, or null if this method was used to remove a property (by setting its value to null).
Throws:
ValueFormatException - if a value cannot be converted to the specified type or if the property already exists and is not multi-valued.
VersionException - if this node is read-only due to a checked-in node and this implementation performs this validation immediately.
LockException - if a lock prevents the setting of the property and this implementation performs this validation immediately.
ConstraintViolationException - if the change would violate a node-type or other constraint and this implementation performs this validation immediately.
RepositoryException - if another error occurs.

getNode

public Node getNode(String relPath)
             throws PathNotFoundException,
                    RepositoryException

Specified by:
getNode in interface Node
Throws:
PathNotFoundException
RepositoryException

getNodes

public NodeIterator getNodes()
                      throws RepositoryException

Specified by:
getNodes in interface Node
Throws:
RepositoryException

getProperties

public PropertyIterator getProperties()
                               throws RepositoryException

Specified by:
getProperties in interface Node
Throws:
RepositoryException

getProperty

public Property getProperty(String relPath)
                     throws PathNotFoundException,
                            RepositoryException

Specified by:
getProperty in interface Node
Throws:
PathNotFoundException
RepositoryException

hasNode

public boolean hasNode(String relPath)
                throws RepositoryException

Specified by:
hasNode in interface Node
Throws:
RepositoryException

hasNodes

public boolean hasNodes()
                 throws RepositoryException

Specified by:
hasNodes in interface Node
Throws:
RepositoryException

hasProperties

public boolean hasProperties()
                      throws RepositoryException

Specified by:
hasProperties in interface Node
Throws:
RepositoryException

isNodeType

public boolean isNodeType(String nodeTypeName)
                   throws RepositoryException

Specified by:
isNodeType in interface Node
Throws:
RepositoryException

getPrimaryNodeType

public NodeType getPrimaryNodeType()
                            throws RepositoryException

Specified by:
getPrimaryNodeType in interface Node
Throws:
RepositoryException

getMixinNodeTypes

public NodeType[] getMixinNodeTypes()
                             throws RepositoryException

Specified by:
getMixinNodeTypes in interface Node
Throws:
RepositoryException

addMixin

public void addMixin(String mixinName)
              throws NoSuchNodeTypeException,
                     VersionException,
                     ConstraintViolationException,
                     LockException,
                     RepositoryException

Specified by:
addMixin in interface Node
Throws:
NoSuchNodeTypeException
VersionException
ConstraintViolationException
LockException
RepositoryException

removeMixin

public void removeMixin(String mixinName)
                 throws NoSuchNodeTypeException,
                        VersionException,
                        ConstraintViolationException,
                        LockException,
                        RepositoryException

Specified by:
removeMixin in interface Node
Throws:
NoSuchNodeTypeException
VersionException
ConstraintViolationException
LockException
RepositoryException

canAddMixin

public boolean canAddMixin(String mixinName)
                    throws NoSuchNodeTypeException,
                           RepositoryException

Specified by:
canAddMixin in interface Node
Throws:
NoSuchNodeTypeException
RepositoryException

hasProperty

public boolean hasProperty(String relPath)
                    throws RepositoryException

Specified by:
hasProperty in interface Node
Throws:
RepositoryException

getReferences

public PropertyIterator getReferences()
                               throws RepositoryException

Specified by:
getReferences in interface Node
Throws:
RepositoryException

getDefinition

public NodeDefinition getDefinition()
                             throws RepositoryException

Specified by:
getDefinition in interface Node
Throws:
RepositoryException

getNodes

public NodeIterator getNodes(String namePattern)
                      throws RepositoryException

Specified by:
getNodes in interface Node
Throws:
RepositoryException

getProperties

public PropertyIterator getProperties(String namePattern)
                               throws RepositoryException

Specified by:
getProperties in interface Node
Throws:
RepositoryException

getPrimaryItem

public Item getPrimaryItem()
                    throws ItemNotFoundException,
                           RepositoryException

Specified by:
getPrimaryItem in interface Node
Throws:
ItemNotFoundException
RepositoryException

getUUID

public String getUUID()
               throws UnsupportedRepositoryOperationException,
                      RepositoryException

Specified by:
getUUID in interface Node
Throws:
UnsupportedRepositoryOperationException
RepositoryException

getCorrespondingNodePath

public String getCorrespondingNodePath(String workspaceName)
                                throws ItemNotFoundException,
                                       NoSuchWorkspaceException,
                                       AccessDeniedException,
                                       RepositoryException

Specified by:
getCorrespondingNodePath in interface Node
Throws:
ItemNotFoundException
NoSuchWorkspaceException
AccessDeniedException
RepositoryException

getIndex

public int getIndex()
             throws RepositoryException

Specified by:
getIndex in interface Node
Throws:
RepositoryException

getSharedSet

public NodeIterator getSharedSet()
                          throws RepositoryException
Returns an iterator over all nodes that are in the shared set of this node. If this node is not shared then the returned iterator contains only this node.

Specified by:
getSharedSet in interface Node
Returns:
a NodeIterator
Throws:
RepositoryException - if an error occurs.
Since:
JCR 2.0

removeSharedSet

public void removeSharedSet()
                     throws VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException
A special kind of remove() that removes this node and every other node in the shared set of this node.

This removal must be done atomically, i.e., if one of the nodes cannot be removed, the function throws the exception remove() would have thrown in that case, and none of the nodes are removed.

If this node is not shared this method removes only this node.

Specified by:
removeSharedSet in interface Node
Throws:
VersionException
LockException
ConstraintViolationException
RepositoryException
Since:
JCR 2.0
See Also:
removeShare(), Item.remove()

removeShare

public void removeShare()
                 throws VersionException,
                        LockException,
                        ConstraintViolationException,
                        RepositoryException
A special kind of remove() that removes this node, but does not remove any other node in the shared set of this node.

All of the exceptions defined for remove() apply to this function. In addition, a RepositoryException is thrown if this node cannot be removed without removing another node in the shared set of this node.

If this node is not shared this method removes only this node.

Specified by:
removeShare in interface Node
Throws:
VersionException
LockException
ConstraintViolationException
RepositoryException
Since:
JCR 2.0
See Also:
removeSharedSet(), Item.remove()

getPrimaryPath

public Path getPrimaryPath()
                    throws RepositoryException
Returns the primary path to this Item. Overridden to return a different path for shareable nodes. TODO SN: copies functionality in that is already available in HierarchyManagerImpl, namely composing a path by concatenating the parent path + this node's name and index: rather use hierarchy manager to do this

Overrides:
getPrimaryPath in class ItemImpl
Returns:
the primary path to this Item
Throws:
RepositoryException

isCheckedOut

public boolean isCheckedOut()
                     throws RepositoryException

Specified by:
isCheckedOut in interface Node
Throws:
RepositoryException

update

public void update(String srcWorkspaceName)
            throws RepositoryException

Specified by:
update in interface Node
Throws:
RepositoryException

checkin

@Deprecated
public Version checkin()
                throws RepositoryException
Deprecated. 

Use VersionManager.checkin(String) instead

Specified by:
checkin in interface Node
Throws:
RepositoryException

checkin

@Deprecated
public Version checkin(Calendar created)
                throws RepositoryException
Deprecated. 

Use VersionManagerImpl.checkin(String, Calendar) instead

Throws:
RepositoryException
Since:
Apache Jackrabbit 1.6
See Also:
JCR-1972

checkout

@Deprecated
public void checkout()
              throws RepositoryException
Deprecated. 

Use VersionManager.checkout(String) instead

Specified by:
checkout in interface Node
Throws:
RepositoryException

merge

@Deprecated
public NodeIterator merge(String srcWorkspace,
                                     boolean bestEffort)
                   throws RepositoryException
Deprecated. 

Use VersionManager.merge(String, String, boolean) instead

Specified by:
merge in interface Node
Throws:
RepositoryException

cancelMerge

@Deprecated
public void cancelMerge(Version version)
                 throws RepositoryException
Deprecated. 

Use VersionManager.cancelMerge(String, Version) instead

Specified by:
cancelMerge in interface Node
Throws:
RepositoryException

doneMerge

@Deprecated
public void doneMerge(Version version)
               throws RepositoryException
Deprecated. 

Use VersionManager.doneMerge(String, Version) instead

Specified by:
doneMerge in interface Node
Throws:
RepositoryException

restore

@Deprecated
public void restore(String versionName,
                               boolean removeExisting)
             throws RepositoryException
Deprecated. 

Use VersionManager.restore(String, String, boolean) instead

Specified by:
restore in interface Node
Throws:
RepositoryException

restore

@Deprecated
public void restore(Version version,
                               boolean removeExisting)
             throws RepositoryException
Deprecated. 

Use VersionManager.restore(String, Version, boolean) instead

Specified by:
restore in interface Node
Throws:
RepositoryException

restore

@Deprecated
public void restore(Version version,
                               String relPath,
                               boolean removeExisting)
             throws RepositoryException
Deprecated. 

Use VersionManager.restore(String, Version, boolean) instead

Specified by:
restore in interface Node
Throws:
RepositoryException

restoreByLabel

@Deprecated
public void restoreByLabel(String versionLabel,
                                      boolean removeExisting)
                    throws RepositoryException
Deprecated. 

Use VersionManager.restoreByLabel(String, String, boolean) instead

Specified by:
restoreByLabel in interface Node
Throws:
RepositoryException

getVersionHistory

@Deprecated
public VersionHistory getVersionHistory()
                                 throws RepositoryException
Deprecated. 

Use VersionManager.getVersionHistory(String) instead

Specified by:
getVersionHistory in interface Node
Throws:
RepositoryException

getBaseVersion

@Deprecated
public Version getBaseVersion()
                       throws RepositoryException
Deprecated. 

Use VersionManager.getBaseVersion(String) instead

Specified by:
getBaseVersion in interface Node
Throws:
RepositoryException

lock

public Lock lock(boolean isDeep,
                 boolean isSessionScoped)
          throws UnsupportedRepositoryOperationException,
                 LockException,
                 AccessDeniedException,
                 InvalidItemStateException,
                 RepositoryException

Specified by:
lock in interface Node
Throws:
UnsupportedRepositoryOperationException
LockException
AccessDeniedException
InvalidItemStateException
RepositoryException

getLock

public Lock getLock()
             throws UnsupportedRepositoryOperationException,
                    LockException,
                    AccessDeniedException,
                    RepositoryException

Specified by:
getLock in interface Node
Throws:
UnsupportedRepositoryOperationException
LockException
AccessDeniedException
RepositoryException

unlock

public void unlock()
            throws UnsupportedRepositoryOperationException,
                   LockException,
                   AccessDeniedException,
                   InvalidItemStateException,
                   RepositoryException

Specified by:
unlock in interface Node
Throws:
UnsupportedRepositoryOperationException
LockException
AccessDeniedException
InvalidItemStateException
RepositoryException

holdsLock

public boolean holdsLock()
                  throws RepositoryException

Specified by:
holdsLock in interface Node
Throws:
RepositoryException

isLocked

public boolean isLocked()
                 throws RepositoryException

Specified by:
isLocked in interface Node
Throws:
RepositoryException

checkLock

protected void checkLock()
                  throws LockException,
                         RepositoryException
Deprecated. 

Check whether this node is locked by somebody else.

Throws:
LockException - if this node is locked by somebody else
RepositoryException - if some other error occurs

getIdentifier

public String getIdentifier()
                     throws RepositoryException

Specified by:
getIdentifier in interface Node
Throws:
RepositoryException

getReferences

public PropertyIterator getReferences(String name)
                               throws RepositoryException

Specified by:
getReferences in interface Node
Throws:
RepositoryException

getWeakReferences

public PropertyIterator getWeakReferences()
                                   throws RepositoryException

Specified by:
getWeakReferences in interface Node
Throws:
RepositoryException

getWeakReferences

public PropertyIterator getWeakReferences(String name)
                                   throws RepositoryException

Specified by:
getWeakReferences in interface Node
Throws:
RepositoryException

getNodes

public NodeIterator getNodes(String[] nameGlobs)
                      throws RepositoryException

Specified by:
getNodes in interface Node
Throws:
RepositoryException

getProperties

public PropertyIterator getProperties(String[] nameGlobs)
                               throws RepositoryException

Specified by:
getProperties in interface Node
Throws:
RepositoryException

setPrimaryType

public void setPrimaryType(String nodeTypeName)
                    throws NoSuchNodeTypeException,
                           VersionException,
                           ConstraintViolationException,
                           LockException,
                           RepositoryException

Specified by:
setPrimaryType in interface Node
Throws:
NoSuchNodeTypeException
VersionException
ConstraintViolationException
LockException
RepositoryException

setProperty

public Property setProperty(String name,
                            BigDecimal value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

setProperty

public Property setProperty(String name,
                            Binary value)
                     throws ValueFormatException,
                            VersionException,
                            LockException,
                            ConstraintViolationException,
                            RepositoryException

Specified by:
setProperty in interface Node
Throws:
ValueFormatException
VersionException
LockException
ConstraintViolationException
RepositoryException

getAllowedLifecycleTransistions

public String[] getAllowedLifecycleTransistions()
                                         throws UnsupportedRepositoryOperationException,
                                                RepositoryException
Returns all allowed transitions from the current lifecycle state of this node.

The lifecycle policy node referenced by the "jcr:lifecyclePolicy" property is expected to contain a "transitions" node with a list of child nodes, one for each transition. These transition nodes must have single-valued string "from" and "to" properties that identify the allowed source and target states of each transition.

Note that future versions of Apache Jackrabbit may well use different lifecycle policy implementations.

Specified by:
getAllowedLifecycleTransistions in interface Node
Returns:
allowed transitions for the current lifecycle state of this node
Throws:
UnsupportedRepositoryOperationException - if this node does not have the mix:lifecycle mixin node type
RepositoryException - if a repository error occurs
Since:
Apache Jackrabbit 2.0

followLifecycleTransition

public void followLifecycleTransition(String transition)
                               throws UnsupportedRepositoryOperationException,
                                      InvalidLifecycleTransitionException,
                                      RepositoryException
Transitions this node through its lifecycle to the given target state.

Specified by:
followLifecycleTransition in interface Node
Parameters:
transition - target lifecycle state
Throws:
UnsupportedRepositoryOperationException - if this node does not have the mix:lifecycle mixin node type
InvalidLifecycleTransitionException - if the given target state is not among the allowed transitions from the current lifecycle state of this node
RepositoryException - if a repository error occurs
Since:
Apache Jackrabbit 2.0
See Also:
getAllowedLifecycleTransistions()

assignLifecyclePolicy

public void assignLifecyclePolicy(Node policy,
                                  String state)
                           throws RepositoryException
Assigns the given lifecycle policy to this node and sets the current state to the one given.

Note that currently no special checks are made against the given arguments, and that you will need to explicitly persist these changes by calling save().

Note that future versions of Apache Jackrabbit may well use different lifecycle policy implementations.

Parameters:
policy - lifecycle policy node
state - current lifecycle state
Throws:
RepositoryException - if a repository error occurs

toString

public String toString()
Return a string representation of this node for diagnostic purposes.

Overrides:
toString in class ItemImpl
Returns:
"node /path/to/item"


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.