org.tolven.doc
Interface DocumentLocal

All Known Implementing Classes:
DocumentBean

public interface DocumentLocal

This is the business interface for Document enterprise bean.


Method Summary
 long countDocuments(long accountId)
          Count of all documents owned by this account.
 long countImages(long account)
          Count of all photo-documents owned by this account.
 long countXMLDocuments(long userId)
          Count of all documents owned by this user (ignoring account) - for demo use only.
 DocAttachment createAttachment(DocBase parentDocument, DocBase attachedDocument, java.lang.String description, AccountUser tolvenAuthor, java.util.Date now)
          Create a new document attachment
 DocCCR createCCRDocument(long userId, long accountId)
          The document is immediately persisted (with no XML in it).
 long createDocument(DocBase doc, long userId, long accountId)
          Persist a new document and return it's ID
 long createFinalDocument(DocBase doc)
          Persist a new document and return it's ID.
 long createImage(DocImage doc, long userId, long accountId, byte[] content)
          Persist a new image and return it's ID
 DocXML createXMLDocument(java.lang.String xmlNS, long userId, long accountId)
           
 void deleteAttachment(long attId, AccountUser accountUser)
          Delete an attachment.
 void finalizeDocument(DocBase doc)
          Complete the document submission process by rendering the document immutable.
 java.util.List<DocBase> findAllDocuments()
          Not a very practical method but we'll use it for testing.
 java.util.List<DocXML> findAllXMLDocuments(long userId, int pageSize, int offset, java.lang.String sortAttribute, java.lang.String sortDir)
          Return XML documents for the specified user
 java.util.List<DocAttachment> findAttachments(DocBase parentDocument)
          Find the attachments to the specified document
 DocBase findDocument(long docId)
          Get a document by its internal ID
 java.util.List<DocBase> findDocuments(long author, int pageSize, int offset, java.lang.String sortAttribute, java.lang.String sortDir)
          Return selected documents
 DocImage findImage(long docId, long accountId)
          Get a document by its internal ID
 java.util.List<DocImage> findImages(long accountId, int pageSize, int offset, java.lang.String sortAttribute, java.lang.String sortDir)
          Return images for the specified account
 java.util.List<DocXML> findXMLDocuments(long accountId, int pageSize, int offset, java.lang.String sortAttribute, java.lang.String sortDir)
          Return XML documents for the specified account
 java.util.List<AdministrativeDetail> getDetails(DocBase doc, AccountUser activeAccountUser)
          Return the content of this structured xml document as a list of administrative detail objects
 void queueTolvenMessage(TolvenMessage tm)
          Queue a document to be processed by Tolven.
 void saveDocument(DocBase doc)
          Save the document without finalizing.
 void setDetails(DocBase doc, java.util.List<AdministrativeDetail> details)
          Store document details in XML form.
 

Method Detail

createDocument

long createDocument(DocBase doc,
                    long userId,
                    long accountId)
Persist a new document and return it's ID

Parameters:
doc -
userId - of the author
accountId - of the account that owns the document
Returns:
the id assigned to the new document.

finalizeDocument

void finalizeDocument(DocBase doc)
Complete the document submission process by rendering the document immutable. A merge will be done in case the finalization occurs in a different transaction from the creation.

Parameters:
doc -

createFinalDocument

long createFinalDocument(DocBase doc)
Persist a new document and return it's ID. This is a final submission. the document is now immutable. Account and author should be provided in the document. Also, mediaType should be present.

Parameters:
doc -
userId - of the author
Returns:
the id assigned to the new document.

saveDocument

void saveDocument(DocBase doc)
Save the document without finalizing. A merge will be done in case the save occurs in a different transaction from the creation. Note: Withholding a "Save" does not imply a rollback. For example, a document that has been created or fetched and then modified within the same local VM and same transaction will "automatically" be saved. So this method simply ensures that documents in other states will also be saved.

Parameters:
doc -

createCCRDocument

DocCCR createCCRDocument(long userId,
                         long accountId)
                         throws CCRException
The document is immediately persisted (with no XML in it). This gives us the ID we'll need to create actual CCR object graph.

Parameters:
userId -
accountId -
Returns:
Throws:
CCRException

createXMLDocument

DocXML createXMLDocument(java.lang.String xmlNS,
                         long userId,
                         long accountId)

findAllDocuments

java.util.List<DocBase> findAllDocuments()
Not a very practical method but we'll use it for testing.

Returns:

findDocument

DocBase findDocument(long docId)
Get a document by its internal ID

Parameters:
docId - the id of the document
Returns:
the document object

findXMLDocuments

java.util.List<DocXML> findXMLDocuments(long accountId,
                                        int pageSize,
                                        int offset,
                                        java.lang.String sortAttribute,
                                        java.lang.String sortDir)
Return XML documents for the specified account


findAllXMLDocuments

java.util.List<DocXML> findAllXMLDocuments(long userId,
                                           int pageSize,
                                           int offset,
                                           java.lang.String sortAttribute,
                                           java.lang.String sortDir)
Return XML documents for the specified user


findImage

DocImage findImage(long docId,
                   long accountId)
Get a document by its internal ID

Parameters:
docId - the id of the document
accountId - This is not part of the primay key but is required to verify account ownership. A request for a docId outside of the current account is rejected.
Returns:
the document object

countDocuments

long countDocuments(long accountId)
Count of all documents owned by this account.


countXMLDocuments

long countXMLDocuments(long userId)
Count of all documents owned by this user (ignoring account) - for demo use only.


countImages

long countImages(long account)
Count of all photo-documents owned by this account.


findDocuments

java.util.List<DocBase> findDocuments(long author,
                                      int pageSize,
                                      int offset,
                                      java.lang.String sortAttribute,
                                      java.lang.String sortDir)
Return selected documents


findImages

java.util.List<DocImage> findImages(long accountId,
                                    int pageSize,
                                    int offset,
                                    java.lang.String sortAttribute,
                                    java.lang.String sortDir)
Return images for the specified account


createImage

long createImage(DocImage doc,
                 long userId,
                 long accountId,
                 byte[] content)
Persist a new image and return it's ID

Parameters:
doc -
accountId - of the author
content - the actual image to store
Returns:
the id assigned to the new document.

setDetails

void setDetails(DocBase doc,
                java.util.List<AdministrativeDetail> details)
                throws javax.xml.bind.JAXBException,
                       java.io.IOException
Store document details in XML form. A valid XML document must contain just one root element and we create that element here, hiding it from the Java programmer who can just deal with the collection.

Parameters:
details - A structure ready for marshalling into XML
Throws:
javax.xml.bind.JAXBException
java.io.IOException

getDetails

java.util.List<AdministrativeDetail> getDetails(DocBase doc,
                                                AccountUser activeAccountUser)
                                                throws javax.xml.bind.JAXBException,
                                                       java.io.IOException
Return the content of this structured xml document as a list of administrative detail objects

Returns:
List
Throws:
javax.xml.bind.JAXBException
java.io.IOException

createAttachment

DocAttachment createAttachment(DocBase parentDocument,
                               DocBase attachedDocument,
                               java.lang.String description,
                               AccountUser tolvenAuthor,
                               java.util.Date now)
Create a new document attachment

Parameters:
parentDocument - The account of the parent document and attachment must be the same.
attachedDocument - The document to attach
description -
tolvenAuthor -
now -
Returns:
A new attachment object which has already been persisted

findAttachments

java.util.List<DocAttachment> findAttachments(DocBase parentDocument)
Find the attachments to the specified document

Parameters:
parentDocument - The document for which attachments are sought
Returns:
The list of attachments. The list may be empty

deleteAttachment

void deleteAttachment(long attId,
                      AccountUser accountUser)
Delete an attachment. the attachment must is part of an editable parent document.

Parameters:
attId -
accountUser -

queueTolvenMessage

void queueTolvenMessage(TolvenMessage tm)
                        throws java.lang.Exception
Queue a document to be processed by Tolven. The payload should be in cleartext and will be encrypted prior to being added to the queue.

Throws:
java.lang.Exception