|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.wso2.registry.ResourceImpl
public class ResourceImpl
Represents any file or collection stored in the registry. It encapsulates both the content of the entity and its metadata. In addition to files and collections, instances of Resource are used to represent results of runtime queries. In such secenarios, comments, tags, ratings as well as collections of comments, etc. are also represented by Resource objects. Each resource instance contains a unique path within a Registry instance. Registry.get(...) method invocation using this path gives an instance of that resource. This path can be combined with the base URL of the registry server to generate a URI for the resource. Handling content Contents of resource can be set either as an input stream or an object. If an input stream is set, an unique file based content will be created for the given input stream. If an object of type byte[] or String is set, an inmemeory input stream will be created from it and then a unique file based input stream is created. If an object of any other type is set, there should be a handler to convert it to an input stream before reaching the repository. When a resource is retrieved from the database layer, its content is not retrieved from the database. Instead, UUID referring to the database content is stored in dbBasedContentID. When the content is first accessed, a file based input stream is created from the database content and fileBasedContentID is set (fileBasedContentID = dbBasedContentID).
Field Summary | |
---|---|
protected java.lang.String |
authorUserName
Username of the user who added the resource to the registry. |
protected java.lang.Object |
content
Content of the resource. |
protected boolean |
contentModified
Used to detect whether the resource content is modified after it is retrieved from the Registry. |
protected java.sql.Timestamp |
createdTime
Time at which the resource is first added to the registry. |
protected javax.sql.DataSource |
dataSource
Registry datasource. |
protected java.lang.String |
dbBasedContentID
UUID of the content stored in the database. |
protected java.lang.String |
description
Description about the resource. |
protected boolean |
directory
Specified whether the resource is a collection (directory) or a file. |
protected java.lang.String |
fileBasedContentID
UUID refering to the file based content of this resource. |
protected java.lang.String |
id
UUID to identify the resource. |
protected java.sql.Timestamp |
lastModified
Time at which the resource modified most recently. |
protected java.lang.String |
lastUpdaterUserName
Username of the user who modified the resource most recently. |
protected long |
matchingSnapshotID
|
protected java.lang.String |
mediaType
Media type of the resource. |
protected java.lang.String |
parentPath
Path of the parent collection of the resource. |
protected java.lang.String |
path
Unique path of the resource within the registry. |
protected java.lang.String |
permanentPath
|
protected java.util.Properties |
properties
Properties associated with the resource. |
protected boolean |
propertiesModified
Used to detect whether properties of this resource is modified since retrieval from the repository. |
protected ResourceDAO |
resourceDAO
Resource DAO instance to access the database directly. |
protected long |
snapshotID
Snapshot for which this resource instance is created. |
protected int |
state
Normal resources have the state RegistryConstants.ACTIVE_STATE (100) Deleted resources have the state RegistryConstants.DELETED_STATE (101) |
protected boolean |
versionableChange
Determines whether the resource is subjected to changes, which causes it to create a new version. |
protected long |
versionNumber
Version of this instance of the resource. |
Constructor Summary | |
---|---|
ResourceImpl()
|
Method Summary | |
---|---|
void |
addAspect(java.lang.String name)
|
void |
addProperty(java.lang.String key,
java.lang.String value)
|
void |
discard()
|
void |
editPropertyValue(java.lang.String key,
java.lang.String oldValue,
java.lang.String newValue)
|
java.util.List<java.lang.String> |
getAspects()
|
java.lang.String |
getAuthorUserName()
|
java.lang.Object |
getContent()
|
java.io.InputStream |
getContentStream()
|
java.util.Date |
getCreatedTime()
|
java.lang.String |
getDbBasedContentID()
|
java.lang.String |
getDescription()
|
java.lang.String |
getFileBasedContentID()
|
java.lang.String |
getId()
|
java.util.Date |
getLastModified()
|
java.lang.String |
getLastUpdaterUserName()
|
long |
getMatchingSnapshotID()
|
java.lang.String |
getMediaType()
|
java.lang.String |
getParentPath()
|
java.lang.String |
getPath()
|
java.lang.String |
getPermanentPath()
If resource is versioned, the associated version of the resource does not get modified by any means. |
java.util.Properties |
getProperties()
Returns all properties of the resource. |
java.lang.String |
getProperty(java.lang.String key)
|
java.util.List |
getPropertyValues(java.lang.String key)
Returns the list of values for the given property name. |
long |
getSnapshotID()
|
int |
getState()
|
long |
getVersionNumber()
|
boolean |
isContentModified()
|
boolean |
isPropertiesModified()
|
boolean |
isVersionableChange()
|
void |
removeAspect(java.lang.String name)
|
void |
removeProperty(java.lang.String key)
|
void |
removePropertyValue(java.lang.String key,
java.lang.String value)
|
void |
setAuthorUserName(java.lang.String authorUserName)
|
void |
setContent(java.lang.Object content)
|
void |
setContentModified(boolean contentModified)
This method is used to explicitly set the content modified state of the resource. |
void |
setContentStream(java.io.InputStream contentStream)
Invalidates the current file based content and creates a new file based content for the new content stream. |
void |
setCreatedTime(java.util.Date createdTime)
|
void |
setDataSource(javax.sql.DataSource dataSource)
|
void |
setDbBasedContentID(java.lang.String dbBasedContentID)
|
void |
setDescription(java.lang.String description)
|
void |
setFileBasedContentID(java.lang.String fileBasedContentID)
|
void |
setId(java.lang.String id)
|
void |
setLastModified(java.util.Date lastModified)
|
void |
setLastUpdaterUserName(java.lang.String lastUpdaterUserName)
|
void |
setMatchingSnapshotID(long matchingSnapshotID)
|
void |
setMediaType(java.lang.String mediaType)
|
void |
setParentPath(java.lang.String parentPath)
|
void |
setPath(java.lang.String path)
|
void |
setProperties(java.util.Properties properties)
|
void |
setPropertiesModified(boolean propertiesModified)
|
void |
setProperty(java.lang.String key,
java.util.List<java.lang.String> value)
|
void |
setProperty(java.lang.String key,
java.lang.String value)
|
void |
setSnapshotID(long snapshotID)
|
void |
setState(int state)
|
void |
setVersionableChange(boolean versionableChange)
|
void |
setVersionNumber(long versionNumber)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String id
protected long snapshotID
protected long versionNumber
protected java.lang.String authorUserName
protected java.sql.Timestamp createdTime
protected java.lang.String lastUpdaterUserName
protected java.sql.Timestamp lastModified
protected java.lang.String description
protected java.lang.String path
protected long matchingSnapshotID
protected java.lang.String permanentPath
protected java.lang.String mediaType
protected java.lang.String parentPath
protected boolean contentModified
protected boolean propertiesModified
protected boolean versionableChange
protected int state
protected java.util.Properties properties
protected java.lang.String fileBasedContentID
protected java.lang.String dbBasedContentID
protected java.lang.Object content
protected boolean directory
protected javax.sql.DataSource dataSource
protected ResourceDAO resourceDAO
Constructor Detail |
---|
public ResourceImpl()
Method Detail |
---|
public void setDataSource(javax.sql.DataSource dataSource)
public java.lang.String getId()
getId
in interface Resource
public void setId(java.lang.String id)
public long getSnapshotID()
public void setSnapshotID(long snapshotID)
public long getVersionNumber()
public void setVersionNumber(long versionNumber)
public java.lang.String getAuthorUserName()
getAuthorUserName
in interface Resource
public void setAuthorUserName(java.lang.String authorUserName)
public java.util.Date getCreatedTime()
getCreatedTime
in interface Resource
public void setCreatedTime(java.util.Date createdTime)
public java.util.Date getLastModified()
getLastModified
in interface Resource
public void setLastModified(java.util.Date lastModified)
public java.lang.String getDescription()
getDescription
in interface Resource
public void setDescription(java.lang.String description)
setDescription
in interface Resource
public java.lang.String getPath()
getPath
in interface Resource
public void setPath(java.lang.String path)
public long getMatchingSnapshotID()
public void setMatchingSnapshotID(long matchingSnapshotID)
public java.lang.String getPermanentPath()
Resource
getPermanentPath
in interface Resource
public java.lang.String getMediaType()
getMediaType
in interface Resource
public void setMediaType(java.lang.String mediaType)
setMediaType
in interface Resource
public java.lang.String getParentPath()
getParentPath
in interface Resource
public void setParentPath(java.lang.String parentPath)
public int getState()
getState
in interface Resource
public void setState(int state)
public java.lang.String getProperty(java.lang.String key)
getProperty
in interface Resource
public java.util.List getPropertyValues(java.lang.String key)
Resource
getPropertyValues
in interface Resource
key
- Key of the property.
public java.util.Properties getProperties()
Resource
getProperties
in interface Resource
public void removeProperty(java.lang.String key)
removeProperty
in interface Resource
public void removePropertyValue(java.lang.String key, java.lang.String value)
removePropertyValue
in interface Resource
public void editPropertyValue(java.lang.String key, java.lang.String oldValue, java.lang.String newValue)
editPropertyValue
in interface Resource
public void setProperty(java.lang.String key, java.lang.String value)
setProperty
in interface Resource
public void setProperty(java.lang.String key, java.util.List<java.lang.String> value)
setProperty
in interface Resource
public void addProperty(java.lang.String key, java.lang.String value)
addProperty
in interface Resource
public void setProperties(java.util.Properties properties)
setProperties
in interface Resource
public java.lang.String getFileBasedContentID()
public void setFileBasedContentID(java.lang.String fileBasedContentID)
public java.lang.String getDbBasedContentID()
public void setDbBasedContentID(java.lang.String dbBasedContentID)
public java.io.InputStream getContentStream() throws RegistryException
getContentStream
in interface Resource
RegistryException
public void setContentStream(java.io.InputStream contentStream) throws RegistryException
setContentStream
in interface Resource
contentStream
- input stream containing the new content
RegistryException
public java.lang.Object getContent() throws RegistryException
getContent
in interface Resource
RegistryException
public void setContent(java.lang.Object content) throws RegistryException
setContent
in interface Resource
RegistryException
public java.lang.String getLastUpdaterUserName()
getLastUpdaterUserName
in interface Resource
public void setLastUpdaterUserName(java.lang.String lastUpdaterUserName)
public boolean isContentModified()
public void setContentModified(boolean contentModified)
contentModified
- true if we want to add a new version upon putting this to the
registry. false otherwise.public boolean isPropertiesModified()
public void setPropertiesModified(boolean propertiesModified)
public boolean isVersionableChange()
public void setVersionableChange(boolean versionableChange)
public java.util.List<java.lang.String> getAspects()
getAspects
in interface Resource
public void addAspect(java.lang.String name)
addAspect
in interface Resource
public void removeAspect(java.lang.String name)
removeAspect
in interface Resource
public void discard()
discard
in interface Resource
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |