org.wso2.carbon.registry.admin.api.resource
Interface IResourceService<MetadataBean,CollectionContentBean,ResourceData,ContentBean,PermissionBean,VersionsBean,ResourceTreeEntryBean,ContentDownloadBean>

Type Parameters:
MetadataBean - This bean can be used to access resource metadata, such as the last modified time, the author, description and the whether this resource is a collection or not. This also contains methods, to obtain formatted representations of dates and times.
CollectionContentBean - This bean can be used to access the content of a collection. A collection on the repository is similar to a folder on a filesystem. And, this bean can be used for operations such as obtaining the child count of a collection or obtaining the list of child resources under the given collection.
ResourceData - This contains the details of a resource, along with the various permissions that are available on it. This also can be used to obtain details of the ratings and tags that have been added to this resource.
ContentBean - This bean is used to manage the content of this resource. This has information on the type of resource and the various access restrictions that have been made to it.
PermissionBean - This bean can be used to manage the permissions associated with this resource or collection.
VersionsBean - This bean can be used to obtain details of versions that were created for this resource or collections. The version path can be used o browse through a version or restore back to it.
ResourceTreeEntryBean - This bean is used in the process of generating the tree view of the resource. This is used for the mere purpose of establishing a parent-child relationship between elements of the resource tree.
ContentDownloadBean - This bean contains a data handler that can be used to access the resource content. It also contains the media type and the last updated time of the resource.
All Superinterfaces:
ITextResourceManagementService

public interface IResourceService<MetadataBean,CollectionContentBean,ResourceData,ContentBean,PermissionBean,VersionsBean,ResourceTreeEntryBean,ContentDownloadBean>
extends ITextResourceManagementService

This provides the functionality to manage resources and collections on the repository. The resource browser on the WSO2 Carbon Management console uses the functionality exposed by this interface.

In addition to managing resources and collections, this also provides the capabilities of managing resource permissions and also installing and un-installing extensions to the repository.


Method Summary
 String addCollection(String parentPath, String collectionName, String collectionType, String description)
          Method to add a new collection to the repository.
 boolean addExtension(String name, DataHandler content)
          Method to upload an extension to the registry.
 void addRemoteLink(String parentPath, String name, String instance, String targetPath)
          Method to create a link to a remote resource (a resource on another repository that has been mounted into this repository).
 boolean addResource(String path, String mediaType, String description, DataHandler content, String symlinkLocation, String[][] properties)
          Method to add a new resource from the filesystem into the repository.
 boolean addRolePermission(String pathToAuthorize, String roleToAuthorize, String actionToAuthorize, String permissionType)
          Method to add a role permission to the given resource (or collection) path.
 void addSymbolicLink(String parentPath, String name, String targetPath)
          Method to create a symbolic link.
 boolean changeRolePermissions(String resourcePath, String permissionsInput)
          Method to change the permissions that have been granted to the given resource.
 boolean copyResource(String optional, String oldResourcePath, String parentPath, String resourceName)
          Method to copy a resource on the repository from one location to another.
 boolean createVersion(String resourcePath)
          Method to create a new version at the given path.
 boolean delete(String pathToDelete)
          Method to delete a resource (or collection) at the given path.
 CollectionContentBean getCollectionContent(String path)
          Method to obtain the content of a collection.
 String getCollectionMediatypeDefinitions()
          Method to obtain a list of media types against which handlers that are responsible for creating various collection types are registered.
 ContentBean getContentBean(String path)
          Method to obtain a bean that can be used to manage the content of this resource.
 ContentDownloadBean getContentDownloadBean(String path)
          Method to obtain a bean from with the content of the given resource can be downloaded.
 String getCustomUIMediatypeDefinitions()
          Method to obtain a list of media types against which custom user interfaces that are which will show up on the management console in place of the standard user interfaces for resources are registered
 String getHumanReadableMediaTypes()
          Method to obtain human readable Media Types.
 String getMediatypeDefinitions()
          Method to obtain a list of media types for resources stored on the repository.
 MetadataBean getMetadata(String path)
          Method to obtain resource metadata.
 String getMimeTypeFromHuman(String mediaType)
          Method to obtain mime types for the corresponding Media Type.
 PermissionBean getPermissions(String path)
          Method to obtain a bean that can be used to manage and manipulate resource permissions.
 String getProperty(String resourcePath, String key)
          Method to obtain a named property of the given resource.
 ResourceData[] getResourceData(String[] paths)
          Method to obtain the resource data for the given list of resource paths.
 ResourceTreeEntryBean getResourceTreeEntry(String resourcePath)
          Method to obtain a bean for an entry on the resource tree.
 String getSessionResourcePath()
          Method to obtain the resource path which has been set on the servlet session.
 VersionsBean getVersionsBean(String path)
          Method to obtain a list of versions of the given resource.
 boolean importResource(String parentPath, String resourceName, String mediaType, String description, String fetchURL, String symlinkLocation, String[][] properties)
          Method to import a resource (available on a specified remote URL) in to the repository.
 String[] listExtensions()
          This method lists all of the installed extensions for the given tenant.
 boolean moveResource(String optional, String oldResourcePath, String parentPath, String resourceName)
          Method to move a resource on the repository from one location to another.
 boolean removeExtension(String name)
          Method to remove the named extension from the registry.
 boolean renameResource(String parentPath, String oldResourcePath, String newResourceName)
          Method to rename resource (or collection) on the repository.
 boolean restoreVersion(String versionPath)
          Method to restore a resource to the given version.
 void setDescription(String path, String description)
          Method to set a description to this resource or collection.
 void setSessionResourcePath(String resourcePath)
          Method to set a resource path to the servlet session, to be used later.
 
Methods inherited from interface org.wso2.carbon.registry.admin.api.resource.ITextResourceManagementService
addTextContent, getTextContent, updateTextContent
 

Method Detail

getMetadata

MetadataBean getMetadata(String path)
                         throws Exception
Method to obtain resource metadata.

Parameters:
path - the resource path.
Returns:
a bean containing the metadata of this resource or collection.
Throws:
Exception - if the operation failed.

setDescription

void setDescription(String path,
                    String description)
                    throws Exception
Method to set a description to this resource or collection.

Parameters:
path - the resource path.
description - the description to set.
Throws:
Exception - if the operation failed.

getCollectionContent

CollectionContentBean getCollectionContent(String path)
                                           throws Exception
Method to obtain the content of a collection.

Parameters:
path - the collection path.
Returns:
bean used to access the content of the given collection.
Throws:
Exception - if the operation failed.

getResourceData

ResourceData[] getResourceData(String[] paths)
                               throws Exception
Method to obtain the resource data for the given list of resource paths.

Parameters:
paths - the list of resource paths for which we need to obtain resource data.
Returns:
the requested resource data.
Throws:
Exception - if the operation failed.

getContentBean

ContentBean getContentBean(String path)
                           throws Exception
Method to obtain a bean that can be used to manage the content of this resource.

Parameters:
path - the resource path.
Returns:
a bean that can be used to manage the resource content.
Throws:
Exception - if the operation failed.

addCollection

String addCollection(String parentPath,
                     String collectionName,
                     String collectionType,
                     String description)
                     throws Exception
Method to add a new collection to the repository.

Parameters:
parentPath - the parent path (or the path at which we are adding this collection).
collectionName - the name of the collection.
collectionType - the type of the collection. Collections unlike resources do not have a concept of media type. However, to create special types of collections, we specify a media type which will be used to trigger a handler which will create a collection of a specific type (ex:- Axis2 Repository collection).
description - the description for the newly added collection.
Returns:
the path at which the collection was added.
Throws:
Exception - if the operation failed.

addSymbolicLink

void addSymbolicLink(String parentPath,
                     String name,
                     String targetPath)
                     throws Exception
Method to create a symbolic link.

Parameters:
parentPath - the parent path (or the path at which we are adding this link). Please note that the parent path should not have trailing slashes.
name - the name of the symbolic link.
targetPath - the actual resource to which this link points to.
Throws:
Exception - if the operation failed.

addRemoteLink

void addRemoteLink(String parentPath,
                   String name,
                   String instance,
                   String targetPath)
                   throws Exception
Method to create a link to a remote resource (a resource on another repository that has been mounted into this repository). All mounted resources will also show-up as remote links.

Parameters:
parentPath - the parent path (or the path at which we are adding this link).
name - the name of the symbolic link.
instance - the identifier of the remote instance.
targetPath - the actual resource to which this link points to.
Throws:
Exception - if the operation failed.

importResource

boolean importResource(String parentPath,
                       String resourceName,
                       String mediaType,
                       String description,
                       String fetchURL,
                       String symlinkLocation,
                       String[][] properties)
                       throws Exception
Method to import a resource (available on a specified remote URL) in to the repository.

Parameters:
parentPath - the parent path (or the path at which we are adding this resource).
resourceName - the name of the resource.
mediaType - the media type of the resource.
description - the description for the newly added resource.
fetchURL - the remote URL at which the resource is available for download.
symlinkLocation - the location of the symbolic link to be created. This parameter is used when importing WSDL and Schema files, which will optionally create a symbolic link that points to the uploaded WSDL or Schema.
properties - list of properties to be added along with the resource.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

delete

boolean delete(String pathToDelete)
               throws Exception
Method to delete a resource (or collection) at the given path.

Parameters:
pathToDelete - the path of the resource (or collection) to delete.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

getPermissions

PermissionBean getPermissions(String path)
                              throws Exception
Method to obtain a bean that can be used to manage and manipulate resource permissions.

Parameters:
path - the path of the resource (or collection).
Returns:
the permissions bean for the given resource path.
Throws:
Exception - if the operation failed.

addRolePermission

boolean addRolePermission(String pathToAuthorize,
                          String roleToAuthorize,
                          String actionToAuthorize,
                          String permissionType)
                          throws Exception
Method to add a role permission to the given resource (or collection) path.

Parameters:
pathToAuthorize - the resource path for which the permission is added to do.
roleToAuthorize - the role for which the permission is granted to.
actionToAuthorize - the action that is authorized. The following actions correspond to following resource permissions:
  • 2 - Read Permission
  • 3 - Write Permission
  • 4 - Delete Permission
  • 5 - Authorize Permission
permissionType - the type of permission to be granted. The following types are available:
  • 0 - Deny permission
  • 1 - Allow (or grant) permission
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

changeRolePermissions

boolean changeRolePermissions(String resourcePath,
                              String permissionsInput)
                              throws Exception
Method to change the permissions that have been granted to the given resource.

Parameters:
resourcePath - the resource path for which the permissions are changed.
permissionsInput - the permission input is a string in the following format:

<permission-string> :- <role-permissions>

<role-permissions> :- <role-permission>|<role-permissions>

<role-permission> :- <role-name>:<permissions>

<permissions> :- <permission>:<permissions>

<permission> :- <action>^<type>

<role-name> :- a name of a valid role on the system

<action> :- ra, rd, wa, wd, da, dd, aa or ad.

<type> :- true or false

where the following defines the actions:

  • ra - Read allowed
  • rd - Read denied
  • wa - Write allowed
  • wd - Write denied
  • da - Delete allowed
  • dd - Delete denied
  • aa - Authorize allowed
  • ad - Authorize denied
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

addResource

boolean addResource(String path,
                    String mediaType,
                    String description,
                    DataHandler content,
                    String symlinkLocation,
                    String[][] properties)
                    throws Exception
Method to add a new resource from the filesystem into the repository. This will provide the data handler which was obtained from the file uploader to the repository in the case of the Management Console.

Parameters:
path - the path to which the resource would be added.
mediaType - the media type of the resource.
description - the description for the newly added resource.
content - the data handler containing the resource's content.
symlinkLocation - the location of the symbolic link to be created. This parameter is used when importing WSDL and Schema files, which will optionally create a symbolic link that points to the uploaded WSDL or Schema.
properties - list of properties to be added along with the resource.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

addExtension

boolean addExtension(String name,
                     DataHandler content)
                     throws Exception
Method to upload an extension to the registry. These extensions will get uploaded to the extensions directory for the given tenant.

Parameters:
name - the name of the extension library (which should be a jar).
content - the content of the jar.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

listExtensions

String[] listExtensions()
                        throws Exception
This method lists all of the installed extensions for the given tenant.

Returns:
list of extensions installed.
Throws:
Exception - if the operation failed.

removeExtension

boolean removeExtension(String name)
                        throws Exception
Method to remove the named extension from the registry.

Parameters:
name - the name of the extension library (which should be a jar).
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

renameResource

boolean renameResource(String parentPath,
                       String oldResourcePath,
                       String newResourceName)
                       throws Exception
Method to rename resource (or collection) on the repository.

Parameters:
parentPath - The parent path of the new resource. If this parameter is to be used, the new resource name should not start with a '/' character.
oldResourcePath - The complete path of the old resource.
newResourceName - The complete or path relative to parent path of the new resource.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

copyResource

boolean copyResource(String optional,
                     String oldResourcePath,
                     String parentPath,
                     String resourceName)
                     throws Exception
Method to copy a resource on the repository from one location to another.

Parameters:
oldResourcePath - the path of the existing resource.
parentPath - the path at which the new resource would be added.
resourceName - the name of the new resource.
optional - this parameter is not being used at the moment.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

moveResource

boolean moveResource(String optional,
                     String oldResourcePath,
                     String parentPath,
                     String resourceName)
                     throws Exception
Method to move a resource on the repository from one location to another.

Parameters:
oldResourcePath - the path of the old resource.
parentPath - the path at which the new resource would be added.
resourceName - the name of the new resource.
optional - this parameter is not being used at the moment.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

getSessionResourcePath

String getSessionResourcePath()
                              throws Exception
Method to obtain the resource path which has been set on the servlet session.

Returns:
the resource path saved on the session.
Throws:
Exception - if the operation failed.

setSessionResourcePath

void setSessionResourcePath(String resourcePath)
                            throws Exception
Method to set a resource path to the servlet session, to be used later.

Parameters:
resourcePath - the resource path saved on the session.
Throws:
Exception - if the operation failed.

getResourceTreeEntry

ResourceTreeEntryBean getResourceTreeEntry(String resourcePath)
                                           throws Exception
Method to obtain a bean for an entry on the resource tree. This method is used to generate the tree view of resources on the Management Console.

Parameters:
resourcePath - the path of the resource.
Returns:
a bean containing details of the resource tree entry.
Throws:
Exception - if the operation failed.

createVersion

boolean createVersion(String resourcePath)
                      throws Exception
Method to create a new version at the given path.

Parameters:
resourcePath - the path of the resource.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

restoreVersion

boolean restoreVersion(String versionPath)
                       throws Exception
Method to restore a resource to the given version. The resource to be restored will be determined from the version path itself.

Parameters:
versionPath - the path of the resource along with the version number to be restored to.
Returns:
whether the operation was successful or not.
Throws:
Exception - if the operation failed due to an unexpected error.

getVersionsBean

VersionsBean getVersionsBean(String path)
                             throws Exception
Method to obtain a list of versions of the given resource.

Parameters:
path - the resource path.
Returns:
a bean containing the versions of the resource (or collection) at the given path.
Throws:
Exception - if the operation failed.

getMediatypeDefinitions

String getMediatypeDefinitions()
                               throws Exception
Method to obtain a list of media types for resources stored on the repository. These media types will initially be populated from the mime.types file.

Returns:
the list of media types for resources. This will have a format as follows:

<media-types> :- <media-type-entry>,<media-type>

<media-type-entry> :- <extension>:<mime-type>

Throws:
Exception - if the operation failed.

getCollectionMediatypeDefinitions

String getCollectionMediatypeDefinitions()
                                         throws Exception
Method to obtain a list of media types against which handlers that are responsible for creating various collection types are registered.

Returns:
the list of media types for collections. This will have a format as follows:

<media-types> :- <media-type-entry>,<media-type>

<media-type-entry> :- <collection-type>:<mime-type>

Throws:
Exception - if the operation failed.

getCustomUIMediatypeDefinitions

String getCustomUIMediatypeDefinitions()
                                       throws Exception
Method to obtain a list of media types against which custom user interfaces that are which will show up on the management console in place of the standard user interfaces for resources are registered

Returns:
the list of media types for custom user interfaces. This will have a format as follows:

<media-types> :- <media-type-entry>,<media-type>

<media-type-entry> :- <custom-ui-name>:<mime-type>

Throws:
Exception - if the operation failed.

getProperty

String getProperty(String resourcePath,
                   String key)
                   throws Exception
Method to obtain a named property of the given resource.

Parameters:
resourcePath - the path of the resource (or collection).
key - the property key.
Returns:
the property value. In the case of a multi-valued property the first property value will be returned.
Throws:
Exception - if the operation failed.

getContentDownloadBean

ContentDownloadBean getContentDownloadBean(String path)
                                           throws Exception
Method to obtain a bean from with the content of the given resource can be downloaded.

Parameters:
path - the resource path.
Returns:
the bean having the resource content as a data handler.
Throws:
Exception - if the operation failed.

getHumanReadableMediaTypes

String getHumanReadableMediaTypes()
                                  throws Exception
Method to obtain human readable Media Types.

Returns:
the string media type
Throws:
Exception - if the operation failed.

getMimeTypeFromHuman

String getMimeTypeFromHuman(String mediaType)
                            throws Exception
Method to obtain mime types for the corresponding Media Type.

Returns:
the string mime type.
Throws:
Exception - if the operation failed.


Copyright © 2012 WSO2 Inc. All Rights Reserved.