|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sourceforge.sconman.Content
public class Content
A content is a typed, categorized, and described document. A content can range from multimedia data, as images, videos, or music files, to text files as HTML or PDF files.
Every content belongs to a project (Project
), has a valid type (
ContentType
, see getType()
) within that project, and is
categorized (Category
, see getCategory()
).
For visibility management, contents have a visibility time range (see getFromDate()
and getToDate()
), within which the content is
"visible". Search operations can look for visible contents, or visible and
not visible contents, as desired.
A content is, before all, a described document, so specific information
fields can be set for this content (see set(java.lang.String, java.lang.String)
).
Finally, where is the content's document file? Look for it at getUri()
, relative to the contents repository.
Field Summary | |
---|---|
protected java.util.Properties |
attributes
Specific content fields for content type |
static java.lang.String |
AUTHOR_ID
AUTHOR_ID field id |
static java.lang.String |
CATEGORY
CATEGORY field id |
static java.lang.String |
CONTENTS
CONTENTS field id |
static java.lang.String |
CREATION_DATE
CREATION_DATE field id |
static java.lang.String |
FROM_DATE
FROM_DATE field id |
static java.lang.String |
INDEX_DATE
INDEX_DATE field id |
static java.lang.String |
MODIFICATION_DATE
MODIFICATION_DATE field id |
static java.text.SimpleDateFormat |
sdf
Date formatter |
static java.text.SimpleDateFormat |
sdf_old
Date formatter |
static java.lang.String |
TO_DATE
TO_DATE field id |
static java.lang.String |
TYPE
CTYPE field id |
static java.lang.String |
URI
URI field id |
Constructor Summary | |
---|---|
Content(ContentType ctype)
Creates a new Content object. |
|
Content(Project prj,
java.io.File file)
Reads a content from a file |
|
Content(Project prj,
java.io.InputStream is)
Reads a content from an input stream |
Method Summary | |
---|---|
void |
addRelatedContent(Content relatedContent)
Adds a related content |
void |
addVisibilityDays(int days)
Add days to the current "toDate" |
boolean |
canModify(User user)
Check modify permissions for this content |
boolean |
canRemove(User user)
Check remove permissions for this content |
boolean |
canView(User user)
Check view permissions for this content |
java.lang.Object |
clone()
Clones this content, but doesn't add it to the project. |
Content |
cloneInCategory(User actor)
Clones a content in the same category. |
boolean |
equals(java.lang.Object obj)
Two contents are equal if both have the same URI |
(package private) java.util.Properties |
getAttributes()
Returns the internal attribute map |
java.lang.String |
getAttributesFilePath()
Returns content's attribute file path, relative to the repository |
static java.lang.String |
getAttributesFilePath(java.lang.String path)
|
User |
getAuthor()
Retrieves content's author |
java.lang.String |
getAuthorId()
|
java.lang.Boolean |
getBoolean(java.lang.String fieldName)
Returns a field's value as a Boolean object. |
Category |
getCategory()
Returns the category where the content was stored |
java.util.List |
getContentsRelatedToContent(User user,
boolean visible)
Returns all the contents who are related to this content |
java.util.Date |
getCreationDate()
Returns the creation date of the content. |
java.util.Date |
getDate(java.lang.String fieldName)
Returns a field's value as a Date object. |
java.lang.String |
getDefaultFieldValue()
Returns the default field's value |
java.lang.String |
getDefaultFieldValue(java.lang.String locale)
Returns the default field's value |
java.lang.String |
getDirPath()
Returns the content's dir path, relative to the filestore |
java.lang.String |
getEncodedString(java.lang.String fieldName,
java.lang.String encoding)
Returns a field's value as a String encoded with encoding parameter. |
java.lang.String |
getEncodedString(java.lang.String locale,
java.lang.String fieldName,
java.lang.String encoding)
Returns a localized field's value as a String encoded with encoding parameter. |
java.lang.String |
getFieldsAsString()
Returns all the non special fields as a long string |
java.lang.String |
getFileExtension()
Returns the content file extension. |
java.lang.String |
getFileName()
Returns the file id |
java.lang.String |
getFilePath()
Return the content's file path, relative to the filestore |
java.lang.Float |
getFloat(java.lang.String fieldName)
Returns a field's value as a Float object. |
java.lang.String |
getFormattedDate(java.lang.String fieldName,
java.lang.String formatPattern)
Returns a field's Date value as a String object formatted. |
java.util.Date |
getFromDate()
Returns the visibility start date. |
java.lang.String |
getFromDate(java.lang.String formatPattern)
Returns the visibility start date formatted with formatPattern. |
java.util.Date |
getIndexDate()
Returns when the content was indexed, or null if the content doesn't comes from the index |
(package private) void |
getInfo(boolean overrideAttrib,
boolean createThumbnail)
|
java.io.InputStream |
getInputStream()
Returns the content's data as an input stream |
java.lang.Integer |
getInteger(java.lang.String fieldName)
Returns a field's value as a Integer object. |
Item |
getItem(java.lang.String fieldName)
Returns a field's value as a Item object. |
java.lang.String |
getItemValue(java.lang.String locale,
java.lang.String fieldName)
Returns the internationalized value of a Item object |
java.util.Date |
getModificationDate()
|
java.lang.String |
getModificationDate(java.lang.String formatPattern)
Returns the last modification date formatted with formatPattern. |
java.io.OutputStream |
getOutputStream()
Returns an output channel to write content's data |
Project |
getProject()
Returns project |
Content |
getReferencedContent(User user,
java.lang.String fieldName)
Returns the content referenced by the specified field. |
java.util.List |
getReferencingContents(User user,
java.lang.String ctype,
java.lang.String fieldName,
boolean visible)
Returns the contents of a given type that reference this content in the specified field. |
java.util.List |
getRelatedContents(User user,
boolean visible)
Returns all the contents related for this content |
IRepository |
getRepository()
Returns the repository where this content is stored |
java.lang.String |
getString(java.lang.String fieldName)
Returns a field's value as a String. |
java.lang.String |
getString(java.lang.String locale,
java.lang.String fieldName)
Returns a localized field's value as a String. |
java.lang.String |
getThumbnailFilePath()
Returns the thumbnail file path |
java.io.InputStream |
getThumbnailInputStream()
Returns the content's thumbnail as an input stream |
java.io.OutputStream |
getThumbnailOutputStream()
Returns an output channel to write thumbnail |
java.util.Date |
getToDate()
Returns the visibility end date. |
java.lang.String |
getToDate(java.lang.String formatPattern)
Returns the visibility end date formatted with formatPattern. |
ContentType |
getType()
Returns the content's type |
java.lang.String |
getUri()
Returns the content's file URI, relative to the contents repository. |
(package private) boolean |
hasAttributeFile()
Returns true if the content's attribute file exists |
(package private) boolean |
hasFile()
Returns true if the content's file exists |
(package private) boolean |
hasNewerAttributeFile(java.util.Date date)
Returns true if the attribute file is newer than the specified date |
(package private) boolean |
hasNewerFile(java.util.Date date)
Returns true if the attribute file is newer than the specified date |
(package private) boolean |
hasThumbnailFile()
Returns true if the content's thumbnail file exists |
boolean |
isAuthor(User user)
Check if user is the author of the Content |
(package private) boolean |
isIndexed()
Return true if the content is indexed |
long |
length()
Gets the size of the content. |
Content |
moveTo(User actor,
Category cat)
Moves this content to another category |
(package private) void |
readAttributes()
Reads content attributes from associated attribute file |
(package private) void |
readAttributes(Project prj,
java.io.InputStream stream)
Read attributes from an input stream |
(package private) void |
readAttributes(java.lang.String filePath)
Reads content attributes from associated attribute file |
(package private) void |
remove()
Removes a content from the repository. |
void |
remove(User actor)
Removes a content from the repository. |
void |
removeRelatedContent(Content relatedContent)
Removes a related content |
(package private) void |
save()
Stores changes in the repository, checking user permissions. |
(package private) void |
save(java.io.InputStream is)
Stores changes in the repository |
void |
save(User user)
Stores changes in the repository, checking user permissions. |
void |
save(User actor,
java.io.InputStream is)
Stores changes in the repository, checking user permissions. |
void |
set(java.lang.String fieldName,
java.lang.Boolean value)
Sets a Boolean field to a given content. |
void |
set(java.lang.String fieldName,
Content refContent)
Sets a reference field to a given content. |
void |
set(java.lang.String fieldName,
java.util.Date fieldValue)
Sets a Date value for a descriptor field, specific to this content. |
void |
set(java.lang.String fieldName,
java.lang.Float value)
Sets a Float field to a given content. |
void |
set(java.lang.String fieldName,
java.lang.Integer value)
Sets a Integer field to a given content. |
void |
set(java.lang.String fieldName,
Item item)
Sets a Item value field to a given content. |
void |
set(java.lang.String fieldName,
java.lang.String fieldValue)
Sets a String value for a descriptor field, specific to this content. |
void |
set(java.lang.String locale,
java.lang.String fieldName,
java.lang.String fieldValue)
Sets an internationalized text field |
void |
setAuthorId(java.lang.String authorId)
|
void |
setCategory(Category cat)
Sets the content's category |
void |
setCreationDate(java.util.Date creationDate)
Sets creation date of the content. |
void |
setFormattedDate(java.lang.String fieldName,
java.lang.String date,
java.lang.String formatPattern)
Sets a Date field as a String formatted in formatPattern pattern |
void |
setFromDate(java.util.Date fromDate)
Sets the visibility start date, when content will become visible to normal search. |
(package private) void |
setIndexDate(java.util.Date indexDate)
Sets the indexation time |
void |
setModificationDate(java.util.Date modificationDate)
|
void |
setToDate(java.util.Date toDate)
Sets the visibility end date, when the content will become invisible to normal search. |
void |
setType(ContentType ctype)
Sets the content's type |
void |
setUri(java.lang.String uri)
Sets the content URI. |
void |
sync()
Synchronized attributes file |
java.lang.String |
toString()
|
(package private) void |
writeAttributes()
Stores content attributes |
(package private) void |
writeAttributes(java.io.OutputStream os)
Write attributes on an output stream |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String INDEX_DATE
public static final java.lang.String URI
public static final java.lang.String CATEGORY
public static final java.lang.String TYPE
public static final java.lang.String AUTHOR_ID
public static final java.lang.String CREATION_DATE
public static final java.lang.String MODIFICATION_DATE
public static final java.lang.String FROM_DATE
public static final java.lang.String TO_DATE
public static final java.lang.String CONTENTS
public static final java.text.SimpleDateFormat sdf
public static final java.text.SimpleDateFormat sdf_old
protected java.util.Properties attributes
Constructor Detail |
---|
Content(ContentType ctype)
ctype
- The content typepublic Content(Project prj, java.io.InputStream is) throws java.io.IOException
prj
- The project for this contentis
- The input stream with the serialized content
java.io.IOException
public Content(Project prj, java.io.File file) throws java.io.IOException
prj
- The project for this contentfile
- The file with the serialized content
java.io.IOException
Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public boolean canView(User user)
user
-
public boolean canModify(User user)
user
- public boolean canRemove(User user)
user
- public boolean isAuthor(User user)
user
-
public User getAuthor()
public java.util.Date getIndexDate()
void setIndexDate(java.util.Date indexDate)
indexDate
- public java.util.Date getCreationDate()
public java.util.Date getFromDate()
getToDate()
.
public java.lang.String getFromDate(java.lang.String formatPattern)
getFromDate()
.
formatPattern
- a SimpleDateFormat valid pattern
public java.util.Date getToDate()
getFromDate()
, to this date.
public java.lang.String getToDate(java.lang.String formatPattern)
getFromDate()
, to this date
formatPattern
- a SimpleDateFormat valid pattern
public ContentType getType()
public java.lang.String getAuthorId()
public void setAuthorId(java.lang.String authorId)
authorId
- The author's user id to set.public java.util.Date getModificationDate()
public java.lang.String getModificationDate(java.lang.String formatPattern)
formatPattern
- a SimpleDateFormat valid pattern
public void setModificationDate(java.util.Date modificationDate)
modificationDate
- The modificationDate to set.public void setCreationDate(java.util.Date creationDate)
creationDate
- Creation date of the contentpublic void setFromDate(java.util.Date fromDate)
fromDate
- Visibility start datepublic void addVisibilityDays(int days)
days
- public void setToDate(java.util.Date toDate)
toDate
- Visibility end datepublic void setType(ContentType ctype)
ctype
- Content's typepublic java.lang.String getUri()
public void setUri(java.lang.String uri)
uri
- void save(java.io.InputStream is) throws SCMStorageException
SCMStorageException
- Thrown if there's an error while removing the content
SCMSecurityException
- Thrown when the user doesn't have the permissions to modify
the content's type, or cannot modify the content categoryvoid save() throws SCMStorageException
SCMStorageException
- Thrown if there's an error while removing the content
SCMSecurityException
- Thrown when the user doesn't have the permissions to modify
the content's type, or cannot modify the content categorypublic void save(User actor, java.io.InputStream is) throws SCMStorageException, SCMSecurityException
actor
- The user that performs the actionis
- The new content's data data source
SCMStorageException
- Thrown if there's an error while saving the content
SCMSecurityException
- Thrown when the user doesn't have the permissions to modify
the content's type, or cannot modify the content categorypublic void save(User user) throws SCMStorageException, SCMSecurityException
actor
- The user that performs the action
SCMStorageException
- Thrown if there's an error while removing the content
SCMSecurityException
- Thrown when the user doesn't have the permissions to modify
the content's type, or cannot modify the content categoryvoid remove() throws SCMStorageException
content
should come from a search operation.
user
- The user who tries to remove contentcontent
- The content to remove
SCMException
- Thrown if there's an error while removing the content
SCMStorageException
public void remove(User actor) throws SCMSecurityException, SCMStorageException
content
should come from a search operation.
actor
- The user who tries to remove contentcontent
- The content to remove
SCMException
- Thrown if there's an error while removing the content
SCMSecurityException
SCMStorageException
public Content moveTo(User actor, Category cat) throws SCMStorageException, SCMSecurityException
actor
- The user that performs the actioncat
- The new category
SCMStorageException
- Thrown if there's a problem changing category
SCMSecurityException
- Thrown if the actor hasn't enough permissionspublic void set(java.lang.String fieldName, java.lang.String fieldValue)
getString(java.lang.String)
to retrieve values set with this method.
fieldName
- The descriptor field to setfieldValue
- The new valuepublic void set(java.lang.String locale, java.lang.String fieldName, java.lang.String fieldValue)
locale
- fieldName
- fieldValue
- public void set(java.lang.String fieldName, java.util.Date fieldValue)
getDate(java.lang.String)
to retrieve values set with this method.
fieldName
- The descriptor field to setfieldValue
- The new valuepublic void set(java.lang.String fieldName, Content refContent)
#getContent
to
retrieve references set with this method
fieldName
- The field to setrefContent
- The referenced contentpublic void set(java.lang.String fieldName, java.lang.Integer value)
getInteger(java.lang.String)
to
retrieve values set with this method
fieldName
- The field to setvalue
- The new valuepublic void set(java.lang.String fieldName, java.lang.Float value)
getFloat(java.lang.String)
to retrieve
values set with this method
fieldName
- The field to setvalue
- The new valuepublic void set(java.lang.String fieldName, java.lang.Boolean value)
getBoolean(java.lang.String)
to
retrieve values set with this method
fieldName
- The field to setvalue
- The new valuepublic void set(java.lang.String fieldName, Item item)
Item
value field to a given content. Use getItem(java.lang.String)
to retrieve Item
set with this method
fieldName
- The field to setItem
- The new Item
valuepublic java.lang.String getDefaultFieldValue()
public java.lang.String getDefaultFieldValue(java.lang.String locale)
public java.lang.String getString(java.lang.String fieldName)
set(String,String)
fieldName
- Field id
public java.lang.String getString(java.lang.String locale, java.lang.String fieldName)
set(String,String)
fieldName
- Field id
public java.lang.String getEncodedString(java.lang.String fieldName, java.lang.String encoding)
set(String,String)
fieldName
- Field idencoding
- Valid encoding type "UTF-8", "ISO-8859-1", ...
public java.lang.String getEncodedString(java.lang.String locale, java.lang.String fieldName, java.lang.String encoding)
set(String,String)
fieldName
- Field idencoding
- Valid encoding type "UTF-8", "ISO-8859-1", ...
public java.util.Date getDate(java.lang.String fieldName)
set(String,Date)
.
fieldName
- Field id.
public java.lang.String getFormattedDate(java.lang.String fieldName, java.lang.String formatPattern)
fieldName
- Field idformatPattern
- a SimpleDateFormat valid pattern
public void setFormattedDate(java.lang.String fieldName, java.lang.String date, java.lang.String formatPattern)
fieldName
- Field iddate
- String representing the Date in formatPattern patternformatPattern
- a SimpleDateFormat valid patternpublic java.lang.Integer getInteger(java.lang.String fieldName)
set(String,Integer)
.
fieldName
- Field id.
public java.lang.Float getFloat(java.lang.String fieldName)
set(String,Float)
.
fieldName
- Field id.
public java.lang.Boolean getBoolean(java.lang.String fieldName)
set(String,Boolean)
.
fieldName
- Field id.
public Item getItem(java.lang.String fieldName)
set(String,Item)
.
fieldName
- Field id.
public java.lang.String getItemValue(java.lang.String locale, java.lang.String fieldName)
locale
- The current localefieldName
- The field's name
public Content getReferencedContent(User user, java.lang.String fieldName) throws SCMStorageException, SCMSecurityException
set(String,Content)
.
user
- The user that requests the referenced contentfieldName
- Field id.
SCMStorageException
SCMSecurityException
public java.util.List getReferencingContents(User user, java.lang.String ctype, java.lang.String fieldName, boolean visible) throws java.io.IOException, SCMException
ctype
- The type of the requested contentsfieldName
- The field id that references this content's typevisible
- True to filter non visible contents
java.io.IOException
- If there's an IO problem
SCMException
public java.util.List getRelatedContents(User user, boolean visible) throws SCMStorageException, SCMSecurityException
user
- The user who requests the related contents
SCMStorageException
SCMSecurityException
public java.util.List getContentsRelatedToContent(User user, boolean visible) throws SCMStorageException, SCMSecurityException
user
- The user who requests the related contents
SCMStorageException
SCMSecurityException
public void addRelatedContent(Content relatedContent) throws SCMStorageException
relatedContent
-
SCMStorageException
public void removeRelatedContent(Content relatedContent) throws SCMStorageException
relatedContent
-
SCMStorageException
public Category getCategory()
public void setCategory(Category cat)
cat
- A valid categorypublic java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
- If there's an IO problempublic java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
- If there's an IO problempublic java.io.InputStream getThumbnailInputStream() throws java.io.IOException
java.io.IOException
- If there's an IO problempublic java.io.OutputStream getThumbnailOutputStream() throws java.io.IOException
java.io.IOException
- If there's an IO problempublic java.lang.String getFileExtension()
public java.lang.String getFileName()
public IRepository getRepository()
public java.lang.String getFilePath()
content
-
public java.lang.String getDirPath()
content
-
void writeAttributes(java.io.OutputStream os) throws java.io.IOException
os
-
java.io.IOException
void readAttributes(Project prj, java.io.InputStream stream) throws java.io.IOException
stream
-
java.io.IOException
void writeAttributes() throws SCMStorageException
SCMStorageException
- Thrown if there's an exception writting the attribute filevoid readAttributes() throws SCMStorageException
SCMStorageException
- Thrown if there's an exception reading the attribute filevoid readAttributes(java.lang.String filePath) throws SCMStorageException
SCMStorageException
- Thrown if there's an exception reading the attribute filepublic java.lang.String getThumbnailFilePath()
public java.lang.String getAttributesFilePath()
public static java.lang.String getAttributesFilePath(java.lang.String path)
boolean isIndexed() throws SCMStorageException
SCMStorageException
boolean hasFile()
boolean hasNewerFile(java.util.Date date)
date
-
boolean hasAttributeFile()
boolean hasNewerAttributeFile(java.util.Date date)
date
-
boolean hasThumbnailFile()
public Project getProject()
public void sync() throws SCMStorageException
java.io.IOException
SCMStorageException
void getInfo(boolean overrideAttrib, boolean createThumbnail)
public long length()
java.util.Properties getAttributes()
public java.lang.Object clone()
Category.addContent(User, Content, InputStream, String)
).
clone
in class java.lang.Object
public Content cloneInCategory(User actor) throws SCMStorageException, SCMSecurityException
SCMStorageException
SCMSecurityException
public java.lang.String getFieldsAsString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |