Package org.wso2.carbon.registry.api
Interface Resource
-
- All Known Subinterfaces:
Collection,Comment
public interface ResourceInterface to represent a resource that is stored on the registry. Each resource will have some metadata and content. Resources can also have properties, and versions. In addition to that, the registry APIs can be used to create associations between resources, rate or comment on resources, and to create search tags.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAspect(String name)Method to add an aspect.voidaddProperty(String key, String value)Add a property value for the provided key.voiddiscard()Method to discard the resourcevoideditPropertyValue(String key, String oldValue, String newValue)Edit property value.List<String>getAspects()Get the aspects associated with the resource.StringgetAuthorUserName()Get the user name of the resource author.ObjectgetContent()Method to get the content of the resource.InputStreamgetContentStream()Method to get the content stream.DategetCreatedTime()Method to get the created time.StringgetDescription()Method to get the description.StringgetId()The Resource ID, In the default implementation this returns the path.DategetLastModified()Method to get the last modified date.StringgetLastUpdaterUserName()Method to get the last updated user name.StringgetMediaType()Get media type.StringgetParentPath()Get the parent path.StringgetPath()Method to get the path.StringgetPermanentPath()If resource is version-ed, the associated version of the resource does not get modified by any means.PropertiesgetProperties()Returns all properties of the resource.StringgetProperty(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.intgetState()Method to get the state.voidremoveAspect(String name)Method to remove an aspect.voidremoveProperty(String key)Remove property.voidremovePropertyValue(String key, String value)Remove property value.voidsetContent(Object content)Set the content of the resource.voidsetContentStream(InputStream contentStream)Method to set the content stream.voidsetDescription(String description)Method to set the description.voidsetMediaType(String mediaType)Set media type.voidsetProperties(Properties properties)Set properties.voidsetProperty(String key, String value)Set a property with single value.voidsetProperty(String key, List<String> value)Set a property with multiple 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
-
-