Ontimize Document Management 0.035EN

com.ontimize.dms
Class ODMSDocument

java.lang.Object
  extended by com.ontimize.dms.ODMSDocument
All Implemented Interfaces:
Document, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class ODMSDocument
extends java.lang.Object
implements Document

See Also:
Serialized Form

Field Summary
protected  java.io.File attachment
           
protected  java.lang.String base
           
static java.lang.String CONVERSION_PROPERTY_KEY
           
protected  java.lang.String file
           
protected  java.util.Map info
           
static java.lang.String INVALID_CONVERT_EXTENDED_KEY
           
static java.lang.String INVALID_CONVERT_KEY
           
static java.lang.String INVALID_KEY
           
static java.lang.String INVALID_KEY_SEPARATOR
           
protected static int invalidConvertExtend
           
protected static java.util.List invalidConvertList
           
protected static java.lang.String invalidConvertString
           
protected static java.util.List invalidList
           
protected static java.lang.String invalidString
           
protected  boolean leaf
           
protected  Document link
           
static java.lang.String MSG_CHECK_FILE_LENGTH
           
static java.lang.String MSG_CHECK_FILE_LOCKED
           
static java.lang.String MSG_CHECK_FILE_NAME
           
static java.lang.String MSG_CHECK_PATH_INVALID
           
static java.lang.String MSG_INIT_CONTEXT_NULL
           
static java.lang.String MSG_INIT_NODE_EMPTY
           
static java.lang.String MSG_INIT_NODE_NULL
           
protected  java.lang.String name
           
protected  java.lang.String path
           
static java.lang.String PROPERTIES
           
static char SEPARATOR_BAR_CHAR
           
static char SEPARATOR_INV_CHAR
           
 
Fields inherited from interface com.ontimize.dms.Document
BASE, BLANK, CHILDREN, COMMA, CONTENT, DATE_INSERT, DATE_UPDATE, DEEP, DESCRIPTION, DOCUMENT, FIELDS, FILE, LENGTH, LINK, LINK_TARGET, MAX_LENGTH, MAX_NUMBER, NAME, NODE_STATUS, NODE_STATUS_DATE, NODE_STATUS_USER, PATH, POINT, SEPARATOR_ASTERISK, SEPARATOR_BLANK, SEPARATOR_FILE, SEPARATOR_PATH, SEPARATOR_VERSION, STREAM, STREAM_VERSION, THUMBNAIL, TITLE, TYPE, TYPE_BASE, TYPE_DIR, TYPE_FILE, TYPE_KEYS, TYPE_LINK, USER_INSERT, USER_UPDATE
 
Constructor Summary
ODMSDocument()
           
ODMSDocument(ContextValues context, java.util.Map node)
           
ODMSDocument(Document parent, java.lang.String name)
          Construct a new Document with the parent base and parent path (path and name) and the given name.
ODMSDocument(Document base, java.lang.String path, java.io.File attachment)
           
ODMSDocument(java.io.File file, java.lang.String base, java.lang.String name)
           
ODMSDocument(java.lang.String base, java.lang.String path, java.lang.String name)
           
ODMSDocument(java.lang.String base, java.lang.String path, java.lang.String name, java.lang.String file)
           
 
Method Summary
protected  void check(java.lang.StringBuffer target, java.io.File file)
           
static boolean check(java.lang.String base, java.lang.String name)
           
protected  void checkLength(java.lang.String target, java.io.File file)
           
protected static boolean checkLength(java.lang.String target, java.lang.String name)
           
static void checkLock(java.io.File file)
          Checks if the file is non locked for read.
protected static void checkName(java.io.File file)
           
static java.lang.String checkName(java.lang.String name)
          Check the directory or file name.
static java.lang.String checkPath(EntityResult er)
          Checks if the model has the same path.
protected static java.lang.String checkUnique(EntityResult er, java.lang.String key)
           
protected  java.lang.Object clone()
           
protected  boolean compare(java.lang.String s1, java.lang.String s2)
           
 int compareTo(java.lang.Object o)
           
protected static java.lang.String convertInvalidASCII2String(java.lang.String string)
           
protected static java.lang.String convertInvalidString2ASCII(java.lang.String string)
           
 DocumentList create(java.io.File[] files)
          Creates a Document list from the given files.
protected static java.lang.String createASCII(char c)
           
protected static java.lang.String createJoinedPath(Document base, java.lang.String path)
           
protected  void createList(DocumentList list, java.lang.String current, java.lang.StringBuffer base, java.io.File file)
           
 Document deepClone()
          Creates a internal clone
 int depth()
           
 boolean equals(java.lang.Object object)
           
 Document flatten()
          Create a Document with path, name and filename.
 java.io.File getAttachedFile()
          Returns the attached file to this document.
 java.util.Map getAttachedInfo()
           
 Document getAttachedLink()
           
 java.lang.String getBase()
          Document base string.
 java.io.File getCanonicalFile(java.io.File source)
          Returns the file from the given source.
 java.io.File getCanonicalFile(java.lang.String source)
          Returns the file from the given source.
 java.lang.String getCanonicalPath()
           
 java.lang.String getCanonicalPath(java.lang.Number version)
          Returns the complete internal path document
 java.lang.String getCanonicalPath(java.lang.String keys)
           
 java.lang.String getExtension()
           
 java.lang.String getFile()
           
 java.lang.String getInternalPath()
           
static int getInvalidConvertExtend()
           
static java.util.List getInvalidConvertList()
           
static java.lang.String getInvalidConvertString()
           
static java.util.List getInvalidList()
           
static Document[] getLinks(Document[] documents)
           
 java.util.Map getMap()
           
 java.lang.String getName()
           
 Document getParent()
           
 java.lang.String getPath()
           
 java.lang.String getPath(java.lang.String keys)
           
 java.lang.String getRelativePath()
          Returns the internal path without the base.
static boolean hasEmptyLinks(Document[] documents)
           
 boolean hasFile()
           
 boolean isEmpty()
          Check if any field is empty.
protected static boolean isInvalidChar(char c)
           
 boolean isLeaf()
          Returns true if this document is a ending node.
 boolean isLink()
           
 boolean isNull()
          If the current document path is null.
 int length()
          Returns the base + path + name length.
static java.lang.String parse(java.lang.String path)
           
protected static java.lang.String parse(java.lang.String string, boolean required)
           
 Document plain()
           
 void setAttachedInfo(java.util.Map info)
           
 void setAttachmentFile(java.io.File attachment)
           
 void setBase(java.lang.String base)
           
 void setFile(java.lang.String file)
           
 void setKeys(java.lang.String keys)
           
 void setLink(Document link)
           
 void setName(java.lang.String name)
           
protected  void setPath(java.lang.String path)
           
 boolean startsWith(Document d)
           
 boolean startsWith(Document d, int level)
           
 boolean startsWith(java.lang.String string)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONVERSION_PROPERTY_KEY

public static final java.lang.String CONVERSION_PROPERTY_KEY
See Also:
Constant Field Values

PROPERTIES

public static final java.lang.String PROPERTIES
See Also:
Constant Field Values

INVALID_KEY

public static final java.lang.String INVALID_KEY
See Also:
Constant Field Values

INVALID_CONVERT_KEY

public static final java.lang.String INVALID_CONVERT_KEY
See Also:
Constant Field Values

INVALID_CONVERT_EXTENDED_KEY

public static final java.lang.String INVALID_CONVERT_EXTENDED_KEY
See Also:
Constant Field Values

INVALID_KEY_SEPARATOR

public static final java.lang.String INVALID_KEY_SEPARATOR
See Also:
Constant Field Values

MSG_INIT_CONTEXT_NULL

public static final java.lang.String MSG_INIT_CONTEXT_NULL
See Also:
Constant Field Values

MSG_INIT_NODE_NULL

public static final java.lang.String MSG_INIT_NODE_NULL
See Also:
Constant Field Values

MSG_INIT_NODE_EMPTY

public static final java.lang.String MSG_INIT_NODE_EMPTY
See Also:
Constant Field Values

MSG_CHECK_FILE_LENGTH

public static final java.lang.String MSG_CHECK_FILE_LENGTH
See Also:
Constant Field Values

MSG_CHECK_FILE_NAME

public static final java.lang.String MSG_CHECK_FILE_NAME
See Also:
Constant Field Values

MSG_CHECK_FILE_LOCKED

public static final java.lang.String MSG_CHECK_FILE_LOCKED
See Also:
Constant Field Values

MSG_CHECK_PATH_INVALID

public static final java.lang.String MSG_CHECK_PATH_INVALID
See Also:
Constant Field Values

SEPARATOR_INV_CHAR

public static final char SEPARATOR_INV_CHAR
See Also:
Constant Field Values

SEPARATOR_BAR_CHAR

public static final char SEPARATOR_BAR_CHAR
See Also:
Constant Field Values

invalidString

protected static java.lang.String invalidString

invalidList

protected static java.util.List invalidList

invalidConvertString

protected static java.lang.String invalidConvertString

invalidConvertList

protected static java.util.List invalidConvertList

invalidConvertExtend

protected static int invalidConvertExtend

base

protected java.lang.String base

path

protected java.lang.String path

name

protected java.lang.String name

file

protected java.lang.String file

link

protected Document link

leaf

protected boolean leaf

attachment

protected java.io.File attachment

info

protected java.util.Map info
Constructor Detail

ODMSDocument

public ODMSDocument()

ODMSDocument

public ODMSDocument(Document parent,
                    java.lang.String name)

Construct a new Document with the parent base and parent path (path and name) and the given name.

Parameters:
parent - Document
name - of the child.

ODMSDocument

public ODMSDocument(Document base,
                    java.lang.String path,
                    java.io.File attachment)

ODMSDocument

public ODMSDocument(java.io.File file,
                    java.lang.String base,
                    java.lang.String name)

ODMSDocument

public ODMSDocument(ContextValues context,
                    java.util.Map node)

ODMSDocument

public ODMSDocument(java.lang.String base,
                    java.lang.String path,
                    java.lang.String name)
             throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

ODMSDocument

public ODMSDocument(java.lang.String base,
                    java.lang.String path,
                    java.lang.String name,
                    java.lang.String file)
             throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException
Method Detail

createJoinedPath

protected static java.lang.String createJoinedPath(Document base,
                                                   java.lang.String path)

parse

public static java.lang.String parse(java.lang.String path)
                              throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

parse

protected static java.lang.String parse(java.lang.String string,
                                        boolean required)
                                 throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

createASCII

protected static java.lang.String createASCII(char c)

isInvalidChar

protected static boolean isInvalidChar(char c)

convertInvalidString2ASCII

protected static java.lang.String convertInvalidString2ASCII(java.lang.String string)

convertInvalidASCII2String

protected static java.lang.String convertInvalidASCII2String(java.lang.String string)

getBase

public java.lang.String getBase()
Description copied from interface: Document

Document base string. Can't be null.

Specified by:
getBase in interface Document
Returns:
Base string.

getName

public java.lang.String getName()
Specified by:
getName in interface Document

getFile

public java.lang.String getFile()
Specified by:
getFile in interface Document

getExtension

public java.lang.String getExtension()
Specified by:
getExtension in interface Document

getPath

public java.lang.String getPath()
Specified by:
getPath in interface Document

getPath

public java.lang.String getPath(java.lang.String keys)
Specified by:
getPath in interface Document

getInternalPath

public java.lang.String getInternalPath()
Specified by:
getInternalPath in interface Document

getParent

public Document getParent()
Specified by:
getParent in interface Document

getRelativePath

public java.lang.String getRelativePath()
Description copied from interface: Document

Returns the internal path without the base.

Specified by:
getRelativePath in interface Document

getCanonicalPath

public java.lang.String getCanonicalPath()
Specified by:
getCanonicalPath in interface Document

getCanonicalPath

public java.lang.String getCanonicalPath(java.lang.String keys)
Specified by:
getCanonicalPath in interface Document

getCanonicalPath

public java.lang.String getCanonicalPath(java.lang.Number version)
Description copied from interface: Document

Returns the complete internal path document

Specified by:
getCanonicalPath in interface Document
Parameters:
version - Version number.
Returns:
String with the internal path.

getCanonicalFile

public java.io.File getCanonicalFile(java.lang.String source)
Description copied from interface: Document

Returns the file from the given source.

Specified by:
getCanonicalFile in interface Document
Parameters:
source - Source path.
Returns:
File from the given source.

getCanonicalFile

public java.io.File getCanonicalFile(java.io.File source)
Description copied from interface: Document

Returns the file from the given source.

Specified by:
getCanonicalFile in interface Document
Parameters:
source - File directory
Returns:
File from the given source.

getAttachedFile

public java.io.File getAttachedFile()
Description copied from interface: Document

Returns the attached file to this document.

Additional Document information. Not required.

Specified by:
getAttachedFile in interface Document
Returns:
Attached file to this document.

getAttachedLink

public Document getAttachedLink()
Specified by:
getAttachedLink in interface Document

getMap

public java.util.Map getMap()
Specified by:
getMap in interface Document

getAttachedInfo

public java.util.Map getAttachedInfo()
Specified by:
getAttachedInfo in interface Document

flatten

public Document flatten()
Description copied from interface: Document

Create a Document with path, name and filename.

Specified by:
flatten in interface Document
Returns:
Document with path, name and file.

plain

public Document plain()
Specified by:
plain in interface Document

create

public DocumentList create(java.io.File[] files)
Description copied from interface: Document

Creates a Document list from the given files. Recursive.

Current document is the base path.

Specified by:
create in interface Document
Parameters:
files - File array to create a Document list. Null if the directory listing is not valid.
Returns:
Document list object with the valid files and invalid in the attached data.

createList

protected void createList(DocumentList list,
                          java.lang.String current,
                          java.lang.StringBuffer base,
                          java.io.File file)

check

public static boolean check(java.lang.String base,
                            java.lang.String name)

check

protected void check(java.lang.StringBuffer target,
                     java.io.File file)
              throws java.io.IOException
Throws:
java.io.IOException

checkLength

protected void checkLength(java.lang.String target,
                           java.io.File file)
                    throws java.io.IOException
Throws:
java.io.IOException

checkName

protected static void checkName(java.io.File file)
                         throws java.io.IOException
Throws:
java.io.IOException

checkLength

protected static boolean checkLength(java.lang.String target,
                                     java.lang.String name)

getInvalidConvertList

public static java.util.List getInvalidConvertList()

getInvalidList

public static java.util.List getInvalidList()

getInvalidConvertString

public static java.lang.String getInvalidConvertString()

getInvalidConvertExtend

public static int getInvalidConvertExtend()

checkName

public static java.lang.String checkName(java.lang.String name)

Check the directory or file name.

First check if the name starts or ends with a space.

Name can't contains only points.

Last, check the full char string searching invalid chars.

Parameters:
name - Directory or file name.
Returns:
The first invalid character found, Otherwise returns null.

checkLock

public static void checkLock(java.io.File file)
                      throws java.io.IOException

Checks if the file is non locked for read.

Parameters:
file - to check.
Throws:
java.io.IOException
DocumentException

checkPath

public static java.lang.String checkPath(EntityResult er)

Checks if the model has the same path.

Returns:

checkUnique

protected static java.lang.String checkUnique(EntityResult er,
                                              java.lang.String key)

setBase

public void setBase(java.lang.String base)
Specified by:
setBase in interface Document

setKeys

public void setKeys(java.lang.String keys)
Specified by:
setKeys in interface Document

setPath

protected void setPath(java.lang.String path)

setName

public void setName(java.lang.String name)
Specified by:
setName in interface Document

setFile

public void setFile(java.lang.String file)
Specified by:
setFile in interface Document

setAttachmentFile

public void setAttachmentFile(java.io.File attachment)
Specified by:
setAttachmentFile in interface Document

setLink

public void setLink(Document link)
Specified by:
setLink in interface Document

setAttachedInfo

public void setAttachedInfo(java.util.Map info)
Specified by:
setAttachedInfo in interface Document

isNull

public boolean isNull()
Description copied from interface: Document

If the current document path is null.

Specified by:
isNull in interface Document
Returns:
True if the current document doesn't contain any valid path.

isEmpty

public boolean isEmpty()
Description copied from interface: Document

Check if any field is empty.

Specified by:
isEmpty in interface Document
Returns:
True if any field is empty.

isLeaf

public boolean isLeaf()
Description copied from interface: Document

Returns true if this document is a ending node.

Specified by:
isLeaf in interface Document
Returns:
True if this node is a ending node. False otherwise.

isLink

public boolean isLink()
Specified by:
isLink in interface Document

hasFile

public boolean hasFile()
Specified by:
hasFile in interface Document

startsWith

public boolean startsWith(java.lang.String string)
Specified by:
startsWith in interface Document

startsWith

public boolean startsWith(Document d)
Specified by:
startsWith in interface Document

startsWith

public boolean startsWith(Document d,
                          int level)
Specified by:
startsWith in interface Document

length

public int length()
Description copied from interface: Document

Returns the base + path + name length.

Specified by:
length in interface Document
Returns:
Internal path length.

depth

public int depth()
Specified by:
depth in interface Document

compare

protected boolean compare(java.lang.String s1,
                          java.lang.String s2)

compareTo

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

equals

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

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

deepClone

public Document deepClone()
Description copied from interface: Document

Creates a internal clone

Specified by:
deepClone in interface Document
Returns:
Copy of the current Document.

toString

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

getLinks

public static Document[] getLinks(Document[] documents)

hasEmptyLinks

public static boolean hasEmptyLinks(Document[] documents)

Ontimize Document Management