org.wso2.registry.jdbc.dao
Class ResourceDAO

java.lang.Object
  extended by org.wso2.registry.jdbc.dao.ResourceDAO

public class ResourceDAO
extends java.lang.Object


Field Summary
static int COLLECTION
           
static int NULL
           
static int RESOURCE
           
 
Constructor Summary
ResourceDAO()
           
 
Method Summary
 void add(java.lang.String path, java.lang.String parentID, ResourceImpl resourceImpl)
           
 java.lang.String addContent(java.io.InputStream contentStream)
           
 void addRoot(java.lang.String path, ResourceImpl resourceImpl)
           
 void attachChild(java.lang.String parentID, java.lang.String childID)
           
 void delete(java.lang.String resourceID)
           
 void deleteSubtree(java.lang.String resourceID)
           
 void detachChild(java.lang.String childID)
           
 void fillChildren(CollectionImpl collection, int start, int pageLen)
           
 void fillResourceProperties(ResourceImpl resourceImpl)
           
 ResourceImpl get(java.lang.String path)
          Returns the resource in the given path filled with metadata and access to the content.
 CollectionImpl get(java.lang.String path, int start, int pageLen)
           
 int getChildCount(java.lang.String resourceID, java.sql.Connection conn)
           
 java.util.List<java.lang.String> getChildIDs(java.lang.String resourceID)
           
 java.util.List<java.lang.String> getChildPaths(java.lang.String resourceID, java.sql.Connection conn)
           
 java.util.List<java.lang.String> getChildPaths(java.lang.String resourceID, int start, int pageLen, java.sql.Connection conn)
           
 int getEquivalentVersion(java.lang.String resourceID)
           
 long getEquivalenVersion(java.lang.String resourceID)
           
 java.lang.String getResourceAuthor(java.lang.String path)
          Return the author (the user who creates the resource) if a resource exists at given path.
 ResourceImpl getResourceByID(java.lang.String resourceID)
           
 java.io.InputStream getResourceContentStream(java.lang.String contentID, java.sql.Connection conn)
          Returns a input stream to fetch content of the resource.
 ResourceDO getResourceDO(java.lang.String resourceID)
           
static java.lang.String getResourceID(java.lang.String path)
          Returns the resource ID (RID) of the resource refered by the given path.
 java.lang.String getResourceID(java.lang.String path, java.sql.Connection conn)
          Returns the resource ID (RID) of the resource refered by the given path.
 java.lang.String getResourcePath(java.lang.String resourceID)
           
 int getResourceType(java.lang.String path)
          Returns the type of the resource refered by the given path.
 void invalidateCurrentSnapshot(java.lang.String resourcePath)
           
 void markDirty(java.lang.String resourceID)
           
 void markDirtyByPath(java.lang.String resourcePath)
           
 boolean resourceExists(java.lang.String path)
           
 boolean resourceExistsWithID(java.lang.String resourceID)
           
 void setPath(java.lang.String resourceID, java.lang.String newPath)
           
 void setSnapshotID(java.lang.String resourceID, long snapshotID)
           
 void update(java.lang.String resourceID, ResourceImpl resourceImpl)
           
 void updateContent(java.lang.String contentID, java.io.InputStream contentStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static final int NULL
See Also:
Constant Field Values

RESOURCE

public static final int RESOURCE
See Also:
Constant Field Values

COLLECTION

public static final int COLLECTION
See Also:
Constant Field Values
Constructor Detail

ResourceDAO

public ResourceDAO()
Method Detail

getResourceID

public static java.lang.String getResourceID(java.lang.String path)
                                      throws RegistryException
Returns the resource ID (RID) of the resource refered by the given path. If a resource does not exists in the given path, it returns null.

Parameters:
path - Pure path of the resource
Returns:
RID of resource exists. null if the resource does not exists.
Throws:
RegistryException - something went wrong

getResourceID

public java.lang.String getResourceID(java.lang.String path,
                                      java.sql.Connection conn)
                               throws java.sql.SQLException
Returns the resource ID (RID) of the resource refered by the given path. If a resource does not exists in the given path, it returns null. This method is used when the registry does participate in an ongoing transaction.

Parameters:
path - Pure path of the resource
conn - Database connection for accessing the RESOURCE table
Returns:
RID of resource exists. null if the resource does not exists.
Throws:
java.sql.SQLException - something went wrong

getResourcePath

public java.lang.String getResourcePath(java.lang.String resourceID)
                                 throws RegistryException
Throws:
RegistryException

getResourceType

public int getResourceType(java.lang.String path)
                    throws RegistryException
Returns the type of the resource refered by the given path.

Parameters:
path - Pure path of a resource
Returns:
ResourceDAO.RESOURCE: path referes to a resource ResourceDAO.COLLECTION: path referes to a collection ResourceDAO.NULL: resource does not exist
Throws:
RegistryException - something went wrong

resourceExists

public boolean resourceExists(java.lang.String path)
                       throws RegistryException
Throws:
RegistryException

resourceExistsWithID

public boolean resourceExistsWithID(java.lang.String resourceID)
                             throws RegistryException
Throws:
RegistryException

attachChild

public void attachChild(java.lang.String parentID,
                        java.lang.String childID)
                 throws RegistryException
Throws:
RegistryException

detachChild

public void detachChild(java.lang.String childID)
                 throws RegistryException
Throws:
RegistryException

get

public ResourceImpl get(java.lang.String path)
                 throws RegistryException
Returns the resource in the given path filled with metadata 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 metadata and access to the resource content.
Throws:
RegistryException - something went wrong

get

public CollectionImpl get(java.lang.String path,
                          int start,
                          int pageLen)
                   throws RegistryException
Throws:
RegistryException

fillResourceProperties

public void fillResourceProperties(ResourceImpl resourceImpl)
                            throws RegistryException
Throws:
RegistryException

addRoot

public void addRoot(java.lang.String path,
                    ResourceImpl resourceImpl)
             throws RegistryException
Throws:
RegistryException

add

public void add(java.lang.String path,
                java.lang.String parentID,
                ResourceImpl resourceImpl)
         throws RegistryException
Throws:
RegistryException

update

public void update(java.lang.String resourceID,
                   ResourceImpl resourceImpl)
            throws RegistryException
Throws:
RegistryException

getEquivalentVersion

public int getEquivalentVersion(java.lang.String resourceID)
                         throws RegistryException
Throws:
RegistryException

markDirty

public void markDirty(java.lang.String resourceID)
               throws RegistryException
Throws:
RegistryException

delete

public void delete(java.lang.String resourceID)
            throws RegistryException
Throws:
RegistryException

deleteSubtree

public void deleteSubtree(java.lang.String resourceID)
                   throws RegistryException
Throws:
RegistryException

getChildIDs

public java.util.List<java.lang.String> getChildIDs(java.lang.String resourceID)
                                             throws RegistryException
Throws:
RegistryException

getChildCount

public int getChildCount(java.lang.String resourceID,
                         java.sql.Connection conn)
                  throws RegistryException
Throws:
RegistryException

getChildPaths

public java.util.List<java.lang.String> getChildPaths(java.lang.String resourceID,
                                                      java.sql.Connection conn)
                                               throws RegistryException
Throws:
RegistryException

getChildPaths

public java.util.List<java.lang.String> getChildPaths(java.lang.String resourceID,
                                                      int start,
                                                      int pageLen,
                                                      java.sql.Connection conn)
                                               throws RegistryException
Throws:
RegistryException

getResourceAuthor

public java.lang.String getResourceAuthor(java.lang.String path)
                                   throws RegistryException
Return the author (the user who creates the resource) if a resource exists at given path. If a resource does not exist, null is returned.

Parameters:
path - Path of the resource.
Returns:
Author if the resourc exists. Null otherwiese.
Throws:
RegistryException - On any database related exception.

fillChildren

public void fillChildren(CollectionImpl collection,
                         int start,
                         int pageLen)
                  throws RegistryException
Throws:
RegistryException

getResourceByID

public ResourceImpl getResourceByID(java.lang.String resourceID)
                             throws RegistryException
Throws:
RegistryException

getResourceContentStream

public java.io.InputStream getResourceContentStream(java.lang.String contentID,
                                                    java.sql.Connection conn)
                                             throws RegistryException
Returns a input stream to fetch content of the resource. Input stream is disconnected from the database, so that it is possible to close the connection before reading the content stream. This method is used to read content from within the resource implementation. Note that this method does not get the connection from the current transaction. Therefore, it is possible to use this method outside a transaction. Usually getting a content from a resource is done after getting the resource. Thus it does not belong to the transactions involving the Registry API.

Parameters:
contentID - UUID of the content
conn - Database connection to the Registry database.
Returns:
InputStream of the resource content
Throws:
RegistryException - on any exception

updateContent

public void updateContent(java.lang.String contentID,
                          java.io.InputStream contentStream)
                   throws RegistryException
Throws:
RegistryException

setPath

public void setPath(java.lang.String resourceID,
                    java.lang.String newPath)
             throws RegistryException
Throws:
RegistryException

getEquivalenVersion

public long getEquivalenVersion(java.lang.String resourceID)
                         throws RegistryException
Throws:
RegistryException

getResourceDO

public ResourceDO getResourceDO(java.lang.String resourceID)
                         throws RegistryException
Throws:
RegistryException

addContent

public java.lang.String addContent(java.io.InputStream contentStream)
                            throws RegistryException
Throws:
RegistryException

setSnapshotID

public void setSnapshotID(java.lang.String resourceID,
                          long snapshotID)
                   throws RegistryException
Throws:
RegistryException

markDirtyByPath

public void markDirtyByPath(java.lang.String resourcePath)
                     throws RegistryException
Throws:
RegistryException

invalidateCurrentSnapshot

public void invalidateCurrentSnapshot(java.lang.String resourcePath)
                               throws RegistryException
Throws:
RegistryException


Copyright © 2007 Apache Web Services Project. All Rights Reserved.