Class Document
- java.lang.Object
-
- org.silverpeas.core.contribution.attachment.model.Document
-
- All Implemented Interfaces:
Serializable
,Attachment
,Contribution
,I18nContribution
,LocalizedAttachment
,LocalizedContribution
,LocalizedResource
,Translatable
,Translation
,Instance<Contribution>
,Nameable
,Securable
,SilverpeasResource
public class Document extends Object implements I18nContribution, LocalizedAttachment
A document as an attachment to a given contribution and gathering for a same document all of its translations, each of them represented by a different (SimpleDocument
instances. These different translations can be got with thegetTranslation(String)
method. The properties of aDocument
instance are those of the document master that is either the single document file (in the case there is only one translation) or the document file written in the default language of Silverpeas (seeI18n.getDefaultLanguage()
or the first translation found (if no translation exists for the default language).The
Document
class is a way to get and use attachments of a contribution without any knowledge about the language in which it is written.- Author:
- mmoquillon
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Document(SimpleDocument master)
Constructs a new document from the specified document file to be used as the master of the document.Document(ContributionIdentifier id)
Constructs a new document with the specified identifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canBeAccessedBy(User user)
Is the specified user can access this contribution?boolean
canBeModifiedBy(User user)
Checks the given user can modify this resource.List<SimpleDocument>
getAllTranslations()
Gets all the translations available for this document.String
getAttachmentPath()
Gets the absolute path of the document file in the filesystem.String
getContentType()
Gets the content type of this attached document file as a predefined MIME type.Date
getCreationDate()
Gets the date at which the resource has been created.User
getCreator()
Gets the user that has created the resource.String
getDisplayIcon()
Gets the path of the icon representing either the attachment itself or its content type.String
getFilename()
Gets the name of the document file as stored in the filesystem.ContributionIdentifier
getIdentifier()
Gets the unique identifier of this contribution.Date
getLastUpdateDate()
Gets the date at which the resource has been lastly updated.User
getLastUpdater()
Gets the user that has lastly updated the resource.int
getMajorVersion()
Gets the major part of the document version.int
getMinorVersion()
Gets the minor part of the document version.long
getSize()
Gets the size of the document file in the filesystem.ContributionIdentifier
getSourceContribution()
Gets the contribution to which this document is attached.String
getTitle()
Gets the title of this contribution if any.SimpleDocument
getTranslation(String language)
Gets a translation in the specified language about some textual properties of the object.boolean
isDownloadAllowedForReaders()
boolean
isDownloadAllowedForRoles(Set<SilverpeasRole> roles)
boolean
isDownloadAllowedForRolesFrom(User user)
boolean
isEdited()
boolean
isEditedBy(User user)
boolean
isReadOnly()
boolean
isSharingAllowedForRolesFrom(User user)
boolean
isVersioned()
Is this attachment versioned?-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.contribution.model.Attachment
getVersion
-
Methods inherited from interface org.silverpeas.core.contribution.model.Contribution
getContributionType, getDescription, getModel, getName, getResourcePath, isIndexable
-
Methods inherited from interface org.silverpeas.core.contribution.model.I18nContribution
getLocalizationIn
-
Methods inherited from interface org.silverpeas.core.contribution.model.LocalizedContribution
getLanguage
-
Methods inherited from interface org.silverpeas.core.security.Securable
canBeDeletedBy, canBeFiledInBy
-
-
-
-
Constructor Detail
-
Document
public Document(ContributionIdentifier id)
Constructs a new document with the specified identifier.- Parameters:
id
- a unique identifier of a document.
-
Document
public Document(SimpleDocument master)
Constructs a new document from the specified document file to be used as the master of the document.- Parameters:
master
- document file to use as master.
-
-
Method Detail
-
getIdentifier
public ContributionIdentifier getIdentifier()
Description copied from interface:I18nContribution
Gets the unique identifier of this contribution.- Specified by:
getIdentifier
in interfaceContribution
- Specified by:
getIdentifier
in interfaceI18nContribution
- Specified by:
getIdentifier
in interfaceSilverpeasResource
- Returns:
- the unique identifier of the contribution.
-
getSourceContribution
public ContributionIdentifier getSourceContribution()
Gets the contribution to which this document is attached.- Returns:
- a
ContributionIdentifier
instance about an unknown contribution type.
-
getTitle
public String getTitle()
Description copied from interface:Contribution
Gets the title of this contribution if any. By default returns an empty String.- Specified by:
getTitle
in interfaceAttachment
- Specified by:
getTitle
in interfaceContribution
- Returns:
- the contribution's title in the specified language. Can be empty if no title was set or no title is defined for a such contribution.
-
getContentType
public String getContentType()
Description copied from interface:Attachment
Gets the content type of this attached document file as a predefined MIME type.- Specified by:
getContentType
in interfaceAttachment
- Returns:
- the MIME type of the document.
-
getDisplayIcon
public String getDisplayIcon()
Description copied from interface:Attachment
Gets the path of the icon representing either the attachment itself or its content type.- Specified by:
getDisplayIcon
in interfaceAttachment
- Returns:
- the path of the icon representing this attachment.
-
getFilename
public String getFilename()
Description copied from interface:Attachment
Gets the name of the document file as stored in the filesystem. The filename can differ from the contribution name that is the title of the document.- Specified by:
getFilename
in interfaceAttachment
- Returns:
- the name of the document file in the filesystem.
-
getSize
public long getSize()
Description copied from interface:Attachment
Gets the size of the document file in the filesystem.- Specified by:
getSize
in interfaceAttachment
- Returns:
- the size in bytes.
-
getAttachmentPath
public String getAttachmentPath()
Description copied from interface:Attachment
Gets the absolute path of the document file in the filesystem.- Specified by:
getAttachmentPath
in interfaceAttachment
- Returns:
- the path of the attachment in the filesystem.
-
isVersioned
public boolean isVersioned()
Description copied from interface:Attachment
Is this attachment versioned? A document is versioned if each change is historized and comes to a new minor or major version.- Specified by:
isVersioned
in interfaceAttachment
- Returns:
- true if this attachment is versioned, false otherwise.
-
getMinorVersion
public int getMinorVersion()
Description copied from interface:Attachment
Gets the minor part of the document version. If the attachment isn't versioned, then zero value is returned.- Specified by:
getMinorVersion
in interfaceAttachment
- Returns:
- the minor version part of the document.
-
getMajorVersion
public int getMajorVersion()
Description copied from interface:Attachment
Gets the major part of the document version. If the attachment isn't versioned, then zero value is returned.- Specified by:
getMajorVersion
in interfaceAttachment
- Returns:
- the major version part of the document.
-
getTranslation
public SimpleDocument getTranslation(String language)
Description copied from interface:Translatable
Gets a translation in the specified language about some textual properties of the object. If no such translation exists, then returns the default translation of the object.- Specified by:
getTranslation
in interfaceLocalizedResource
- Specified by:
getTranslation
in interfaceTranslatable
- Parameters:
language
- the ISO 631-1 code of a language.- Returns:
- a translation of the object in the given language. Can be never null.
-
getAllTranslations
public List<SimpleDocument> getAllTranslations()
Gets all the translations available for this document.- Returns:
- a list of
SimpleDocument
instances, each of them being a document file of this document written in a given language. If no translations exist, otherwise if this document doesn't exist yet, then an empty list is returned.
-
getCreationDate
public Date getCreationDate()
Description copied from interface:SilverpeasResource
Gets the date at which the resource has been created.- Specified by:
getCreationDate
in interfaceSilverpeasResource
- Returns:
- the date of creation of the resource.
-
getLastUpdateDate
public Date getLastUpdateDate()
Description copied from interface:SilverpeasResource
Gets the date at which the resource has been lastly updated. If the resource doesn't have such an information, then this method should return the date of the resource creation.- Specified by:
getLastUpdateDate
in interfaceSilverpeasResource
- Returns:
- the date of the last update of the resource.
-
getCreator
public User getCreator()
Description copied from interface:SilverpeasResource
Gets the user that has created the resource.- Specified by:
getCreator
in interfaceSilverpeasResource
- Returns:
- a
User
in Silverpeas.
-
getLastUpdater
public User getLastUpdater()
Description copied from interface:SilverpeasResource
Gets the user that has lastly updated the resource. If the resource doesn't have such an information, then this method should return the user that has created the resource.- Specified by:
getLastUpdater
in interfaceSilverpeasResource
- Returns:
- a
User
in Silverpeas.
-
isReadOnly
public boolean isReadOnly()
-
isEdited
public boolean isEdited()
-
isEditedBy
public boolean isEditedBy(User user)
-
isSharingAllowedForRolesFrom
public boolean isSharingAllowedForRolesFrom(User user)
-
canBeAccessedBy
public boolean canBeAccessedBy(User user)
Description copied from interface:Contribution
Is the specified user can access this contribution?By default
Securable.canBeAccessedBy(User)
is implemented so that a user can access a contribution if it has enough rights to access the application instance in which is managed this contribution.
Indeed, this behavior is mostly the common one.
But In the case the application instance distributes its contribution along of a categorization tree and the nodes of this tree support access rights, then the user must have also the rights to access the node to which belongs the content.
Of course it could exist other access rules...- Specified by:
canBeAccessedBy
in interfaceContribution
- Specified by:
canBeAccessedBy
in interfaceSecurable
- Parameters:
user
- a user in Silverpeas.- Returns:
- true if the user can access this content, false otherwise.
-
canBeModifiedBy
public boolean canBeModifiedBy(User user)
Description copied from interface:Securable
Checks the given user can modify this resource. By default, if the user can access this securable resource, then it can also modify it.- Specified by:
canBeModifiedBy
in interfaceSecurable
- Parameters:
user
- a user in Silverpeas.- Returns:
- true if the user can modify the data managed by this instance, false otherwise.
-
isDownloadAllowedForRolesFrom
public boolean isDownloadAllowedForRolesFrom(User user)
-
isDownloadAllowedForRoles
public boolean isDownloadAllowedForRoles(Set<SilverpeasRole> roles)
-
isDownloadAllowedForReaders
public boolean isDownloadAllowedForReaders()
-
-