org.outerj.daisy.repository
Interface Repository


public interface Repository

Start point for a user to access the repository.

An instance of this object is obtained from the RepositoryManager and is contextualized for a certain user. Thus instead of having to supply credentials to each method, you authenticate once via the RepositoryManager and can then do all further operations on this Repository object.


Method Summary
 void addListener(RepositoryListener listener)
          Add an event listener.
 Document createDocument(java.lang.String name, long documentTypeId)
          Same as createDocument(String, long, long, long) but assumes branch id 1 and language id 1.
 Document createDocument(java.lang.String name, long documentTypeId, long branchId, long languageId)
          Creates a new document.
 Document createDocument(java.lang.String name, java.lang.String documentTypeName)
          Same as createDocument(String, long) but takes a document type name instead of an id.
 Document createDocument(java.lang.String name, java.lang.String documentTypeName, java.lang.String branchName, java.lang.String languageName)
          Same as createDocument(String, long, long, long) but takes names instead of ids.
 Document createVariant(long documentId, long startBranchId, long startLanguageId, long startVersionId, long newBranchId, long newLanguageId, boolean copyContent)
          Creates a new variant on a document.
 Document createVariant(long documentId, java.lang.String startBranchName, java.lang.String startLanguageName, long startVersionId, java.lang.String newBranchName, java.lang.String newLanguageName, boolean copyContent)
           
 void deleteDocument(long documentId)
          Deletes a document permanently (unrecoverable) from the repository (including all its variants).
 void deleteVariant(long documentId, long branchId, long languageId)
           
 void deleteVariant(VariantKey variantKey)
          Deletes a document variant permanently (unrecoverable) from the repository.
 AccessManager getAccessManager()
           
 long[] getActiveRoleIds()
          The roles of the user that are currently active.
 java.lang.String[] getActiveRolesDisplayNames()
          Returns the names of the active roles.
 long[] getAvailableRoles()
          The id's of the available roles of the user.
 AvailableVariants getAvailableVariants(long documentId)
          Gets the available variants of a document.
 CollectionManager getCollectionManager()
          Returns the Collection Manager for this Repository.
 CommentManager getCommentManager()
           
 Document getDocument(long documentId, boolean updateable)
           
 Document getDocument(long documentId, long branchId, long languageId, boolean updateable)
          Gets a document from the repository.
 Document getDocument(long documentId, java.lang.String branchName, java.lang.String languageName, boolean updateable)
           
 Document getDocument(VariantKey key, boolean updateable)
           
 java.lang.Object getExtension(java.lang.String name)
          Retrieves an extension of the standard repository functionality.
 java.io.InputStream getPartData(long documentId, long versionId, long partTypeId)
          Retrieves part data for the branch "main", language "default".
 java.io.InputStream getPartData(long documentId, long branchId, long languageId, long versionId, long partTypeId)
          Retrieves the specified blob without the need to go through the Document object.
 QueryManager getQueryManager()
           
 RepositorySchema getRepositorySchema()
           
 java.lang.String getUserDisplayName()
          The name of the user with who this Repository instance is associated, the same as returned from User.getDisplayName().
 long getUserId()
          Id of the user with who this Repository instance is associated.
 org.outerx.daisy.x10.UserInfoDocument getUserInfoAsXml()
          Returns an XML document containing some information about the user with which this Repository instance is associated.
 java.lang.String getUserLogin()
          The login of the user with who this Repository instance is associated.
 UserManager getUserManager()
          Returns the User Manager for this Repository
 VariantManager getVariantManager()
           
 boolean isInRole(long roleId)
           
 boolean isInRole(java.lang.String roleName)
           
 void removeListener(RepositoryListener listener)
          Removes an event listener.
 void setActiveRoleIds(long[] roleIds)
          Sets the active roles of the user.
 void switchRole(long roleId)
          Changes the user's role for this Repository instance.
 

Method Detail

createDocument

public Document createDocument(java.lang.String name,
                               long documentTypeId,
                               long branchId,
                               long languageId)
Creates a new document. You need to supply:

The document will not be stored physically in the repository until Document.save() is called. Thus calling this method has no permanent side effects.


createDocument

public Document createDocument(java.lang.String name,
                               java.lang.String documentTypeName,
                               java.lang.String branchName,
                               java.lang.String languageName)
Same as createDocument(String, long, long, long) but takes names instead of ids.


createDocument

public Document createDocument(java.lang.String name,
                               long documentTypeId)
Same as createDocument(String, long, long, long) but assumes branch id 1 and language id 1.


createDocument

public Document createDocument(java.lang.String name,
                               java.lang.String documentTypeName)
Same as createDocument(String, long) but takes a document type name instead of an id.


createVariant

public Document createVariant(long documentId,
                              long startBranchId,
                              long startLanguageId,
                              long startVersionId,
                              long newBranchId,
                              long newLanguageId,
                              boolean copyContent)
                       throws RepositoryException
Creates a new variant on a document. If the copyContent argument is true, the new variant will be immediately persisted and its first version will be initialiased with the data from the start variant. The start variant and version will also be stored in the variant (retrievable via Document.getVariantCreatedFromBranchId() etc. methods). If copyContent is false, a document object for the new variant will be returned, with no data copied from the start variant (except for the document name), and the new variant will not yet be persisted (i.o.w. you need to call save on the returned Document object to do this). Thus using copyContent = false allows to create a variant from scratch, while copyContent = true branches of from an existing variant.

Parameters:
startVersionId - -1 for last version, -2 for live version
Throws:
RepositoryException

createVariant

public Document createVariant(long documentId,
                              java.lang.String startBranchName,
                              java.lang.String startLanguageName,
                              long startVersionId,
                              java.lang.String newBranchName,
                              java.lang.String newLanguageName,
                              boolean copyContent)
                       throws RepositoryException
Throws:
RepositoryException

getDocument

public Document getDocument(long documentId,
                            long branchId,
                            long languageId,
                            boolean updateable)
                     throws RepositoryException
Gets a document from the repository.

Parameters:
updateable - if false, you won't be able to make modifications to the document (and thus to save it). The repository can return a cached copy in this case.
Throws:
DocumentReadDeniedException - if read access to the document is denied.
RepositoryException

getDocument

public Document getDocument(long documentId,
                            java.lang.String branchName,
                            java.lang.String languageName,
                            boolean updateable)
                     throws RepositoryException
Parameters:
branchName - a branch name, or a branch id as string
languageName - a language name, or a language id as string
Throws:
RepositoryException

getDocument

public Document getDocument(VariantKey key,
                            boolean updateable)
                     throws RepositoryException
Throws:
RepositoryException

getDocument

public Document getDocument(long documentId,
                            boolean updateable)
                     throws RepositoryException
Throws:
RepositoryException

getAvailableVariants

public AvailableVariants getAvailableVariants(long documentId)
                                       throws RepositoryException
Gets the available variants of a document. This returns all variants, also the variants the user may not have access too, and retired variants. Everyone can retrieve the list of available variants of each document, there is no security constraint to this. This information is not really sensitive, and access control works on document variants and not on documents, so it would be a bit difficult to do this.

Throws:
RepositoryException

deleteDocument

public void deleteDocument(long documentId)
                    throws RepositoryException
Deletes a document permanently (unrecoverable) from the repository (including all its variants).

Throws:
RepositoryException

deleteVariant

public void deleteVariant(long documentId,
                          long branchId,
                          long languageId)
                   throws RepositoryException
Throws:
RepositoryException
See Also:
deleteVariant(VariantKey)

deleteVariant

public void deleteVariant(VariantKey variantKey)
                   throws RepositoryException
Deletes a document variant permanently (unrecoverable) from the repository.

To delete a document variant virtually, but not permanently, you can set it retired (see Document.setRetired(boolean)).

Throws:
RepositoryException

getPartData

public java.io.InputStream getPartData(long documentId,
                                       long branchId,
                                       long languageId,
                                       long versionId,
                                       long partTypeId)
                                throws RepositoryException
Retrieves the specified blob without the need to go through the Document object. Of course, all access control checks still apply.

Throws:
DocumentReadDeniedException - if read access to the document is denied.
RepositoryException

getPartData

public java.io.InputStream getPartData(long documentId,
                                       long versionId,
                                       long partTypeId)
                                throws RepositoryException
Retrieves part data for the branch "main", language "default".

Throws:
RepositoryException

getRepositorySchema

public RepositorySchema getRepositorySchema()

getAccessManager

public AccessManager getAccessManager()

getQueryManager

public QueryManager getQueryManager()

getCommentManager

public CommentManager getCommentManager()

getVariantManager

public VariantManager getVariantManager()

getCollectionManager

public CollectionManager getCollectionManager()
Returns the Collection Manager for this Repository.


getUserManager

public UserManager getUserManager()
Returns the User Manager for this Repository


getUserId

public long getUserId()
Id of the user with who this Repository instance is associated.


getUserDisplayName

public java.lang.String getUserDisplayName()
The name of the user with who this Repository instance is associated, the same as returned from User.getDisplayName().


getUserLogin

public java.lang.String getUserLogin()
The login of the user with who this Repository instance is associated.


getActiveRoleIds

public long[] getActiveRoleIds()
The roles of the user that are currently active. These can be changed through setActiveRoleIds(long[]).


isInRole

public boolean isInRole(long roleId)

isInRole

public boolean isInRole(java.lang.String roleName)

setActiveRoleIds

public void setActiveRoleIds(long[] roleIds)
Sets the active roles of the user.

Parameters:
roleIds - a subset of, or equal to, the roles returned by getAvailableRoles().

getActiveRolesDisplayNames

public java.lang.String[] getActiveRolesDisplayNames()
Returns the names of the active roles.


getAvailableRoles

public long[] getAvailableRoles()
The id's of the available roles of the user.


switchRole

public void switchRole(long roleId)
Changes the user's role for this Repository instance. This is the same as calling setActiveRoleIds(long[]) with a one-length array.

Parameters:
roleId - a valid roleId, thus one of those returned by getAvailableRoles().

getUserInfoAsXml

public org.outerx.daisy.x10.UserInfoDocument getUserInfoAsXml()
Returns an XML document containing some information about the user with which this Repository instance is associated.


addListener

public void addListener(RepositoryListener listener)
Add an event listener.

See also the comments in RepositoryListener.

Not all events are per-se also implemented in the repository client, and for so far as they are, they only provide events for operations done through that client, and not other ones happening on the server or through other clients.

This listener functionality is mostly meant for internal use, usually to clear caches. For most usecases you should use the JMS-based (assynchronous) event notification system.

A listener stays in effect until it is removed using removeListener(org.outerj.daisy.repository.RepositoryListener).


removeListener

public void removeListener(RepositoryListener listener)
Removes an event listener.


getExtension

public java.lang.Object getExtension(java.lang.String name)
Retrieves an extension of the standard repository functionality. Extensions are additional available repository services. What these services are is not defined by this API.

The reason for making this extension functionality part of the Repository API, instead of using completely separate and standalone components, is that in this way the extensions can operate in the authenticated context of the current user (ie Repository instance).

So, for as far as the extension performs any operations that depend on the current user and its role, the extension will operate using the same credentials as associated with the Repository object from which the extension instance has been retrieved.



Copyright © -2005 . All Rights Reserved.