org.wso2.carbon.registry.core.jdbc
Class Repository

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.Repository

public class Repository
extends Object

Encapsulates the retrieving, storing, modifying and deleting of resources. This class only deals with the current versions of resources and it is unaware of any versioning or snapshot activity. Only the current version related tables are accessed and updated from the methods of this class.


Constructor Summary
Repository(DataAccessManager dataAccessManager, VersionRepository versionRepository, boolean versionOnChange, RecursionRepository recursionRepository)
          Constructs a Repository
 
Method Summary
 String copy(ResourcePath sourceResourcePath, ResourcePath targetResourcePath)
          Method to copy a resource from source to target.
 void delete(String _path)
          Deletes the pure resource referred by the path.
 void deleteNode(ResourceIDImpl resourceID, ResourceDO resourceDO, boolean keepAuthorization)
          Method to delete just the node in the collection hierarchy.
 void deleteSubTree(ResourceIDImpl resourceID, ResourceDO resourceDO, boolean keepAuthorization)
          Method to delete a sub tree of the collection hierarchy.
 void dump(String _path, Writer writer)
          Method to do a dump.
 Resource get(String path)
          Gets the pure resource referred by the given path.
 Collection get(String path, int start, int pageLen)
          Method to get a paged collection.
 Resource getMetaData(String path)
          Gets the meta data of resource referred by the given path.
 String importResource(String path, String sourceURL, Resource metaResource)
          Creates a resource with the content imported from the source URL and meta data extracted from the given meta data resource instance.
 String move(ResourcePath oldResourcePath, String newPath)
          Moves the resource at oldPath to the newPath.
 String moveRecursively(ResourceIDImpl sourceID, String targetPath, ResourceIDImpl targetParentResourceID)
          Method to do a recursive move.
 void prepareDumpRestore(String path)
          This will delete only the current resource, keeps the authorizations.
 void prepareVersionRestore(String _path)
          This will delete the entire resource, except it keeps the authorizations.
 void put(String path, Resource resource)
          Adds or updates the resource in the given path with the given resource.
 String rename(ResourcePath oldResourcePath, String newName)
          Renames the resource at oldPath with the given newName.
 boolean resourceExists(String path)
          Checks if a pure resource exists in the given path.
 void restore(String _path, Reader reader)
          Method to restore a dump.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Repository

public Repository(DataAccessManager dataAccessManager,
                  VersionRepository versionRepository,
                  boolean versionOnChange,
                  RecursionRepository recursionRepository)
Constructs a Repository

Parameters:
dataAccessManager - the data access manager that is used for database communication.
versionRepository - the version repository.
versionOnChange - whether versioning needs to be done on change.
recursionRepository - the recursion repository for recursive operations.
Method Detail

resourceExists

public boolean resourceExists(String path)
                       throws RegistryException
Checks if a pure resource exists in the given path.

Parameters:
path - Path of a possible pure resource.
Returns:
true if a resource exists in the given path. false otherwise.
Throws:
RegistryException - if the operation failed.

getMetaData

public Resource getMetaData(String path)
                     throws RegistryException
Gets the meta data of resource referred by the given path.

Parameters:
path - Path of a "pure" resource. Path should map to an actual resource stored in the database. Paths referring to virtual resource are not handled (e.g. /c1/r1;comments).
Returns:
Resource referred by the given path. Resource can be a file or a collection.
Throws:
RegistryException - if the operation failed.

get

public Resource get(String path)
             throws RegistryException
Gets the pure resource referred by the given path.

Parameters:
path - Path of a "pure" resource. Path should map to an actual resource stored in the database. Paths referring to virtual resource are not handled (e.g. /c1/r1;comments).
Returns:
Resource referred by the given path. Resource can be a file or a collection.
Throws:
RegistryException - if the operation failed.

get

public Collection get(String path,
                      int start,
                      int pageLen)
               throws RegistryException
Method to get a paged collection.

Parameters:
path - the collection path.
start - the starting index.
pageLen - the page length.
Returns:
collection with resources on the given page.
Throws:
RegistryException - if the operation failed.

put

public void put(String path,
                Resource resource)
         throws RegistryException
Adds or updates the resource in the given path with the given resource. Put is executed if the current user has authorization to do so. Below is the method of evaluating authorizations.

Parameters:
path - Path of the resource to be added or updated. Path should only refer to current version a pure resource. i.e. Path should not contain any version information as it is impossible to add or update old versions.
resource - Resource to be added or updated.
Throws:
RegistryException - if the operation failed.

importResource

public String importResource(String path,
                             String sourceURL,
                             Resource metaResource)
                      throws RegistryException
Creates a resource with the content imported from the source URL and meta data extracted from the given meta data resource instance. Then the created resource is put to the registry using the Repository.put() method.

Parameters:
path - Path to put the resource
sourceURL - URL to import resource content
metaResource - Meta data for the new resource is extracted from this meta data resource
Returns:
Actual path where the new resource is stored in the registry
Throws:
RegistryException - for all exceptional scenarios

delete

public void delete(String _path)
            throws RegistryException
Deletes the pure resource referred by the path.

Parameters:
_path - path Path of the resource deleted. Path should only refer to current version a pure resource. i.e. Path should not contain any version information as it is impossible to delete old versions.
Throws:
RegistryException - if the operation failed.

prepareVersionRestore

public void prepareVersionRestore(String _path)
                           throws RegistryException
This will delete the entire resource, except it keeps the authorizations.

Parameters:
_path - the path to be restored.
Throws:
RegistryException - if the operation failed.

prepareDumpRestore

public void prepareDumpRestore(String path)
                        throws RegistryException
This will delete only the current resource, keeps the authorizations.

Parameters:
path - the path to be prepared to restore.
Throws:
RegistryException - if the operation failed.

deleteSubTree

public void deleteSubTree(ResourceIDImpl resourceID,
                          ResourceDO resourceDO,
                          boolean keepAuthorization)
                   throws RegistryException
Method to delete a sub tree of the collection hierarchy.

Parameters:
resourceID - the resource identifier.
resourceDO - the resource data object.
keepAuthorization - whether to keep authorizations.
Throws:
RegistryException - if the operation failed.

deleteNode

public void deleteNode(ResourceIDImpl resourceID,
                       ResourceDO resourceDO,
                       boolean keepAuthorization)
                throws RegistryException
Method to delete just the node in the collection hierarchy.

Parameters:
resourceID - the resource identifier.
resourceDO - the resource data object.
keepAuthorization - whether to keep authorizations.
Throws:
RegistryException - if the operation failed.

rename

public String rename(ResourcePath oldResourcePath,
                     String newName)
              throws RegistryException
Renames the resource at oldPath with the given newName. If oldPath is "/projects/wso2/config.xml" and newName is "registry.xml" then the new path of the resource will be "/projects/wso2/registry.xml". If the renamed resource is a collection, paths of all its descendants will also be changed.

Parameters:
oldResourcePath - Path of the resource to be renamed.
newName - New name for the resource. Name should not contain "/".
Returns:
New path of the resource.
Throws:
RegistryException - if the operation failed.

move

public String move(ResourcePath oldResourcePath,
                   String newPath)
            throws RegistryException
Moves the resource at oldPath to the newPath. If the resource is a collection, all its descendant resources will also be moved.

Parameters:
oldResourcePath - Path of a existing resource
newPath - New path of the resource
Returns:
the actual new path
Throws:
RegistryException - if the operation failed.

moveRecursively

public String moveRecursively(ResourceIDImpl sourceID,
                              String targetPath,
                              ResourceIDImpl targetParentResourceID)
                       throws RegistryException
Method to do a recursive move.

Parameters:
sourceID - the source resource's identifier.
targetPath - the target resource path.
targetParentResourceID - the target resource's parent's identifier.
Returns:
the target path.
Throws:
RegistryException - if the operation failed.

copy

public String copy(ResourcePath sourceResourcePath,
                   ResourcePath targetResourcePath)
            throws RegistryException
Method to copy a resource from source to target.

Parameters:
sourceResourcePath - the source path.
targetResourcePath - the target path.
Returns:
the target path.
Throws:
RegistryException - if the operation failed.

restore

public void restore(String _path,
                    Reader reader)
             throws RegistryException
Method to restore a dump.

Parameters:
_path - the path to restore from a dump.
reader - the reader used.
Throws:
RegistryException - if the operation failed.

dump

public void dump(String _path,
                 Writer writer)
          throws RegistryException
Method to do a dump.

Parameters:
_path - the path to obtain the dump from.
writer - the writer used.
Throws:
RegistryException - if the operation failed.


Copyright © 2013 WSO2 Inc. All Rights Reserved.