Registry Host Object
1.0 Introduction
From
a Mashup, you might want to store/retrieve content from the Registry.
This Registry hostobject allows you to execute core registry operations
such GET, PUT, DELETE etc. on Mashup Server's registry instance. You
can create a Resource/Collection object, add properties, metadata and
store it in the registry. When you use Registry Hostobject along with
other hostobjects of Mashup Server, you can create enterprice level
mashups easily.
All registry operations are executed relative to the registry path /_system/governance.
1.1 Example
function registryPut() {
var registry = new Registry();
var resource = registry.newResource();
resource.content = <products><product name="Mashup Server"/><product name="Gadget Server"/></products>;
resource.addProperty("url", "http://wso2.com");
resource.addProperty("company", "WSO2 Inc.");
registry.put("products/middleware/wso2.xml", resource);
}
2.0 Registry Object
2.1 Registry Interface
{
function boolean resourceExists(String path);
function (Resource|Collection) get(String path, [Number start, Number pageSize]);
function void remove(String path);
function String put(String suggestedPath, Resource|Collection resource);
function Resource newResource();
function Collection newCollection();
}
2.2 API Documentation
| Member | Description |
function boolean |
This method returns true or false depending on the existance
of either a Resource or a Collection in the specified path. var registry = new Registry(); boolean existance = registry.resourceExists("middleware/wso2/products"); Above code returns true if a resource exists in the path
/_system/governance/middleware/wso2/products. |
function (Resource|Collection) |
This method returns the resource in the specified path. If
the resource in the path is a collection, then a Collection object is
returned. Else, it returns a Resource object. If it is a collection,
then you can specfify optional start and pageSize parameters to filter
your results. |
function void |
This method removes the resource in the specified path from the Registry. |
function String |
This method adds either a Resource or a Collection into the specified path in the registry. |
function Resource newResource(); |
Whe you insert a new Resource into the registry, then you
should use this method to create the initial Resource object. |
function Collection newCollection(); |
Whe you insert a new Resource into the registry, then you should use this method to create the initial Resource object. |
3.0 Resource Object
3.1 Resource Interface
{
function String addProperty(String key, String value);
function String getProperty(String key);
function Array getPropertyValues(String key);
function Array getProperties();
function void editPropertyValue(String key, String oldValue, String newValue);
function void removeProperty(String key);
function void removePropertyValue(String key, String value);
function void setProperty(String key, String|Array value);
readonly property String author;
readonly property String lastUpdatedUser;
readonly property String createdTime;
readonly property String lastUpdatedTime;
readonly property String id;
readonly property String parentPath;
readonly property String path;
readonly property String permanantPath;
readonly property String state;
property String mediaType;
property String|Array|XML content;
property String description;
}
3.2 API Documentation
| Member | Description |
function String
|
Add a property value for the provided key. If there are values associated with the key, this will append value. If not this will create a new property value for the key. |
function String
|
Get the property value for the given key, if there are multiple value for that key, it will return the first value. |
function Array
|
Returns the list of values for the given property name. |
function Array getProperties(); |
This method returns an object with all the properties of the Resource in the following format.
[
|
function void
|
Replace the oldValue of a property specifed by the key, with the newValue. As many values can be associated with a particular key in a property, it needs to pass the oldValue too. |
function void
|
Removes the property specified by the key from a Resource. |
function void
|
Remove the specified value from a property with the specified key. |
function void
|
Set properties either as a single value or an array of values. |
readonly property String author; |
Get the user name of the resource author. |
readonly property String lastUpdatedUser; |
Property to get the last updated user name |
readonly property String createdTime; |
Property to get the created time. |
readonly property String lastUpdatedTime; |
Property to get the last modified date. |
readonly property String id; |
The Resource ID, In the default implementation this returns the path. |
readonly property String parentPath; |
Get the parent path. |
readonly property String path; |
Property to get the path, the unique identifier of the resources in the present state. |
readonly property String permanantPath; |
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. |
readonly property String state; |
Get the state. |
property String mediaType; |
Get/set media type. |
property String|Array|XML content; |
Method to get the content of the resource. If the resource is a collection, this will return an array of string that represents the paths of its children, otherwise it returns a string or XML depending on the content type. |
property String description; |
Property to get/set the description. |
3.0 Collection Object
3.1 Collection Interface extends Resource
{
function Array getChildren([Number start, Number pageLen]);
readonly property Number childCount;
}
3.2 API Documentation
| Member | Description |
function Array getChildren([Number start, Number pageLen]); |
Method to return the absolute paths of the children of the collection. Using start and pageLen values, you can get children of a selected range. |
readonly property Number childCount; |
Property to get the the number of children. |