org.alfresco.wcm.util
Class WCMUtil

java.lang.Object
  extended by org.alfresco.repo.avm.util.AVMUtil
      extended by org.alfresco.wcm.util.WCMUtil
Direct Known Subclasses:
SandboxFactory, WebProjectServiceImpl

public class WCMUtil
extends AVMUtil

Helper methods and constants related to WCM directories, paths and store name manipulation.


Field Summary
static java.lang.String DIR_ROOT
           
static java.lang.String LOCK_KEY_STORE_NAME
           
protected static java.util.regex.Pattern PATTERN_ILLEGAL_SEQUENCE
          Matches character sequences that must be escaped in a compound store name.
static java.lang.String ROLE_CONTENT_CONTRIBUTOR
           
static java.lang.String ROLE_CONTENT_MANAGER
           
static java.lang.String ROLE_CONTENT_PUBLISHER
           
static java.lang.String ROLE_CONTENT_REVIEWER
           
protected static java.lang.String SPACE_ICON_WEBSITE
           
protected static java.lang.String STORE_PREVIEW
           
protected static java.lang.String STORE_SEPARATOR
           
protected static java.lang.String STORE_WORKFLOW
           
static java.lang.String WORKFLOW_SUBMITDIRECT_NAME
           
 
Fields inherited from class org.alfresco.repo.avm.util.AVMUtil
AVM_PATH_SEPARATOR, AVM_PATH_SEPARATOR_CHAR, AVM_STORE_SEPARATOR, AVM_STORE_SEPARATOR_CHAR, INITIAL_SNAPSHOT
 
Constructor Summary
WCMUtil()
           
 
Method Summary
static java.lang.String buildSandboxRootPath(java.lang.String storeName)
          Returns the root path for the specified sandbox name * eg.
protected static java.lang.String buildStagingPreviewStoreName(java.lang.String storeId)
          Returns the preview store name for the specified store id.
static java.lang.String buildStagingStoreName(java.lang.String wpStoreId)
          Returns the main staging store name for the specified web project
static java.lang.String buildStoreRootPath(java.lang.String storeName)
          Returns the root path for the specified store name eg.
static java.lang.String buildStoreWebappPath(java.lang.String storeName, java.lang.String webApp)
          Returns the root webapp path for the specified store and webapp name
static java.lang.String buildUserMainStoreName(java.lang.String storeId, java.lang.String userName)
          Returns the user's main store name for a specific username
protected static java.lang.String buildUserPreviewStoreName(java.lang.String storeId, java.lang.String username)
          Returns the preview store name for a specific username.
protected static java.lang.String buildWorkflowMainStoreName(java.lang.String storeId, java.lang.String workflowId)
          Returns the store name for a specific workflow Id.
protected static java.lang.String buildWorkflowPreviewStoreName(java.lang.String storeId, java.lang.String workflowId)
          Returns the preview store name for a specific workflow Id.
static java.lang.String escapeStoreNameComponent(java.lang.String component)
          Utility function for escaping part of a compound store name (delimited by STORE_SEPARATOR sequences).
static java.lang.String getCommonWebApp(java.lang.String sbStoreId, java.util.List storeRelativePaths)
           
protected static java.lang.String getCorrespondingMainStoreName(java.lang.String storeName)
          Returns the corresponding main store name if this is a preview store name.
static java.lang.String getCorrespondingPath(java.lang.String avmPath, java.lang.String otherStoreName)
          Returns the corresponding path in the store provided.
protected static java.lang.String getCorrespondingPathInMainStore(java.lang.String avmPath)
          Returns the corresponding path in the main store name if this is a path in a preview store.
protected static java.lang.String getCorrespondingPathInPreviewStore(java.lang.String avmPath)
          Returns the corresponding path in the preview store name if this is a path in a main store.
protected static java.lang.String getCorrespondingPreviewStoreName(java.lang.String storeName)
          Returns the corresponding preview store name if this is a main store name.
protected static java.lang.String getSandboxPath(java.lang.String absoluteAVMPath)
          Returns the path portion up the sandbox
protected static java.lang.String getSandboxRelativePath(java.lang.String absoluteAVMPath)
          Returns a path relative to the sandbox porition of the avm path.
static java.lang.String getSandboxStoreId(java.lang.String avmPath)
          Extracts the sandbox store id from the avm path
static java.lang.String getStoreRelativePath(java.lang.String absoluteAVMPath)
          Returns a path relative to the store portion of the avm path.
static java.lang.String getUserName(java.lang.String storeName)
          Extracts the username from the store name.
static java.lang.String getWebapp(java.lang.String absoluteAVMPath)
          Returns the webapp within the path
protected static java.lang.String getWebappPath(java.lang.String absoluteAVMPath)
          Returns the path portion up the webapp
protected static java.lang.String getWebappRelativePath(java.lang.String absoluteAVMPath)
          Returns a path relative to the webapp portion of the avm path.
static java.lang.String getWebProject(AVMService avmService, java.lang.String avmStoreName)
          Returns web project store id for an AVM store name (or null for vanilla AVM store)
static org.alfresco.service.cmr.repository.NodeRef getWebProjectNodeFromWebProjectStore(AVMService avmService, java.lang.String wpStoreId)
           
static java.lang.String getWebProjectStoreId(java.lang.String storeName)
          Extracts the web project store id from the (sandbox) store name
static java.lang.String getWebProjectStoreIdFromPath(java.lang.String avmPath)
          Extracts the web project store id from the avm path For example, if the avm path is: teststore--admin:/www/ROOT then the web project id is: teststore
static java.lang.String getWorkflowId(java.lang.String storeName)
          Extracts the workflow id
protected static boolean isLocalhostDeployedStore(java.lang.String wpStoreId, java.lang.String storeName)
          http://wiki.alfresco.com/wiki/WCM_Deployment_Features#Debugging_.26_Testing Examples of locally deployed store names for web project "MyWebProj" are: MyWebProjlive MyWebProj--adminlive Note: if web project "MyWebProjlive" is pre-created then should be possible to browse staging: http://wiki.alfresco.com/wiki/WCM_Deployment_Features#Deployed_Runtime
protected static boolean isPreviewStore(java.lang.String storeName)
          Indicates whether the store name describes a preview store.
static boolean isStagingStore(java.lang.String storeName)
          Indicates whether the store name describes a staging store.
static boolean isUserStore(java.lang.String storeName)
          Indicates whether the store name describes a user store.
protected static boolean isWorkflowStore(java.lang.String storeName)
          Indicates whether the store name describes a workflow store.
protected static java.util.List listWebUserRefs(org.alfresco.service.cmr.repository.NodeService nodeService, org.alfresco.service.cmr.repository.NodeRef wpNodeRef, boolean preLoad)
           
protected static java.util.Map listWebUsers(org.alfresco.service.cmr.repository.NodeService nodeService, org.alfresco.service.cmr.repository.NodeRef wpNodeRef)
           
static java.lang.String lookupStoreDNS(AVMService avmService, java.lang.String store)
           
protected static void removeAllVServerWebapps(org.alfresco.mbeans.VirtServerRegistry vServerRegistry, java.lang.String path, boolean force)
          Removal notification on all the virtualisation server webapp as required by the specified path
protected static void removeVServerWebapp(org.alfresco.mbeans.VirtServerRegistry vServerRegistry, java.lang.String path, boolean force)
          Removal notification on the virtualisation server webapp as required for the specified path
static void updateVServerWebapp(org.alfresco.mbeans.VirtServerRegistry vServerRegistry, java.lang.String path, boolean force)
          Update notification on the virtualisation server webapp as required for the specified path
 
Methods inherited from class org.alfresco.repo.avm.util.AVMUtil
addLeadingSlash, buildAVMPath, extendAVMPath, getStoreName, normalizePath, splitBase, splitPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STORE_SEPARATOR

protected static final java.lang.String STORE_SEPARATOR
See Also:
Constant Field Values

PATTERN_ILLEGAL_SEQUENCE

protected static final java.util.regex.Pattern PATTERN_ILLEGAL_SEQUENCE
Matches character sequences that must be escaped in a compound store name. We disallow non-ASCII characters due to Tomcat 5.5's insistence on URL decoding paths with the JVM default charset (not necessarily UTF-8)


STORE_WORKFLOW

protected static final java.lang.String STORE_WORKFLOW
See Also:
Constant Field Values

STORE_PREVIEW

protected static final java.lang.String STORE_PREVIEW
See Also:
Constant Field Values

DIR_ROOT

public static final java.lang.String DIR_ROOT
See Also:
Constant Field Values

SPACE_ICON_WEBSITE

protected static final java.lang.String SPACE_ICON_WEBSITE
See Also:
Constant Field Values

LOCK_KEY_STORE_NAME

public static final java.lang.String LOCK_KEY_STORE_NAME
See Also:
Constant Field Values

ROLE_CONTENT_MANAGER

public static final java.lang.String ROLE_CONTENT_MANAGER
See Also:
Constant Field Values

ROLE_CONTENT_PUBLISHER

public static final java.lang.String ROLE_CONTENT_PUBLISHER
See Also:
Constant Field Values

ROLE_CONTENT_CONTRIBUTOR

public static final java.lang.String ROLE_CONTENT_CONTRIBUTOR
See Also:
Constant Field Values

ROLE_CONTENT_REVIEWER

public static final java.lang.String ROLE_CONTENT_REVIEWER
See Also:
Constant Field Values

WORKFLOW_SUBMITDIRECT_NAME

public static final java.lang.String WORKFLOW_SUBMITDIRECT_NAME
See Also:
Constant Field Values
Constructor Detail

WCMUtil

public WCMUtil()
Method Detail

getSandboxStoreId

public static java.lang.String getSandboxStoreId(java.lang.String avmPath)
Extracts the sandbox store id from the avm path

Parameters:
avmPath - an absolute avm path
Returns:
the sandbox store id

getWebProjectStoreId

public static java.lang.String getWebProjectStoreId(java.lang.String storeName)
Extracts the web project store id from the (sandbox) store name

For example, if the (sandbox) store name is: teststore--admin then the web project store id is: teststore

Note: Although the staging sandbox store name is currently equivalent to the web project store id, it should be derived using 'buildStagingStoreName'.

Parameters:
storeName - the sandbox store id
Returns:
the web project store id

getWebProjectStoreIdFromPath

public static java.lang.String getWebProjectStoreIdFromPath(java.lang.String avmPath)
Extracts the web project store id from the avm path For example, if the avm path is: teststore--admin:/www/ROOT then the web project id is: teststore

Parameters:
avmPath - an absolute avm path
Returns:
the web project store id.

isPreviewStore

protected static boolean isPreviewStore(java.lang.String storeName)
Indicates whether the store name describes a preview store.

Parameters:
storeName - the store name
Returns:
true if the store is a preview store, false otherwise.

isLocalhostDeployedStore

protected static boolean isLocalhostDeployedStore(java.lang.String wpStoreId,
                                                  java.lang.String storeName)
http://wiki.alfresco.com/wiki/WCM_Deployment_Features#Debugging_.26_Testing Examples of locally deployed store names for web project "MyWebProj" are: MyWebProjlive MyWebProj--adminlive Note: if web project "MyWebProjlive" is pre-created then should be possible to browse staging: http://wiki.alfresco.com/wiki/WCM_Deployment_Features#Deployed_Runtime

Parameters:
storeName -
Returns:

isWorkflowStore

protected static boolean isWorkflowStore(java.lang.String storeName)
Indicates whether the store name describes a workflow store.

Parameters:
storeName - the store name
Returns:
true if the store is a workflow store, false otherwise.

isUserStore

public static boolean isUserStore(java.lang.String storeName)
Indicates whether the store name describes a user store.

Parameters:
storeName - the store name
Returns:
true if the store is a user store, false otherwise.

isStagingStore

public static boolean isStagingStore(java.lang.String storeName)
Indicates whether the store name describes a staging store.

Parameters:
storeName - the store name
Returns:
true if the store is a main store, false otherwise.

getUserName

public static java.lang.String getUserName(java.lang.String storeName)
Extracts the username from the store name.

Parameters:
storeName - the store name
Returns:
the username associated or null if this is a staging store.

getWorkflowId

public static java.lang.String getWorkflowId(java.lang.String storeName)
Extracts the workflow id

Parameters:
storeName -
Returns:

getCorrespondingMainStoreName

protected static java.lang.String getCorrespondingMainStoreName(java.lang.String storeName)
Returns the corresponding main store name if this is a preview store name.

Parameters:
storeName - the preview store name.
Returns:
the corresponding main store name.
Throws:
java.lang.IllegalArgumentException - if this is not a preview store name.

getCorrespondingPreviewStoreName

protected static java.lang.String getCorrespondingPreviewStoreName(java.lang.String storeName)
Returns the corresponding preview store name if this is a main store name.

Parameters:
storeName - the main store name.
Returns:
the corresponding preview store name.
Throws:
java.lang.IllegalArgumentException - if this is not a main store name.

getCorrespondingPathInMainStore

protected static java.lang.String getCorrespondingPathInMainStore(java.lang.String avmPath)
Returns the corresponding path in the main store name if this is a path in a preview store.

Parameters:
avmPath - an avm path within the main store.
Returns:
the corresponding path within the preview store.
Throws:
java.lang.IllegalArgumentException - if this is not a path within the preview store.

getCorrespondingPathInPreviewStore

protected static java.lang.String getCorrespondingPathInPreviewStore(java.lang.String avmPath)
Returns the corresponding path in the preview store name if this is a path in a main store.

Parameters:
avmPath - an avm path within the main store.
Returns:
the corresponding path within the preview store.
Throws:
java.lang.IllegalArgumentException - if this is not a path within the preview store.

getCorrespondingPath

public static java.lang.String getCorrespondingPath(java.lang.String avmPath,
                                                    java.lang.String otherStoreName)
Returns the corresponding path in the store provided.

Parameters:
avmPath - an avm path
otherStore - the other store name to return the corresponding path for
Returns:
the corresponding path within the supplied store

escapeStoreNameComponent

public static final java.lang.String escapeStoreNameComponent(java.lang.String component)
Utility function for escaping part of a compound store name (delimited by STORE_SEPARATOR sequences). Uses ISO 9075 style encoding to escape otherwise problematic character sequences.

Parameters:
component - the component
Returns:
the escaped string

buildStagingStoreName

public static java.lang.String buildStagingStoreName(java.lang.String wpStoreId)
Returns the main staging store name for the specified web project

Parameters:
wpStoreId - web project store id to build staging store name for
Returns:
String main staging store name for the specified web project store id

buildStagingPreviewStoreName

protected static java.lang.String buildStagingPreviewStoreName(java.lang.String storeId)
Returns the preview store name for the specified store id.

Parameters:
storeId - store id to build preview store name for
Returns:
preview store name for the specified store id

buildUserMainStoreName

public static java.lang.String buildUserMainStoreName(java.lang.String storeId,
                                                      java.lang.String userName)
Returns the user's main store name for a specific username

Parameters:
storeId - store id to build user store name for
username - of the user to build store name for
Returns:
the main store for the specified user and store id

buildUserPreviewStoreName

protected static java.lang.String buildUserPreviewStoreName(java.lang.String storeId,
                                                            java.lang.String username)
Returns the preview store name for a specific username.

Parameters:
storeId - store id to build user preview store name for
username - of the user to build preview store name for
Returns:
the preview store for the specified user and store id

buildWorkflowMainStoreName

protected static java.lang.String buildWorkflowMainStoreName(java.lang.String storeId,
                                                             java.lang.String workflowId)
Returns the store name for a specific workflow Id.

Parameters:
storeId - store id to build workflow store name for
workflowId - of the user to build workflow store name for
Returns:
the store for the specified workflow and store ids

buildWorkflowPreviewStoreName

protected static java.lang.String buildWorkflowPreviewStoreName(java.lang.String storeId,
                                                                java.lang.String workflowId)
Returns the preview store name for a specific workflow Id.

Parameters:
storeId - store id to build preview workflow store name for
workflowId - of the user to build preview workflow store name for
Returns:
the store for the specified preview workflow and store ids

buildStoreRootPath

public static java.lang.String buildStoreRootPath(java.lang.String storeName)
Returns the root path for the specified store name eg. mystore -> mystore:/www

Parameters:
storeName - store to build root path for
Returns:
root path for the specified store name

buildSandboxRootPath

public static java.lang.String buildSandboxRootPath(java.lang.String storeName)
Returns the root path for the specified sandbox name * eg. mystore -> mystore:/www/avm_webapps

Parameters:
storeName - store to build root sandbox path for
Returns:
root sandbox path for the specified store name

buildStoreWebappPath

public static java.lang.String buildStoreWebappPath(java.lang.String storeName,
                                                    java.lang.String webApp)
Returns the root webapp path for the specified store and webapp name

Parameters:
storeName - store to build root webapp path for
webapp - webapp folder name
Returns:
the root webapp path for the specified store and webapp name

lookupStoreDNS

public static java.lang.String lookupStoreDNS(AVMService avmService,
                                              java.lang.String store)

getWebProjectNodeFromWebProjectStore

public static org.alfresco.service.cmr.repository.NodeRef getWebProjectNodeFromWebProjectStore(AVMService avmService,
                                                                                               java.lang.String wpStoreId)

getWebProject

public static java.lang.String getWebProject(AVMService avmService,
                                             java.lang.String avmStoreName)
Returns web project store id for an AVM store name (or null for vanilla AVM store)


getStoreRelativePath

public static java.lang.String getStoreRelativePath(java.lang.String absoluteAVMPath)
Returns a path relative to the store portion of the avm path.

Parameters:
absoluteAVMPath - an absolute path within the avm
Returns:
the path without the store prefix.

getWebappRelativePath

protected static java.lang.String getWebappRelativePath(java.lang.String absoluteAVMPath)
Returns a path relative to the webapp portion of the avm path.

Parameters:
absoluteAVMPath - an absolute path within the avm
Returns:
a relative path within the webapp.

getWebapp

public static java.lang.String getWebapp(java.lang.String absoluteAVMPath)
Returns the webapp within the path

Parameters:
absoluteAVMPath - the path from which to extract the webapp name
Returns:
an the webapp name contained within the path or null.

getWebappPath

protected static java.lang.String getWebappPath(java.lang.String absoluteAVMPath)
Returns the path portion up the webapp

Parameters:
absoluteAVMPath - the path from which to extract the webapp path
Returns:
an absolute avm path to the webapp contained within the path or null.

getSandboxRelativePath

protected static java.lang.String getSandboxRelativePath(java.lang.String absoluteAVMPath)
Returns a path relative to the sandbox porition of the avm path.

Parameters:
absoluteAVMPath - an absolute path within the avm
Returns:
a relative path within the sandbox.

getSandboxPath

protected static java.lang.String getSandboxPath(java.lang.String absoluteAVMPath)
Returns the path portion up the sandbox

Parameters:
absoluteAVMPath - the path from which to extract the sandbox path
Returns:
an absolute avm path to the sandbox contained within the path or null.

listWebUsers

protected static java.util.Map listWebUsers(org.alfresco.service.cmr.repository.NodeService nodeService,
                                            org.alfresco.service.cmr.repository.NodeRef wpNodeRef)

listWebUserRefs

protected static java.util.List listWebUserRefs(org.alfresco.service.cmr.repository.NodeService nodeService,
                                                org.alfresco.service.cmr.repository.NodeRef wpNodeRef,
                                                boolean preLoad)

updateVServerWebapp

public static void updateVServerWebapp(org.alfresco.mbeans.VirtServerRegistry vServerRegistry,
                                       java.lang.String path,
                                       boolean force)
Update notification on the virtualisation server webapp as required for the specified path

Parameters:
path - Path to match against
force - True to force update of server even if path does not match

removeAllVServerWebapps

protected static void removeAllVServerWebapps(org.alfresco.mbeans.VirtServerRegistry vServerRegistry,
                                              java.lang.String path,
                                              boolean force)
Removal notification on all the virtualisation server webapp as required by the specified path

Parameters:
path - Path to match against
force - True to force update of server even if path does not match

removeVServerWebapp

protected static void removeVServerWebapp(org.alfresco.mbeans.VirtServerRegistry vServerRegistry,
                                          java.lang.String path,
                                          boolean force)
Removal notification on the virtualisation server webapp as required for the specified path

Parameters:
path - Path to match against
force - True to force update of server even if path does not match

getCommonWebApp

public static java.lang.String getCommonWebApp(java.lang.String sbStoreId,
                                               java.util.List storeRelativePaths)


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.