Class SimpleDocument

    • Method Detail

      • 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 interface SilverpeasResource
        Returns:
        a User in Silverpeas.
      • setDocumentType

        public void setDocumentType​(DocumentType documentType)
      • getCloneId

        public String getCloneId()
        Get the value of cloneId
        Returns:
        the value of cloneId
      • setCloneId

        public void setCloneId​(String cloneId)
        Set the value of cloneId
        Parameters:
        cloneId - new value of cloneId
      • 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 interface Attachment
        Returns:
        the name of the document file in the filesystem.
      • setFilename

        public void setFilename​(String filename)
      • setLanguage

        public void setLanguage​(String language)
      • getTitle

        public String getTitle()
        Description copied from interface: Attachment
        Gets the title of the document. The title is either the name set explicitly by the user to the attachment or the title fetched from the document metadata itself or the filename whether the previous data weren't provided.
        Specified by:
        getTitle in interface Attachment
        Specified by:
        getTitle in interface Contribution
        Returns:
        the title of the document.
      • setTitle

        public void setTitle​(String title)
      • getDescription

        public String getDescription()
        Description copied from interface: Contribution
        Gets a description about this contribution if any. By default returns an empty String.
        Specified by:
        getDescription in interface Contribution
        Specified by:
        getDescription in interface Nameable
        Specified by:
        getDescription in interface ResourceTranslation
        Returns:
        the description on this contribution. Can be empty if no description was set or no description is defined for a such contribution.
      • setDescription

        public void setDescription​(String description)
      • getSize

        public long getSize()
        Description copied from interface: Attachment
        Gets the size of the document file in the filesystem.
        Specified by:
        getSize in interface Attachment
        Returns:
        the size in bytes.
      • setSize

        public void setSize​(long size)
      • 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 interface Attachment
        Returns:
        the MIME type of the document.
      • setContentType

        public void setContentType​(String contentType)
      • getCreatedBy

        public String getCreatedBy()
      • setCreationDate

        public void setCreationDate​(Date created)
      • getUpdatedBy

        public String getUpdatedBy()
      • setUpdatedBy

        public void setUpdatedBy​(String updatedBy)
      • 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 interface SilverpeasResource
        Returns:
        the date of the last update of the resource.
      • setLastUpdateDate

        public void setLastUpdateDate​(Date updated)
      • getReservation

        public Date getReservation()
      • setReservation

        public final void setReservation​(Date reservationDate)
      • getAlert

        public Date getAlert()
      • setAlert

        public void setAlert​(Date alert)
      • getExpiry

        public Date getExpiry()
      • setExpiry

        public void setExpiry​(Date expiry)
      • getStatus

        public String getStatus()
      • setStatus

        public void setStatus​(String status)
      • 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 interface Attachment
        Returns:
        the minor version part of the document.
      • setMinorVersion

        public void setMinorVersion​(int minorVersion)
      • 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 interface Attachment
        Returns:
        the major version part of the document.
      • setMajorVersion

        public void setMajorVersion​(int majorVersion)
      • getVersion

        public String getVersion()
        Description copied from interface: Attachment
        Gets the version of the document. It is a concatenation of the major and of the minor version with a dot as separator.
        Specified by:
        getVersion in interface Attachment
        Returns:
        the version of the attachment or "0.0" if the document isn't versioned.
      • getComment

        public String getComment()
      • setComment

        public void setComment​(String comment)
      • resetWebdavContentEditionContext

        protected void resetWebdavContentEditionContext()
      • getWebdavContentEditionLanguage

        public String getWebdavContentEditionLanguage()
        Gets the content language handled into webdav for the document.
        Returns:
        the content language if the document is currently handled into the webdav repository, empty string otherwise.
      • getWebdavContentEditionSize

        public long getWebdavContentEditionSize()
        Gets the content size handled into webdav for the document.
        Returns:
        the content size if the document is currently handled into the webdav repository, a value less than zero otherwise.
      • getEditedBy

        public String getEditedBy()
      • edit

        public void edit​(String currentEditor)
      • release

        public void release()
      • getXmlFormId

        public String getXmlFormId()
      • setXmlFormId

        public void setXmlFormId​(String xmlFormId)
      • getId

        public String getId()
        Description copied from interface: Identifiable
        Gets the unique identifier of the object in Silverpeas. If he's also identified by a local identifier, then this method should return the one global to Silverpeas.
        Specified by:
        getId in interface Identifiable
        Returns:
        the identifier encoded as a String. If the identifier is a complex one, that is made up of several identification parts, then the returned representation should take care of such a structure.
      • setId

        public void setId​(String id)
      • getInstanceId

        public String getInstanceId()
      • getOldSilverpeasId

        public long getOldSilverpeasId()
      • setOldSilverpeasId

        public void setOldSilverpeasId​(long oldSilverpeasId)
      • getForeignId

        public String getForeignId()
      • setForeignId

        public void setForeignId​(String foreignId)
      • getOrder

        public int getOrder()
      • setOrder

        public void setOrder​(int order)
      • 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 interface Attachment
        Returns:
        true if this attachment is versioned, false otherwise.
      • isPublic

        public boolean isPublic()
      • setPublicDocument

        public void setPublicDocument​(boolean publicDocument)
      • unlock

        public void unlock()
      • getNodeName

        public String getNodeName()
      • setNodeName

        public void setNodeName​(String nodeName)
      • computeNodeName

        public String computeNodeName()
      • getFullJcrContentPath

        public String getFullJcrContentPath()
        Full JCR path to the file node.
        Returns:
        the full JCR path to the file node (starting with /).
      • getFullJcrPath

        public String getFullJcrPath()
        Full JCR path to the document node.
        Returns:
        the full JCR path to the document node (starting with /).
      • 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 interface Attachment
        Returns:
        the path of the icon representing this attachment.
      • isOpenOfficeCompatible

        public boolean isOpenOfficeCompatible()
        Check if the document is compatible with OpenOffice using the mime type .
        Returns:
        true if the document is compatible with OpenOffice false otherwise.
      • isReadOnly

        public boolean isReadOnly()
        Is this document in read-only? A document is read-only if either it is currently being editing by another user than the current one, or it isn't edited, and it cannot be modified by the current user, or it is currently being editing by another user than the current one. If there is no user behind the scene, then the method behave like the isEdited() method.
        Returns:
        true if this document cannot be modified, false otherwise.
      • isEdited

        public boolean isEdited()
        Is this document currently being edited?
        Returns:
        true if this document is being edited by a user in Silverpeas. False otherwise.
      • isEditedBy

        public boolean isEditedBy​(User user)
        Is this document currently being edited by the specified user? If the document isn't being currently edited by any user, false is returned.
        Parameters:
        user - a user in Silverpeas
        Returns:
        true if the specified user is editing this document. False either no users are editing it or another user is editing it.
      • getAttachmentPath

        public String getAttachmentPath()
        Path to the file stored on the filesystem.
        Specified by:
        getAttachmentPath in interface Attachment
        Returns:
        the path to the file stored on the filesystem.
      • getDirectoryPath

        public String getDirectoryPath​(String language)
        Path to the directory where the file is to be stored.
        Parameters:
        language - the language of the document.
        Returns:
        the path to the directory where the file is to be stored.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getAttachmentURL

        public String getAttachmentURL()
        Returns the attachment URL.
        Returns:
        the attachment URL.
      • getUniversalURL

        public String getUniversalURL()
      • getOnlineURL

        public String getOnlineURL()
      • getWebdavUrl

        public String getWebdavUrl()
      • getWebdavJcrPath

        public String getWebdavJcrPath()
      • getVersionMaster

        public SimpleDocument getVersionMaster()
        Returns the master of versioned document. If not versioned, it returns itself. If versioned, it returns the master of versioned document (the last created or updated in other words).
        Returns:
        the master version of this document.
      • setVersionMaster

        public void setVersionMaster​(SimpleDocument versionMaster)
      • isVersionMaster

        public boolean isVersionMaster()
        Indicates if the current instance is a master one.
        Returns:
        true if current instance is master, false otherwise.
      • getRepositoryPath

        public String getRepositoryPath()
        Returns the path into the repository.
        Returns:
        the repository path.
      • setRepositoryPath

        public void setRepositoryPath​(String repositoryPath)
      • getVersionIndex

        public int getVersionIndex()
        Returns the index of document into the history if any and if the document is a versioned one. In other cases, it returns 0 (the start index).
        Returns:
        the index of the document version in the document change history.
      • setVersionIndex

        public void setVersionIndex​(int versionIndex)
      • getLastPublicVersion

        public SimpleDocument getLastPublicVersion()
        Returns the more recent public version of this document - null if none exists.
        Returns:
        the more recent public version of this document - null if none exists.
      • getFolder

        public String getFolder()
      • isSharingAllowedForRolesFrom

        public boolean isSharingAllowedForRolesFrom​(User user)
      • canBeAccessedBy

        public boolean canBeAccessedBy​(User user)
        Is the specified user can access this document?
        Specified by:
        canBeAccessedBy in interface Contribution
        Specified by:
        canBeAccessedBy in interface Securable
        Parameters:
        user - a user in Silverpeas.
        Returns:
        true if the user can access this document, false otherwise.
      • canBeModifiedBy

        public boolean canBeModifiedBy​(User user)
        Is the specified user can access this document on persist context?
        Specified by:
        canBeModifiedBy in interface Securable
        Parameters:
        user - a user in Silverpeas.
        Returns:
        true if the user can access this document, false otherwise.
      • isDownloadAllowedForRolesFrom

        public boolean isDownloadAllowedForRolesFrom​(User user)
        Indicates if the download of the document is allowed for the given user in relation to its roles. DON'T USE THIS METHOD IN CASE OF LARGE NUMBER OF ATTACHMENT TO PERFORM.
        Parameters:
        user - a user in Silverpeas.
        Returns:
        true if download is allowed.
      • isDownloadAllowedForRoles

        public boolean isDownloadAllowedForRoles​(Set<SilverpeasRole> roles)
        Indicates if the download of the document is allowed for the given roles.
        Parameters:
        roles - a set of silverpeas roles
        Returns:
        true if download is allowed.
      • isDownloadAllowedForReaders

        public boolean isDownloadAllowedForReaders()
        Indicates if the download is allowed for readers.
      • addRolesForWhichDownloadIsForbidden

        public boolean addRolesForWhichDownloadIsForbidden​(SilverpeasRole... forbiddenRoles)
        Forbids the download for the given roles. PLEASE BE CAREFUL : this method doesn't persist the information. It is used by attachment services during the conversion from JCR data to SimpleDocument data.
        Parameters:
        forbiddenRoles - one or more silverpeas roles
        Returns:
        true if roles were not forbidden before the call of this method.
      • addRolesForWhichDownloadIsForbidden

        public boolean addRolesForWhichDownloadIsForbidden​(Collection<SilverpeasRole> forbiddenRoles)
        Forbids the download for the given roles. PLEASE BE CAREFUL : this method doesn't persist the information. It is used by attachment services during the conversion from JCR data to SimpleDocument data.
        Parameters:
        forbiddenRoles - a collection of silverpeas roles
        Returns:
        true if roles were not forbidden before the call of this method.
      • addRolesForWhichDownloadIsAllowed

        public void addRolesForWhichDownloadIsAllowed​(SilverpeasRole... allowedRoles)
        Allows the download for the given roles. PLEASE BE CAREFUL : this method doesn't persist the information. It is used by attachment services during the conversion from JCR data to SimpleDocument data.
        Parameters:
        allowedRoles - one or more silverpeas roles
      • addRolesForWhichDownloadIsAllowed

        public boolean addRolesForWhichDownloadIsAllowed​(Collection<SilverpeasRole> allowedRoles)
        Allows the download for the given roles. PLEASE BE CAREFUL : this method doesn't persist the information. It is used by attachment services during the conversion from JCR data to SimpleDocument data.
        Parameters:
        allowedRoles - a collection of silverpeas roles
        Returns:
        true if roles were not allowed before the call of this method.
      • getForbiddenDownloadForRoles

        public Set<SilverpeasRole> getForbiddenDownloadForRoles()
        Gets roles for which download is not allowed.
        Returns:
        a set of silverpeas roles
      • isContentImage

        public boolean isContentImage()
        Indicates if the file described by current SimpleAttachment is type of image.
      • isContentSpinfire

        public boolean isContentSpinfire()
        Indicates if the file described by current SimpleAttachment is type of 3D.
      • isContentArchive

        public boolean isContentArchive()
        Indicates if the file described by current SimpleAttachment is type of archive.
      • isContentMail

        public boolean isContentMail()
        Indicates if the file described by current SimpleAttachment is type of mail.
      • isContentPdf

        public boolean isContentPdf()
        Indicates if the file described by current SimpleAttachment is type of pdf.
      • isDisplayableAsContent

        public boolean isDisplayableAsContent()
        Indicates if the attachment content can be displayed as a contribution content.
        Returns:
        true to display as content, false otherwise.
      • setDisplayableAsContent

        public void setDisplayableAsContent​(boolean displayableAsContent)
      • 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 interface LocalizedResource
        Specified by:
        getTranslation in interface Translatable
        Parameters:
        language - the ISO 631-1 code of a language.
        Returns:
        a translation of the object in the given language. Can be never null.
      • editableSimultaneously

        public Optional<Boolean> editableSimultaneously()
        Indicates if the attachment can be edited simultaneously into web browser by several users.
        Returns:
        An optional true if editable, false otherwise. If Optional is empty, it means that the indicator is not handled.
      • setEditableSimultaneously

        public void setEditableSimultaneously​(boolean editableSimultaneously)