Here my try is to introduce the Remote API and its abilities.
How to create an instance of the RemoteRegistry
Before we start use the Remote API we have to create an instance of the registry to use it. It can be done like below.
System.setProperty("javax.net.ssl.trustStore", "CARBON_HOME/resources/security/client-truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");
System.setProperty("javax.net.ssl.trustStoreType","JKS");
RemoteRegistry remote_registry = new RemoteRegistry(new URL("https://localhost:9443/registry"),username,password);
reading aresource from /foo/c1.
Resource resource = registry.get("/foo/c1");
Adding a collection
Add a collection /c1/c2.
Collection collection = registry.newCollection();
registry.put("/c1/c2", collection);
Adding a resource
Add a resource r1 to the collection /c1/c2.
Resource r1 = registry.newResource();
String str = "My File Content";
r1.setContent(str.getBytes());
registry.put("/c1/c2/r1", r1);
Checking the existence of a resource
Check whether r1 is in the collection /c1c2.
boolean value = registry.resourceExists("/c1/c2/r1");
Delete resource
Delete the resource r1 from the collection /c1/c2.
registry.delete("/c1/c2/r1");
Rename a resource
Rename resource r1 to r2 in the collection /c1/c2.
registry.rename("/c1/c2/r1", "/c1/c2/r2");
Creating versions of resources/collections
Create a version for resource or collection.
registry.createVersion("/c1/c2");
Retrieving different versions of a Given Resource
Retrieve the versions of the collection /c1/c2.
String [] versions = registry.getVersions("/c1/c2");
Restoring to an old version
Restoring the old version.
registry.restoreVersion ("/c1/c2;version:2");
Adding a Tag
Add a tag to the resource /c1/c2/r2.
registry.applyTag("/c1/c2/r2" , "rename resource");
Retrieving all tags of a given resource
Retrieve
the tags apply to the resource /c1/c2/r2.
Tag[] tags = registry.getTags("/c1/c2/r2");
Deleting a tag
Delete a tag apply to the resource /c1/c2/r2.
registry.removeTag("/c1/c2/r2","rename resource");
Commenting a resource
Make a comment on a resource /c1/c2/r2.
Comment c1 = new Comment();
c1.setText("This is my comment");
String commentpath = registry.addComment("/c1/c2/r2", c1), c1);
Edit a comment
Edit a comment which applied to a resource.
registry.editComment(commentpath,"This is cool");
Rating a resource
Rate a resource.
registry.rateResource("c1/c2/r2 " , 4);
Importing the local file system to the registry
Import a file to the registry via remote client.
File file = new File("Path of the file");
RemoteRegistry remote_registry = new RemoteRegistry(new URL("http://localhost:9443/registry"), "admin", "admin");
RegistryClientUtils.importToRegistry(file ,"/myfile/filesystem" ,remote_registry);
Exporting the registry to a file system
Export the content of a resource in the registry to a file in the Remote Client machine.
File toFile = new File("Path of the new file");
RemoteRegistry remote_registry = new RemoteRegistry(new URL("http://localhost:9443/registry"), "admin", "admin");
RegistryClientUtils.exportFromRegistry( toFile, "/myfile/filesystem" ,remote_registry);