org.silverpeas.attachment.model
Class SimpleDocument

java.lang.Object
  extended by org.silverpeas.attachment.model.SimpleDocument
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HistorisedDocument, SimpleDocumentVersion

public class SimpleDocument
extends Object
implements Serializable

Author:
ehugonnet
See Also:
Serialized Form

Field Summary
static String ATTACHMENT_PREFIX
           
static String DOCUMENT_PREFIX
           
static String FILE_PREFIX
           
static String VERSION_PREFIX
           
static String WEBDAV_FOLDER
           
 
Constructor Summary
SimpleDocument()
           
SimpleDocument(SimpleDocument simpleDocument)
           
SimpleDocument(SimpleDocumentPK pk, String foreignId, int order, boolean versioned, Date reservation, Date alert, Date expiry, String comment, SimpleAttachment attachment)
           
SimpleDocument(SimpleDocumentPK pk, String foreignId, int order, boolean versioned, SimpleAttachment attachment)
           
SimpleDocument(SimpleDocumentPK pk, String foreignId, int order, boolean versioned, String editedBy, Date reservation, Date alert, Date expiry, String comment, SimpleAttachment attachment)
           
SimpleDocument(SimpleDocumentPK pk, String foreignId, int order, boolean versioned, String editedBy, SimpleAttachment attachment)
           
 
Method Summary
 boolean addRolesForWhichDownloadIsAllowed(Collection<SilverpeasRole> allowedRoles)
          Allows the download for the given roles.
 boolean addRolesForWhichDownloadIsAllowed(SilverpeasRole... allowedRoles)
          Allows the download for the given roles.
 boolean addRolesForWhichDownloadIsForbidden(Collection<SilverpeasRole> forbiddenRoles)
          Forbids the download for the given roles.
 boolean addRolesForWhichDownloadIsForbidden(SilverpeasRole... forbiddenRoles)
          Forbids the download for the given roles.
 boolean canBeAccessedBy(UserDetail user)
          Is the specified user can access this document?
 boolean canBeModifiedBy(UserDetail user)
          Is the specified user can access this document on persist context?
 String computeNodeName()
           
 void edit(String currentEditor)
           
 boolean equals(Object obj)
           
 Date getAlert()
           
 String getAliasURL()
           
 SimpleAttachment getAttachment()
           
 String getAttachmentPath()
          Path to the file stored on the filesystem.
 String getAttachmentURL()
          Returns the attachment URL.
 String getCloneId()
          Get the value of cloneId
 String getComment()
           
 String getContentType()
           
 Date getCreated()
           
 String getCreatedBy()
           
 String getDescription()
           
 String getDirectoryPath(String language)
          Path to the directory where the file is to be stored.
 String getDisplayIcon()
          Return the icon correponding to the file.
 DocumentType getDocumentType()
           
 String getEditedBy()
           
 Date getExpiry()
           
 String getFilename()
           
 String getFolder()
           
 Set<SilverpeasRole> getForbiddenDownloadForRoles()
          Gets roles for which download is not allowed.
 String getForeignId()
           
 String getFullJcrContentPath()
          Full JCR path to the file node.
 String getFullJcrPath()
          Full JCR path to the document node.
 String getId()
           
 String getInstanceId()
           
 String getLanguage()
           
 SimpleDocument getLastPublicVersion()
          Returns the more recent public version of this document - null if none exists.
 int getMajorVersion()
           
 int getMinorVersion()
           
 String getNodeName()
           
 long getOldSilverpeasId()
           
 String getOnlineURL()
           
 int getOrder()
           
 SimpleDocumentPK getPk()
           
 String getRepositoryPath()
          Returns the path into the repository.
 Date getReservation()
           
 long getSize()
           
 String getStatus()
           
 String getTitle()
           
 String getUniversalURL()
           
 Date getUpdated()
           
 String getUpdatedBy()
           
 String getVersion()
          Gets a version number as String.
 int getVersionIndex()
          Returns the index of document into the history if any and if the document is a versioned one.
 SimpleDocument getVersionMaster()
          Returns the master of versioned document.
 String getWebdavContentEditionLanguage()
          Gets the content language handled into webdav for the document.
 long getWebdavContentEditionSize()
          Gets the content size handled into webdav for the document.
 String getWebdavJcrPath()
           
 String getWebdavUrl()
           
 String getWebURL()
          Deprecated. use getAttachmentURL instead.
 String getXmlFormId()
           
 int hashCode()
           
 boolean isContentArchive()
          Indicates if the file described by current SimpleAttachment is type of archive.
 boolean isContentImage()
          Indicates if the file described by current SimpleAttachment is type of image.
 boolean isContentMail()
          Indicates if the file described by current SimpleAttachment is type of mail.
 boolean isContentPdf()
          Indicates if the file described by current SimpleAttachment is type of pdf.
 boolean isContentSpinfire()
          Indicates if the file described by current SimpleAttachment is type of 3D.
 boolean isDownloadAllowedForReaders()
          Indicates if the download is allowed for readers.
 boolean isDownloadAllowedForRoles(Set<SilverpeasRole> roles)
          Indicates if the download of the document is allowed for the given roles.
 boolean isDownloadAllowedForRolesFrom(UserDetail user)
          Indicates if the download of the document is allowed for the given user in relation to its roles.
 boolean isOpenOfficeCompatible()
          Check if the document is compatible with OpenOffice using the mime type .
 boolean isPublic()
           
 boolean isReadOnly()
           
 boolean isSharingAllowedForRolesFrom(UserDetail user)
           
 boolean isVersioned()
           
 boolean isVersionMaster()
          Indicates if the current instance is a master one.
 void release()
           
protected  void resetWebdavContentEditionContext()
           
 void setAlert(Date alert)
           
 void setAttachment(SimpleAttachment attachment)
           
 void setCloneId(String cloneId)
          Set the value of cloneId
 void setComment(String comment)
           
 void setContentType(String contentType)
           
 void setCreated(Date created)
           
 void setDescription(String description)
           
 void setDocumentType(DocumentType documentType)
           
 void setExpiry(Date expiry)
           
 void setFilename(String filename)
           
 void setForeignId(String foreignId)
           
 void setId(String id)
           
 void setLanguage(String language)
           
 void setMajorVersion(int majorVersion)
           
 void setMinorVersion(int minorVersion)
           
 void setNodeName(String nodeName)
           
 void setOldSilverpeasId(long oldSilverpeasId)
           
 void setOrder(int order)
           
 void setPK(SimpleDocumentPK pk)
           
 void setPublicDocument(boolean publicDocument)
           
 void setRepositoryPath(String repositoryPath)
           
 void setReservation(Date reservationDate)
           
 void setSize(long size)
           
 void setStatus(String status)
           
 void setTitle(String title)
           
 void setUpdated(Date updated)
           
 void setUpdatedBy(String updatedBy)
           
 void setVersionIndex(int versionIndex)
           
 void setVersionMaster(SimpleDocument versionMaster)
           
 void setXmlFormId(String xmlFormId)
           
 String toString()
           
 void unlock()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

WEBDAV_FOLDER

public static final String WEBDAV_FOLDER
See Also:
Constant Field Values

ATTACHMENT_PREFIX

public static final String ATTACHMENT_PREFIX
See Also:
Constant Field Values

VERSION_PREFIX

public static final String VERSION_PREFIX
See Also:
Constant Field Values

FILE_PREFIX

public static final String FILE_PREFIX
See Also:
Constant Field Values

DOCUMENT_PREFIX

public static final String DOCUMENT_PREFIX
See Also:
Constant Field Values
Constructor Detail

SimpleDocument

public SimpleDocument(SimpleDocumentPK pk,
                      String foreignId,
                      int order,
                      boolean versioned,
                      SimpleAttachment attachment)

SimpleDocument

public SimpleDocument(SimpleDocumentPK pk,
                      String foreignId,
                      int order,
                      boolean versioned,
                      String editedBy,
                      SimpleAttachment attachment)

SimpleDocument

public SimpleDocument(SimpleDocumentPK pk,
                      String foreignId,
                      int order,
                      boolean versioned,
                      Date reservation,
                      Date alert,
                      Date expiry,
                      String comment,
                      SimpleAttachment attachment)

SimpleDocument

public SimpleDocument(SimpleDocumentPK pk,
                      String foreignId,
                      int order,
                      boolean versioned,
                      String editedBy,
                      Date reservation,
                      Date alert,
                      Date expiry,
                      String comment,
                      SimpleAttachment attachment)
Parameters:
pk -
foreignId -
order -
versioned -
editedBy -
reservation -
alert -
expiry -
comment -
attachment -

SimpleDocument

public SimpleDocument()

SimpleDocument

public SimpleDocument(SimpleDocument simpleDocument)
Method Detail

setDocumentType

public void setDocumentType(DocumentType documentType)

getDocumentType

public DocumentType getDocumentType()

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()

setFilename

public void setFilename(String filename)

getLanguage

public String getLanguage()

setLanguage

public void setLanguage(String language)

getTitle

public String getTitle()

setTitle

public void setTitle(String title)

getDescription

public String getDescription()

setDescription

public void setDescription(String description)

getSize

public long getSize()

setSize

public void setSize(long size)

getContentType

public String getContentType()

setContentType

public void setContentType(String contentType)

getCreatedBy

public String getCreatedBy()

getCreated

public Date getCreated()

setCreated

public void setCreated(Date created)

getUpdatedBy

public String getUpdatedBy()

setUpdatedBy

public void setUpdatedBy(String updatedBy)

getUpdated

public Date getUpdated()

setUpdated

public void setUpdated(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()

setMinorVersion

public void setMinorVersion(int minorVersion)

getMajorVersion

public int getMajorVersion()

setMajorVersion

public void setMajorVersion(int majorVersion)

getVersion

public String getVersion()
Gets a version number as String. For now, this is the concatenation of major and minor version data that are separated by a point.

Returns:

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()

setId

public void setId(String id)

setPK

public void setPK(SimpleDocumentPK pk)

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()

getAttachment

public SimpleAttachment getAttachment()

getPk

public SimpleDocumentPK getPk()

setAttachment

public void setAttachment(SimpleAttachment attachment)

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()
Return the icon correponding to the file.

Returns:

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()

getAttachmentPath

public String getAttachmentPath()
Path to the file stored on the filesystem.

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.

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getAttachmentURL

public String getAttachmentURL()
Returns the attachment URL.

Returns:
the attachment URL.

getUniversalURL

public String getUniversalURL()

getOnlineURL

public String getOnlineURL()

getAliasURL

public String getAliasURL()

getWebdavUrl

public String getWebdavUrl()

getWebdavJcrPath

public String getWebdavJcrPath()

getWebURL

@Deprecated
public String getWebURL()
Deprecated. use getAttachmentURL instead.

Returns the attachment URL.

Returns:
the attachment URL.

getVersionMaster

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

Returns:

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:

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:

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(UserDetail user)

canBeAccessedBy

public boolean canBeAccessedBy(UserDetail user)
Is the specified user can access this document?

Parameters:
user - a user in Silverpeas.
Returns:
true if the user can access this document, false otherwise.

canBeModifiedBy

public boolean canBeModifiedBy(UserDetail user)
Is the specified user can access this document on persist context?

Parameters:
user - a user in Silverpeas.
Returns:
true if the user can access this document, false otherwise.

isDownloadAllowedForRolesFrom

public boolean isDownloadAllowedForRolesFrom(UserDetail 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 -
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 -
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 -
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 -
Returns:
true if roles were not forbidden before the call of this method.

addRolesForWhichDownloadIsAllowed

public boolean 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 -
Returns:
true if roles were not allowed before the call of this method.

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 -
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:

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.



Copyright © 2016 Silverpeas. All Rights Reserved.