| org.outerj.daisy.repository.Document
All known Subclasses: org.outerj.daisy.repository.serverimpl.acl.DummyDocForAppliesToTest, org.outerj.daisy.repository.commonimpl.DocumentImpl, org.outerj.daisy.repository.commonimpl.DocumentAccessWrapper,
Document | public interface Document extends VersionedData(Code) | | A document in the repository. This object actually always represents one
particular variant (branch-language combination) of the document. There
is no separate object representing a document itself as such, access to
documents is always done through a certain variant of it (since access
control is also determined based on the information that is part of the
variant). Letting a document object represent both the document and
document variant was also the most backwards-compatible way to introduce
the variants feature.
Since one object is used to manipulate both the document and document
variant, most methods include a mentioning of whether they apply to the
document or the document variant. All methods inherited from
VersionedData are variant-level methods.
A document can be created using
Repository.createDocument(StringString) or retrieved using
Repository.getDocument(Stringboolean) .
|
Method Summary | |
void | addLink(String title, String target) Adds an out-of-line link (at the end of the list). | void | addToCollection(DocumentCollection collection) Adds the document variant to a supplied Collection. | boolean | canReadLiveOnly() Returns true if the current user can only access live data of the document. | void | changeDocumentType(long documentTypeId) Changes the document type of this document. | void | changeDocumentType(String documentTypeName) See
Document.changeDocumentType(long) . | void | clearCollections() Removes the document variant from all the collections it belongs to. | void | clearCustomFields() Removes all custom fields. | void | clearLinks() Removes all out-of-line links. | void | deleteCustomField(String name) Removes the specified custom field. | void | deleteField(String name) Removes the specified field. | void | deleteField(long fieldTypeId) Removes the specified field. | void | deleteLink(int index) Removes an out-of-line link. | void | deletePart(long partTypeId) Removes a part, passes silently if there is no part in the document with the given id. | void | deletePart(String name) Removes a part, passes silently if there is no part in the document with the given name. | AvailableVariants | getAvailableVariants() Returns the available variants for this document. | long | getBranchId() | DocumentCollections | getCollections() Returns the collections the document variant belongs to, null if the document variant
belongs to no Collections. | Date | getCreated() Gets the time this document was created. | String | getCustomField(String name) Gets the value of the specified custom field, or null if there is no
custom field with that name. | Map<String, String> | getCustomFields() Returns a map containing the fields, with the field type name being the key. | long | getDocumentTypeId() Returns the id of the document type to which this document adheres. | String | getId() Returns the id of this document. | long | getLanguageId() | long | getLastMajorChangeVersionId() Gets the last version for which the change type was major.
Returns -1 if there is no such version.
This is an automatically calculated field. | Date | getLastModified() The time this document was last saved. | long | getLastModifier() Returns the user id of the last user who saved this document.
Returns -1 for documents that have never been saved yet.
This is a document-level property. | Version | getLastVersion() Returns the Version object for the last stored version, or null for unsaved
documents. | long | getLastVersionId() Returns the id of the last stored version. | long | getLiveMajorChangeVersionId() Gets the last version, up to the current live version, for which the change type was major.
Returns -1 if there is no such version.
This is an automatically calculated field. | Version | getLiveVersion() Returns the live version of this document, or null if there is none. | long | getLiveVersionId() Returns the id of the live version, or -1 if there is none. | LockInfo | getLockInfo(boolean fresh) Returns information about the current lock on the document variant.
This is a variant-level method.
Parameters: fresh - if true, the lock information will be refetched. | String | getName() Gets the name of this document. | String | getNamespace() Returns the sequence ID part of the document ID. | String | getNewChangeComment() | ChangeType | getNewChangeType() | VersionKey | getNewSyncedWith() | VersionState | getNewVersionState() See
Document.setNewVersionState(VersionState) . | long | getOwner() Returns the user id of the owner of this document. | long | getReferenceLanguageId() The current reference language for this document. | String | getRequestedId() | long | getSeqId() Returns the sequence ID part of the document ID. | String | getSummary() Returns a summary text for the document variant. | long | getUpdateCount() | long | getVariantCreatedFromBranchId() If the variant currently loaded in this document object is created from an existing
branch, this method will return the id of that branch, otherwise it will return -1. | long | getVariantCreatedFromLanguageId() Similar to
Document.getVariantCreatedFromBranchId() . | long | getVariantCreatedFromVersionId() Similar to
Document.getVariantCreatedFromBranchId() . | VariantKey | getVariantKey() | Date | getVariantLastModified() The time the document variant was last saved. | long | getVariantLastModifier() Returns the user id of the last user who saved this document variant.
Returns -1 for document variants that have never been saved yet.
This is a variant-level property. | long | getVariantUpdateCount() | Version | getVersion(long id) Returns the requested version. | Versions | getVersions() Returns all versions stored for this document. | DocumentDocument | getXml() | DocumentDocument | getXml(long versionId) Gets the XML of the document but include the data from the
specified version, instead of the current data. | DocumentDocument | getXmlWithoutVariant() | DocumentDocument | getXmlWithoutVersionedData() | boolean | hasCustomField(String name) Returns true if there is a custom field with the specified name. | boolean | inCollection(DocumentCollection collection) Checks if the document variant belongs to the specified collection. | boolean | inCollection(long collectionId) Checks if the document variant belongs to the specified collection. | boolean | isNew() Returns true if this document has never been saved yet (thus does
not exist in the repository yet). | boolean | isPrivate() Is this a private document or not. | boolean | isRetired() Is this document retired or not. | boolean | isVariantNew() Returns true if the variant represented by this document object has
never been stored yet. | boolean | lock(long duration, LockType lockType) Takes a lock on the document variant. | boolean | releaseLock() Releases the lock on the document variant. | void | removeFromCollection(DocumentCollection collection) | void | save() Saves a document. | void | save(boolean validate) Saves the document and document variant.
If only changes have been done to document-level properties,
only the document will be saved. | void | setCustomField(String name, String value) Sets a custom field. | void | setDocumentTypeChecksEnabled(boolean documentTypeChecksEnabled) Allows to disable some document type related checks. | void | setField(String name, Object value) Sets the value of a field. | void | setField(long fieldTypeId, Object value) Same as
Document.setField(String,Object) but using the id of the field type. | void | setName(String name) Sets the name of the document. | void | setNewChangeComment(String changeComment) Sets the change comment that should be used if a new version is created
when saving the document. | void | setNewChangeType(ChangeType changeType) Sets the ChangeType that should be used if a new version is created
when saving the document. | void | setNewSyncedWith(long languageId, long versionId) Sets the 'synced with' value that should be used if a new version is created
as part of saving this document. | void | setNewSyncedWith(String languageName, long versionId) Alternative to
Document.setNewSyncedWith(long,long) . | void | setNewSyncedWith(VersionKey syncedWith) Sets the 'synced with' pointer by specifying a VersionKey object.
Only the language ID and version ID fields of the VersionKey object
are significant. | void | setNewVersionState(VersionState versionState) Sets the VersionState that should be used if a new version is created
when saving the document. | void | setOwner(long userId) Change the owner of this document. | void | setPart(String partTypeName, String mimeType, byte[] data) Sets a part. | void | setPart(long partTypeId, String mimeType, byte[] data) Sets a part. | void | setPart(String partTypeName, String mimeType, PartDataSource partDataSource) Sets a part. | void | setPart(long partTypeId, String mimeType, PartDataSource partDataSource) Sets a part. | void | setPartFileName(String partTypeName, String fileName) Update the file name of an already existing part. | void | setPartFileName(long partTypeId, String fileName) Update the file name of an already existing part. | void | setPartMimeType(String partTypeName, String mimeType) Update the mime-type of an already existing part. | void | setPartMimeType(long partTypeId, String mimeType) Update the mime-type of an already existing part. | void | setPrivate(boolean _private) Sets the private flag for this document, see also
Document.isPrivate() . | void | setReferenceLanguage(String referenceLanguageName) | void | setReferenceLanguageId(long referenceLanguageId) | void | setRequestedId(String documentId) Requests that this new document will be saved with the given document ID.
This can only be done for document IDs in a namespace other than
the namespace of the current repository. | void | setRetired(boolean retired) Sets the retired flag for this document, see also
Document.isRetired() . | void | validate() Validates that this document confirms to its document type. |
addLink | void addLink(String title, String target)(Code) | | Adds an out-of-line link (at the end of the list).
This is a variant-level method.
|
addToCollection | void addToCollection(DocumentCollection collection)(Code) | | Adds the document variant to a supplied Collection.
Parameters: collection - the collection to add the current document to |
canReadLiveOnly | boolean canReadLiveOnly()(Code) | | Returns true if the current user can only access live data of the document.
|
changeDocumentType | void changeDocumentType(long documentTypeId) throws RepositoryException(Code) | | Changes the document type of this document.
Will throw an exception if the document type does not exist.
Changing the documenttype does not influence the content of the document,
you have to assure yourself that you update/add/remove parts and fields so
that the document conforms to the document type.
The document type is a variant-level property.
|
clearCollections | void clearCollections()(Code) | | Removes the document variant from all the collections it belongs to.
|
clearCustomFields | void clearCustomFields()(Code) | | Removes all custom fields.
This is a variant-level method.
|
clearLinks | void clearLinks()(Code) | | Removes all out-of-line links.
This is a variant-level method.
|
deleteCustomField | void deleteCustomField(String name)(Code) | | Removes the specified custom field. Passes silently if there is no
custom field with the given name.
This is a variant-level method.
|
deleteField | void deleteField(String name)(Code) | | Removes the specified field. Silently ignored if the document doesn't have that field.
This is a variant-level method.
Parameters: name - name of the field type |
deleteField | void deleteField(long fieldTypeId)(Code) | | Removes the specified field. Silently ignored if the document doesn't have that field.
This is a variant-level method.
|
deleteLink | void deleteLink(int index)(Code) | | Removes an out-of-line link.
This is a variant-level method.
|
deletePart | void deletePart(long partTypeId)(Code) | | Removes a part, passes silently if there is no part in the document with the given id.
This is a variant-level method.
|
deletePart | void deletePart(String name)(Code) | | Removes a part, passes silently if there is no part in the document with the given name.
This is a variant-level method.
|
getAvailableVariants | AvailableVariants getAvailableVariants() throws RepositoryException(Code) | | Returns the available variants for this document. If the document is new and unsaved, this
returns an empty list. If the document variant in this document is new and unsaved, the
returned list will not yet contain this new variant. Thus only variants persisted in the
repository are returned. This method does the same as
Repository.getAvailableVariants(String) .
|
getBranchId | long getBranchId()(Code) | | |
getCollections | DocumentCollections getCollections()(Code) | | Returns the collections the document variant belongs to, null if the document variant
belongs to no Collections.
|
getCreated | Date getCreated()(Code) | | Gets the time this document was created.
This is a document-level property.
|
getCustomField | String getCustomField(String name)(Code) | | Gets the value of the specified custom field, or null if there is no
custom field with that name.
This is a variant-level method.
|
getCustomFields | Map<String, String> getCustomFields()(Code) | | Returns a map containing the fields, with the field type name being the key.
Making changes to this map will not be reflected in the document.
This is a variant-level method.
|
getId | String getId()(Code) | | Returns the id of this document. For newly created documents, this method
returns null until
Document.save() is called.
|
getLanguageId | long getLanguageId()(Code) | | |
getLastMajorChangeVersionId | long getLastMajorChangeVersionId()(Code) | | Gets the last version for which the change type was major.
Returns -1 if there is no such version.
This is an automatically calculated field. This information is fetched
when this document object is retrieved and is not updated afterwards.
This is a variant level method.
|
getLastModified | Date getLastModified()(Code) | | The time this document was last saved. Returns null for documents that
have never been saved yet.
This is a document-level property. See also
Document.getVariantLastModified() .
|
getLastModifier | long getLastModifier()(Code) | | Returns the user id of the last user who saved this document.
Returns -1 for documents that have never been saved yet.
This is a document-level property. See also
Document.getVariantLastModifier() .
|
getLastVersion | Version getLastVersion() throws RepositoryException(Code) | | Returns the Version object for the last stored version, or null for unsaved
documents.
This is a variant-level method.
|
getLastVersionId | long getLastVersionId()(Code) | | Returns the id of the last stored version. For new, unsaved documents this
returns -1.
This is a variant-level property.
|
getLiveMajorChangeVersionId | long getLiveMajorChangeVersionId()(Code) | | Gets the last version, up to the current live version, for which the change type was major.
Returns -1 if there is no such version.
This is an automatically calculated field. This information is fetched
when this document object is retrieved and is not updated afterwards.
This is a variant level method.
|
getLiveVersion | Version getLiveVersion() throws RepositoryException(Code) | | Returns the live version of this document, or null if there is none.
The live version is the most recent version that has the state 'publish'.
This is a variant-level method.
|
getLiveVersionId | long getLiveVersionId()(Code) | | Returns the id of the live version, or -1 if there is none.
This is a variant-level method.
|
getLockInfo | LockInfo getLockInfo(boolean fresh) throws RepositoryException(Code) | | Returns information about the current lock on the document variant.
This is a variant-level method.
Parameters: fresh - if true, the lock information will be refetched. Otherwisethe existing information stored in this Document object willbe returned (which may be out of date). |
getNamespace | String getNamespace()(Code) | | Returns the sequence ID part of the document ID. This method returns -1
until
Document.save() is called.
since: Daisy 2.0 |
getNewSyncedWith | VersionKey getNewSyncedWith()(Code) | | : to indicate which variant/version the document was synced withor null if the document is not synced |
getOwner | long getOwner()(Code) | | Returns the user id of the owner of this document. The owner is the user that
created the document, unless changed.
The owner is a document-level property.
|
getReferenceLanguageId | long getReferenceLanguageId()(Code) | | The current reference language for this document.
Returns -1 if the reference language is not set.
Setting the reference language is also used as an indication that the document should be considered to be under "translation management".
this is a document level method
|
getSeqId | long getSeqId()(Code) | | Returns the sequence ID part of the document ID. This method returns -1
until
Document.save() is called.
since: Daisy 2.0 |
getSummary | String getSummary()(Code) | | Returns a summary text for the document variant. The summary is only created/updated
when the document is saved. Returns an empty string if there's no summary.
The summary always corresponds to the live version of the document.
|
getUpdateCount | long getUpdateCount()(Code) | | |
getVariantCreatedFromBranchId | long getVariantCreatedFromBranchId()(Code) | | If the variant currently loaded in this document object is created from an existing
branch, this method will return the id of that branch, otherwise it will return -1.
Note that the branch could possibly no longer exist.
|
getVariantKey | VariantKey getVariantKey()(Code) | | null for documents which have not yet been saved. |
getVariantLastModified | Date getVariantLastModified()(Code) | | The time the document variant was last saved. Returns null for document variants that
have never been saved yet.
This is a variant-level property. See also
Document.getLastModified() .
|
getVariantLastModifier | long getVariantLastModifier()(Code) | | Returns the user id of the last user who saved this document variant.
Returns -1 for document variants that have never been saved yet.
This is a variant-level property. See also
Document.getLastModifier() .
|
getVariantUpdateCount | long getVariantUpdateCount()(Code) | | |
getVersion | Version getVersion(long id) throws RepositoryException(Code) | | Returns the requested version.
Note that in contrast with the
Document.getVersions() method, typical
implementations will usually return a Version object containing all details
about the version.
This is a variant-level method.
|
getVersions | Versions getVersions() throws RepositoryException(Code) | | Returns all versions stored for this document.
In a typical implementation, the returned Version objects will only contain
basic information about the version (like its id and creation time) which is
needed to show a version list, but the actual version content (fields,
parts, ...) will only be loaded when requested.
This is a variant-level method.
|
getXml | DocumentDocument getXml(long versionId) throws RepositoryException(Code) | | Gets the XML of the document but include the data from the
specified version, instead of the current data. This only
applies to the data of the document that is actually versionable, of course.
For the rest of the data, you'll get what's currently in the document
object, whether that data has already been saved or not.
|
hasCustomField | boolean hasCustomField(String name)(Code) | | Returns true if there is a custom field with the specified name.
This is a variant-level method.
|
inCollection | boolean inCollection(DocumentCollection collection)(Code) | | Checks if the document variant belongs to the specified collection.
|
inCollection | boolean inCollection(long collectionId)(Code) | | Checks if the document variant belongs to the specified collection.
|
isNew | boolean isNew()(Code) | | Returns true if this document has never been saved yet (thus does
not exist in the repository yet).
|
isPrivate | boolean isPrivate()(Code) | | Is this a private document or not. A private document is a document that can
only be accessed by its owner, or users having (and acting) in the role of
Administrator.
This is a document-level property.
|
isRetired | boolean isRetired()(Code) | | Is this document retired or not. A retired document behaves very much likes
a deleted document. Retired documents don't show up in query results (unless
specifically requested).
This is a variant-level property.
|
isVariantNew | boolean isVariantNew()(Code) | | Returns true if the variant represented by this document object has
never been stored yet.
|
lock | boolean lock(long duration, LockType lockType) throws RepositoryException(Code) | | Takes a lock on the document variant. If the lock type is "pessimistic", this will prevent
others from saving the document variant while you're working on it. If the lock
is "warn", the lock only serves for informational purposes and will
not enforce anything. So called "optimistic locking" (ie checking against
concurrent modifications) happens always, and doesn't require to take a lock.
Changing a lock doesn't need a
Document.save() call afterwards,
calling this method has immediate effect.
The lock can be removed with
Document.releaseLock() .
This is a variant-level method.
Parameters: duration - indication of how long the lock should remain (in ms).Use -1 for a never-expiring lock. false if someone else already has a lock on this document, inwhich case you can call Document.getLockInfo(boolean) with falseas parameter to know who is holding the lock. |
releaseLock | boolean releaseLock() throws RepositoryException(Code) | | Releases the lock on the document variant. This can only be done by the person
holding this lock, or by an Administrator.
This is a variant-level method.
true if the lock is removed (or if there was no lock). If a lockremains on the document, false will be returned, in which caseyou can call Document.getLockInfo(boolean) with falseas parameter to know who is holding the lock. |
removeFromCollection | void removeFromCollection(DocumentCollection collection)(Code) | | Removes the document variant from a collection
Parameters: collection - the collection from which the document needs to be removed |
save | void save(boolean validate) throws RepositoryException(Code) | | Saves the document and document variant.
If only changes have been done to document-level properties,
only the document will be saved. If only changes have been done
to variant-level properties, only the variant will be saved.
If this is a new document, it will cause an id to be assigned
to this document object.
Saving the document variant might or might not cause the creation of a new
version, depending on whether any versioned data has changed. Versioned
data includes the parts, fields, links and the document's name. So if
for example only the retired flag changed, customfields were changed,
or collection membership changed, no new version will be created.
After saving, you can get the new version id from the method
Document.getLastVersionId() . The state of the new version can be
influenced by using
Document.setNewVersionState(org.outerj.daisy.repository.VersionState) before calling save().
If someone else holds a pessimistic lock on the document variant, saving it
will fail. Likewise, if another person saved the document since you retrieved
this document object (ie a concurrent modification), saving will also fail.
Note that locks apply only to document variants, so don't protect from concurrent
changes to document-level properties.
Saving a document will cause the server to send out an assynchronous
event, to which other processes can listen, for example the full
text indexer. (There are separate events for updates to the document and
the variant)
Using the argument validate you can specify whether the document variant
should be validated against its document type. Usually you will always
provide true here. As an example use case for not using validation,
it might be that you just want to mark a
document as retired without bothering that its content doesn't correspond
to the schema anymore.
throws: DocumentTypeInconsistencyException - in case validation against the schema fails. |
setCustomField | void setCustomField(String name, String value)(Code) | | Sets a custom field. A custom field is an arbitrary name/value pair.
Custom fields are not versioned.
This is a variant-level method.
|
setDocumentTypeChecksEnabled | void setDocumentTypeChecksEnabled(boolean documentTypeChecksEnabled)(Code) | | Allows to disable some document type related checks. When disabled,
it is possible to set fields and parts on this document that are
not allowed by the document type. For parts, the mime-type
checking won't be performed either.
|
setField | void setField(String name, Object value) throws DocumentTypeInconsistencyException(Code) | | Sets the value of a field. The field must be part of the document type
of this document.
This is a variant-level method.
See
Document.setDocumentTypeChecksEnabled to disable checks against the document type.
Parameters: name - name of the field type of the field to set. Parameters: value - the value of the field, the type of the object must be in correspondence with the ValueType of the field type.For multi-value fields, the value should be an array (i.e. Object[] or a more specifically typed array).For link field types, the value is a VariantKey object. The branch and language fields of the VariantKeyobject can be -1 to indicate they are the same as the containing document (recommended for most uses).For hierarchical fields, the value is a HierarchyPath containing values according to the field type.For multi-value hierarchical fields, the value is an array of HierarchyPath objects. |
setName | void setName(String name)(Code) | | Sets the name of the document. The document name is not required to be unique,
and is versioned, ie changing the document name and then saving the document
will create a new version.
The document name is a variant-level property.
|
setNewChangeComment | void setNewChangeComment(String changeComment)(Code) | | Sets the change comment that should be used if a new version is created
when saving the document.
By default this is null
|
setNewChangeType | void setNewChangeType(ChangeType changeType)(Code) | | Sets the ChangeType that should be used if a new version is created
when saving the document.
By default this is ChangeType.MAJOR
|
setNewSyncedWith | void setNewSyncedWith(long languageId, long versionId) throws RepositoryException(Code) | | Sets the 'synced with' value that should be used if a new version is created
as part of saving this document.
The 'synced with' indicates the version is synced with another language:version.
Use setSyncedWithVersion(-1,-1) to clear any previous set value.
|
setNewVersionState | void setNewVersionState(VersionState versionState)(Code) | | Sets the VersionState that should be used if a new version is created
when saving the document.
By default this is VersionState.PUBLISH.
|
setOwner | void setOwner(long userId)(Code) | | Change the owner of this document. Only users acting in the Administrator role,
or the current owner, can change the owner.
The owner is a document-level property.
|
setPartFileName | void setPartFileName(String partTypeName, String fileName)(Code) | | Update the file name of an already existing part. Throws an exception if the document doesn't
have the indicated part.
This is a variant-level method.
Parameters: fileName - allowed to be null (to remove the filename information) |
setPartFileName | void setPartFileName(long partTypeId, String fileName)(Code) | | Update the file name of an already existing part. Throws an exception if the document doesn't
have the indicated part.
This is a variant-level method.
Parameters: fileName - allowed to be null (to remove the filename information) |
setPartMimeType | void setPartMimeType(String partTypeName, String mimeType)(Code) | | Update the mime-type of an already existing part. Throws an exception if the document doesn't
have the indicated part.
This is a variant-level method.
|
setPartMimeType | void setPartMimeType(long partTypeId, String mimeType)(Code) | | Update the mime-type of an already existing part. Throws an exception if the document doesn't
have the indicated part.
This is a variant-level method.
|
setPrivate | void setPrivate(boolean _private)(Code) | | Sets the private flag for this document, see also
Document.isPrivate() .
New documents are not private by default.
This is a document-level property.
|
setReferenceLanguageId | void setReferenceLanguageId(long referenceLanguageId)(Code) | | |
setRequestedId | void setRequestedId(String documentId)(Code) | | Requests that this new document will be saved with the given document ID.
This can only be done for document IDs in a namespace other than
the namespace of the current repository. This is simply because the
current repository is responsible itself for the assigning numbers
to its documents. For foreign namespaces, it is assumed that some
external entity is responsible for the numbering (typically another
Daisy repository, though it could be anything).
Setting the document ID is only possible for new, not-yet-saved
documents.
If a document with the given ID would already exist in the
repository, then this will give an exception when saving the document.
Parameters: documentId - allowed to be null, in which case a previous setting is reset since: Daisy 2.0 |
setRetired | void setRetired(boolean retired)(Code) | | Sets the retired flag for this document, see also
Document.isRetired() .
This is a variant-level property.
|
|
|