org.wso2.registry
Class ResourceImpl

java.lang.Object
  extended by org.wso2.registry.ResourceImpl
All Implemented Interfaces:
Resource
Direct Known Subclasses:
CollectionImpl, Comment

public class ResourceImpl
extends java.lang.Object
implements Resource

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.


Field Summary
protected  java.lang.Object content
          Content of the resource.
protected  java.util.List<java.lang.String> dependencies
          Paths of the resources on which this resource depends on.
protected  java.util.List<java.lang.String> dependents
          Paths of the resources that depends on this resource.
protected  java.util.Properties properties
          Properties associated with the resource.
 
Constructor Summary
ResourceImpl()
           
 
Method Summary
 void addDependency(java.lang.String dependencyPath)
           
 void addDependent(java.lang.String dependentPath)
           
 void addLifecycle(java.lang.String name)
           
 void addProperty(java.lang.String key, java.lang.String value)
           
 java.lang.String getAuthorUserName()
           
 java.lang.Object getContent()
           
 java.io.InputStream getContentStream()
           
 java.util.Date getCreatedTime()
           
 java.lang.String[] getDependencies()
           
 java.lang.String[] getDependents()
           
 java.lang.String getDescription()
           
 long getId()
           
 java.util.Date getLastModified()
           
 java.lang.String getLastUpdaterUserName()
           
 java.util.List<java.lang.String> getLifecycles()
           
 java.lang.String getMediaType()
           
 java.lang.String getParentPath()
           
 java.lang.String getPath()
           
 java.util.Properties getProperties()
           
 java.lang.String getProperty(java.lang.String key)
           
 java.util.List getPropertyValues(java.lang.String key)
           
 int getState()
           
 long getVersionNumber()
           
 boolean isContentModified()
           
 boolean isDirectory()
           
 void removeLifecycle(java.lang.String name)
           
 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)
           
 void setCreatedTime(java.util.Date createdTime)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setDependencies(java.lang.String[] dependencies)
           
 void setDependents(java.lang.String[] dependents)
           
 void setDescription(java.lang.String description)
           
 void setId(long id)
           
 void setLastModified(java.util.Date lastModified)
           
 void setLastUpdaterUserName(java.lang.String lastUpdaterUserName)
           
 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 setProperty(java.lang.String key, java.util.List<java.lang.String> value)
           
 void setProperty(java.lang.String key, java.lang.String value)
           
 void setState(int state)
           
 void setVersionNumber(long versionNumber)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

protected java.util.Properties properties
Properties associated with the resource. A resource can contain zero or more properties, where each property is a name->value pair. Both name and the value should be strings.


dependencies

protected java.util.List<java.lang.String> dependencies
Paths of the resources on which this resource depends on. This feature is not implemented currently.


dependents

protected java.util.List<java.lang.String> dependents
Paths of the resources that depends on this resource. This feature is not implemented currently.


content

protected java.lang.Object content
Content of the resource. Object and the type stored in this field depends on the resource type. If the resource is a file with no special media type handling, this contains an array of bytes (byte[]) conatining the raw bytes of the file. If the resource is a collection, this contains a String[] containing the paths of child resources. If the resource is processed by a media type handler, it is upto the media type handler to set a content. In that case content can be anything ranging from String to custom type. Therefore, clients of the API should be aware of the media type and the content for that media type.

Constructor Detail

ResourceImpl

public ResourceImpl()
Method Detail

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)

getId

public long getId()

setId

public void setId(long id)

getVersionNumber

public long getVersionNumber()

setVersionNumber

public void setVersionNumber(long versionNumber)

getAuthorUserName

public java.lang.String getAuthorUserName()
Specified by:
getAuthorUserName in interface Resource

setAuthorUserName

public void setAuthorUserName(java.lang.String authorUserName)

getCreatedTime

public java.util.Date getCreatedTime()
Specified by:
getCreatedTime in interface Resource

setCreatedTime

public void setCreatedTime(java.util.Date createdTime)

getLastModified

public java.util.Date getLastModified()
Specified by:
getLastModified in interface Resource

setLastModified

public void setLastModified(java.util.Date lastModified)

getDescription

public java.lang.String getDescription()
Specified by:
getDescription in interface Resource

setDescription

public void setDescription(java.lang.String description)
Specified by:
setDescription in interface Resource

getPath

public java.lang.String getPath()
Specified by:
getPath in interface Resource

setPath

public void setPath(java.lang.String path)

getMediaType

public java.lang.String getMediaType()
Specified by:
getMediaType in interface Resource

setMediaType

public void setMediaType(java.lang.String mediaType)
Specified by:
setMediaType in interface Resource

getParentPath

public java.lang.String getParentPath()
Specified by:
getParentPath in interface Resource

setParentPath

public void setParentPath(java.lang.String parentPath)

getState

public int getState()
Specified by:
getState in interface Resource

setState

public void setState(int state)

getProperty

public java.lang.String getProperty(java.lang.String key)
Specified by:
getProperty in interface Resource

getPropertyValues

public java.util.List getPropertyValues(java.lang.String key)
Specified by:
getPropertyValues in interface Resource

getProperties

public java.util.Properties getProperties()
Specified by:
getProperties in interface Resource

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Specified by:
setProperty in interface Resource

setProperty

public void setProperty(java.lang.String key,
                        java.util.List<java.lang.String> value)
Specified by:
setProperty in interface Resource

addProperty

public void addProperty(java.lang.String key,
                        java.lang.String value)
Specified by:
addProperty in interface Resource

setProperties

public void setProperties(java.util.Properties properties)
Specified by:
setProperties in interface Resource

getContentStream

public java.io.InputStream getContentStream()
                                     throws RegistryException
Specified by:
getContentStream in interface Resource
Throws:
RegistryException

setContentStream

public void setContentStream(java.io.InputStream contentStream)
Specified by:
setContentStream in interface Resource

getContent

public java.lang.Object getContent()
                            throws RegistryException
Specified by:
getContent in interface Resource
Throws:
RegistryException

setContent

public void setContent(java.lang.Object content)
Specified by:
setContent in interface Resource

getLastUpdaterUserName

public java.lang.String getLastUpdaterUserName()
Specified by:
getLastUpdaterUserName in interface Resource

setLastUpdaterUserName

public void setLastUpdaterUserName(java.lang.String lastUpdaterUserName)

isDirectory

public boolean isDirectory()

getDependents

public java.lang.String[] getDependents()
Specified by:
getDependents in interface Resource

setDependents

public void setDependents(java.lang.String[] dependents)
Specified by:
setDependents in interface Resource

addDependent

public void addDependent(java.lang.String dependentPath)
Specified by:
addDependent in interface Resource

getDependencies

public java.lang.String[] getDependencies()
Specified by:
getDependencies in interface Resource

setDependencies

public void setDependencies(java.lang.String[] dependencies)
Specified by:
setDependencies in interface Resource

addDependency

public void addDependency(java.lang.String dependencyPath)
Specified by:
addDependency in interface Resource

isContentModified

public boolean isContentModified()

setContentModified

public void setContentModified(boolean contentModified)
This method is used to explicitly set the content modified state of the resource. Normal users of the Registry API should not call this method.

Parameters:
contentModified - true if we want to add a new version upon putting this to the registry. false otherwise.

getLifecycles

public java.util.List<java.lang.String> getLifecycles()
Specified by:
getLifecycles in interface Resource

addLifecycle

public void addLifecycle(java.lang.String name)
Specified by:
addLifecycle in interface Resource

removeLifecycle

public void removeLifecycle(java.lang.String name)
Specified by:
removeLifecycle in interface Resource


Copyright © 2007 Apache Web Services Project. All Rights Reserved.