com.ibm.pim.docstore
Interface Document


public interface Document

Interface for the Document object. A document is a file that is stored in the docstore.

Since:
6.0.0

Nested Class Summary
static class Document.Property
          Enumeration listing document properties
 
Field Summary
static java.lang.String copyright
           
 
Method Summary
 Document copyTo(java.lang.String documentPath)
          Copies the document to documentPath.
 void delete()
          Deletes this document.
 AccessControlGroup getAccessControlGroup()
          Fetches the access control group for this document.
 java.util.Collection<DocumentAuditLog> getAuditLog()
          Fetches the audit log for this document.
 java.lang.String getContent()
          Fetches the content of this document object as a String
 java.io.OutputStream getContent(java.io.OutputStream content)
          Fetches the content of this document as an OutputStream.
 java.io.Reader getContentReader()
          Fetches the content of the document in a Reader
 java.io.Reader getContentReader(CharSet charSet)
          Fetches the content of the document in a Reader using the encoding passed as the argument
 java.util.Date getLastModifiedTimestamp()
          Fetches the date and time at which this document was last modified.
 java.lang.String getPath()
          Fetches the path of the document in the docstore.
 java.lang.String getProperty(Document.Property propertyName)
          Fetches the value of the property given by property name
 java.lang.String getProperty(java.lang.String propertyName)
          Fetches the value of the property given by propertyName
 java.util.Collection<java.lang.String> getPropertyNames()
          Returns a collection of names of properties of this document.
 java.lang.String getRealPath()
          Returns the path of the document in the file system, if the document is present in the file system.
 java.lang.String getURL()
          Fetches the absolute path for the document.
 Document moveTo(java.lang.String documentPath)
          Moves this document to documentPath.
 void setAccessControlGroup(AccessControlGroup accessControlGroup)
          Sets the access control group for this document.
 void setContent(java.io.InputStream content)
          Sets the content of this document from the InputStream.
 void setContent(java.lang.String content)
          Sets the content of this document.
 void setProperty(Document.Property propertyName, java.lang.String propertyValue)
          Sets the value for the property, the property name is specified by propertyName and the value is given by propertyValue.
 void setProperty(java.lang.String propertyName, java.lang.String propertyValue)
          Sets the value for the property, the property name is specified by propertyName and the value is given by propertyValue.
 long size()
          Fetches the size of this document
 

Field Detail

copyright

static final java.lang.String copyright
See Also:
Constant Field Values
Method Detail

getContent

java.lang.String getContent()
Fetches the content of this document object as a String

Returns:
The content of this document
Throws:
PIMInternalException - If an internal error occurred.

getContent

java.io.OutputStream getContent(java.io.OutputStream content)
Fetches the content of this document as an OutputStream. To read binary content pass a ByteArrayOutputStream to this method.

Parameters:
content - The OutputStream object to which the content has to be written.
Returns:
The content of this document as an OutputStream.
Throws:
PIMInternalException - If an internal error occurred.
java.lang.IllegalArgumentException - If content is null.

getContentReader

java.io.Reader getContentReader()
Fetches the content of the document in a Reader

Returns:
A Reader object
Throws:
PIMInternalException - If an internal error occurs

getContentReader

java.io.Reader getContentReader(CharSet charSet)
Fetches the content of the document in a Reader using the encoding passed as the argument

Parameters:
charSet - The charset to be used for the reader.
Returns:
A Reader object
Throws:
PIMInternalException - If an internal error occurs
java.lang.IllegalArgumentException - If the encoding is empty

getPropertyNames

java.util.Collection<java.lang.String> getPropertyNames()
Returns a collection of names of properties of this document.

Returns:
A Collection of Strings
Throws:
PIMInternalException - If an internal error occurred.

getProperty

java.lang.String getProperty(Document.Property propertyName)
Fetches the value of the property given by property name

Parameters:
propertyName - The name of the property whose value has to be fetched
Returns:
The value of the property specified by propertyName. Returns null if the property does not exist for this document.
Throws:
PIMInternalException - If an internal error occurred.
java.lang.IllegalArgumentException - If propertyName is null.

getProperty

java.lang.String getProperty(java.lang.String propertyName)
Fetches the value of the property given by propertyName

Parameters:
propertyName - The name of the property whose value has to be fetched.
Returns:
The value of the property specified by propertyName. Returns null if the property does not exist for this document.
Throws:
PIMInternalException - If an internal error occurred.
java.lang.IllegalArgumentException - If propertyName is null or empty.

getAccessControlGroup

AccessControlGroup getAccessControlGroup()
Fetches the access control group for this document.

Returns:
AccessControlGroup object for this document.
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.

getLastModifiedTimestamp

java.util.Date getLastModifiedTimestamp()
Fetches the date and time at which this document was last modified.

Returns:
A Date object containing the date and time at which this document was last modified.
Throws:
PIMInternalException - If an internal error occurred.

size

long size()
Fetches the size of this document

Returns:
The size of this document as the number of bytes
Throws:
PIMInternalException - If an internal error occurred.

getAuditLog

java.util.Collection<DocumentAuditLog> getAuditLog()
Fetches the audit log for this document.

Returns:
Collection of DocumentAuditLog objects
Throws:
PIMInternalException - If an internal error occurred.

getPath

java.lang.String getPath()
Fetches the path of the document in the docstore.

Returns:
Path of the document in the docstore including the filename.
Throws:
PIMInternalException - If an internal error occurred.

getURL

java.lang.String getURL()
                        throws java.io.UnsupportedEncodingException
Fetches the absolute path for the document. This can be used in an HTML reference to provide a reference to the document.

Returns:
The absolute path of the document as a String.
Throws:
PIMInternalException - If an internal error occurred.
java.io.UnsupportedEncodingException - If the character encoding is not supported.

getRealPath

java.lang.String getRealPath()
Returns the path of the document in the file system, if the document is present in the file system.

Returns:
The path of the document in the file system
Throws:
PIMInternalException - If an internal error occurred.

setContent

void setContent(java.lang.String content)
Sets the content of this document. If the document had any content before this method is invoked, it will be replaced with the new content. Saves the document.

Parameters:
content - The content for this document
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.
java.lang.IllegalArgumentException - If content is null or empty.

setContent

void setContent(java.io.InputStream content)
Sets the content of this document from the InputStream. Saves the document. If the document had any content before this method is invoked, it will be replaced with the new content. To set binary content, pass a ByteArrayInputStream to this method.

Parameters:
content - An InputStream
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.
java.lang.IllegalArgumentException - If content is null.

setProperty

void setProperty(Document.Property propertyName,
                 java.lang.String propertyValue)
Sets the value for the property, the property name is specified by propertyName and the value is given by propertyValue. Saves the document.

Parameters:
propertyName - The property whose value has to be set
propertyValue - The value for the property
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use
java.lang.IllegalArgumentException - If propertyName is null.

setProperty

void setProperty(java.lang.String propertyName,
                 java.lang.String propertyValue)
Sets the value for the property, the property name is specified by propertyName and the value is given by propertyValue. Saves the document.

Parameters:
propertyName - The property whose value has to be set
propertyValue - The value for the property
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.
java.lang.IllegalArgumentException - If propertyName is null or empty

setAccessControlGroup

void setAccessControlGroup(AccessControlGroup accessControlGroup)
Sets the access control group for this document. Saves the document.

Parameters:
accessControlGroup - The access control group for this document
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.
java.lang.IllegalArgumentException - If accessControlGroup is null.
java.lang.IllegalStateException - If the access control group has not been persisted.

delete

void delete()
Deletes this document.

Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - If the user does not have the equivalent of Permission.DOCSTORE_DELETE_FILES

copyTo

Document copyTo(java.lang.String documentPath)
Copies the document to documentPath. Returns the document after copy. If a document is already present at the specified documentPath, its content is overwritten and its access control group will be retained. If a document is not present at the specified documentPath, a new document is created and the default access control group is set as the access control group of the document.

Parameters:
documentPath - The path to which the document has to be copied.
Returns:
The document found at documentPath.
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.
java.lang.IllegalArgumentException - If the documentPath is empty.

moveTo

Document moveTo(java.lang.String documentPath)
Moves this document to documentPath. If a document is already present at the specified documentPath, its content is overwritten and its access control group will be retained. If a document is not present at the specified documentPath, a new document is created and the default access control group is set as the access control group of the document. Once the document is moved, the instance on which move is called cannot be used and usage will result in IllegalStateException being thrown.

Parameters:
documentPath - The path to which the document has to be moved.
Returns:
The document found at documentPath.
Throws:
PIMInternalException - If an internal error occurred.
PIMAuthorizationException - Reserved for future use.
java.lang.IllegalArgumentException - If the documentPath is empty.