|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
A document can be created using Repository.createDocument(String, String)
or retrieved using Repository.getDocument(long, boolean)
.
Method Summary | |
void |
addLink(java.lang.String title,
java.lang.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(java.lang.String documentTypeName)
See 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(java.lang.String name)
Removes the specified custom field. |
void |
deleteField(long fieldTypeId)
Removes the specified field. |
void |
deleteField(java.lang.String name)
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(java.lang.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. |
java.util.Date |
getCreated()
Gets the time this document was created. |
java.lang.String |
getCustomField(java.lang.String name)
Gets the value of the specified custom field, or null if there is no custom field with that name. |
java.util.Map |
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. |
Field |
getField(long fieldTypeId)
Same as getField(String) but using the field type id.
|
Field |
getField(java.lang.String fieldTypeName)
Gets a field by field type name. |
Fields |
getFields()
Gets all fields in the document. |
Fields |
getFieldsInOrder()
Gets all fields in the document, sorted in the same order as the fields are defined in the document type. |
long |
getId()
Returns the id of this document. |
long |
getLanguageId()
|
java.util.Date |
getLastModified()
The time this document was last saved. |
long |
getLastModifier()
Returns the user id of the last user who saved this document. |
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. |
Links |
getLinks()
Removes all out-of-line links. |
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. |
java.lang.String |
getName()
Gets the name of this document. |
VersionState |
getNewVersionState()
See setNewVersionState(VersionState) . |
long |
getOwner()
Returns the user id of the owner of this document. |
Part |
getPart(long partTypeId)
Gets a part. |
Part |
getPart(java.lang.String name)
Gets a part. |
Parts |
getParts()
Returns the parts contained in the document variant, in unspecified order. |
Parts |
getPartsInOrder()
|
java.lang.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 getVariantCreatedFromBranchId() . |
long |
getVariantCreatedFromVersionId()
Similar to getVariantCreatedFromBranchId() . |
VariantKey |
getVariantKey()
|
java.util.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. |
long |
getVariantUpdateCount()
|
Version |
getVersion(long id)
Returns the requested version. |
Versions |
getVersions()
Returns all versions stored for this document. |
org.outerx.daisy.x10.DocumentDocument |
getXml()
|
org.outerx.daisy.x10.DocumentDocument |
getXml(long versionId)
Gets the XML of the document but include the data from the specified version, instead of the current data. |
org.outerx.daisy.x10.DocumentDocument |
getXmlWithoutVariant()
|
org.outerx.daisy.x10.DocumentDocument |
getXmlWithoutVersionedData()
|
boolean |
hasCustomField(java.lang.String name)
Returns true if there is a custom field with the specified name. |
boolean |
hasField(long fieldTypeId)
Checks if the document contains the field with the specified field type id. |
boolean |
hasField(java.lang.String fieldTypeName)
Checks if the document contains the field with the specified field type name. |
boolean |
hasPart(long partTypeId)
Checks if the document variant has the part for the specified part type. |
boolean |
hasPart(java.lang.String name)
Checks if the document variant has the part for the specified part type. |
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 |
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)
Removes the document variant from a collection |
void |
save()
Saves a document. |
void |
save(boolean validate)
Saves the document and document variant. |
void |
setCustomField(java.lang.String name,
java.lang.String value)
Sets a custom field. |
void |
setField(long fieldTypeId,
java.lang.Object value)
Same as setField(String, Object) but using the id of the field type.
|
void |
setField(java.lang.String name,
java.lang.Object value)
Sets the value of a field. |
void |
setName(java.lang.String name)
Sets the name of the document. |
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(long partTypeId,
java.lang.String mimeType,
byte[] data)
Sets a part. |
void |
setPart(long partTypeId,
java.lang.String mimeType,
PartDataSource partDataSource)
Sets a part. |
void |
setPart(java.lang.String partTypeName,
java.lang.String mimeType,
byte[] data)
Sets a part. |
void |
setPart(java.lang.String partTypeName,
java.lang.String mimeType,
PartDataSource partDataSource)
Sets a part. |
void |
setPartFileName(long partTypeId,
java.lang.String fileName)
Update the file name of an already existing part. |
void |
setPartFileName(java.lang.String partTypeName,
java.lang.String fileName)
Update the file name of an already existing part. |
void |
setPartMimeType(long partTypeId,
java.lang.String mimeType)
Update the mime-type of an already existing part. |
void |
setPartMimeType(java.lang.String partTypeName,
java.lang.String mimeType)
Update the mime-type of an already existing part. |
void |
setPrivate(boolean _private)
Sets the private flag for this document, see also isPrivate() .
|
void |
setRetired(boolean retired)
Sets the retired flag for this document, see also isRetired() .
|
void |
validate()
Validates that this document confirms to its document type. |
Method Detail |
public long getId()
save()
is called.
public long getBranchId()
public long getLanguageId()
public VariantKey getVariantKey()
public boolean isVariantNew()
public AvailableVariants getAvailableVariants() throws RepositoryException
Repository.getAvailableVariants(long)
.
RepositoryException
public long getDocumentTypeId()
RepositorySchema
.
The document type is a variant-level property.
public void changeDocumentType(long documentTypeId) throws RepositoryException
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.
RepositoryException
public void changeDocumentType(java.lang.String documentTypeName) throws RepositoryException
changeDocumentType(long)
.
RepositoryException
public java.lang.String getName()
The document name is a variant-level property.
public void setName(java.lang.String name)
The document name is a variant-level property.
public long getOwner()
The owner is a document-level property.
public void setOwner(long userId)
The owner is a document-level property.
public boolean isPrivate()
This is a document-level property.
public void setPrivate(boolean _private)
isPrivate()
.
New documents are not private by default.
This is a document-level property.
public java.util.Date getCreated()
This is a document-level property.
public boolean isRetired()
This is a variant-level property.
public void setRetired(boolean retired)
isRetired()
.
This is a variant-level property.
public java.util.Date getLastModified()
This is a document-level property. See also getVariantLastModified()
.
public long getLastModifier()
This is a document-level property. See also getVariantLastModifier()
.
public java.util.Date getVariantLastModified()
This is a variant-level property. See also getLastModified()
.
public long getVariantLastModifier()
This is a variant-level property. See also getLastModifier()
.
public Versions getVersions() throws RepositoryException
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.
RepositoryException
public Version getVersion(long id) throws RepositoryException
Note that in contrast with the getVersions()
method, typical
implementations will usually return a Version object containing all details
about the version.
This is a variant-level method.
RepositoryException
public long getLastVersionId()
This is a variant-level property.
public Version getLastVersion() throws RepositoryException
This is a variant-level method.
RepositoryException
public Version getLiveVersion() throws RepositoryException
This is a variant-level method.
RepositoryException
public long getLiveVersionId()
This is a variant-level method.
public boolean canReadLiveOnly()
public void setField(java.lang.String name, java.lang.Object value) throws DocumentTypeInconsistencyException
This is a variant-level method.
name
- name of the field type of the field to set.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).
DocumentTypeInconsistencyException
public void setField(long fieldTypeId, java.lang.Object value) throws DocumentTypeInconsistencyException
setField(String, Object)
but using the id of the field type.
This is a variant-level method.
DocumentTypeInconsistencyException
public void deleteField(java.lang.String name)
This is a variant-level method.
name
- name of the field typepublic void deleteField(long fieldTypeId)
This is a variant-level method.
public Field getField(java.lang.String fieldTypeName) throws FieldNotFoundException
hasField(String)
to check if the
document has the field.
This is a variant-level method.
FieldNotFoundException
public Field getField(long fieldTypeId) throws FieldNotFoundException
getField(String)
but using the field type id.
This is a variant-level method.
FieldNotFoundException
public boolean hasField(long fieldTypeId)
This is a variant-level method.
public boolean hasField(java.lang.String fieldTypeName)
This is a variant-level method.
public Fields getFields()
This is a variant-level method.
public Fields getFieldsInOrder()
This is a variant-level method.
public void save() throws RepositoryException
This is the same as calling save(boolean)
with argument true.
RepositoryException
public void save(boolean validate) throws RepositoryException
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
getLastVersionId()
. The state of the new version can be
influenced by using 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.
RepositoryException
public void validate() throws DocumentTypeInconsistencyException
DocumentTypeInconsistencyException
public void setNewVersionState(VersionState versionState)
By default this is VersionState.PUBLISH.
public VersionState getNewVersionState()
setNewVersionState(VersionState)
.
public boolean lock(long duration, LockType lockType) throws RepositoryException
Changing a lock doesn't need a save()
call afterwards,
calling this method has immediate effect.
This is a variant-level method.
duration
- indication of how long the lock should remain (in ms).
Use -1 for a never-expiring lock.
getLockInfo(boolean)
with false
as parameter to know who is holding the lock.
RepositoryException
public boolean releaseLock() throws RepositoryException
This is a variant-level method.
getLockInfo(boolean)
with false
as parameter to know who is holding the lock.
RepositoryException
public LockInfo getLockInfo(boolean fresh) throws RepositoryException
This is a variant-level method.
fresh
- if true, the lock information will be refetched. Otherwise
the existing information stored in this Document object will
be returned (which may be out of date).
RepositoryException
public void setCustomField(java.lang.String name, java.lang.String value)
This is a variant-level method.
public void deleteCustomField(java.lang.String name)
This is a variant-level method.
public java.lang.String getCustomField(java.lang.String name)
This is a variant-level method.
public boolean hasCustomField(java.lang.String name)
This is a variant-level method.
public void clearCustomFields()
This is a variant-level method.
public java.util.Map getCustomFields()
This is a variant-level method.
public void setPart(java.lang.String partTypeName, java.lang.String mimeType, byte[] data) throws DocumentTypeInconsistencyException
This is a variant-level method.
DocumentTypeInconsistencyException
public void setPart(long partTypeId, java.lang.String mimeType, byte[] data) throws DocumentTypeInconsistencyException
This is a variant-level method.
DocumentTypeInconsistencyException
public void setPart(java.lang.String partTypeName, java.lang.String mimeType, PartDataSource partDataSource) throws DocumentTypeInconsistencyException
This is a variant-level method.
DocumentTypeInconsistencyException
public void setPart(long partTypeId, java.lang.String mimeType, PartDataSource partDataSource) throws DocumentTypeInconsistencyException
This is a variant-level method.
DocumentTypeInconsistencyException
public void setPartFileName(java.lang.String partTypeName, java.lang.String fileName)
This is a variant-level method.
fileName
- allowed to be null (to remove the filename information)public void setPartFileName(long partTypeId, java.lang.String fileName)
This is a variant-level method.
fileName
- allowed to be null (to remove the filename information)public void setPartMimeType(java.lang.String partTypeName, java.lang.String mimeType)
This is a variant-level method.
public void setPartMimeType(long partTypeId, java.lang.String mimeType)
This is a variant-level method.
public void deletePart(long partTypeId)
This is a variant-level method.
public void deletePart(java.lang.String name)
This is a variant-level method.
public Part getPart(long partTypeId) throws PartNotFoundException
This is a variant-level method.
PartNotFoundException
public Part getPart(java.lang.String name) throws PartNotFoundException
This is a variant-level method.
PartNotFoundException
public boolean hasPart(long partTypeId)
This is a variant-level method.
public boolean hasPart(java.lang.String name)
This is a variant-level method.
public Parts getParts()
public Parts getPartsInOrder()
public void addLink(java.lang.String title, java.lang.String target)
This is a variant-level method.
public void deleteLink(int index)
This is a variant-level method.
public void clearLinks()
This is a variant-level method.
public Links getLinks()
This is a variant-level method.
public void addToCollection(DocumentCollection collection)
collection
- the collection to add the current document topublic void removeFromCollection(DocumentCollection collection)
collection
- the collection from which the document needs to be removedpublic DocumentCollections getCollections()
public boolean inCollection(DocumentCollection collection)
public boolean inCollection(long collectionId)
public org.outerx.daisy.x10.DocumentDocument getXml() throws RepositoryException
RepositoryException
public org.outerx.daisy.x10.DocumentDocument getXmlWithoutVariant() throws RepositoryException
RepositoryException
public org.outerx.daisy.x10.DocumentDocument getXmlWithoutVersionedData() throws RepositoryException
RepositoryException
public org.outerx.daisy.x10.DocumentDocument getXml(long versionId) throws RepositoryException
RepositoryException
public void clearCollections()
public java.lang.String getSummary()
public long getVariantCreatedFromBranchId()
public long getVariantCreatedFromLanguageId()
getVariantCreatedFromBranchId()
.
public long getVariantCreatedFromVersionId()
getVariantCreatedFromBranchId()
.
public long getUpdateCount()
public long getVariantUpdateCount()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |