public class JDBCResourceDAO extends Object implements ResourceDAO
ResourceDAO to store resources on a JDBC-based database.| Constructor and Description |
|---|
JDBCResourceDAO() |
| Modifier and Type | Method and Description |
|---|---|
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 |
fillChildren(CollectionImpl collection,
int start,
int pageLen,
Connection conn)
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,
Connection conn)
Method to return a child count of a collection (database connection should also be provided)
|
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,
Connection conn)
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.
|
public ResourceIDImpl getResourceID(String path) throws RegistryException
ResourceDAOgetResourceID in interface ResourceDAOpath - Pure path of the resourceRegistryException - throws the retrieval of resource id failedpublic ResourceIDImpl getResourceID(String path, boolean isCollection) throws RegistryException
ResourceDAOgetResourceID in interface ResourceDAOpath - Pure path of the resourceisCollection - true if it is a collectionRegistryException - throws the retrieval of resource id failedpublic boolean resourceExists(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOresourceExists in interface ResourceDAOresourceID - the resource id which is checked for existence of a resource.RegistryException - throws if checking existence failed.public boolean resourceExists(String path) throws RegistryException
ResourceDAOresourceExists in interface ResourceDAOpath - the path to check the resource existenceRegistryException - throws if checking existence failed.public boolean resourceExists(String path, boolean isCollection) throws RegistryException
ResourceDAOresourceExists in interface ResourceDAOpath - the path to check the resource existence.isCollection - provide whether the resource in the path is collection or not.RegistryException - throws if checking existence failed.public long getVersion(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOgetVersion in interface ResourceDAOresourceID - the id of the resource to get the version of.RegistryException - throws if the version retrieval failed.public ResourceImpl get(String path) throws RegistryException
ResourceDAOget in interface ResourceDAOpath - Path of the resource.RegistryException - throws if the resource retrieval failed.public ResourceImpl get(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOget in interface ResourceDAOresourceID - the resource idRegistryException - throws if resource retrieval failed.public CollectionImpl get(String path, int start, int pageLen) throws RegistryException
ResourceDAOget in interface ResourceDAOpath - path of the collectionstart - start value of the range of children.pageLen - the length of the children to retrieveRegistryException - throws if resource retrieval failed.public CollectionImpl get(ResourceIDImpl resourceID, int start, int pageLen) throws RegistryException
ResourceDAOget in interface ResourceDAOresourceID - resourceID of the collectionstart - start value of the range of children.pageLen - the length of the children to retrieveRegistryException - throws if resource retrieval failed.public void fillResource(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOfillResource in interface ResourceDAOresourceImpl - the resource instance to be filled with contents (if non-collection) and
fill properties.RegistryException - throws if resource filling failed.public void fillResource(CollectionImpl collection, int start, int pageLen) throws RegistryException
ResourceDAOfillResource in interface ResourceDAOcollection - collection to fill the children and properties.start - start value of the range of children.pageLen - the length of the children to retrieveRegistryException - throws if resource filling failed.public void fillResourcePropertiesWithNoUpdate(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOfillResourcePropertiesWithNoUpdate in interface ResourceDAOresourceImpl - the resource object.RegistryException - throws if the operation failed.public void fillResourceProperties(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOfillResourceProperties in interface ResourceDAOresourceImpl - the resource object.RegistryException - throws if the operation failed.public void addRoot(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOaddRoot in interface ResourceDAOresourceImpl - the resource instanceRegistryException - throws if the operation failedpublic void add(String path, ResourceIDImpl parentID, ResourceImpl resourceImpl) throws RegistryException
ResourceDAOadd in interface ResourceDAOpath - path of the resourceparentID - parent resourceIDresourceImpl - the instance of the resource to be added.RegistryException - throws if the operation failedpublic void createAndApplyResourceID(String path, ResourceIDImpl parentID, ResourceImpl resourceImpl) throws RegistryException
ResourceDAOcreateAndApplyResourceID in interface ResourceDAOpath - path of the resourceparentID - parent path idresourceImpl - the resource instance to be assigned the resource id.RegistryException - throws if operation failed.public ResourceIDImpl createResourceID(String path, ResourceIDImpl parentID, boolean isCollection) throws RegistryException
ResourceDAOcreateResourceID in interface ResourceDAOpath - the path of the resourceparentID - parent resource idisCollection - whether the resource is a collection or notRegistryException - throws if operation failed.public void deleteContentStream(int contentID)
throws RegistryException
ResourceDAOdeleteContentStream in interface ResourceDAOcontentID - content id.RegistryException - throws if the operation failed.public InputStream getContentStream(int contentID) throws RegistryException
ResourceDAOgetContentStream in interface ResourceDAOcontentID - the content id as an argument.RegistryException - throws if the operation failed.public void update(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOupdate in interface ResourceDAOresourceImpl - the resource to be updated.RegistryException - throws if the operation failed.public int getChildCount(CollectionImpl collection, DataAccessManager dataAccessManager) throws RegistryException
ResourceDAOgetChildCount in interface ResourceDAOcollection - the collection object which the children are calculated.dataAccessManager - the data access manager to access the database.RegistryException - throws if the operation failed.public int getChildCount(CollectionImpl collection, Connection conn) throws RegistryException
collection - the collection object which the children are calculated.conn - the database connection.RegistryException - throws if the operation failed.public void fillChildren(CollectionImpl collection, int start, int pageLen) throws RegistryException
ResourceDAOfillChildren in interface ResourceDAOcollection - collection to fill the children and properties.start - start value of the range of children.pageLen - the length of the children to retrieveRegistryException - if the operation failed.public void fillChildren(CollectionImpl collection, DataAccessManager dataAccessManager) throws RegistryException
ResourceDAOfillChildren in interface ResourceDAOcollection - collection to fill the children and properties.dataAccessManager - the data access manager to access the databaseRegistryException - if the operation failed.public void fillChildren(CollectionImpl collection, int start, int pageLen, Connection conn) throws RegistryException
collection - collection to fill the children and properties.start - start value of the range of children.pageLen - the length of the children to retrieveconn - the database connectionRegistryException - if the operation failed.public String[] getChildren(CollectionImpl collection, int start, int pageLen, DataAccessManager dataAccessManager) throws RegistryException
ResourceDAOgetChildren in interface ResourceDAOcollection - collection to fill the children and properties.start - start value of the range of children.pageLen - the length of the children to retrievedataAccessManager - the data access manager to access the databaseRegistryException - throws if the operation failed.public String[] getChildren(CollectionImpl collection, int start, int pageLen, Connection conn) throws RegistryException
collection - collection to fill the children and properties.start - start value of the range of children.pageLen - the length of the children to retrieveconn - the database connectionRegistryException - throws if the operation failed.public String[] getChildren(CollectionImpl collection, int start, int pageLen) throws RegistryException
ResourceDAOgetChildren in interface ResourceDAOcollection - collection to fill the children and properties.start - start value of the range of children.pageLen - the length of the children to retrieveRegistryException - throws if the operation failed.public ResourceImpl getResourceMetaData(String path) throws RegistryException
ResourceDAOgetResourceMetaData in interface ResourceDAOpath - the of the resourceRegistryException - throws if the operation failed.public ResourceImpl getResourceMetaData(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOgetResourceMetaData in interface ResourceDAOresourceID - the resource idRegistryException - throws if the operation failed.public ResourceImpl getResourceWithNoUpdate(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOgetResourceWithNoUpdate in interface ResourceDAOresourceID - the resource id.RegistryException - throws if the operation failed.public void fillResourceContent(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOfillResourceContent in interface ResourceDAOresourceImpl - resource object.RegistryException - throws if the operation failed.public void fillResourceContentWithNoUpdate(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOfillResourceContentWithNoUpdate in interface ResourceDAOresourceImpl - resource object.RegistryException - throws if the operation failed.public void updateCollectionLastUpdatedTime(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOupdateCollectionLastUpdatedTime in interface ResourceDAOresourceID - the id of the resource to get the version of.RegistryException - throws if the operation failed.public void updateContentId(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOupdateContentId in interface ResourceDAOresourceImpl - the resource object.RegistryException - throws if the operation failed.public void addResourceWithoutContentId(ResourceImpl resourceImpl, boolean isUpdatingExisting) throws RegistryException
ResourceDAOaddResourceWithoutContentId in interface ResourceDAOresourceImpl - the resource object.isUpdatingExisting - whether the resource is updating or not.RegistryException - throws if the operation failed.public void addResourceWithNoUpdate(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOaddResourceWithNoUpdate in interface ResourceDAOresourceImpl - the resource to be added.RegistryException - throws if the operation failed.public void addResourceDO(ResourceDO resourceDO) throws RegistryException
ResourceDAOaddResourceDO in interface ResourceDAOresourceDO - the resource data object.RegistryException - throws if the operation failed.public void deleteResource(ResourceDO resourceDO) throws RegistryException
ResourceDAOdeleteResource in interface ResourceDAOresourceDO - the resource to be deleted.RegistryException - throws if the operation failed.public void addProperties(ResourceImpl resource) throws RegistryException
ResourceDAOaddProperties in interface ResourceDAOresource - to add properties forRegistryException - throws if the operation failed.public void removeProperties(ResourceDO resourceDO) throws RegistryException
ResourceDAOremoveProperties in interface ResourceDAOresourceDO - the resource DO which the properties have to be deleted.RegistryException - throws if the operation failed.public void addContent(ResourceImpl resourceImpl) throws RegistryException
ResourceDAOaddContent in interface ResourceDAOresourceImpl - the resource to add content.RegistryException - throws if the operation failed.public int addContentBytes(InputStream contentStream) throws RegistryException
ResourceDAOaddContentBytes in interface ResourceDAOcontentStream - the input stream.RegistryException - throws if the operation failed.public ResourceDO getResourceDO(long version) throws RegistryException
ResourceDAOgetResourceDO in interface ResourceDAOversion - the version of the resource.RegistryException - throws if the operation failed.public ResourceDO getResourceDO(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOgetResourceDO in interface ResourceDAOresourceID - the resource id.RegistryException - throws if the operation failed.public List<ResourceIDImpl> getChildPathIds(ResourceIDImpl resourceID) throws RegistryException
ResourceDAOgetChildPathIds in interface ResourceDAOresourceID - the resource id of the collection.RegistryException - throws if the operation failed.public String getPathFromId(int pathId) throws RegistryException
ResourceDAOgetPathFromId in interface ResourceDAOpathId - the path id.RegistryException - throws if operation failed.public String getPath(long version) throws RegistryException
ResourceDAOgetPath in interface ResourceDAOversion - the version of the resource.RegistryException - throws if the operation failed.public String getPath(int pathId, String resourceName, boolean checkExistence) throws RegistryException
ResourceDAOgetPath in interface ResourceDAOpathId - the path idresourceName - the resource namecheckExistence - boolean to indicate whether the resource existence should be checked.RegistryException - if the operation failed.public void moveResources(ResourceIDImpl source, ResourceIDImpl target) throws RegistryException
ResourceDAOmoveResources in interface ResourceDAOsource - the resource Id of the source.target - the resource id of the target.RegistryException - throws if the operation failed.public void moveResourcePaths(ResourceIDImpl source, ResourceIDImpl target) throws RegistryException
ResourceDAOmoveResourcePaths in interface ResourceDAOsource - the path id of the source resource.target - the path id of the target resource.RegistryException - throws if the operation failed.public void moveProperties(ResourceIDImpl source, ResourceIDImpl target) throws RegistryException
ResourceDAOmoveProperties in interface ResourceDAOsource - the resource id of the source resource.target - the resource id of the target resource.RegistryException - throws if the operation failed.public void movePropertyPaths(ResourceIDImpl source, ResourceIDImpl target) throws RegistryException
ResourceDAOmovePropertyPaths in interface ResourceDAOsource - the resource id of the source resource.target - the resource id of the target resource.RegistryException - throws if the operation failed.Copyright © 2016 WSO2 Inc. All Rights Reserved.