org.outerj.daisy.repository.commonimpl
Interface DocumentStrategy


public interface DocumentStrategy

Allows to customise some of the behaviour of the CommonRepository, and especially DocumentImpl.

The typical use of this is to provide two implementations of the repository API's: one for local (in-server) use, and one for remote (= client) use, by only having to implement twice those aspects which differ in each implementation.

The most important difference between the client and server API implementations will be how they load and store entities (such as Document objects): the client API implementation will do this by contacting the server, the server implementation will do this by using its persistence mechanisms (such as an RDBMS).

Note that this API is not really meant for public consumption, and the correct workings of its implementations (especially the server-side one) are crucial for the correct operation of the repository. It is important that the strategy implementation correctly initialiases, updates and interprets the internal state of the objects it handles.

Certain methonds, like load(AuthenticatedUser,long,long,long) and store(org.outerj.daisy.repository.commonimpl.DocumentImpl) need to check if the user has the rights to perform this operation. This is especially true for the serverside implementation, the client side implementation doesn't need to do this as it will contact the server which will automatically do this checks.

Certain methods, like store(org.outerj.daisy.repository.commonimpl.DocumentImpl) might also need to send out events to eventlisteners.


Method Summary
 void completeVersion(DocumentVariantImpl variant, VersionImpl version)
          Loads the additional information skipped when the version was loaded via loadShallowVersions(org.outerj.daisy.repository.commonimpl.DocumentVariantImpl).
 org.outerj.daisy.repository.Document createVariant(long documentId, long startBranchId, long startLanguageId, long startVersionId, long newBranchId, long newLanguageId, AuthenticatedUser user)
           
 void deleteDocument(long documentId, AuthenticatedUser user)
           
 void deleteVariant(long documentId, long branchId, long languageId, AuthenticatedUser user)
           
 AvailableVariantImpl[] getAvailableVariants(long documentId, AuthenticatedUser user)
           
 java.io.InputStream getBlob(long documentId, long branchId, long languageId, long versionId, long partTypeId, AuthenticatedUser user)
           
 java.io.InputStream getBlob(java.lang.String blobKey)
          This method does not check access rights (unlike getBlob(long, long, long, long, long, AuthenticatedUser), because this one is only intended for use by Part objects.
 java.lang.String getClientVersion(AuthenticatedUser user)
           
 LockInfoImpl getLockInfo(DocumentVariantImpl documentVariant)
           
 java.lang.String getServerVersion(AuthenticatedUser user)
           
 org.outerj.daisy.repository.Document load(AuthenticatedUser user, long documentId, long branchId, long languageId)
           
 VersionImpl[] loadShallowVersions(DocumentVariantImpl variant)
          Loads all Version objects for this document as shallow Version objects (i.e.
 VersionImpl loadVersion(DocumentVariantImpl documentVariant, long versionId)
           
 LockInfoImpl lock(DocumentVariantImpl documentVariant, long duration, org.outerj.daisy.repository.LockType lockType)
          Tries to create a lock on the document.
 LockInfoImpl releaseLock(DocumentVariantImpl documentVariant)
           
 void setVersionState(DocumentImpl document, VersionImpl version, org.outerj.daisy.repository.VersionState versionState)
           
 void store(DocumentImpl document)
          Stores a document.
 

Method Detail

load

org.outerj.daisy.repository.Document load(AuthenticatedUser user,
                                          long documentId,
                                          long branchId,
                                          long languageId)
                                          throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

store

void store(DocumentImpl document)
           throws org.outerj.daisy.repository.RepositoryException
Stores a document. After successful storage, the document object status should be updates, i.e. the lastModified and lastModifier parts should be updated, and some dirty-indication flags should be reset.

Throws:
org.outerj.daisy.repository.RepositoryException

createVariant

org.outerj.daisy.repository.Document createVariant(long documentId,
                                                   long startBranchId,
                                                   long startLanguageId,
                                                   long startVersionId,
                                                   long newBranchId,
                                                   long newLanguageId,
                                                   AuthenticatedUser user)
                                                   throws org.outerj.daisy.repository.RepositoryException
Parameters:
startVersionId - -1 for last version, -2 for live version
Throws:
org.outerj.daisy.repository.RepositoryException

getAvailableVariants

AvailableVariantImpl[] getAvailableVariants(long documentId,
                                            AuthenticatedUser user)
                                            throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

deleteDocument

void deleteDocument(long documentId,
                    AuthenticatedUser user)
                    throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

deleteVariant

void deleteVariant(long documentId,
                   long branchId,
                   long languageId,
                   AuthenticatedUser user)
                   throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

loadVersion

VersionImpl loadVersion(DocumentVariantImpl documentVariant,
                        long versionId)
                        throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

completeVersion

void completeVersion(DocumentVariantImpl variant,
                     VersionImpl version)
                     throws org.outerj.daisy.repository.RepositoryException
Loads the additional information skipped when the version was loaded via loadShallowVersions(org.outerj.daisy.repository.commonimpl.DocumentVariantImpl).

Throws:
org.outerj.daisy.repository.RepositoryException

loadShallowVersions

VersionImpl[] loadShallowVersions(DocumentVariantImpl variant)
                                  throws org.outerj.daisy.repository.RepositoryException
Loads all Version objects for this document as shallow Version objects (i.e. without their full content, but only the data necessary to show a version overview table).

Throws:
org.outerj.daisy.repository.RepositoryException

setVersionState

void setVersionState(DocumentImpl document,
                     VersionImpl version,
                     org.outerj.daisy.repository.VersionState versionState)
                     throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

getBlob

java.io.InputStream getBlob(long documentId,
                            long branchId,
                            long languageId,
                            long versionId,
                            long partTypeId,
                            AuthenticatedUser user)
                            throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

getBlob

java.io.InputStream getBlob(java.lang.String blobKey)
                            throws org.outerj.daisy.repository.RepositoryException
This method does not check access rights (unlike getBlob(long, long, long, long, long, AuthenticatedUser), because this one is only intended for use by Part objects.

Throws:
org.outerj.daisy.repository.RepositoryException

lock

LockInfoImpl lock(DocumentVariantImpl documentVariant,
                  long duration,
                  org.outerj.daisy.repository.LockType lockType)
                  throws org.outerj.daisy.repository.RepositoryException
Tries to create a lock on the document. If there was alread a pessimitic lock on the document, this method will return a LockInfo object containing information about that lock, so it is important to check the info in the LockInfo object to know if the lock was successful.

Throws:
org.outerj.daisy.repository.RepositoryException

getLockInfo

LockInfoImpl getLockInfo(DocumentVariantImpl documentVariant)
                         throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

releaseLock

LockInfoImpl releaseLock(DocumentVariantImpl documentVariant)
                         throws org.outerj.daisy.repository.RepositoryException
Throws:
org.outerj.daisy.repository.RepositoryException

getClientVersion

java.lang.String getClientVersion(AuthenticatedUser user)

getServerVersion

java.lang.String getServerVersion(AuthenticatedUser user)


Copyright © -2012 . All Rights Reserved.