|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.wso2.carbon.registry.core.utils.RegistryUtils
public class RegistryUtils
This class contains a set of useful utility methods used by the Registry Kernel. These can also be used by third party components as well as the various clients written to access the registry via its remote APIs.
Constructor Summary | |
---|---|
RegistryUtils()
|
Method Summary | |
---|---|
static void |
addBaseCollectionStructure(Registry registry,
org.wso2.carbon.user.core.UserRealm userRealm)
This method builds the base collection structure for the registry. |
static void |
addCarbonRootCollection(Registry userRegistry,
org.wso2.carbon.user.core.UserRealm userRealm)
Deprecated. |
static void |
addMountCollection(Registry registry)
Method to add the collection where the mount information is stored. |
static void |
addMountEntry(Registry registry,
RegistryContext registryContext,
java.lang.String path,
java.lang.String target,
boolean remote,
java.lang.String author)
Method to add a mount entry. |
static void |
addMountEntry(Registry registry,
RegistryContext registryContext,
java.lang.String path,
java.lang.String target,
java.lang.String targetSubPath,
java.lang.String author)
Method to add a mount entry. |
static void |
addRootCollectionAuthorization(org.wso2.carbon.user.core.UserRealm userRealm)
Deprecated. |
static void |
addServiceConfigResources(Registry registry)
Method to add the resources where the service configuration are stored. |
static void |
addServiceStoreCollection(Registry registry,
java.lang.String servicePath)
Method to add the collection where the services are stored. |
static void |
addSystemCollection(Registry registry,
org.wso2.carbon.user.core.UserRealm userRealm)
Deprecated. |
static void |
addTenantsCollection(Registry registry,
org.wso2.carbon.user.core.UserRealm userRealm)
Deprecated. |
static void |
addUserProfileCollection(Registry registry,
java.lang.String profilesPath)
Method to add the collection where the user profiles are stored. |
static org.wso2.carbon.caching.core.registry.RegistryCacheKey |
buildRegistryCacheKey(java.lang.String connectionId,
int tenantId,
java.lang.String resourcePath)
Builds the cache key for a resource path. |
static java.lang.String |
concatenateChroot(java.lang.String chroot1,
java.lang.String chroot2)
Method to concatenate two chroot paths. |
static boolean |
containsAsSubString(java.lang.String value,
java.lang.String[] array)
Method to determine whether the given array of strings contains a string which has the given string as a portion (sub-string) of it. |
static boolean |
containsString(java.lang.String value,
java.lang.String[] array)
Method to determine whether the given array of strings contains the given string. |
static java.lang.String |
getAbsoluteAssociationPath(java.lang.String path,
java.lang.String referencePath)
Calculate the absolute associations path if a relative path is given to the reference path. |
static java.lang.String |
getAbsolutePath(RegistryContext context,
java.lang.String relativePath)
Method to obtain the absolute path for the given relative path. |
static java.lang.String |
getAbsolutePathToOriginal(java.lang.String relativePath,
java.lang.String originalPath)
Method to obtain the path absolute to the given path. |
static org.wso2.carbon.user.core.UserRealm |
getBootstrapRealm()
Deprecated. |
static org.wso2.carbon.user.core.UserRealm |
getBootstrapRealm(org.wso2.carbon.user.core.service.RealmService realmService)
This method returns the bootstrap (or initial) user realm from the realm service. |
static byte[] |
getByteArray(java.io.InputStream inputStream)
Convert an input stream into a byte array. |
static net.sf.jsr107cache.Cache |
getCommonCache(java.lang.String name)
Return an instance of a named cache that is common to all tenants. |
static java.lang.String |
getConnectionId(java.sql.Connection connection)
Method to obtain a unique identifier for the database connection. |
static java.lang.String |
getExtensionLibDirectoryPath()
|
static java.io.InputStream |
getMemoryStream(java.io.InputStream inputStream)
Create an in-memory input stream for the given input stream. |
static URLMatcher |
getMountingMatcher(java.lang.String path)
Method to obtain the filter used with the mounting handler. |
static java.lang.String[] |
getMountingMethods()
Utility method obtain the list of operations supported by the mount handler. |
static java.lang.String |
getParentPath(java.lang.String resourcePath)
Method to obtain the parent path of the given resource path. |
static java.lang.String |
getPureResourcePath(java.lang.String resourcePath)
All "valid" paths pure resources should be in the form /c1/c2/r1. |
static java.lang.String |
getRelativeAssociationPath(java.lang.String path,
java.lang.String referencePath)
Calculate the relative associations path to the reference path if an absolute path is given. |
static java.lang.String |
getRelativePath(RegistryContext context,
java.lang.String absolutePath)
Method to obtain the relative path for the given absolute path. |
static java.lang.String |
getRelativePathToOriginal(java.lang.String absolutePath,
java.lang.String originalPath)
Method to obtain the path relative to the given path. |
static java.lang.String |
getResourceName(java.lang.String resourcePath)
Returns resource name when full resource path is passed. |
static ResourceImpl |
getResourceWithMinimumData(java.lang.String path,
ResourceDAO resourceDAO,
boolean versioned)
Gets the resource with sufficient data to differentiate it from another resource. |
static Registry |
getSystemRegistry(Registry coreRegistry)
this method can only be called if the registry context is initialized. |
static java.lang.String |
getUnChrootedPath(java.lang.String path)
Method to obtain the unchrooted path for the given relative path. |
static VersionedPath |
getVersionedPath(ResourcePath resourcePath)
Paths referring to a version of a resource are in the form /c1/c2/r1?v=2. |
static boolean |
hasAdminAuthorizations(java.lang.String userName,
org.wso2.carbon.user.core.UserRealm userRealm)
Method to determine whether the given user is in an admin role. |
static boolean |
isHiddenProperty(java.lang.String propertyName)
Method to determine whether a property is a hidden property or not. |
static boolean |
isRegistryReadOnly(RegistryContext registryContext)
Method to determine whether this registry is running in Read-Only mode. |
static java.lang.String |
prepareGeneralPath(java.lang.String rawPath)
Prepare the given path as a general resource path to be used in the registry. |
static void |
redirect(javax.servlet.http.HttpServletResponse response,
java.lang.String url)
Method to redirect a given response to some URL. |
static void |
registerHandlerForRemoteLinks(RegistryContext registryContext,
java.lang.String path,
java.lang.String target,
java.lang.String targetSubPath,
java.lang.String author)
Method to register handlers for remote links for the tenant on the current registry session. |
static void |
registerHandlerForRemoteLinks(RegistryContext registryContext,
java.lang.String path,
java.lang.String target,
java.lang.String targetSubPath,
java.lang.String author,
boolean forAllTenants)
Method to register handlers for remote links. |
static void |
registerHandlerForSymbolicLinks(RegistryContext context,
java.lang.String path,
java.lang.String target,
java.lang.String author)
Method to register handlers for symbolic links for the tenant on the current registry session. |
static void |
registerMountPoints(Registry systemRegistry,
int tenantId)
Method to register mount points. |
static org.apache.axiom.om.OMElement |
removeAuthorUpdaterFromDump(org.apache.axiom.om.OMElement root)
Method to remove the author and updater from a dump. |
static void |
setTrustStoreSystemProperties()
Set-up the system properties required to access the trust-store in Carbon. |
static boolean |
systemResourceShouldBeAdded(Registry registry,
java.lang.String absolutePath)
Method to determine whether a system resource (or collection) is existing or whether it should be created. |
static boolean |
systemResourceShouldBeAdded(ResourceDAO dataAccessObject,
java.lang.String absolutePath)
Method to determine whether a system resource (or collection) is existing or whether it should be created. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RegistryUtils()
Method Detail |
---|
public static VersionedPath getVersionedPath(ResourcePath resourcePath)
resourcePath
- versioned resource path.
public static byte[] getByteArray(java.io.InputStream inputStream) throws RegistryException
inputStream
- the input stream.
RegistryException
- if the operation failed.public static java.io.InputStream getMemoryStream(java.io.InputStream inputStream) throws RegistryException
inputStream
- the input stream.
RegistryException
- if the operation failed.public static java.lang.String getConnectionId(java.sql.Connection connection)
connection
- the database connection.
public static org.wso2.carbon.caching.core.registry.RegistryCacheKey buildRegistryCacheKey(java.lang.String connectionId, int tenantId, java.lang.String resourcePath)
connectionId
- the database connection identifiertenantId
- the tenant identifierresourcePath
- the resource path
public static java.lang.String getPureResourcePath(java.lang.String resourcePath)
resourcePath
- Path of a pure resource.
public static net.sf.jsr107cache.Cache getCommonCache(java.lang.String name)
name
- the name of the cache.
public static java.lang.String getParentPath(java.lang.String resourcePath)
resourcePath
- the resource path.
public static java.lang.String getResourceName(java.lang.String resourcePath)
resourcePath
- full resource path.
public static void redirect(javax.servlet.http.HttpServletResponse response, java.lang.String url)
response
- the HTTP Response.url
- The URL to redirect to.public static java.lang.String prepareGeneralPath(java.lang.String rawPath)
rawPath
- Raw path to be prepared
public static boolean hasAdminAuthorizations(java.lang.String userName, org.wso2.carbon.user.core.UserRealm userRealm) throws RegistryException
userName
- the user name.userRealm
- the user realm.
RegistryException
- if the operation failed.public static boolean containsString(java.lang.String value, java.lang.String[] array)
value
- the string to search.array
- the array of string.
public static boolean containsAsSubString(java.lang.String value, java.lang.String[] array)
value
- the string to search.array
- the array of string.
public static org.apache.axiom.om.OMElement removeAuthorUpdaterFromDump(org.apache.axiom.om.OMElement root)
root
- the input XML element.
@Deprecated public static void addRootCollectionAuthorization(org.wso2.carbon.user.core.UserRealm userRealm) throws RegistryException
RegistryException
public static void setTrustStoreSystemProperties()
public static boolean systemResourceShouldBeAdded(Registry registry, java.lang.String absolutePath) throws RegistryException
registry
- the base registry to use.absolutePath
- the absolute path of the system resource (or collection)
RegistryException
- if an error occurred.public static boolean systemResourceShouldBeAdded(ResourceDAO dataAccessObject, java.lang.String absolutePath) throws RegistryException
dataAccessObject
- the resource data access object.absolutePath
- the absolute path of the system resource (or collection)
RegistryException
- if an error occurred.public static void addBaseCollectionStructure(Registry registry, org.wso2.carbon.user.core.UserRealm userRealm) throws RegistryException
registry
- the base registry to use.userRealm
- the user realm.
RegistryException
- if an error occurred.@Deprecated public static void addSystemCollection(Registry registry, org.wso2.carbon.user.core.UserRealm userRealm) throws RegistryException
RegistryException
@Deprecated public static void addCarbonRootCollection(Registry userRegistry, org.wso2.carbon.user.core.UserRealm userRealm) throws RegistryException
RegistryException
@Deprecated public static void addTenantsCollection(Registry registry, org.wso2.carbon.user.core.UserRealm userRealm) throws RegistryException
RegistryException
public static void addUserProfileCollection(Registry registry, java.lang.String profilesPath) throws RegistryException
registry
- the registry to use.profilesPath
- the path at which user profiles are stored.
RegistryException
- if an error occurred.public static void addServiceStoreCollection(Registry registry, java.lang.String servicePath) throws RegistryException
registry
- the registry to use.servicePath
- the path at which services are stored.
RegistryException
- if an error occurred.public static void addMountCollection(Registry registry) throws RegistryException
registry
- the registry to use.
RegistryException
- if an error occurred.public static void registerMountPoints(Registry systemRegistry, int tenantId) throws RegistryException
systemRegistry
- the registry to use.tenantId
- the identifier of the tenant.
RegistryException
- if an error occurred.public static URLMatcher getMountingMatcher(java.lang.String path)
path
- the path at which the mount was added.
public static java.lang.String[] getMountingMethods()
public static void addServiceConfigResources(Registry registry) throws RegistryException
registry
- the registry to use.
RegistryException
- if an error occurred.public static java.lang.String concatenateChroot(java.lang.String chroot1, java.lang.String chroot2)
chroot1
- the base chroot path (or the registry root).chroot2
- the the relative chroot path.
public static boolean isRegistryReadOnly(RegistryContext registryContext)
registryContext
- the registry context.
public static Registry getSystemRegistry(Registry coreRegistry) throws RegistryException
coreRegistry
- the core registry instance.
RegistryException
- if the operation failed.@Deprecated public static org.wso2.carbon.user.core.UserRealm getBootstrapRealm() throws RegistryException
RegistryException
- if the operation failed.public static org.wso2.carbon.user.core.UserRealm getBootstrapRealm(org.wso2.carbon.user.core.service.RealmService realmService) throws RegistryException
realmService
- the OSGi service which we can use to obtain the user realm.
RegistryException
- if the operation failed.public static java.lang.String getUnChrootedPath(java.lang.String path)
path
- the relative path.
public static java.lang.String getRelativePath(RegistryContext context, java.lang.String absolutePath)
context
- the registry context.absolutePath
- the absolute path.
public static java.lang.String getAbsolutePath(RegistryContext context, java.lang.String relativePath)
context
- the registry context.relativePath
- the relative path.
public static java.lang.String getRelativePathToOriginal(java.lang.String absolutePath, java.lang.String originalPath)
absolutePath
- the absolute path.originalPath
- the path to which we need to make the given absolute path a relative
one.
public static java.lang.String getAbsolutePathToOriginal(java.lang.String relativePath, java.lang.String originalPath)
relativePath
- the relative path.originalPath
- the path to which we need to make the given relative path a absolute
one.
public static void registerHandlerForSymbolicLinks(RegistryContext context, java.lang.String path, java.lang.String target, java.lang.String author) throws RegistryException
context
- the registry context.path
- the path at which the symbolic link is created.target
- the target path.author
- the creator of the symbolic link.
RegistryException
- if the operation failed.public static void registerHandlerForRemoteLinks(RegistryContext registryContext, java.lang.String path, java.lang.String target, java.lang.String targetSubPath, java.lang.String author) throws RegistryException
registryContext
- the registry context.path
- the path at which the remote link is created.target
- the target path.targetSubPath
- the target sub-path.author
- the creator of the remote link.
RegistryException
- if the operation failed.public static void registerHandlerForRemoteLinks(RegistryContext registryContext, java.lang.String path, java.lang.String target, java.lang.String targetSubPath, java.lang.String author, boolean forAllTenants) throws RegistryException
registryContext
- the registry context.path
- the path at which the remote link is created.target
- the target path.targetSubPath
- the target sub-path.author
- the creator of the remote link.forAllTenants
- whether the remote link should be added to the tenant on the current
registry session or to all the tenants.
RegistryException
- if the operation failed.public static void addMountEntry(Registry registry, RegistryContext registryContext, java.lang.String path, java.lang.String target, java.lang.String targetSubPath, java.lang.String author) throws RegistryException
registry
- the registry instance to use.registryContext
- the registry context.path
- the source path.target
- the target path or instance.targetSubPath
- the target sub-path.author
- the author
RegistryException
- if the operation failed.public static void addMountEntry(Registry registry, RegistryContext registryContext, java.lang.String path, java.lang.String target, boolean remote, java.lang.String author) throws RegistryException
registry
- the registry instance to use.registryContext
- the registry context.path
- the source path.target
- the target path or instance.remote
- whether local or remote link.author
- the author
RegistryException
- if the operation failed.public static ResourceImpl getResourceWithMinimumData(java.lang.String path, ResourceDAO resourceDAO, boolean versioned) throws RegistryException
ResourceImpl
with the path, name and path identifier
of a resource.
path
- the path of the resource.resourceDAO
- the resource data access object to use.versioned
- whether version or not.
RegistryException
- if an error occurs while retrieving resource data.public static java.lang.String getRelativeAssociationPath(java.lang.String path, java.lang.String referencePath)
path
- absolute path value.referencePath
- the reference path
public static java.lang.String getAbsoluteAssociationPath(java.lang.String path, java.lang.String referencePath)
path
- relative path value.referencePath
- the reference path
public static boolean isHiddenProperty(java.lang.String propertyName)
propertyName
- the name of property.
public static java.lang.String getExtensionLibDirectoryPath()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |