org.wso2.carbon.registry.core
Interface Resource

All Known Subinterfaces:
Collection
All Known Implementing Classes:
CollectionImpl, CollectionVersionImpl, Comment, RemoteResourceImpl, ResourceImpl

public interface Resource

Interface to represent a resource.


Method Summary
 void addAspect(String name)
          Method to add an aspect.
 void addProperty(String key, String value)
          Add a property value for the provided key.
 void discard()
          Method to discard the resource
 void editPropertyValue(String key, String oldValue, String newValue)
          Edit property value.
 List<String> getAspects()
          Get the aspects associated with the resource.
 String getAuthorUserName()
          Get the user name of the resource author.
 Object getContent()
          Method to get the content of the resource.
 InputStream getContentStream()
          Method to get the content stream.
 Date getCreatedTime()
          Method to get the created time.
 String getDescription()
          Method to get the description.
 String getId()
          The Resource ID, In the default implementation this returns the path.
 Date getLastModified()
          Method to get the last modified date.
 String getLastUpdaterUserName()
          Method to get the last updated user name.
 String getMediaType()
          Get media type.
 String getParentPath()
          Get the parent path.
 String getPath()
          Method to get the path.
 String getPermanentPath()
          If resource is version-ed, the associated version of the resource does not get modified by any means.
 Properties getProperties()
          Returns all properties of the resource.
 String getProperty(String key)
          Get the property value for the given key, if there are multiple value for that key, it will return the first value.
 List<String> getPropertyValues(String key)
          Returns the list of values for the given property name.
 int getState()
          Method to get the state.
 void removeAspect(String name)
          Method to remove an aspect.
 void removeProperty(String key)
          Remove property.
 void removePropertyValue(String key, String value)
          Remove property value.
 void setContent(Object content)
          Set the content of the resource.
 void setContentStream(InputStream contentStream)
          Method to set the content stream.
 void setDescription(String description)
          Method to set the description.
 void setMediaType(String mediaType)
          Set media type.
 void setProperties(Properties properties)
          Set properties.
 void setProperty(String key, List<String> value)
          Set a property with multiple value.
 void setProperty(String key, String value)
          Set a property with single value.
 

Method Detail

getId

String getId()
The Resource ID, In the default implementation this returns the path.

Returns:
the resource id

getAuthorUserName

String getAuthorUserName()
Get the user name of the resource author.

Returns:
the user name of the resource author.

getCreatedTime

Date getCreatedTime()
Method to get the created time.

Returns:
the created time

getLastModified

Date getLastModified()
Method to get the last modified date.

Returns:
the last modified date.

getDescription

String getDescription()
Method to get the description.

Returns:
the description.

setDescription

void setDescription(String description)
Method to set the description.

Parameters:
description - the description.

getPath

String getPath()
Method to get the path. the unique identifier of the resources in the present state.

Returns:
the path.

getPermanentPath

String getPermanentPath()
If resource is version-ed, the associated version of the resource does not get modified by any means. Therefore, the path of that version is the permanent path (permalink) of the current state of the resource.

Returns:
Permanent path (permalink) of the resource.

getMediaType

String getMediaType()
Get media type.

Returns:
the media type.

getState

int getState()
Method to get the state.

Returns:
the state.

setMediaType

void setMediaType(String mediaType)
Set media type.

Parameters:
mediaType - the media type.

getParentPath

String getParentPath()
Get the parent path.

Returns:
the parent path.

getProperty

String getProperty(String key)
Get the property value for the given key, if there are multiple value for that key, it will return the first value.

Parameters:
key - the property key.
Returns:
the property value.

getPropertyValues

List<String> getPropertyValues(String key)
Returns the list of values for the given property name. Note that these values are read-only. Changes made to these values will not be persisted on putting the resource.

Parameters:
key - Key of the property.
Returns:
List of values of the given property key.

getProperties

Properties getProperties()
Returns all properties of the resource. Properties are stored as key (String) -> values (List) pairs. It is not recommended to use this method to access properties. Instead, use other property related Resource API methods provided.

Note that these values are read-only. Changes made to these values will not be persisted on putting the resource.

Returns:
All properties of the resource.

setProperty

void setProperty(String key,
                 String value)
Set a property with single value.

Parameters:
key - the property key.
value - the property value.

setProperty

void setProperty(String key,
                 List<String> value)
Set a property with multiple value.

Parameters:
key - the property key.
value - the property values.

addProperty

void addProperty(String key,
                 String value)
Add a property value for the provided key. If there are values associated with the key, this will add append value. If not this will create a new property value for the key.

Parameters:
key - the property key.
value - the property value.

setProperties

void setProperties(Properties properties)
Set properties.

Parameters:
properties - the properties.

editPropertyValue

void editPropertyValue(String key,
                       String oldValue,
                       String newValue)
Edit property value.

Parameters:
key - the key.
oldValue - the old value.
newValue - the new value.

removeProperty

void removeProperty(String key)
Remove property.

Parameters:
key - the property key.

removePropertyValue

void removePropertyValue(String key,
                         String value)
Remove property value.

Parameters:
key - the property key.
value - the property value.

getContent

Object getContent()
                  throws RegistryException
Method to get the content of the resource. If the resource is a collection this will return an array of string that represent the paths of its children, otherwise it returns an byte array or a string from the default resource implementation.

Returns:
the content.
Throws:
RegistryException - throws if the operation fail.

setContent

void setContent(Object content)
                throws RegistryException
Set the content of the resource.

Parameters:
content - the resource.
Throws:
RegistryException - throws if the operation fail.

getLastUpdaterUserName

String getLastUpdaterUserName()
Method to get the last updated user name.

Returns:
the last updated user name.

getContentStream

InputStream getContentStream()
                             throws RegistryException
Method to get the content stream.

Returns:
content as an input stream.
Throws:
RegistryException - throws if the operation fail.

setContentStream

void setContentStream(InputStream contentStream)
                      throws RegistryException
Method to set the content stream.

Parameters:
contentStream - the content stream to set.
Throws:
RegistryException - throws if the operation fail.

getAspects

List<String> getAspects()
Get the aspects associated with the resource.

Returns:
an array of associated aspects.

addAspect

void addAspect(String name)
Method to add an aspect.

Parameters:
name - the name of the aspect.

removeAspect

void removeAspect(String name)
Method to remove an aspect.

Parameters:
name - the name of the aspect to remove.

discard

void discard()
Method to discard the resource



Copyright © 2010. All Rights Reserved.