org.wso2.carbon.registry.core.dao
Interface ResourceDAO

All Known Implementing Classes:
JDBCResourceDAO

public interface ResourceDAO

The data access object for resources.


Method Summary
 void add(String path, ResourceIDImpl parentID, ResourceImpl resourceImpl)
          Add the resource to a pat when resource instance and the parent resource id is given.
 void addContent(ResourceImpl resourceImpl)
          Add the content for a resource.
 int addContentBytes(InputStream contentStream)
          Add the content to the content table and return the auto generated id of content table.
 void addProperties(ResourceImpl resource)
          Add the properties to the database from given resource
 void addResourceDO(ResourceDO resourceDO)
          Add the resource data object.
 void addResourceWithNoUpdate(ResourceImpl resourceImpl)
          Add a resource without setting the resource modified flag on.
 void addResourceWithoutContentId(ResourceImpl resourceImpl, boolean isUpdatingExisting)
          Add a resource without a content id, provided whether it is overwriting existing one or not.
 void addRoot(ResourceImpl resourceImpl)
          Add the root collection.
 void createAndApplyResourceID(String path, ResourceIDImpl parentID, ResourceImpl resourceImpl)
          The method to create a resource id and assign to resource instance
 ResourceIDImpl createResourceID(String path, ResourceIDImpl parentID, boolean isCollection)
          Create a resource ID for a path given the parent resource id and whether it is a collection or not.
 void deleteContentStream(int contentID)
          delete the content for a given content id.
 void deleteResource(ResourceDO resourceDO)
          Delete the resource provided as a resource DO
 void fillChildren(CollectionImpl collection, DataAccessManager dataAccessManager)
          Fill the children for a resource that already filled with meta data.
 void fillChildren(CollectionImpl collection, int start, int pageLen)
          Fill the children for a resource that already filled with meta data.
 void fillResource(CollectionImpl collection, int start, int pageLen)
          Fill the children and the properties for a resource that already filled with meta data.
 void fillResource(ResourceImpl resourceImpl)
          Fill the content (for non-collection) and the properties for a resource that already filled meta data
 void fillResourceContent(ResourceImpl resourceImpl)
          Fill resource content for a given resource implementation.
 void fillResourceContentWithNoUpdate(ResourceImpl resourceImpl)
          Fill resource content for a given resource implementation without setting the resource modified flag on.
 void fillResourceProperties(ResourceImpl resourceImpl)
          Fill the properties for a resource, this will change the properties modified flag.
 void fillResourcePropertiesWithNoUpdate(ResourceImpl resourceImpl)
          Fill the properties for a resource without making the properties modified flag.
 ResourceImpl get(ResourceIDImpl resourceID)
          Returns the resource in the given path filled with meta-data and access to the content.
 CollectionImpl get(ResourceIDImpl resourceID, int start, int pageLen)
          Return a collection with children only at the range of the intersect of the given range and resource existence range provided the resource id.
 ResourceImpl get(String path)
          Returns the resource in the given path filled with meta-data and access to the content.
 CollectionImpl get(String path, int start, int pageLen)
          Return a collection with children only at the range of the intersect of the given range and resource existence range provided the resource path.
 int getChildCount(CollectionImpl collection, DataAccessManager dataAccessManager)
          Method to return a child count of a collection (database connection should also be provided)
 List<ResourceIDImpl> getChildPathIds(ResourceIDImpl resourceID)
          Get the child path ids of a resource, (should be a collection)
 String[] getChildren(CollectionImpl collection, int start, int pageLen)
          Get the children of the collection.
 String[] getChildren(CollectionImpl collection, int start, int pageLen, DataAccessManager dataAccessManager)
          Get the children of the collection.
 InputStream getContentStream(int contentID)
          Get the content input stream for a given content id.
 String getPath(int pathId, String resourceName, boolean checkExistence)
          Get the path given the path id, resource name and provided whether the resourceExistence should be checked.
 String getPath(long version)
          Get the path provided the resource version.
 String getPathFromId(int pathId)
          Get the path from the path id.
 ResourceDO getResourceDO(long version)
          Method to return resourceDO from a version number.
 ResourceDO getResourceDO(ResourceIDImpl resourceID)
          Method to get resource from resource id.
 ResourceIDImpl getResourceID(String path)
          Returns the resource ID (RID) of the resource referred by the given path.
 ResourceIDImpl getResourceID(String path, boolean isCollection)
          Returns the resource ID (RID) of the resource referred by the given path.
 ResourceImpl getResourceMetaData(ResourceIDImpl resourceID)
          Method to return the resource meta data (excluding properties, content and children)
 ResourceImpl getResourceMetaData(String path)
          Method to return the resource meta data (excluding properties, content and children)
 ResourceImpl getResourceWithNoUpdate(ResourceIDImpl resourceID)
          Method to get resource without setting the resource modified flags on.
 long getVersion(ResourceIDImpl resourceID)
          Method to return the version of a resource from resourceID
 void moveProperties(ResourceIDImpl source, ResourceIDImpl target)
          Move the properties.
 void movePropertyPaths(ResourceIDImpl source, ResourceIDImpl target)
          this function will move the paths from one path id to another regardless of the resource name
 void moveResourcePaths(ResourceIDImpl source, ResourceIDImpl target)
          This method will move the paths from one path id to another regardless of the resource name
 void moveResources(ResourceIDImpl source, ResourceIDImpl target)
          Move resource provided the source and target resource ids.
 void removeProperties(ResourceDO resourceDO)
          Remove properties of a resource.
 boolean resourceExists(ResourceIDImpl resourceID)
          Method to check the whether a resource in the provided resource id exist or not.
 boolean resourceExists(String path)
          Method to check the resource existence for a given path.
 boolean resourceExists(String path, boolean isCollection)
          Method to check the resource existence for a given path provided the resource is collection or not.
 void update(ResourceImpl resourceImpl)
          Save the updates of a given resource.
 void updateCollectionLastUpdatedTime(ResourceIDImpl resourceID)
          Update the last updated time of a resource, This is called to update the parent's last updated time when a child is created, deleted or moved out/in, copy in.
 void updateContentId(ResourceImpl resourceImpl)
          Update the content id of a resource, Normally this should be called after calling addResourceWithoutContentId is called.
 

Method Detail

getResourceID

ResourceIDImpl getResourceID(String path)
                             throws RegistryException
Returns the resource ID (RID) of the resource referred by the given path. NOTE: This doesn't guarantee that the path exist in the resource. It only guarantee if it is a collection: the path exist in the path table. if it is a resource: the parent path exist in the path table. In order to make sure the existence of the resource please use the resourceExists function Note that if the same path is used for a collection and resource, this returns the resourceID of the collection.

Parameters:
path - Pure path of the resource
Returns:
Resource id of resource exists in path cache. null if the resource does not exists.
Throws:
RegistryException - throws the retrieval of resource id failed

getResourceID

ResourceIDImpl getResourceID(String path,
                             boolean isCollection)
                             throws RegistryException
Returns the resource ID (RID) of the resource referred by the given path. We use this overloaded function when we know our resource is a collection or non-collection NOTE: This doesn't guarantee that the path exist in the resource. It only guarantee if it is a collection: the path exist in the path table. if it is a resource: the parent path exist in the path table. In order to make sure the existence of the resource please use the resourceExists function

Parameters:
path - Pure path of the resource
isCollection - true if it is a collection
Returns:
Resource id of resource exists. null if the resource does not exists.
Throws:
RegistryException - throws the retrieval of resource id failed

resourceExists

boolean resourceExists(ResourceIDImpl resourceID)
                       throws RegistryException
Method to check the whether a resource in the provided resource id exist or not.

Parameters:
resourceID - the resource id which is checked for existence of a resource.
Returns:
true if the resource exists, false otherwise.
Throws:
RegistryException - throws if checking existence failed.

resourceExists

boolean resourceExists(String path)
                       throws RegistryException
Method to check the resource existence for a given path.

Parameters:
path - the path to check the resource existence
Returns:
true, if the resource exists, false otherwise
Throws:
RegistryException - throws if checking existence failed.

resourceExists

boolean resourceExists(String path,
                       boolean isCollection)
                       throws RegistryException
Method to check the resource existence for a given path provided the resource is collection or not.

Parameters:
path - the path to check the resource existence.
isCollection - provide whether the resource in the path is collection or not.
Returns:
true, if the resource exists, false otherwise.
Throws:
RegistryException - throws if checking existence failed.

getVersion

long getVersion(ResourceIDImpl resourceID)
                throws RegistryException
Method to return the version of a resource from resourceID

Parameters:
resourceID - the id of the resource to get the version of.
Returns:
the version of the resource for the given resource id.
Throws:
RegistryException - throws if the version retrieval failed.

get

ResourceImpl get(String path)
                 throws RegistryException
Returns the resource in the given path filled with meta-data and access to the content. If a resource does not exist in the given path, null is returned.

Parameters:
path - Path of the resource.
Returns:
ResourceImpl filled with resource meta-data and access to the resource content.
Throws:
RegistryException - throws if the resource retrieval failed.

get

ResourceImpl get(ResourceIDImpl resourceID)
                 throws RegistryException
Returns the resource in the given path filled with meta-data and access to the content. If a resource does not exist in the given resourceID, null is returned.

Parameters:
resourceID - the resource id
Returns:
resource object.
Throws:
RegistryException - throws if resource retrieval failed.

get

CollectionImpl get(String path,
                   int start,
                   int pageLen)
                   throws RegistryException
Return a collection with children only at the range of the intersect of the given range and resource existence range provided the resource path. Use for resource browser pagination.

Parameters:
path - path of the collection
start - start value of the range of children.
pageLen - the length of the children to retrieve
Returns:
an instance of collection with child
Throws:
RegistryException - throws if resource retrieval failed.

get

CollectionImpl get(ResourceIDImpl resourceID,
                   int start,
                   int pageLen)
                   throws RegistryException
Return a collection with children only at the range of the intersect of the given range and resource existence range provided the resource id. Use for resource browser pagination.

Parameters:
resourceID - resourceID of the collection
start - start value of the range of children.
pageLen - the length of the children to retrieve
Returns:
an instance of collection with child
Throws:
RegistryException - throws if resource retrieval failed.

fillResource

void fillResource(ResourceImpl resourceImpl)
                  throws RegistryException
Fill the content (for non-collection) and the properties for a resource that already filled meta data

Parameters:
resourceImpl - the resource instance to be filled with contents (if non-collection) and fill properties.
Throws:
RegistryException - throws if resource filling failed.

fillResource

void fillResource(CollectionImpl collection,
                  int start,
                  int pageLen)
                  throws RegistryException
Fill the children and the properties for a resource that already filled with meta data. Children are filled only at the at of the intersect of the given range and resource existence range.

Parameters:
collection - collection to fill the children and properties.
start - start value of the range of children.
pageLen - the length of the children to retrieve
Throws:
RegistryException - throws if resource filling failed.

fillResourcePropertiesWithNoUpdate

void fillResourcePropertiesWithNoUpdate(ResourceImpl resourceImpl)
                                        throws RegistryException
Fill the properties for a resource without making the properties modified flag.

Parameters:
resourceImpl - the resource object.
Throws:
RegistryException - throws if the operation failed.

fillResourceProperties

void fillResourceProperties(ResourceImpl resourceImpl)
                            throws RegistryException
Fill the properties for a resource, this will change the properties modified flag.

Parameters:
resourceImpl - the resource object.
Throws:
RegistryException - throws if the operation failed.

addRoot

void addRoot(ResourceImpl resourceImpl)
             throws RegistryException
Add the root collection. Only called at the very first time resource loading process.

Parameters:
resourceImpl - the resource instance
Throws:
RegistryException - throws if the operation failed

add

void add(String path,
         ResourceIDImpl parentID,
         ResourceImpl resourceImpl)
         throws RegistryException
Add the resource to a pat when resource instance and the parent resource id is given.

Parameters:
path - path of the resource
parentID - parent resourceID
resourceImpl - the instance of the resource to be added.
Throws:
RegistryException - throws if the operation failed

createAndApplyResourceID

void createAndApplyResourceID(String path,
                              ResourceIDImpl parentID,
                              ResourceImpl resourceImpl)
                              throws RegistryException
The method to create a resource id and assign to resource instance

Parameters:
path - path of the resource
parentID - parent path id
resourceImpl - the resource instance to be assigned the resource id.
Throws:
RegistryException - throws if operation failed.

createResourceID

ResourceIDImpl createResourceID(String path,
                                ResourceIDImpl parentID,
                                boolean isCollection)
                                throws RegistryException
Create a resource ID for a path given the parent resource id and whether it is a collection or not.

Parameters:
path - the path of the resource
parentID - parent resource id
isCollection - whether the resource is a collection or not
Returns:
the newly created resource id.
Throws:
RegistryException - throws if operation failed.

deleteContentStream

void deleteContentStream(int contentID)
                         throws RegistryException
delete the content for a given content id.

Parameters:
contentID - content id.
Throws:
RegistryException - throws if the operation failed.

getContentStream

InputStream getContentStream(int contentID)
                             throws RegistryException
Get the content input stream for a given content id.

Parameters:
contentID - the content id as an argument.
Returns:
the content input stream.
Throws:
RegistryException - throws if the operation failed.

update

void update(ResourceImpl resourceImpl)
            throws RegistryException
Save the updates of a given resource.

Parameters:
resourceImpl - the resource to be updated.
Throws:
RegistryException - throws if the operation failed.

getChildCount

int getChildCount(CollectionImpl collection,
                  DataAccessManager dataAccessManager)
                  throws RegistryException
Method to return a child count of a collection (database connection should also be provided)

Parameters:
collection - the collection object which the children are calculated.
dataAccessManager - the data access manager to access the database.
Returns:
the child count.
Throws:
RegistryException - throws if the operation failed.

fillChildren

void fillChildren(CollectionImpl collection,
                  int start,
                  int pageLen)
                  throws RegistryException
Fill the children for a resource that already filled with meta data. Children are filled only at the at of the intersect of the given range and resource existence range.

Parameters:
collection - collection to fill the children and properties.
start - start value of the range of children.
pageLen - the length of the children to retrieve
Throws:
RegistryException - if the operation failed.

fillChildren

void fillChildren(CollectionImpl collection,
                  DataAccessManager dataAccessManager)
                  throws RegistryException
Fill the children for a resource that already filled with meta data. Children are filled only at the at of the intersect of the given range and resource existence range.

Parameters:
collection - collection to fill the children and properties.
dataAccessManager - the data access manager to access the database
Throws:
RegistryException - if the operation failed.

getChildren

String[] getChildren(CollectionImpl collection,
                     int start,
                     int pageLen,
                     DataAccessManager dataAccessManager)
                     throws RegistryException
Get the children of the collection. Children are filled only at the at of the intersect of the given range and resource existence range.

Parameters:
collection - collection to fill the children and properties.
start - start value of the range of children.
pageLen - the length of the children to retrieve
dataAccessManager - the data access manager to access the database
Returns:
an array of children paths
Throws:
RegistryException - throws if the operation failed.

getChildren

String[] getChildren(CollectionImpl collection,
                     int start,
                     int pageLen)
                     throws RegistryException
Get the children of the collection. Children are filled only at the at of the intersect of the given range and resource existence range.

Parameters:
collection - collection to fill the children and properties.
start - start value of the range of children.
pageLen - the length of the children to retrieve
Returns:
an array of children paths
Throws:
RegistryException - throws if the operation failed.

getResourceMetaData

ResourceImpl getResourceMetaData(String path)
                                 throws RegistryException
Method to return the resource meta data (excluding properties, content and children)

Parameters:
path - the of the resource
Returns:
resource instance with the meta data filled.
Throws:
RegistryException - throws if the operation failed.

getResourceMetaData

ResourceImpl getResourceMetaData(ResourceIDImpl resourceID)
                                 throws RegistryException
Method to return the resource meta data (excluding properties, content and children)

Parameters:
resourceID - the resource id
Returns:
resource instance with the meta data filled.
Throws:
RegistryException - throws if the operation failed.

getResourceWithNoUpdate

ResourceImpl getResourceWithNoUpdate(ResourceIDImpl resourceID)
                                     throws RegistryException
Method to get resource without setting the resource modified flags on.

Parameters:
resourceID - the resource id.
Returns:
the resource for the given id.
Throws:
RegistryException - throws if the operation failed.

fillResourceContent

void fillResourceContent(ResourceImpl resourceImpl)
                         throws RegistryException
Fill resource content for a given resource implementation.

Parameters:
resourceImpl - resource object.
Throws:
RegistryException - throws if the operation failed.

fillResourceContentWithNoUpdate

void fillResourceContentWithNoUpdate(ResourceImpl resourceImpl)
                                     throws RegistryException
Fill resource content for a given resource implementation without setting the resource modified flag on.

Parameters:
resourceImpl - resource object.
Throws:
RegistryException - throws if the operation failed.

updateCollectionLastUpdatedTime

void updateCollectionLastUpdatedTime(ResourceIDImpl resourceID)
                                     throws RegistryException
Update the last updated time of a resource, This is called to update the parent's last updated time when a child is created, deleted or moved out/in, copy in.

Parameters:
resourceID - the id of the resource to get the version of.
Throws:
RegistryException - throws if the operation failed.

updateContentId

void updateContentId(ResourceImpl resourceImpl)
                     throws RegistryException
Update the content id of a resource, Normally this should be called after calling addResourceWithoutContentId is called.

Parameters:
resourceImpl - the resource object.
Throws:
RegistryException - throws if the operation failed.

addResourceWithoutContentId

void addResourceWithoutContentId(ResourceImpl resourceImpl,
                                 boolean isUpdatingExisting)
                                 throws RegistryException
Add a resource without a content id, provided whether it is overwriting existing one or not. If the resource is already existing the removal of the older resource will not be handled in this function.

Parameters:
resourceImpl - the resource object.
isUpdatingExisting - whether the resource is updating or not.
Throws:
RegistryException - throws if the operation failed.

addResourceWithNoUpdate

void addResourceWithNoUpdate(ResourceImpl resourceImpl)
                             throws RegistryException
Add a resource without setting the resource modified flag on.

Parameters:
resourceImpl - the resource to be added.
Throws:
RegistryException - throws if the operation failed.

addResourceDO

void addResourceDO(ResourceDO resourceDO)
                   throws RegistryException
Add the resource data object.

Parameters:
resourceDO - the resource data object.
Throws:
RegistryException - throws if the operation failed.

deleteResource

void deleteResource(ResourceDO resourceDO)
                    throws RegistryException
Delete the resource provided as a resource DO

Parameters:
resourceDO - the resource to be deleted.
Throws:
RegistryException - throws if the operation failed.

addProperties

void addProperties(ResourceImpl resource)
                   throws RegistryException
Add the properties to the database from given resource

Parameters:
resource - to add properties for
Throws:
RegistryException - throws if the operation failed.

removeProperties

void removeProperties(ResourceDO resourceDO)
                      throws RegistryException
Remove properties of a resource.

Parameters:
resourceDO - the resource DO which the properties have to be deleted.
Throws:
RegistryException - throws if the operation failed.

addContent

void addContent(ResourceImpl resourceImpl)
                throws RegistryException
Add the content for a resource.

Parameters:
resourceImpl - the resource to add content.
Throws:
RegistryException - throws if the operation failed.

addContentBytes

int addContentBytes(InputStream contentStream)
                    throws RegistryException
Add the content to the content table and return the auto generated id of content table.

Parameters:
contentStream - the input stream.
Returns:
the auto generated id of content table.
Throws:
RegistryException - throws if the operation failed.

getResourceDO

ResourceDO getResourceDO(long version)
                         throws RegistryException
Method to return resourceDO from a version number.

Parameters:
version - the version of the resource.
Returns:
the resourceDO for the given version.
Throws:
RegistryException - throws if the operation failed.

getResourceDO

ResourceDO getResourceDO(ResourceIDImpl resourceID)
                         throws RegistryException
Method to get resource from resource id.

Parameters:
resourceID - the resource id.
Returns:
the resource DO for the resource id.
Throws:
RegistryException - throws if the operation failed.

getChildPathIds

List<ResourceIDImpl> getChildPathIds(ResourceIDImpl resourceID)
                                     throws RegistryException
Get the child path ids of a resource, (should be a collection)

Parameters:
resourceID - the resource id of the collection.
Returns:
an array of child path ids.
Throws:
RegistryException - throws if the operation failed.

getPathFromId

String getPathFromId(int pathId)
                     throws RegistryException
Get the path from the path id.

Parameters:
pathId - the path id.
Returns:
the path corresponding to the path id.
Throws:
RegistryException - throws if operation failed.

getPath

String getPath(long version)
               throws RegistryException
Get the path provided the resource version.

Parameters:
version - the version of the resource.
Returns:
the path of the resource.
Throws:
RegistryException - throws if the operation failed.

getPath

String getPath(int pathId,
               String resourceName,
               boolean checkExistence)
               throws RegistryException
Get the path given the path id, resource name and provided whether the resourceExistence should be checked.

Parameters:
pathId - the path id
resourceName - the resource name
checkExistence - boolean to indicate whether the resource existence should be checked.
Returns:
the path
Throws:
RegistryException - if the operation failed.

moveResources

void moveResources(ResourceIDImpl source,
                   ResourceIDImpl target)
                   throws RegistryException
Move resource provided the source and target resource ids.

Parameters:
source - the resource Id of the source.
target - the resource id of the target.
Throws:
RegistryException - throws if the operation failed.

moveResourcePaths

void moveResourcePaths(ResourceIDImpl source,
                       ResourceIDImpl target)
                       throws RegistryException
This method will move the paths from one path id to another regardless of the resource name

Parameters:
source - the path id of the source resource.
target - the path id of the target resource.
Throws:
RegistryException - throws if the operation failed.

moveProperties

void moveProperties(ResourceIDImpl source,
                    ResourceIDImpl target)
                    throws RegistryException
Move the properties.

Parameters:
source - the resource id of the source resource.
target - the resource id of the target resource.
Throws:
RegistryException - throws if the operation failed.

movePropertyPaths

void movePropertyPaths(ResourceIDImpl source,
                       ResourceIDImpl target)
                       throws RegistryException
this function will move the paths from one path id to another regardless of the resource name

Parameters:
source - the resource id of the source resource.
target - the resource id of the target resource.
Throws:
RegistryException - throws if the operation failed.


Copyright © 2012 WSO2 Inc. All Rights Reserved.