org.wso2.registry.app
Class RemoteRegistry

java.lang.Object
  extended by org.wso2.registry.app.RemoteRegistry
All Implemented Interfaces:
CoreRegistry, Registry, RegistryConstants

public class RemoteRegistry
extends java.lang.Object
implements Registry, RegistryConstants


Field Summary
 
Fields inherited from interface org.wso2.registry.RegistryConstants
ACTION, ACTIVE_STATE, ADMIN_PASSWORD, ADMIN_ROLE, ADMIN_USER, ANONYMOUS_PASSWORD, ANONYMOUS_USER, ATT_NAME, ATT_PATH, AXIS2_CONF_COLLECTION_MEDIA_TYPE, AXIS2_CONF_COLLECTION_NAME, AXIS2_MODULES_COLLECTION_MEDIA_TYPE, AXIS2_MODULES_COLLECTION_NAME, AXIS2_SERVICES_COLLECTION_MEDIA_TYPE, AXIS2_SERVICES_COLLECTION_NAME, COMMENT_MEDIA_TYPE, COMMENTS_RESULT_TYPE, DEFAULT_MEDIA_TYPE, DELETED_STATE, DIRECTORY_ELEMENT, ERROR_JSP, ERROR_MESSAGE, EVERYONE_ROLE, FILE_ELEMENT, GUESTS_ROLE, INMEM_REGISTRY_TYPE, JDBC_REGISTRY_TYPE, NAMESPACE, PARAMETER_AVERAGE_RATINGS, PARAMETER_COMMENTS, PARAMETER_LOGS, PARAMETER_QUERY, PARAMETER_RATINGS, PARAMETER_RENAME, PARAMETER_RESOURCE_EXIST, PARAMETER_RESTORE, PARAMETER_TAG_PATHS, PARAMETER_TAGS, PARAMETER_TAGS_REMOVED, PARAMETER_VERSION, PATH, PATH_ATTR, PATH_SEPARATOR, QNAME_AVGRATING, QUERIES_COLLECTION_NAME, RATING_MEDIA_TYPE, RATINGS_RESULT_TYPE, REGISTRY, REGISTRY_CONFIG_PATH, REGISTRY_CONTEXT, REGISTRY_INSTANCE, REGISTRY_REALM, REGISTRY_TYPE_PARAMTER, REMOTE_REGISTRY_TYPE, RESOURCE_DETAILS_JSP, RESOURCES_JSP, RESOURCES_PATH, RESOURCES_RESULT_TYPE, RESULT_TYPE_PROPERTY_NAME, ROOT_PATH, SESSION_PROPERTY, SQL_QUERY_MEDIA_TYPE, STATUS_MESSAGE_NAME, SYNAPSE_CONF_COLLECTION_MEDIA_TYPE, SYNAPSE_CONF_COLLECTION_NAME, SYNAPSE_ENDPOINT_COLLECTION_MEDIA_TYPE, SYNAPSE_ENDPOINT_COLLECTION_NAME, SYNAPSE_ENTRIES_COLLECTION_MEDIA_TYPE, SYNAPSE_ENTRIES_COLLECTION_NAME, SYNAPSE_PROXY_SERVICES_COLLECTION_MEDIA_TYPE, SYNAPSE_PROXY_SERVICES_COLLECTION_NAME, SYNAPSE_SEQUENCE_COLLECTION_MEDIA_TYPE, SYNAPSE_SEQUENCES_COLLECTION_NAME, SYNAPSE_TASKS_COLLECTION_MEDIA_TYPE, SYNAPSE_TASKS_COLLECTION_NAME, SYNPASE_REPOSITORY_MEDIA_TYPE, SYSTEM_PASSWORD, SYSTEM_REGISTRY, SYSTEM_USER, TAG_MEDIA_TYPE, TAG_PROPERTY, TAG_REGISTRY, TAG_UPLOAD, TAGS_RESULT_TYPE, URL_SEPARATOR, USER_REGISTRY, USERS_COLLECTION_NAME, WSDL_MEDIA_TYPE, XSD_MEDIA_TYPE
 
Constructor Summary
RemoteRegistry(java.net.URL registryURL)
          To create a remote registry need to provide a URL of a remote registry and the URL should be something like http://localhost:8080/wso2registry/atom/r1
RemoteRegistry(java.net.URL registryURL, java.lang.String userName, java.lang.String password)
          To create a remote registry to connect to a secure registry or a registry where we need to pass userName and the password to perform any operation.
 
Method Summary
 java.lang.String addComment(java.lang.String resourcePath, Comment comment)
          Adds a comment to a resource.
static void addPropertyExtensionElement(java.util.Properties properties, org.apache.abdera.Abdera abdera, org.apache.abdera.model.ExtensibleElement entry, javax.xml.namespace.QName node1name, javax.xml.namespace.QName node2Name)
          This will generate extension element and that will add to the entry , the created element will be something like +
 void applyTag(java.lang.String resourcePath, java.lang.String tag)
          Applies the given tag to the resource in the given path.
static void createPropertiesFromExtensionElement(Properties properties, Resource resource)
           
static java.util.Map decodeParametesAsString(java.lang.String value)
           
 void delete(java.lang.String path)
          Deletes the resource in the given path.
 void editComment(java.lang.String commentPath, java.lang.String text)
           
static java.lang.String encodeParametersAsString(java.util.Map parameters)
           
 Resource executeQuery(java.lang.String path, java.util.Map parameters)
          Executes a custom query defined by users.
 Resource get(java.lang.String path)
          Returns the resource in the given path.
 float getAverageRating(java.lang.String resourcePath)
          Returns the average rating for the given resource.
 Comment[] getComments(java.lang.String resourcePath)
          Retruns all comments for the given resource.
 LogEntry[] getLogs(java.lang.String resourcePath, int action, java.lang.String userName, java.util.Date from, java.util.Date to, boolean recentFirst)
          Returns the logs of the activities occured in the registy.
 int getRating(java.lang.String path, java.lang.String userName)
          Returns the rating given to the specified resource by the given user
 TaggedResourcePath[] getResourcePathsWithTag(java.lang.String tag)
          Returns the paths of the resources, which are tagged using the given tag.
 Tag[] getTags(java.lang.String resourcePath)
          Returns all tags used for tagging the given resource.
 java.lang.String[] getVersions(java.lang.String path)
          Returns the paths of the versions of the resource located at the given path.
 java.lang.String importResource(java.lang.String suggestedPath, java.lang.String sourceURL, Resource metadata)
          Creates a resource in the suggested path (which may be altered) by fetching the resource content from the given URL.
 java.lang.String put(java.lang.String suggestedPath, Resource resource)
          Adds or updates resources in the registry.
 void rateResource(java.lang.String resourcePath, int rating)
          Rates the given resource.
 void removeTag(java.lang.String path, java.lang.String tag)
          Removes a tag on a resource.
 java.lang.String rename(java.lang.String currentPath, java.lang.String newPath)
          Move or rename a resources in the registry.
 boolean resourceExists(java.lang.String path)
          Check whether a resource exist in the given path
 void restoreVersion(java.lang.String versionPath)
          Reverts a resource to a given version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteRegistry

public RemoteRegistry(java.net.URL registryURL)
To create a remote registry need to provide a URL of a remote registry and the URL should be something like http://localhost:8080/wso2registry/atom/r1

Parameters:
registryURL - : URL to the registry or to the resource

RemoteRegistry

public RemoteRegistry(java.net.URL registryURL,
                      java.lang.String userName,
                      java.lang.String password)
To create a remote registry to connect to a secure registry or a registry where we need to pass userName and the password to perform any operation. Passing not null value registry will send the username and the password for each request. Need to remember here is that the username and the password send as plain text.

Parameters:
registryURL - : URL to the registry or to the resource
userName - : user name of the registry , value can be null , if the value is null then the user will be the anonymous.
password - : password , value can be null
Method Detail

get

public Resource get(java.lang.String path)
             throws RegistryException
Description copied from interface: CoreRegistry
Returns the resource in the given path.

Specified by:
get in interface CoreRegistry
Parameters:
path - Path of the resource. e.g. /project1/server/deployment.xml
Returns:
Resource instance
Throws:
RegistryException - is thrown if the resource is not in the registry

resourceExists

public boolean resourceExists(java.lang.String path)
                       throws RegistryException
Description copied from interface: CoreRegistry
Check whether a resource exist in the given path

Specified by:
resourceExists in interface CoreRegistry
Parameters:
path - Path of the resource to be checked
Returns:
true if a resource exist in the given path, false otherwise.
Throws:
RegistryException - if an error occurs

put

public java.lang.String put(java.lang.String suggestedPath,
                            Resource resource)
                     throws RegistryException
Description copied from interface: CoreRegistry
Adds or updates resources in the registry. If there is no resource in the given path, resource is added. If a resource already exist in the given path, it will be replaced with the new resource.

Specified by:
put in interface CoreRegistry
Parameters:
suggestedPath - the path which we'd like to use for the new resource.
resource - Resource instance for the new resource
Returns:
the actual path that the server chose to use for our Resource
Throws:
RegistryException

createPropertiesFromExtensionElement

public static void createPropertiesFromExtensionElement(Properties properties,
                                                        Resource resource)

addPropertyExtensionElement

public static void addPropertyExtensionElement(java.util.Properties properties,
                                               org.apache.abdera.Abdera abdera,
                                               org.apache.abdera.model.ExtensibleElement entry,
                                               javax.xml.namespace.QName node1name,
                                               javax.xml.namespace.QName node2Name)
This will generate extension element and that will add to the entry , the created element will be something like +

Parameters:
properties - : List of Name value pairs
abdera - : Abdera instance
entry - : Instanc of entery where extension element need to add
node1name - : Name of node 1
node2Name - : Name of node 2

importResource

public java.lang.String importResource(java.lang.String suggestedPath,
                                       java.lang.String sourceURL,
                                       Resource metadata)
                                throws RegistryException
Description copied from interface: Registry
Creates a resource in the suggested path (which may be altered) by fetching the resource content from the given URL.

Specified by:
importResource in interface Registry
Parameters:
suggestedPath - Path to add the new resource. Although this path is specified by the caller of the method, resource may not be actually added to this path.
sourceURL - URL to fetch the resource content
Returns:
Actual path to which the resource is added
Throws:
RegistryException

delete

public void delete(java.lang.String path)
            throws RegistryException
Description copied from interface: CoreRegistry
Deletes the resource in the given path. If the path refers to a directory, all child resources of the directory will also be deleted.

Specified by:
delete in interface CoreRegistry
Specified by:
delete in interface Registry
Parameters:
path - Path of the resource to be deleted.
Throws:
RegistryException - is thrown depending on the implementation.

rename

public java.lang.String rename(java.lang.String currentPath,
                               java.lang.String newPath)
                        throws RegistryException
Description copied from interface: Registry
Move or rename a resources in the registry. Rename can be considered as - First delete the resource - Then add the resource to the new location

Specified by:
rename in interface Registry
Parameters:
currentPath - : Current path of the resource
newPath - where to move the reosurce
Returns:
generated path for the resource
Throws:
RegistryException - : If something went wrong

getVersions

public java.lang.String[] getVersions(java.lang.String path)
                               throws RegistryException
Description copied from interface: Registry
Returns the paths of the versions of the resource located at the given path. Version paths are returned in the form /projects/myresource?v=12

Specified by:
getVersions in interface Registry
Parameters:
path - Path of a current version of a resource
Returns:
Paths of versions
Throws:
RegistryException - if there is an error

restoreVersion

public void restoreVersion(java.lang.String versionPath)
                    throws RegistryException
Description copied from interface: Registry
Reverts a resource to a given version.

Specified by:
restoreVersion in interface Registry
Parameters:
versionPath - path of the version to be reverted. It is not necessary to provide the path of the resource as it can be derived from the version path.
Throws:
RegistryException - if there is an error

applyTag

public void applyTag(java.lang.String resourcePath,
                     java.lang.String tag)
              throws RegistryException
Description copied from interface: Registry
Applies the given tag to the resource in the given path. If the given tag is not defined in the registry, it will be defined.

Specified by:
applyTag in interface Registry
Parameters:
resourcePath - Path of the resource to be tagged.
tag - Tag. Any string can be used for the tag.
Throws:
RegistryException - is thrown if a resource does not exist in the given path.

getResourcePathsWithTag

public TaggedResourcePath[] getResourcePathsWithTag(java.lang.String tag)
                                             throws RegistryException
Description copied from interface: Registry
Returns the paths of the resources, which are tagged using the given tag.

Specified by:
getResourcePathsWithTag in interface Registry
Parameters:
tag - Tag
Returns:
Resource paths
Throws:
RegistryException - if an error occurs

getTags

public Tag[] getTags(java.lang.String resourcePath)
              throws RegistryException
Description copied from interface: Registry
Returns all tags used for tagging the given resource.

Specified by:
getTags in interface Registry
Parameters:
resourcePath - Path of the resource
Returns:
Tags tag names
Throws:
RegistryException - is thrown if a resource does not exist in the given path.

removeTag

public void removeTag(java.lang.String path,
                      java.lang.String tag)
               throws RegistryException
Description copied from interface: Registry
Removes a tag on a resource. If the resource at the path is owned by the current user, all taggings done using the given tag will be removed. If the resource is not owned by the current user, only the tagging done by the current user will be removed.

Specified by:
removeTag in interface Registry
Parameters:
path - Resource path tagged with the given tag.
tag - Name of the tag to be removed.
Throws:
RegistryException - if there's a problem

addComment

public java.lang.String addComment(java.lang.String resourcePath,
                                   Comment comment)
                            throws RegistryException
Description copied from interface: Registry
Adds a comment to a resource.

Specified by:
addComment in interface Registry
Parameters:
resourcePath - Path of the resource to add the comment.
comment - Comment instance for the new comment.
Returns:
the path of the new comment.
Throws:
RegistryException - is thrown if a resource does not exist in the given path.

editComment

public void editComment(java.lang.String commentPath,
                        java.lang.String text)
                 throws RegistryException
Specified by:
editComment in interface Registry
Throws:
RegistryException

getComments

public Comment[] getComments(java.lang.String resourcePath)
                      throws RegistryException
Description copied from interface: Registry
Retruns all comments for the given resource.

Specified by:
getComments in interface Registry
Parameters:
resourcePath - Path of the resource.
Returns:
Array of Comment objects.
Throws:
RegistryException - if an error occurs

rateResource

public void rateResource(java.lang.String resourcePath,
                         int rating)
                  throws RegistryException
Description copied from interface: Registry
Rates the given resource.

Specified by:
rateResource in interface Registry
Parameters:
resourcePath - Path of the resource.
rating - rating value between 1 and 5.
Throws:
RegistryException - is thrown if a resource does not exist in the given path.

getAverageRating

public float getAverageRating(java.lang.String resourcePath)
                       throws RegistryException
Description copied from interface: Registry
Returns the average rating for the given resource. This is the average of all ratings done by all users for the given resource.

Specified by:
getAverageRating in interface Registry
Parameters:
resourcePath - Path of the resource.
Returns:
Average rating between 1 and 5.
Throws:
RegistryException - if an error occurs

getRating

public int getRating(java.lang.String path,
                     java.lang.String userName)
              throws RegistryException
Description copied from interface: Registry
Returns the rating given to the specified resource by the given user

Specified by:
getRating in interface Registry
Parameters:
path - Path of the resource
userName - username of the user
Returns:
rating given by the given user
Throws:
RegistryException - if there is a problem

executeQuery

public Resource executeQuery(java.lang.String path,
                             java.util.Map parameters)
                      throws RegistryException
Description copied from interface: Registry
Executes a custom query defined by users. Returned RowSet contains fields of tables specified by the custom query.

Specified by:
executeQuery in interface Registry
Parameters:
path - Path of the query to execute.
parameters - Query parameters.
Returns:
RowSet containing the fields specified in the query.
Throws:
RegistryException - depends on the implementation.

encodeParametersAsString

public static java.lang.String encodeParametersAsString(java.util.Map parameters)

decodeParametesAsString

public static java.util.Map decodeParametesAsString(java.lang.String value)

getLogs

public LogEntry[] getLogs(java.lang.String resourcePath,
                          int action,
                          java.lang.String userName,
                          java.util.Date from,
                          java.util.Date to,
                          boolean recentFirst)
                   throws RegistryException
Description copied from interface: Registry
Returns the logs of the activities occured in the registy.

Specified by:
getLogs in interface Registry
Parameters:
resourcePath - If given, only the logs related to the resource path will be returned. If null, logs for all resources will be returned.
action - Only the logs pertaining to this action will be returned.
userName - If given, only the logs for activities done by the given user will be returned. If null, logs for all users will be returned.
from - If given, logs for activities occured after the given date will be returned. If null, there will not be a bound for the starting date.
to - If given, logs for activities occured before the given date will be returned. If null, there will not be a bound for the ending date.
recentFirst - If true, returned activities will be in the descending order. If false, returned activities will be in the ascending order.
Returns:
Array of LogEntry objects representing the logs
Throws:
RegistryException - if there is a problem


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