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(java.lang.String path, 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)
           
 void addResourceVersion(Resource resource, java.sql.Connection connection)
           
 void deleteResource(Resource resource, java.sql.Connection connection)
          To delete a resource , what actualy happen here is that update the version table with the new data and resource will not actualy 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)
           
 long getLatestVerisonNumber(long resourceId, java.sql.Connection connection)
           
 Resource getLatestVersion(java.lang.String path, java.sql.Connection conn)
          Returns the latest (current) version of an artifact.
 java.util.List getLogs(java.lang.String resourcePath, java.lang.String userName, java.util.Date from, java.util.Date to, java.sql.Connection conn)
          To get the log messages for all the artifacts
 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 will check whether a given resource is delete or not , there can be mutiple resource with the same path and thier ID will vary from one to another.
 void markDeleted(java.lang.String path, java.sql.Connection conn)
           
 void removeProperties(long resourceID, 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 restore2(long resourceId, long toVersion, java.sql.Connection connection)
          To restoreVersion or rollback artifcat to a given version number
 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 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 artifacy
conn - :Connection to DB
Returns:
: Result artifcat
Throws:
java.sql.SQLException - : if somthing went wrong

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(java.lang.String path,
                Resource resource,
                java.sql.Connection conn)
         throws java.sql.SQLException
Adds the given resource to the database.

Parameters:
path - Path of the new resource
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

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

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

addResourceVersion

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

getLatestVerisonNumber

public long getLatestVerisonNumber(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
Throws:
java.sql.SQLException

restore2

public void restore2(long resourceId,
                     long toVersion,
                     java.sql.Connection connection)
              throws java.sql.SQLException
To restoreVersion or rollback artifcat to a given version number

Parameters:
resourceId - : Resource ID
connection - : Connection to DB
toVersion - : to which version we need to restoreVersion
Throws:
java.sql.SQLException - : If something went wrong

deleteResource

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

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

isResourceActive

public boolean isResourceActive(java.lang.String resourcePath,
                                java.sql.Connection connection)
This method will check whether a given resource is delete or not , there can be mutiple resource with the same path and thier ID will vary from one to another. So when we list out the resources by giving the path then we will have one or more resources. Then we go though the list and figure out whether there is any resource which is in active state if so return true else return false

Parameters:
resourcePath - : reosurce path
connection - : Connection to DB
Returns:
: return true if there is a resource for the given path in the active state else false

getLogs

public java.util.List getLogs(java.lang.String resourcePath,
                              java.lang.String userName,
                              java.util.Date from,
                              java.util.Date to,
                              java.sql.Connection conn)
                       throws java.lang.Exception
To get the log messages for all the artifacts

Parameters:
resourcePath - : Path of the resource
userName - : user name
from - : from which date
to - : to date
Returns:
List of LogEntry lits
Throws:
RegistryException - : if something went wrong
java.lang.Exception


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