OKMDocument

From OpenKM Documentation
Revision as of 09:02, 6 March 2012 by Pavila (talk | contribs) (Document create(String token, Document doc, byte[] content))

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Methods related to document management.

Document create(String token, Document doc, byte[] content)

Create a new document in the repository.

Parameters

  • token - The session authorization token.
  • doc - A document object with the new document properties.
  • content - The document content in bytes.

Returns

  • A document object with the properties of the new created document.

Throws

  • IOException - An error when inserting document data into the repository.
  • UnsupportedMimeTypeException - If the uploaded file has an unsupported MIME type.
  • FileSizeExceededException - If the document content is biggest than the maximum accepted.
  • VirusDetectedException - If the document is infected by a virus.
  • PathNotFoundException - If the parent folder doesn't exist.
  • ItemExistsException - If there is already a document in the repository with the same name.
  • AccessDeniedException - If there is any security problem: you can't modify the parent document folder because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

Document createSimple(String token, String docPath, byte[] content)

Create a new document in the repository.

Parameters

  • token - The session authorization token.
  • docPath - The document destination path in the repository.
  • content - The document content in bytes.

Returns

  • A document object with the properties of the new created document.

Throws

  • IOException - An error when inserting document data into the repository.
  • UnsupportedMimeTypeException - If the uploaded file has an unsupported MIME type.
  • FileSizeExceededException - If the document content is biggest than the maximum accepted.
  • VirusDetectedException - If the document is infected by a virus.
  • PathNotFoundException - If the parent folder doesn't exist.
  • ItemExistsException - If there is already a document in the repository with the same name.
  • AccessDeniedException - If there is any security problem: you can't modify the parent document folder because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

void delete(String token, String docId)

Removes a document from the repository and move it to the user trash.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • none

Throws

  • LockException - Can't delete a locked document.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

void lock(String token, String docPath)

Lock a document, so only is editable by the locker.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • A Collection of Versions with every document version.

Throws

  • LockException - If the node is already locked.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

void unlock(String token, String docPath)

Unlock a document, so will be editable for other users.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • none

Throws

  • LockException - If the node is not locked.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

Document rename(String token, String docPath, String newName)

Rename a document in the repository.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.
  • newName - The new document name.

Returns

  • A document object with the new document properties.

Throws

  • PathNotFoundException - If there is no document in this repository path.
  • ItemExistsException - If there is already a document in the repository with the same name in the same path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

void move(String token, String docPath, String fldPath)

Move a document to another location in the repository.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.
  • fldPath - The destination folder path.

Returns

  • none

Throws

  • PathNotFoundException - If the fldPath does not exists.
  • ItemExistsException - If there is already a document in the destination folder with the same name.
  • AccessDeniedException - If there is any security problem: you can't modify the document's parent folder or the destination folder because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

Document getProperties(String token, String docPath)

Obtain document properties from the repository.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • The document properties.

Throws

  • PathNotFoundException - If there is no document in this repository path.
  • RepositoryException - If there is any general repository problem.

void setProperties(String token, Document doc)

Set the properties of a repository document.

Parameters

  • token - The session authorization token.
  • doc - An document object with the properties.

Returns

  • none

Throws

  • LockException - A locked document can't be modified.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

void setContent(String token, String docPath, byte[] content)

Set document content in the repository.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.
  • content - The new document content.

Returns

  • none

Throws

  • IOException - If there is any error setting the new content.
  • VersionException - A document checked in can't be modified.
  • LockException - A locked document can't be modified.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

byte[] getContent(String token, String docPath, boolean checkout)

Obtain document content from the repository.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.
  • checkout - If the content is retrieved after a check-out or not.

Returns

  • none

Throws

  • IOException - An error when retrieving document data from the repository.
  • PathNotFoundException - If there is no document in this repository path.
  • RepositoryException - If there is any general repository problem.

byte[] getContentByVersion(String token, String docPath, String versionId)

Obtain document content from the repository.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.
  • versionId - The version identification associated to the document content.

Returns

  • none

Throws

  • IOException - An error when retrieving document data from the repository.
  • PathNotFoundException - If there is no document in this repository path.
  • RepositoryException - If there is any general repository problem.

void checkout(String token, String docPath)

Checkout the document to edit it. The document can't be edited by another user until it is checked in o the checkout is cancelled.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • A Collection with the child documents.

Throws

  • LockException - A locked document can't be modified.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

void cancelCheckout(String token, String docPath)

Cancel a previous checked out state in a document.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • A Collection with the child documents.

Throws

  • LockException - A locked document can't be modified.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

Version checkin(String token, String docPath, String comment)

Check in the document to create a new version.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • A version object with the properties of the new generated version.

Throws

  • LockException - A locked document can't be modified.
  • VersionException - If the nodes was not previously checked out.
  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

VersionArray getVersionHistory(String token, String docPath)

Get the document version history.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • A Collection of Versions with every document version.

Throws

  • PathNotFoundException - If there is no document in this repository path.
  • RepositoryException - If there is any general repository problem.

void restoreVersion(String token, String docPath, String versionId)

Revert the document to an specific previous version.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.
  • versionId - The version id to revert to.

Returns

  • none

Throws

  • PathNotFoundException - If there is no document in this repository path.
  • AccessDeniedException - If there is any security problem: you can't modify the document because of lack of permissions.
  • RepositoryException - If there is any general repository problem.

DocumentArray getChilds(String token, String fldId)

Retrieve a list of child documents from an existing folder.

Parameters

  • token - The session authorization token.
  • fldPath - The path that identifies an unique folder.

Returns

  • A Collection with the child documents.

Throws

  • PathNotFoundException - If there is no document in this repository path.
  • RepositoryException If there is any general repository problem.

boolean isValid(String token, String docPath)

Test if a document path is valid.

Parameters

  • token - The session authorization token.
  • docPath - The path that identifies an unique document.

Returns

  • True if the path denotes a document, otherwise false.

Throws

  • AccessDeniedException - If there is any security problem: you can't access this folder because of lack of permissions.
  • RepositoryException - If there is any general repository problem.
  • PathNotFoundException - If there is no folder in the repository with this path.

String getPath(String token, String uuid)

The the document path from a UUID.

Parameters

  • token - The session authorization token.
  • uuid - The unique document identifier.

Returns

  • The document path or null if this UUID does not correspond to a document node.

Throws

  • AccessDeniedException - If there is any security problem: you can't access this folder because of lack of permissions.
  • RepositoryException If there is any general repository problem.