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
ResourceDAO
getResourceID
in interface ResourceDAO
path
- Pure path of the resourceRegistryException
- throws the retrieval of resource id failedpublic ResourceIDImpl getResourceID(String path, boolean isCollection) throws RegistryException
ResourceDAO
getResourceID
in interface ResourceDAO
path
- Pure path of the resourceisCollection
- true if it is a collectionRegistryException
- throws the retrieval of resource id failedpublic boolean resourceExists(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
resourceExists
in interface ResourceDAO
resourceID
- the resource id which is checked for existence of a resource.RegistryException
- throws if checking existence failed.public boolean resourceExists(String path) throws RegistryException
ResourceDAO
resourceExists
in interface ResourceDAO
path
- the path to check the resource existenceRegistryException
- throws if checking existence failed.public boolean resourceExists(String path, boolean isCollection) throws RegistryException
ResourceDAO
resourceExists
in interface ResourceDAO
path
- 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
ResourceDAO
getVersion
in interface ResourceDAO
resourceID
- the id of the resource to get the version of.RegistryException
- throws if the version retrieval failed.public ResourceImpl get(String path) throws RegistryException
ResourceDAO
get
in interface ResourceDAO
path
- Path of the resource.RegistryException
- throws if the resource retrieval failed.public ResourceImpl get(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
get
in interface ResourceDAO
resourceID
- the resource idRegistryException
- throws if resource retrieval failed.public CollectionImpl get(String path, int start, int pageLen) throws RegistryException
ResourceDAO
get
in interface ResourceDAO
path
- 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
ResourceDAO
get
in interface ResourceDAO
resourceID
- 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
ResourceDAO
fillResource
in interface ResourceDAO
resourceImpl
- 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
ResourceDAO
fillResource
in interface ResourceDAO
collection
- 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
ResourceDAO
fillResourcePropertiesWithNoUpdate
in interface ResourceDAO
resourceImpl
- the resource object.RegistryException
- throws if the operation failed.public void fillResourceProperties(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
fillResourceProperties
in interface ResourceDAO
resourceImpl
- the resource object.RegistryException
- throws if the operation failed.public void addRoot(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
addRoot
in interface ResourceDAO
resourceImpl
- the resource instanceRegistryException
- throws if the operation failedpublic void add(String path, ResourceIDImpl parentID, ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
add
in interface ResourceDAO
path
- 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
ResourceDAO
createAndApplyResourceID
in interface ResourceDAO
path
- 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
ResourceDAO
createResourceID
in interface ResourceDAO
path
- 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
ResourceDAO
deleteContentStream
in interface ResourceDAO
contentID
- content id.RegistryException
- throws if the operation failed.public InputStream getContentStream(int contentID) throws RegistryException
ResourceDAO
getContentStream
in interface ResourceDAO
contentID
- the content id as an argument.RegistryException
- throws if the operation failed.public void update(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
update
in interface ResourceDAO
resourceImpl
- the resource to be updated.RegistryException
- throws if the operation failed.public int getChildCount(CollectionImpl collection, DataAccessManager dataAccessManager) throws RegistryException
ResourceDAO
getChildCount
in interface ResourceDAO
collection
- 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
ResourceDAO
fillChildren
in interface ResourceDAO
collection
- 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
ResourceDAO
fillChildren
in interface ResourceDAO
collection
- 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
ResourceDAO
getChildren
in interface ResourceDAO
collection
- 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
ResourceDAO
getChildren
in interface ResourceDAO
collection
- 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
ResourceDAO
getResourceMetaData
in interface ResourceDAO
path
- the of the resourceRegistryException
- throws if the operation failed.public ResourceImpl getResourceMetaData(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
getResourceMetaData
in interface ResourceDAO
resourceID
- the resource idRegistryException
- throws if the operation failed.public ResourceImpl getResourceWithNoUpdate(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
getResourceWithNoUpdate
in interface ResourceDAO
resourceID
- the resource id.RegistryException
- throws if the operation failed.public void fillResourceContent(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
fillResourceContent
in interface ResourceDAO
resourceImpl
- resource object.RegistryException
- throws if the operation failed.public void fillResourceContentWithNoUpdate(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
fillResourceContentWithNoUpdate
in interface ResourceDAO
resourceImpl
- resource object.RegistryException
- throws if the operation failed.public void updateCollectionLastUpdatedTime(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
updateCollectionLastUpdatedTime
in interface ResourceDAO
resourceID
- the id of the resource to get the version of.RegistryException
- throws if the operation failed.public void updateContentId(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
updateContentId
in interface ResourceDAO
resourceImpl
- the resource object.RegistryException
- throws if the operation failed.public void addResourceWithoutContentId(ResourceImpl resourceImpl, boolean isUpdatingExisting) throws RegistryException
ResourceDAO
addResourceWithoutContentId
in interface ResourceDAO
resourceImpl
- the resource object.isUpdatingExisting
- whether the resource is updating or not.RegistryException
- throws if the operation failed.public void addResourceWithNoUpdate(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
addResourceWithNoUpdate
in interface ResourceDAO
resourceImpl
- the resource to be added.RegistryException
- throws if the operation failed.public void addResourceDO(ResourceDO resourceDO) throws RegistryException
ResourceDAO
addResourceDO
in interface ResourceDAO
resourceDO
- the resource data object.RegistryException
- throws if the operation failed.public void deleteResource(ResourceDO resourceDO) throws RegistryException
ResourceDAO
deleteResource
in interface ResourceDAO
resourceDO
- the resource to be deleted.RegistryException
- throws if the operation failed.public void addProperties(ResourceImpl resource) throws RegistryException
ResourceDAO
addProperties
in interface ResourceDAO
resource
- to add properties forRegistryException
- throws if the operation failed.public void removeProperties(ResourceDO resourceDO) throws RegistryException
ResourceDAO
removeProperties
in interface ResourceDAO
resourceDO
- the resource DO which the properties have to be deleted.RegistryException
- throws if the operation failed.public void addContent(ResourceImpl resourceImpl) throws RegistryException
ResourceDAO
addContent
in interface ResourceDAO
resourceImpl
- the resource to add content.RegistryException
- throws if the operation failed.public int addContentBytes(InputStream contentStream) throws RegistryException
ResourceDAO
addContentBytes
in interface ResourceDAO
contentStream
- the input stream.RegistryException
- throws if the operation failed.public ResourceDO getResourceDO(long version) throws RegistryException
ResourceDAO
getResourceDO
in interface ResourceDAO
version
- the version of the resource.RegistryException
- throws if the operation failed.public ResourceDO getResourceDO(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
getResourceDO
in interface ResourceDAO
resourceID
- the resource id.RegistryException
- throws if the operation failed.public List<ResourceIDImpl> getChildPathIds(ResourceIDImpl resourceID) throws RegistryException
ResourceDAO
getChildPathIds
in interface ResourceDAO
resourceID
- the resource id of the collection.RegistryException
- throws if the operation failed.public String getPathFromId(int pathId) throws RegistryException
ResourceDAO
getPathFromId
in interface ResourceDAO
pathId
- the path id.RegistryException
- throws if operation failed.public String getPath(long version) throws RegistryException
ResourceDAO
getPath
in interface ResourceDAO
version
- the version of the resource.RegistryException
- throws if the operation failed.public String getPath(int pathId, String resourceName, boolean checkExistence) throws RegistryException
ResourceDAO
getPath
in interface ResourceDAO
pathId
- 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
ResourceDAO
moveResources
in interface ResourceDAO
source
- 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
ResourceDAO
moveResourcePaths
in interface ResourceDAO
source
- 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
ResourceDAO
moveProperties
in interface ResourceDAO
source
- 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
ResourceDAO
movePropertyPaths
in interface ResourceDAO
source
- 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.