org.opencms.ade.configuration
Class CmsADEManager

java.lang.Object
  extended by org.opencms.ade.configuration.CmsADEManager

public class CmsADEManager
extends java.lang.Object

This is the main class used to access the ADE configuration and also accomplish some other related tasks like loading/saving favorite and recent lists.


Nested Class Summary
protected static class CmsADEManager.FavListProp
          JSON property name constant.
protected static class CmsADEManager.Status
          A status enum for the initialization status.
 
Field Summary
protected static java.lang.String ADDINFO_ADE_FAVORITE_LIST
          User additional info key constant.
static java.lang.String ADDINFO_ADE_FAVORITE_LIST_SIZE
          User additional info key constant.
protected static java.lang.String ADDINFO_ADE_RECENT_LIST
          User additional info key constant.
static java.lang.String ADDINFO_ADE_RECENT_LIST_SIZE
          User additional info key constant.
static java.lang.String ADDINFO_ADE_SEARCH_PAGE_SIZE
          User additional info key constant.
static java.lang.String CLIENT_ID_SEPERATOR
          The client id separator.
static java.lang.String CONFIG_FILE_NAME
          The configuration file name.
static java.lang.String CONFIG_FOLDER_TYPE
          The name of the sitemap configuration file type.
static java.lang.String CONFIG_SUFFIX
          The path for sitemap configuration files relative from the base path.
static java.lang.String CONFIG_TYPE
          The name of the sitemap configuration file type.
static java.lang.String CONTENT_FOLDER_NAME
          The content folder name.
static int DEFAULT_FAVORITE_LIST_SIZE
          Default favorite list size constant.
static int DEFAULT_RECENT_LIST_SIZE
          Default recent list size constant.
static java.lang.String MODULE_CONFIG_TYPE
          The name of the module configuration file type.
static java.lang.String N_LINK
          Node name for the nav level link value.
static java.lang.String N_TYPE
          Node name for the nav level type value.
static java.lang.String PATH_SITEMAP_EDITOR_JSP
          The path to the sitemap editor JSP.
 
Constructor Summary
CmsADEManager(CmsObject adminCms, CmsMemoryMonitor memoryMonitor, CmsSystemConfiguration systemConfiguration)
          Creates a new ADE manager.
 
Method Summary
protected  CmsContainerElementBean elementFromJson(JSONObject data)
          Creates an element from its serialized data.
protected  JSONObject elementToJson(CmsContainerElementBean element, java.util.Set<java.lang.String> excludeSettings)
          Converts the given element to JSON.
 java.lang.String findEntryPoint(CmsObject cms, java.lang.String openPath)
          Finds the entry point to a sitemap.
 java.util.List<CmsDetailPageInfo> getAllDetailPages(CmsObject cms)
          Gets the complete list of beans for the currently configured detail pages.
 CmsADECache getCache()
          Gets the containerpage cache instance.
 I_CmsResourceType getConfigurationType()
          Gets the configuration file type.
 CmsContainerElementBean getCurrentElement(javax.servlet.ServletRequest req)
          Reads the current element bean from the request.
 java.lang.String getDetailPage(CmsObject cms, java.lang.String pageRootPath, java.lang.String originPath)
          Gets the detail page for a content element.
 I_CmsDetailPageFinder getDetailPageFinder()
          Gets the detail page finder.
 java.util.List<java.lang.String> getDetailPages(CmsObject cms, java.lang.String type)
          Returns the main detail pages for a type in all of the VFS tree.
 java.util.Set<java.lang.String> getDetailPageTypes(CmsObject cms)
          Gets the set of types for which detail pages are defined.
 java.util.Map<java.lang.String,CmsXmlContentProperty> getElementSettings(CmsObject cms, CmsResource resource)
          Returns the element settings for a given resource.
 java.util.List<CmsContainerElementBean> getFavoriteList(CmsObject cms)
          Returns the favorite list, or creates it if not available.
 CmsInheritedContainerState getInheritedContainerState(CmsObject cms, CmsResource resource, java.lang.String name)
          Returns the inheritance state for the given inheritance name and resource.
 CmsInheritedContainerState getInheritedContainerState(CmsObject cms, java.lang.String rootPath, java.lang.String name)
          Returns the inheritance state for the given inheritance name and root path.
 int getMaxSitemapDepth()
          Gets the maximum sitemap depth.
 I_CmsResourceType getModuleConfigurationType()
          Gets the module configuration resource type.
protected  org.opencms.ade.configuration.CmsConfigurationCache getOfflineCache()
          Gets the offline cache.
protected  org.opencms.ade.configuration.CmsConfigurationCache getOnlineCache()
          Gets the online cache.
 java.util.List<CmsContainerElementBean> getRecentList(CmsObject cms)
          Returns the favorite list, or creates it if not available.
 int getRecentListMaxSize(CmsUser user)
          Gets the maximum length of the recent list.
protected  java.lang.String getRootPath(CmsUUID structureId, boolean online)
          Gets the root path for a given resource structure id.
 java.lang.String getSubSiteRoot(CmsObject cms, java.lang.String rootPath)
          Tries to get the subsite root for a given resource root path.
protected  CmsProject getTempfileProject(CmsObject cms)
          Gets a tempfile project, creating one if it doesn't exist already.
 void handleHtmlRedirect(CmsObject userCms, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String htmlRedirect)
          Processes a HTML redirect content.
 void initialize()
          Initializes the configuration by reading all configuration files and caching their data.
protected  CmsADEConfigData internalLookupConfiguration(CmsObject cms, java.lang.String rootPath)
          Internal configuration lookup method.
 boolean isDetailPage(CmsObject cms, CmsResource resource)
          Checks whether the given resource is configured as a detail page.
 boolean isInitialized()
          Checks whether the ADE manager is initialized (this should usually be the case except during the setup).
 CmsADEConfigData lookupConfiguration(CmsObject cms, java.lang.String rootPath)
          Looks up the configuration data for a given sitemap path.
 void refresh()
          Reloads the configuration.
 boolean saveDetailPages(CmsObject cms, java.lang.String rootPath, java.util.List<CmsDetailPageInfo> detailPages, CmsUUID newId)
          Saves a list of detail pages.
 void saveFavoriteList(CmsObject cms, java.util.List<CmsContainerElementBean> favoriteList)
          Saves the favorite list, user based.
 void saveInheritedContainer(CmsObject cms, CmsResource pageResource, java.lang.String name, boolean newOrder, java.util.List<CmsContainerElementBean> elements)
          Saves the inheritance container information.
 void saveInheritedContainer(CmsObject cms, java.lang.String sitePath, java.lang.String name, boolean newOrder, java.util.List<CmsContainerElementBean> elements)
          Saves the inheritance container information.
 void saveRecentList(CmsObject cms, java.util.List<CmsContainerElementBean> recentList)
          Saves the favorite list, user based.
 void shutdown()
          The method which is called when the OpenCms instance is shut down.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ADDINFO_ADE_FAVORITE_LIST_SIZE

public static final java.lang.String ADDINFO_ADE_FAVORITE_LIST_SIZE
User additional info key constant.

See Also:
Constant Field Values

ADDINFO_ADE_RECENT_LIST_SIZE

public static final java.lang.String ADDINFO_ADE_RECENT_LIST_SIZE
User additional info key constant.

See Also:
Constant Field Values

ADDINFO_ADE_SEARCH_PAGE_SIZE

public static final java.lang.String ADDINFO_ADE_SEARCH_PAGE_SIZE
User additional info key constant.

See Also:
Constant Field Values

CLIENT_ID_SEPERATOR

public static final java.lang.String CLIENT_ID_SEPERATOR
The client id separator.

See Also:
Constant Field Values

CONFIG_FILE_NAME

public static final java.lang.String CONFIG_FILE_NAME
The configuration file name.

See Also:
Constant Field Values

CONFIG_FOLDER_TYPE

public static final java.lang.String CONFIG_FOLDER_TYPE
The name of the sitemap configuration file type.

See Also:
Constant Field Values

CONFIG_SUFFIX

public static final java.lang.String CONFIG_SUFFIX
The path for sitemap configuration files relative from the base path.

See Also:
Constant Field Values

CONFIG_TYPE

public static final java.lang.String CONFIG_TYPE
The name of the sitemap configuration file type.

See Also:
Constant Field Values

CONTENT_FOLDER_NAME

public static final java.lang.String CONTENT_FOLDER_NAME
The content folder name.

See Also:
Constant Field Values

DEFAULT_FAVORITE_LIST_SIZE

public static final int DEFAULT_FAVORITE_LIST_SIZE
Default favorite list size constant.

See Also:
Constant Field Values

DEFAULT_RECENT_LIST_SIZE

public static final int DEFAULT_RECENT_LIST_SIZE
Default recent list size constant.

See Also:
Constant Field Values

MODULE_CONFIG_TYPE

public static final java.lang.String MODULE_CONFIG_TYPE
The name of the module configuration file type.

See Also:
Constant Field Values

N_LINK

public static final java.lang.String N_LINK
Node name for the nav level link value.

See Also:
Constant Field Values

N_TYPE

public static final java.lang.String N_TYPE
Node name for the nav level type value.

See Also:
Constant Field Values

PATH_SITEMAP_EDITOR_JSP

public static final java.lang.String PATH_SITEMAP_EDITOR_JSP
The path to the sitemap editor JSP.

See Also:
Constant Field Values

ADDINFO_ADE_FAVORITE_LIST

protected static final java.lang.String ADDINFO_ADE_FAVORITE_LIST
User additional info key constant.

See Also:
Constant Field Values

ADDINFO_ADE_RECENT_LIST

protected static final java.lang.String ADDINFO_ADE_RECENT_LIST
User additional info key constant.

See Also:
Constant Field Values
Constructor Detail

CmsADEManager

public CmsADEManager(CmsObject adminCms,
                     CmsMemoryMonitor memoryMonitor,
                     CmsSystemConfiguration systemConfiguration)
Creates a new ADE manager.

Parameters:
adminCms - a CMS context with admin privileges
memoryMonitor - the memory monitor instance
systemConfiguration - the system configuration
Method Detail

findEntryPoint

public java.lang.String findEntryPoint(CmsObject cms,
                                       java.lang.String openPath)
Finds the entry point to a sitemap.

Parameters:
cms - the CMS context
openPath - the resource path to find the sitemap to
Returns:
the sitemap entry point

getAllDetailPages

public java.util.List<CmsDetailPageInfo> getAllDetailPages(CmsObject cms)
Gets the complete list of beans for the currently configured detail pages.

Parameters:
cms - the CMS context to use
Returns:
the list of detail page infos

getCache

public CmsADECache getCache()
Gets the containerpage cache instance.

Returns:
the containerpage cache instance

getConfigurationType

public I_CmsResourceType getConfigurationType()
Gets the configuration file type.

Returns:
the configuration file type

getCurrentElement

public CmsContainerElementBean getCurrentElement(javax.servlet.ServletRequest req)
                                          throws CmsException
Reads the current element bean from the request.

Parameters:
req - the servlet request
Returns:
the element bean
Throws:
CmsException - if no current element is set

getDetailPage

public java.lang.String getDetailPage(CmsObject cms,
                                      java.lang.String pageRootPath,
                                      java.lang.String originPath)
Gets the detail page for a content element.

Parameters:
cms - the CMS context
pageRootPath - the element's root path
originPath - the path in which the the detail page is being requested
Returns:
the detail page for the content element

getDetailPageFinder

public I_CmsDetailPageFinder getDetailPageFinder()
Gets the detail page finder.

Returns:
the detail page finder

getDetailPages

public java.util.List<java.lang.String> getDetailPages(CmsObject cms,
                                                       java.lang.String type)
Returns the main detail pages for a type in all of the VFS tree.

Parameters:
cms - the current CMS context
type - the resource type name
Returns:
a list of detail page root paths

getDetailPageTypes

public java.util.Set<java.lang.String> getDetailPageTypes(CmsObject cms)
Gets the set of types for which detail pages are defined.

Parameters:
cms - the current CMS context
Returns:
the set of types for which detail pages are defined

getElementSettings

public java.util.Map<java.lang.String,CmsXmlContentProperty> getElementSettings(CmsObject cms,
                                                                                CmsResource resource)
                                                                         throws CmsException
Returns the element settings for a given resource.

Parameters:
cms - the current cms context
resource - the resource
Returns:
the element settings for a given resource
Throws:
CmsException - if something goes wrong

getFavoriteList

public java.util.List<CmsContainerElementBean> getFavoriteList(CmsObject cms)
                                                        throws CmsException
Returns the favorite list, or creates it if not available.

Parameters:
cms - the cms context
Returns:
the favorite list
Throws:
CmsException - if something goes wrong

getInheritedContainerState

public CmsInheritedContainerState getInheritedContainerState(CmsObject cms,
                                                             CmsResource resource,
                                                             java.lang.String name)
Returns the inheritance state for the given inheritance name and resource.

Parameters:
cms - the current cms context
resource - the resource
name - the inheritance name
Returns:
the inheritance state

getInheritedContainerState

public CmsInheritedContainerState getInheritedContainerState(CmsObject cms,
                                                             java.lang.String rootPath,
                                                             java.lang.String name)
                                                      throws CmsException
Returns the inheritance state for the given inheritance name and root path.

Parameters:
cms - the current cms context
rootPath - the root path
name - the inheritance name
Returns:
the inheritance state
Throws:
CmsException - if something goes wrong

getMaxSitemapDepth

public int getMaxSitemapDepth()
Gets the maximum sitemap depth.

Returns:
the maximum sitemap depth

getModuleConfigurationType

public I_CmsResourceType getModuleConfigurationType()
Gets the module configuration resource type.

Returns:
the module configuration resource type

getRecentList

public java.util.List<CmsContainerElementBean> getRecentList(CmsObject cms)
                                                      throws CmsException
Returns the favorite list, or creates it if not available.

Parameters:
cms - the cms context
Returns:
the favorite list
Throws:
CmsException - if something goes wrong

getRecentListMaxSize

public int getRecentListMaxSize(CmsUser user)
Gets the maximum length of the recent list.

Parameters:
user - the user for which to get the maximum length
Returns:
the maximum recent list size for the user

getSubSiteRoot

public java.lang.String getSubSiteRoot(CmsObject cms,
                                       java.lang.String rootPath)
Tries to get the subsite root for a given resource root path.

Parameters:
cms - the current CMS context
rootPath - the root path for which the subsite root should be found
Returns:
the subsite root

handleHtmlRedirect

public void handleHtmlRedirect(CmsObject userCms,
                               javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               java.lang.String htmlRedirect)
                        throws java.lang.Exception
Processes a HTML redirect content.

This needs to be in the ADE manager because the user for whom the HTML redirect is being loaded does not necessarily have read permissions for the redirect target, so we read the redirect target with admin privileges.

Parameters:
userCms - the CMS context of the current user
request - the servlet request
response - the servlet response
htmlRedirect - the path of the HTML redirect resource
Throws:
java.lang.Exception - if something goes wrong

initialize

public void initialize()
Initializes the configuration by reading all configuration files and caching their data.


isDetailPage

public boolean isDetailPage(CmsObject cms,
                            CmsResource resource)
Checks whether the given resource is configured as a detail page.

Parameters:
cms - the current CMS context
resource - the resource which should be tested
Returns:
true if the resource is configured as a detail page

isInitialized

public boolean isInitialized()
Checks whether the ADE manager is initialized (this should usually be the case except during the setup).

Returns:
true if the ADE manager is initialized

lookupConfiguration

public CmsADEConfigData lookupConfiguration(CmsObject cms,
                                            java.lang.String rootPath)
Looks up the configuration data for a given sitemap path.

Parameters:
cms - the current CMS context
rootPath - the root path for which the configuration data should be looked up
Returns:
the configuration data

refresh

public void refresh()
Reloads the configuration.

Normally you shouldn't call this directly since the event handlers take care of updating the configuration.


saveDetailPages

public boolean saveDetailPages(CmsObject cms,
                               java.lang.String rootPath,
                               java.util.List<CmsDetailPageInfo> detailPages,
                               CmsUUID newId)
                        throws CmsException
Saves a list of detail pages.

Parameters:
cms - the cms context
rootPath - the root path
detailPages - the detail pages
newId - the id to use for new detail pages without an id
Returns:
true if the detail pages could be successfully saved
Throws:
CmsException - if something goes wrong

saveFavoriteList

public void saveFavoriteList(CmsObject cms,
                             java.util.List<CmsContainerElementBean> favoriteList)
                      throws CmsException
Saves the favorite list, user based.

Parameters:
cms - the cms context
favoriteList - the element list
Throws:
CmsException - if something goes wrong

saveInheritedContainer

public void saveInheritedContainer(CmsObject cms,
                                   CmsResource pageResource,
                                   java.lang.String name,
                                   boolean newOrder,
                                   java.util.List<CmsContainerElementBean> elements)
                            throws CmsException
Saves the inheritance container information.

Parameters:
cms - the current cms context
pageResource - the resource or parent folder
name - the inheritance name
newOrder - if the element have been reordered
elements - the elements
Throws:
CmsException - if something goes wrong

saveInheritedContainer

public void saveInheritedContainer(CmsObject cms,
                                   java.lang.String sitePath,
                                   java.lang.String name,
                                   boolean newOrder,
                                   java.util.List<CmsContainerElementBean> elements)
                            throws CmsException
Saves the inheritance container information.

Parameters:
cms - the current cms context
sitePath - the site path of the resource or parent folder
name - the inheritance name
newOrder - if the element have been reordered
elements - the elements
Throws:
CmsException - if something goes wrong

saveRecentList

public void saveRecentList(CmsObject cms,
                           java.util.List<CmsContainerElementBean> recentList)
                    throws CmsException
Saves the favorite list, user based.

Parameters:
cms - the cms context
recentList - the element list
Throws:
CmsException - if something goes wrong

shutdown

public void shutdown()
The method which is called when the OpenCms instance is shut down.


elementFromJson

protected CmsContainerElementBean elementFromJson(JSONObject data)
                                           throws JSONException
Creates an element from its serialized data.

Parameters:
data - the serialized data
Returns:
the restored element bean
Throws:
JSONException - if the serialized data got corrupted

elementToJson

protected JSONObject elementToJson(CmsContainerElementBean element,
                                   java.util.Set<java.lang.String> excludeSettings)
Converts the given element to JSON.

Parameters:
element - the element to convert
excludeSettings - the keys of settings which should not be written to the JSON
Returns:
the JSON representation

getOfflineCache

protected org.opencms.ade.configuration.CmsConfigurationCache getOfflineCache()
Gets the offline cache.

Returns:
the offline configuration cache

getOnlineCache

protected org.opencms.ade.configuration.CmsConfigurationCache getOnlineCache()
Gets the online cache.

Returns:
the online configuration cache

getRootPath

protected java.lang.String getRootPath(CmsUUID structureId,
                                       boolean online)
                                throws CmsException
Gets the root path for a given resource structure id.

Parameters:
structureId - the structure id
online - if true, the resource will be looked up in the online project ,else in the offline project
Returns:
the root path for the given structure id
Throws:
CmsException - if something goes wrong

getTempfileProject

protected CmsProject getTempfileProject(CmsObject cms)
                                 throws CmsException
Gets a tempfile project, creating one if it doesn't exist already.

Parameters:
cms - the CMS context to use
Returns:
the tempfile project
Throws:
CmsException - if something goes wrong

internalLookupConfiguration

protected CmsADEConfigData internalLookupConfiguration(CmsObject cms,
                                                       java.lang.String rootPath)
Internal configuration lookup method.

Parameters:
cms - the cms context
rootPath - the root path for which to look up the configuration
Returns:
the configuration for the given path