org.wso2.carbon.registry.core
Interface Resource

All Superinterfaces:
org.wso2.carbon.registry.api.Resource
All Known Subinterfaces:
Collection

public interface Resource
extends org.wso2.carbon.registry.api.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.
 String getUUID()
          Method to get the UUID of a resource
 boolean isVersionableChange()
          Check whether there are any changes that need to make a version
 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.
 void setUUID(String uuid)
          Method to set the UUID for a resource
 void setVersionableChange(boolean versionableChange)
          Method to set whether there are any changes that need to make a version
 

Method Detail

getId

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

Specified by:
getId in interface org.wso2.carbon.registry.api.Resource
Returns:
the resource id

getAuthorUserName

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

Specified by:
getAuthorUserName in interface org.wso2.carbon.registry.api.Resource
Returns:
the user name of the resource author.

getCreatedTime

Date getCreatedTime()
Method to get the created time.

Specified by:
getCreatedTime in interface org.wso2.carbon.registry.api.Resource
Returns:
the created time

getLastModified

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

Specified by:
getLastModified in interface org.wso2.carbon.registry.api.Resource
Returns:
the last modified date.

getDescription

String getDescription()
Method to get the description.

Specified by:
getDescription in interface org.wso2.carbon.registry.api.Resource
Returns:
the description.

setDescription

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

Specified by:
setDescription in interface org.wso2.carbon.registry.api.Resource
Parameters:
description - the description.

getPath

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

Specified by:
getPath in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
getPermanentPath in interface org.wso2.carbon.registry.api.Resource
Returns:
Permanent path (permalink) of the resource.

getMediaType

String getMediaType()
Get media type.

Specified by:
getMediaType in interface org.wso2.carbon.registry.api.Resource
Returns:
the media type.

getState

int getState()
Method to get the state.

Specified by:
getState in interface org.wso2.carbon.registry.api.Resource
Returns:
the state.

setMediaType

void setMediaType(String mediaType)
Set media type.

Specified by:
setMediaType in interface org.wso2.carbon.registry.api.Resource
Parameters:
mediaType - the media type.

getParentPath

String getParentPath()
Get the parent path.

Specified by:
getParentPath in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
getProperty in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
getPropertyValues in interface org.wso2.carbon.registry.api.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.

Specified by:
getProperties in interface org.wso2.carbon.registry.api.Resource
Returns:
All properties of the resource.

setProperty

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

Specified by:
setProperty in interface org.wso2.carbon.registry.api.Resource
Parameters:
key - the property key.
value - the property value.

setProperty

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

Specified by:
setProperty in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
addProperty in interface org.wso2.carbon.registry.api.Resource
Parameters:
key - the property key.
value - the property value.

setProperties

void setProperties(Properties properties)
Set properties.

Specified by:
setProperties in interface org.wso2.carbon.registry.api.Resource
Parameters:
properties - the properties.

editPropertyValue

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

Specified by:
editPropertyValue in interface org.wso2.carbon.registry.api.Resource
Parameters:
key - the key.
oldValue - the old value.
newValue - the new value.

removeProperty

void removeProperty(String key)
Remove property.

Specified by:
removeProperty in interface org.wso2.carbon.registry.api.Resource
Parameters:
key - the property key.

removePropertyValue

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

Specified by:
removePropertyValue in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
getContent in interface org.wso2.carbon.registry.api.Resource
Returns:
the content.
Throws:
RegistryException - throws if the operation fail.

setContent

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

Specified by:
setContent in interface org.wso2.carbon.registry.api.Resource
Parameters:
content - the resource.
Throws:
RegistryException - throws if the operation fail.

getLastUpdaterUserName

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

Specified by:
getLastUpdaterUserName in interface org.wso2.carbon.registry.api.Resource
Returns:
the last updated user name.

getContentStream

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

Specified by:
getContentStream in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
setContentStream in interface org.wso2.carbon.registry.api.Resource
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.

Specified by:
getAspects in interface org.wso2.carbon.registry.api.Resource
Returns:
an array of associated aspects.

addAspect

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

Specified by:
addAspect in interface org.wso2.carbon.registry.api.Resource
Parameters:
name - the name of the aspect.

removeAspect

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

Specified by:
removeAspect in interface org.wso2.carbon.registry.api.Resource
Parameters:
name - the name of the aspect to remove.

discard

void discard()
Method to discard the resource

Specified by:
discard in interface org.wso2.carbon.registry.api.Resource

isVersionableChange

boolean isVersionableChange()
Check whether there are any changes that need to make a version

Returns:
true, if there are version-able changes, false otherwise.

setVersionableChange

void setVersionableChange(boolean versionableChange)
Method to set whether there are any changes that need to make a version

Parameters:
versionableChange - whether version-able change is made or not.

setUUID

void setUUID(String uuid)
Method to set the UUID for a resource

Parameters:
uuid - the UUID to be set to the resource

getUUID

String getUUID()
Method to get the UUID of a resource

Returns:
UUID of the resource


Copyright © 2014 WSO2 Inc. All Rights Reserved.