Ontimize Document Management 0.035EN

com.ontimize.dms.jcr
Class JcrNodeBase

java.lang.Object
  extended by com.ontimize.dms.jcr.JcrWrapperAbstract
      extended by com.ontimize.dms.jcr.JcrNodeBase
All Implemented Interfaces:
JcrLockable, JcrNode, JcrWrapper, java.lang.Comparable

public abstract class JcrNodeBase
extends JcrWrapperAbstract
implements JcrNode


Field Summary
protected static java.util.List ALLOWED_STATUS_TYPES
           
protected  Node base
           
static java.util.List DEFAULT_PATH_TYPES
           
static java.util.List DEFAULT_PROPERTIES
           
static java.util.List DEFAULT_TYPES
           
protected static java.util.List INTERNAL_NODE_TYPES
           
protected static java.util.List NODE_STATUS_PROPERTIES
           
static java.util.List QUERY_DEFAULT_PROPERTIES
           
protected static java.util.List QUERY_DENY_PROPERTIES
           
protected static java.util.List STREAM_STATUS_PROPERTIES
           
 
Fields inherited from class com.ontimize.dms.jcr.JcrWrapperAbstract
MSG_CREATE_NM
 
Fields inherited from interface com.ontimize.dms.jcr.JcrNode
AUTO_NAMES, BASE, CHILDREN, DATA, DATE_INSERT, DATE_UPDATE, DEEP, DESCRIPTION, DOCUMENT, FIELDS, FILE, JCR_CONTENT, KEYS, LAST_MODIFIED, LINK, LINK_TARGET, MIME_TYPE, NAME, NODE_FIELDS, NODE_FILE, NODE_FOLDER, NODE_LINK, NODE_STATUS, NODE_STATUS_DATE, NODE_STATUS_USER, NT_UNSTRUCTURED, PARENT_FIELDS, PATH, PROPERTY_STATUS, PROPERTY_STATUS_DATE, PROPERTY_STATUS_USER, STREAM, STREAM_DATE, STREAM_LENGTH, STREAM_OPENED, STREAM_STATUS, STREAM_STATUS_DATE, STREAM_STATUS_USER, STREAM_VERSION, THUMBNAIL, TITLE, TYPE, TYPE_BASE, TYPE_DIR, TYPE_FILE, TYPE_KEYS, TYPE_LINK, USER_INSERT, USER_UPDATE
 
Constructor Summary
JcrNodeBase(JcrSession session, Node base, Node node)
           
 
Method Summary
 void checkEditable()
           
protected  void checkInsert(Type nodeType)
           
 JcrNode clone(Node node)
           
 int compareTo(java.lang.Object o)
           
protected abstract  java.lang.String createDecoded(java.lang.String path)
           
protected abstract  java.lang.String createEncoded(java.lang.String path)
           
protected  Node createFileNode(Node parent, java.lang.String name)
           
protected  Node createFolderNode(Node parent, java.lang.String name)
           
protected  Lock createInternalLock(Node node)
           
protected  void createInternalUnlock(Node node)
           
protected  Node createLinkNode(Node parent, java.lang.String name, Node content)
           
protected  JcrLock createLock(Lock nodeLock, Status status)
           
protected  JcrProperty createProperty(Node node)
           
protected static java.util.Map createQueryFields(java.util.Map fields)
           
static java.util.List createQueryKeys(java.util.List keys)
           
protected  JcrStream createStream(Node node, boolean data)
           
protected  JcrVersion createVersion(JcrNode node)
           
protected  void doRemove(java.lang.String property, Status status, java.util.List properties)
           
 boolean equals(java.lang.Object o)
           
 Node getBase()
          Returns the node base for the node and the current session request.
 JcrNodeIterator getChildren(java.util.Map fields, boolean recursive)
          Return a iterator with the children filtered with the given Map.
 long getChildrenSize()
          Returns the children node list size.
 java.lang.String getFile()
          Returns the attached file name.
 java.lang.String getName()
          Returns the node name.
 Node getNode()
          Returns the internal JCR node interface.
 Type getNodeType()
           
 java.lang.String getPath()
          Returns the path of the current node.
 java.util.Map getPathTypes()
          Returns the path types of the current node path.
 java.util.Map getPathTypes(java.util.List types, java.util.Map alias)
          Returns the path types of the current node path.
 JcrProperty getProperty()
          Returns a property handler for the current node.
 JcrStream getStream()
          Returns the saved stream in the node.
 JcrStream getStream(boolean data)
          Returns the saved stream in the node and / or its properties.
protected  java.lang.String getSubpath(java.lang.String type)
           
 JcrVersion getVersion()
          Returns a version handle for the current node.
 boolean hasNodeType()
           
protected  boolean hasValue(JcrNode node, java.lang.String property, java.lang.String[] values)
           
 JcrNode insert(java.util.Map info, java.util.Map properties)
          Insert a new child node to current node.
 boolean isBase()
          Check if the current node is in the base path of the repository.
 boolean isEditable()
          Check if the current node can be changed.
 boolean isKeys()
          Check if the current node is a key node.
 boolean isLeaf()
          Checks if there is a ending node.
 boolean isLink()
          Check if the current node is a link to another.
 JcrLock isLocked()
          Check if the current node is locked (directory or file).
protected  JcrLock isLocked(boolean checkEmpty)
          Searchs in the current node the selected lock flags.
 boolean isRoot()
           
static boolean isSaveInSessionEnabled()
           
 JcrLock lock(Status status)
          Tags the current element as locked with the Status.
 JcrNode paste(java.util.Map info, java.util.Map properties, boolean copy)
          Moves the current node to the desired target.
 JcrNode remove()
          Removes the current node.
protected  void removeReferences(Node node)
           
 JcrNode rename(java.lang.String name)
          Changes the name of the current node.
static void setSaveInSessionChanges(boolean saveInSessionChanges)
           
 java.lang.String toString()
           
 JcrLock unlock()
           
 JcrLock unlock(boolean emptyLength)
          
 JcrLock unlock(Status status)
           
 JcrLock unlock(Status[] status)
           
 JcrNode update(java.util.Map info, boolean version)
          Set new information to the base version of the current node.
 
Methods inherited from class com.ontimize.dms.jcr.JcrWrapperAbstract
createNodeManager, createNodeManager, getConverter, getInnerSession, getInternal, getSession, getWrapper, save, save, setConverter, setInnerSession, setInternal, setSaveInSession, setSession, setWrapper
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ontimize.dms.jcr.JcrWrapper
getInnerSession, getInternal, getSession, getWrapper, save
 

Field Detail

INTERNAL_NODE_TYPES

protected static java.util.List INTERNAL_NODE_TYPES

DEFAULT_TYPES

public static java.util.List DEFAULT_TYPES

DEFAULT_PATH_TYPES

public static java.util.List DEFAULT_PATH_TYPES

QUERY_DENY_PROPERTIES

protected static java.util.List QUERY_DENY_PROPERTIES

QUERY_DEFAULT_PROPERTIES

public static java.util.List QUERY_DEFAULT_PROPERTIES

DEFAULT_PROPERTIES

public static java.util.List DEFAULT_PROPERTIES

NODE_STATUS_PROPERTIES

protected static java.util.List NODE_STATUS_PROPERTIES

STREAM_STATUS_PROPERTIES

protected static java.util.List STREAM_STATUS_PROPERTIES

ALLOWED_STATUS_TYPES

protected static java.util.List ALLOWED_STATUS_TYPES

base

protected Node base
Constructor Detail

JcrNodeBase

public JcrNodeBase(JcrSession session,
                   Node base,
                   Node node)
            throws RepositoryException
Throws:
RepositoryException
Method Detail

isSaveInSessionEnabled

public static boolean isSaveInSessionEnabled()

setSaveInSessionChanges

public static void setSaveInSessionChanges(boolean saveInSessionChanges)

getBase

public Node getBase()
Description copied from interface: JcrNode

Returns the node base for the node and the current session request.

Specified by:
getBase in interface JcrNode
Returns:
The internal JCR node base.

getNode

public Node getNode()
Description copied from interface: JcrNode

Returns the internal JCR node interface.

Specified by:
getNode in interface JcrNode
Returns:
Returns the internal JCR node interface.

getName

public java.lang.String getName()
                         throws RepositoryException
Description copied from interface: JcrNode

Returns the node name.

Specified by:
getName in interface JcrNode
Returns:
Current node name.
Throws:
RepositoryException - if JCR exception is thrown.

getFile

public java.lang.String getFile()
                         throws RepositoryException
Description copied from interface: JcrNode

Returns the attached file name.

Note: File name can be different of current node name.

Specified by:
getFile in interface JcrNode
Returns:
Attached file name.
Throws:
RepositoryException - if JCR exception is thrown.

getPath

public java.lang.String getPath()
                         throws RepositoryException
Description copied from interface: JcrNode

Returns the path of the current node.

Specified by:
getPath in interface JcrNode
Returns:
Current node path.
Throws:
RepositoryException - if JCR exception is thrown.

getPathTypes

public java.util.Map getPathTypes()
                           throws RepositoryException
Description copied from interface: JcrNode

Returns the path types of the current node path.
Parse: base, keys, path, name and file of the current node.

Specified by:
getPathTypes in interface JcrNode
Returns:
Map with base, keys, path, name and file.
Throws:
RepositoryException - if JCR exception is thrown.

getPathTypes

public java.util.Map getPathTypes(java.util.List types,
                                  java.util.Map alias)
                           throws RepositoryException
Description copied from interface: JcrNode

Returns the path types of the current node path.
Parse: base, keys, path, name and file of the current node.

Specified by:
getPathTypes in interface JcrNode
Parameters:
types - Path types to return.
alias - map with alternative keys.
Returns:
Map with base, keys, path, name and file.
Throws:
RepositoryException - if JCR exception is thrown.

getSubpath

protected java.lang.String getSubpath(java.lang.String type)

getNodeType

public Type getNodeType()
                 throws RepositoryException
Specified by:
getNodeType in interface JcrNode
Throws:
RepositoryException

getChildrenSize

public long getChildrenSize()
                     throws RepositoryException
Description copied from interface: JcrNode

Returns the children node list size.

Specified by:
getChildrenSize in interface JcrNode
Returns:
Children node list size. Returns -1 if the node is a leaf.
Throws:
RepositoryException - if JCR exception ocurrs.

hasValue

protected boolean hasValue(JcrNode node,
                           java.lang.String property,
                           java.lang.String[] values)

isLeaf

public boolean isLeaf()
               throws RepositoryException
Description copied from interface: JcrNode

Checks if there is a ending node.

Specified by:
isLeaf in interface JcrNode
Returns:
True if this is a ending node.
Throws:
RepositoryException - if JCR exception ocurrs.

isRoot

public boolean isRoot()
               throws RepositoryException
Specified by:
isRoot in interface JcrNode
Throws:
RepositoryException

isBase

public boolean isBase()
               throws RepositoryException
Description copied from interface: JcrNode

Check if the current node is in the base path of the repository.

Specified by:
isBase in interface JcrNode
Returns:
True is this node is in the base path.
Throws:
RepositoryException - if JCR exception ocurrs.

isKeys

public boolean isKeys()
               throws RepositoryException
Description copied from interface: JcrNode

Check if the current node is a key node.

Specified by:
isKeys in interface JcrNode
Returns:
True is this node is a key node.
Throws:
RepositoryException - if JCR exception ocurrs.

isLink

public boolean isLink()
               throws RepositoryException
Description copied from interface: JcrNode

Check if the current node is a link to another.

Specified by:
isLink in interface JcrNode
Returns:
True if the current node is a link.
Throws:
RepositoryException - if JCR exception ocurrs.

isEditable

public boolean isEditable()
                   throws RepositoryException
Description copied from interface: JcrNode

Check if the current node can be changed. (System nodes root, keys and base can be changed.)

Specified by:
isEditable in interface JcrNode
Returns:
True if the node can be changed.
Throws:
RepositoryException

checkEditable

public void checkEditable()
                   throws RepositoryException
Specified by:
checkEditable in interface JcrNode
Throws:
RepositoryException

hasNodeType

public boolean hasNodeType()
                    throws RepositoryException
Specified by:
hasNodeType in interface JcrNode
Throws:
RepositoryException

getStream

public JcrStream getStream()
                    throws RepositoryException,
                           LockException
Description copied from interface: JcrNode

Returns the saved stream in the node.

Specified by:
getStream in interface JcrNode
Returns:
Stream handler for current node.
Throws:
RepositoryException - if JCR exception ocurrs.
LockException - if the current node is locked.

getStream

public JcrStream getStream(boolean data)
                    throws RepositoryException,
                           LockException
Description copied from interface: JcrNode

Returns the saved stream in the node and / or its properties.

Specified by:
getStream in interface JcrNode
Parameters:
data - True returns the stream data and related properties.
False to return the stream related properties.
Returns:
Stream handler for current node.
Throws:
RepositoryException - if JCR exception ocurrs.
LockException - if the current node is locked.

createStream

protected JcrStream createStream(Node node,
                                 boolean data)
                          throws RepositoryException
Throws:
RepositoryException

getProperty

public JcrProperty getProperty()
                        throws RepositoryException
Description copied from interface: JcrNode

Returns a property handler for the current node.

Specified by:
getProperty in interface JcrNode
Returns:
Property handler for current node.
Throws:
RepositoryException - if JCR exception ocurrs.

createProperty

protected JcrProperty createProperty(Node node)
                              throws RepositoryException
Throws:
RepositoryException

getVersion

public JcrVersion getVersion()
                      throws RepositoryException
Description copied from interface: JcrNode

Returns a version handle for the current node.

Specified by:
getVersion in interface JcrNode
Returns:
Version handler for current node. Null if the node is not versionable.
Throws:
RepositoryException - if JCR exception ocurrs.

createVersion

protected JcrVersion createVersion(JcrNode node)
                            throws RepositoryException
Throws:
RepositoryException

createQueryKeys

public static java.util.List createQueryKeys(java.util.List keys)

createQueryFields

protected static java.util.Map createQueryFields(java.util.Map fields)

getChildren

public JcrNodeIterator getChildren(java.util.Map fields,
                                   boolean recursive)
                            throws RepositoryException
Description copied from interface: JcrNode

Return a iterator with the children filtered with the given Map.

Specified by:
getChildren in interface JcrNode
Parameters:
fields - List only the nodes with the current keys/values.
recursive - Search child nodes recursive.
Returns:
Iterator with the children list.
Throws:
RepositoryException - if JCR exception ocurrs.

checkInsert

protected void checkInsert(Type nodeType)
                    throws RepositoryException
Throws:
RepositoryException

createFolderNode

protected Node createFolderNode(Node parent,
                                java.lang.String name)
                         throws RepositoryException
Throws:
RepositoryException

createFileNode

protected Node createFileNode(Node parent,
                              java.lang.String name)
                       throws RepositoryException
Throws:
RepositoryException

createLinkNode

protected Node createLinkNode(Node parent,
                              java.lang.String name,
                              Node content)
                       throws RepositoryException
Throws:
RepositoryException

insert

public JcrNode insert(java.util.Map info,
                      java.util.Map properties)
               throws RepositoryException
Description copied from interface: JcrNode

Insert a new child node to current node.

Support to insert complete directories path.

Specified by:
insert in interface JcrNode
Parameters:
info - New node information
properties - Additional properties to new nodes.
Returns:
The new child node
Throws:
RepositoryException - if JCR exception ocurrs.

update

public JcrNode update(java.util.Map info,
                      boolean version)
               throws RepositoryException,
                      LockException
Description copied from interface: JcrNode

Set new information to the base version of the current node.

Specified by:
update in interface JcrNode
Parameters:
info - Node information
Returns:
The current node
Throws:
RepositoryException - if JCR exception ocurrs.
LockException - if the current node is locked.

paste

public JcrNode paste(java.util.Map info,
                     java.util.Map properties,
                     boolean copy)
              throws LockException,
                     RepositoryException
Description copied from interface: JcrNode

Moves the current node to the desired target.

Recursive

The target must exists.

Specified by:
paste in interface JcrNode
Parameters:
info - Node to paste information
properties - Additional properties to the target node.
Returns:
Current node.
Throws:
LockException - if the current node is locked.
RepositoryException - if JCR exception ocurrs.

rename

public JcrNode rename(java.lang.String name)
               throws LockException,
                      RepositoryException
Description copied from interface: JcrNode

Changes the name of the current node.

Specified by:
rename in interface JcrNode
Parameters:
name - New node name
Returns:
Current node.
Throws:
LockException - if the current node is locked.
RepositoryException - if JCR exception ocurrs.

remove

public JcrNode remove()
               throws LockException,
                      RepositoryException
Description copied from interface: JcrNode

Removes the current node.

If the current node is a file, remove all links to current node.

Specified by:
remove in interface JcrNode
Returns:
Current node.
Throws:
LockException - if the current node is locked.
RepositoryException - if JCR exception ocurrs.

removeReferences

protected void removeReferences(Node node)
                         throws RepositoryException
Throws:
RepositoryException

isLocked

public JcrLock isLocked()
                 throws RepositoryException
Description copied from interface: JcrLockable

Check if the current node is locked (directory or file).

Directory is locked if any of this children is locked.

File is locked if STREAM_STATUS exists.

Specified by:
isLocked in interface JcrLockable
Returns:
Lock handler if the node is locked, otherwise null.
Throws:
RepositoryException - if JCR exception ocurrs.

createInternalLock

protected Lock createInternalLock(Node node)
                           throws RepositoryException
Throws:
RepositoryException

createInternalUnlock

protected void createInternalUnlock(Node node)
                             throws RepositoryException
Throws:
RepositoryException

isLocked

protected JcrLock isLocked(boolean checkEmpty)
                    throws RepositoryException

Searchs in the current node the selected lock flags.

Parameters:
checkEmpty - Searchs all files without length (already not uploaded).
Returns:
Lock object of the current node.
Throws:
RepositoryException

lock

public JcrLock lock(Status status)
             throws RepositoryException
Description copied from interface: JcrLockable

Tags the current element as locked with the Status.

Specified by:
lock in interface JcrLockable
Parameters:
status - New status.
Returns:
The created lock.
Throws:
RepositoryException - if JCR exception ocurrs.

createLock

protected JcrLock createLock(Lock nodeLock,
                             Status status)
                      throws RepositoryException
Throws:
RepositoryException

unlock

public JcrLock unlock()
               throws RepositoryException
Specified by:
unlock in interface JcrLockable
Throws:
RepositoryException

unlock

public JcrLock unlock(boolean emptyLength)
               throws RepositoryException
Description copied from interface: JcrLockable

Specified by:
unlock in interface JcrLockable
Parameters:
emptyLength - Allows to set a zero length to reset status.
Returns:
Throws:
RepositoryException

unlock

public JcrLock unlock(Status status)
               throws RepositoryException
Specified by:
unlock in interface JcrLockable
Throws:
RepositoryException

unlock

public JcrLock unlock(Status[] status)
               throws RepositoryException
Specified by:
unlock in interface JcrLockable
Throws:
RepositoryException

doRemove

protected void doRemove(java.lang.String property,
                        Status status,
                        java.util.List properties)
                 throws RepositoryException
Throws:
RepositoryException

createEncoded

protected abstract java.lang.String createEncoded(java.lang.String path)

createDecoded

protected abstract java.lang.String createDecoded(java.lang.String path)

clone

public JcrNode clone(Node node)
              throws RepositoryException
Specified by:
clone in interface JcrNode
Throws:
RepositoryException

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Ontimize Document Management