org.wso2.carbon.registry.core.session
Class ChrootWrapper

java.lang.Object
  extended by org.wso2.carbon.registry.core.session.ChrootWrapper

public class ChrootWrapper
extends java.lang.Object

Class providing the chroot related functionality. The instance of this is used by the UserRegistry to wrap all the operation for inputs and outputs with chroot


Field Summary
protected  java.lang.String basePrefix
          The base prefix.
 
Constructor Summary
ChrootWrapper(java.lang.String basePrefix)
          Construct a ChrootWrapper with a base prefix.
 
Method Summary
 Collection filterSearchResult(Collection collection)
          Filter search results, so the results outside the base prefix will be ignored and results inside the base prefix will be converted to relative paths.
 LogEntry[] fixLogEntries(LogEntry[] logEntries)
          Convert the paths of the log entries to relative values.
 java.lang.String getBasePrefix()
          Method to return the base prefix.
 java.lang.String getInPath(java.lang.String path)
          Get an absolute path for the given path argument, taking into account both initial double-slashes (indicating an absolute path) and any basePrefix that has been established.
 Association[] getOutAssociations(Association[] associations)
          Return the associations array with converting all to relative paths.
 Collection getOutCollection(Collection collection)
          When returning collection (with pagination) it need to unset the collection content.
 Comment[] getOutComments(Comment[] comments)
          Method to return the comments with relative paths set.
 java.lang.String getOutPath(java.lang.String absolutePath)
          Take an absolute path in the "real" registry and convert it to a relative path suitable for this particular RemoteRegistry (which may be rooted at a particular place).
 java.lang.String[] getOutPaths(java.lang.String[] absolutePaths)
          returns a set of relative path for the provided absolute paths.
 Resource getOutResource(Resource resource)
          The resource needed to be modified in case of out resource
 TaggedResourcePath[] getOutTaggedResourcePaths(TaggedResourcePath[] taggedResourcePaths)
          Method to return the tagged resource after converting to relative paths
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

basePrefix

protected java.lang.String basePrefix
The base prefix.

Constructor Detail

ChrootWrapper

public ChrootWrapper(java.lang.String basePrefix)
Construct a ChrootWrapper with a base prefix.

Parameters:
basePrefix - the base prefix.
Method Detail

getBasePrefix

public java.lang.String getBasePrefix()
Method to return the base prefix.

Returns:
the base prefix.

getInPath

public java.lang.String getInPath(java.lang.String path)
Get an absolute path for the given path argument, taking into account both initial double-slashes (indicating an absolute path) and any basePrefix that has been established.

This is the converse of getOutPath().

Parameters:
path - a relative path
Returns:
an absolute path into the "real" registry.

getOutPath

public java.lang.String getOutPath(java.lang.String absolutePath)
Take an absolute path in the "real" registry and convert it to a relative path suitable for this particular RemoteRegistry (which may be rooted at a particular place).

This is the converse of getInPath().

Parameters:
absolutePath - a full path from the root of the registry, starting with "/"
Returns:
a relative path which generates the correct absolute path

getOutPaths

public java.lang.String[] getOutPaths(java.lang.String[] absolutePaths)
returns a set of relative path for the provided absolute paths.

Parameters:
absolutePaths - the array of absolute paths.
Returns:
the array of relative paths

getOutResource

public Resource getOutResource(Resource resource)
                        throws RegistryException
The resource needed to be modified in case of out resource

Parameters:
resource - the resource that should prepared with chroot to return out.
Returns:
the resource after preparing with chroot processing
Throws:
RegistryException - throws if the operation failed.

getOutCollection

public Collection getOutCollection(Collection collection)
                            throws RegistryException
When returning collection (with pagination) it need to unset the collection content.

Parameters:
collection - the collection to be prepared with chroot to return out.
Returns:
the resource after preparing with chroot processing
Throws:
RegistryException - throws if the operation failed.

getOutAssociations

public Association[] getOutAssociations(Association[] associations)
Return the associations array with converting all to relative paths.

Parameters:
associations - the associations that are in absolute paths.
Returns:
the associations after converting to the relative paths.

getOutTaggedResourcePaths

public TaggedResourcePath[] getOutTaggedResourcePaths(TaggedResourcePath[] taggedResourcePaths)
Method to return the tagged resource after converting to relative paths

Parameters:
taggedResourcePaths - the set of tagged resource paths.
Returns:
the tagged resource paths after making them relative.

getOutComments

public Comment[] getOutComments(Comment[] comments)
Method to return the comments with relative paths set.

Parameters:
comments - the comments with absolute paths
Returns:
the comments after converting to the relative paths.

filterSearchResult

public Collection filterSearchResult(Collection collection)
                              throws RegistryException
Filter search results, so the results outside the base prefix will be ignored and results inside the base prefix will be converted to relative paths.

Parameters:
collection - unfiltered search results
Returns:
filtered search results
Throws:
RegistryException - throws if the operation failed.

fixLogEntries

public LogEntry[] fixLogEntries(LogEntry[] logEntries)
Convert the paths of the log entries to relative values.

Parameters:
logEntries - the array of log entries to be converted to relative paths.
Returns:
the log entries after converting them relative values.


Copyright © 2011 WSO2 Inc. All Rights Reserved.