org.wso2.registry.jdbc.dao
Class VersionedResourceDAO

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

public class VersionedResourceDAO
extends java.lang.Object


Constructor Summary
VersionedResourceDAO()
           
 
Method Summary
 void add(Resource resource, java.sql.Connection conn)
          Adds the given resource to the database.
 void addProperties(long resourceID, java.util.Properties props, java.sql.Connection conn)
           
 long addResourceVersion(Resource resource, java.sql.Connection connection)
           
static byte[] convertToBytes(java.lang.Object object)
           
 void deleteResource(Resource resource, java.sql.Connection connection)
          To delete a resource , what actually happen here is that update the version table with the new data and resource will not actually removed from the table
 Resource get(java.lang.String path, long versionNumber, java.sql.Connection conn)
          Returns the given version of the artifact.
 java.lang.String[] getChildPaths(long artifcatID, long versionNumber, java.sql.Connection connection)
           
 java.util.List getChildren(long resourceID, long versionNumber, java.sql.Connection connection)
           
 java.lang.String[] getLatestChildPaths(long resourceID, long versionNumber, java.sql.Connection connection)
           
 Resource getLatestVersion(java.lang.String path, java.sql.Connection conn)
          Returns the latest (current) version of an artifact.
 long getLatestVersionNumber(long resourceId, java.sql.Connection connection)
           
 java.lang.String getParentPath(long resourceID, long versionNumber, java.sql.Connection connection)
           
 Resource getResourceByID(long artifactID, long versionNumber, java.sql.Connection conn)
           
 long getResourceID(java.lang.String path, java.sql.Connection conn)
           
 java.lang.String getResourcePath(long id, java.sql.Connection conn)
           
 java.lang.String[] getVersionNumbers(long resourceId, java.sql.Connection connection)
           
 boolean isResourceActive(java.lang.String resourcePath, java.sql.Connection connection)
          This method is use to see whether a give resource is active or not , one can delete a resource and try to access that giving the path of the resource in that case we should not return the resource if it is deleted.
 void markActivated(long id, java.sql.Connection conn)
           
 void markDeleted(java.lang.String path, java.sql.Connection conn)
           
 void removeProperties(long resourceID, java.sql.Connection conn)
           
 void renameResource(java.lang.String oldPath, java.lang.String newPath, java.sql.Connection conn, java.lang.String userId, org.wso2.usermanager.Realm realm)
          This method will move a resource from oldpath to newpath , the internal implementation is such that frit the release will be deleted from oldPath parent and will be added to the newptah so if the oldpath is "foo/bar/r1" then the r1 will be removed from foo/bar.
 boolean resourceActive(java.lang.String path, java.sql.Connection conn)
           
 boolean resourceExist(java.lang.String path, java.sql.Connection conn)
           
 void restore(long resourceId, long toVersion, java.sql.Connection connection)
           
 void update(java.lang.String path, Resource resource, java.sql.Connection conn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VersionedResourceDAO

public VersionedResourceDAO()
Method Detail

get

public Resource get(java.lang.String path,
                    long versionNumber,
                    java.sql.Connection conn)
             throws java.sql.SQLException
Returns the given version of the artifact. If artifact is a collection all child paths will be added as versioned paths in the form /a/b?v=12

Parameters:
path - : path of the artifact
versionNumber - : Version number
conn - : Connection to DB
Returns:
Resource for the given version number
Throws:
java.sql.SQLException - : If something went wrong

getResourceByID

public Resource getResourceByID(long artifactID,
                                long versionNumber,
                                java.sql.Connection conn)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

getLatestVersion

public Resource getLatestVersion(java.lang.String path,
                                 java.sql.Connection conn)
                          throws RegistryException,
                                 java.sql.SQLException
Returns the latest (current) version of an artifact. If artifact is a collection, all child paths will be added as latest paths in the form /a/b

Parameters:
path - : path of the artifact
conn - :Connection to DB
Returns:
: Result artifact
Throws:
java.sql.SQLException - : if something went wrong
RegistryException

getChildPaths

public java.lang.String[] getChildPaths(long artifcatID,
                                        long versionNumber,
                                        java.sql.Connection connection)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

getParentPath

public java.lang.String getParentPath(long resourceID,
                                      long versionNumber,
                                      java.sql.Connection connection)
                               throws java.sql.SQLException
Throws:
java.sql.SQLException

getLatestChildPaths

public java.lang.String[] getLatestChildPaths(long resourceID,
                                              long versionNumber,
                                              java.sql.Connection connection)
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getChildren

public java.util.List getChildren(long resourceID,
                                  long versionNumber,
                                  java.sql.Connection connection)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

add

public void add(Resource resource,
                java.sql.Connection conn)
         throws java.sql.SQLException
Adds the given resource to the database.

Parameters:
resource - New resource
conn - : Connection to Db
Throws:
java.sql.SQLException - : if something went wrong

update

public void update(java.lang.String path,
                   Resource resource,
                   java.sql.Connection conn)
            throws java.sql.SQLException
Throws:
java.sql.SQLException

markDeleted

public void markDeleted(java.lang.String path,
                        java.sql.Connection conn)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException

markActivated

public void markActivated(long id,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

addProperties

public void addProperties(long resourceID,
                          java.util.Properties props,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

removeProperties

public void removeProperties(long resourceID,
                             java.sql.Connection conn)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

resourceExist

public boolean resourceExist(java.lang.String path,
                             java.sql.Connection conn)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

resourceActive

public boolean resourceActive(java.lang.String path,
                              java.sql.Connection conn)
                       throws java.sql.SQLException
Throws:
java.sql.SQLException

getResourceID

public long getResourceID(java.lang.String path,
                          java.sql.Connection conn)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getResourcePath

public java.lang.String getResourcePath(long id,
                                        java.sql.Connection conn)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

renameResource

public void renameResource(java.lang.String oldPath,
                           java.lang.String newPath,
                           java.sql.Connection conn,
                           java.lang.String userId,
                           org.wso2.usermanager.Realm realm)
                    throws java.sql.SQLException,
                           RegistryException
This method will move a resource from oldpath to newpath , the internal implementation is such that frit the release will be deleted from oldPath parent and will be added to the newptah so if the oldpath is "foo/bar/r1" then the r1 will be removed from foo/bar. However later we can restore and get everything working fine

Parameters:
oldPath - : Current path of the resource
newPath - : Where to move the resource
conn - : Connection to DB
userId - : current user
realm - : Realm
Throws:
RegistryException - : If something went wrong
java.sql.SQLException

addResourceVersion

public long addResourceVersion(Resource resource,
                               java.sql.Connection connection)
                        throws java.sql.SQLException,
                               RegistryException
Throws:
java.sql.SQLException
RegistryException

convertToBytes

public static byte[] convertToBytes(java.lang.Object object)

getLatestVersionNumber

public long getLatestVersionNumber(long resourceId,
                                   java.sql.Connection connection)
                            throws java.sql.SQLException
Throws:
java.sql.SQLException

getVersionNumbers

public java.lang.String[] getVersionNumbers(long resourceId,
                                            java.sql.Connection connection)
                                     throws java.sql.SQLException
Throws:
java.sql.SQLException

restore

public void restore(long resourceId,
                    long toVersion,
                    java.sql.Connection connection)
             throws java.sql.SQLException,
                    RegistryException
Throws:
java.sql.SQLException
RegistryException

deleteResource

public void deleteResource(Resource resource,
                           java.sql.Connection connection)
                    throws java.sql.SQLException,
                           RegistryException
To delete a resource , what actually happen here is that update the version table with the new data and resource will not actually removed from the table

Parameters:
resource - : Resource to be deleted
connection - : Connection to the DB
Throws:
java.sql.SQLException - : if something went wrong
RegistryException

isResourceActive

public boolean isResourceActive(java.lang.String resourcePath,
                                java.sql.Connection connection)
This method is use to see whether a give resource is active or not , one can delete a resource and try to access that giving the path of the resource in that case we should not return the resource if it is deleted.

Parameters:
resourcePath - : Path of the resource
connection - : Connection to DB
Returns:
: return true if the resource is active , else false


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