org.opencms.ade.configuration
Class CmsADEManager

java.lang.Object
  extended by org.opencms.ade.configuration.CmsADEManager
All Implemented Interfaces:
I_CmsEventListener

public class CmsADEManager
extends Object
implements I_CmsEventListener

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 String ADDINFO_ADE_FAVORITE_LIST
          User additional info key constant.
static String ADDINFO_ADE_FAVORITE_LIST_SIZE
          User additional info key constant.
protected static String ADDINFO_ADE_RECENT_LIST
          User additional info key constant.
static String ADDINFO_ADE_RECENT_LIST_SIZE
          User additional info key constant.
static String ADDINFO_ADE_SEARCH_PAGE_SIZE
          User additional info key constant.
static String CLIENT_ID_SEPERATOR
          The client id separator.
static String CONFIG_FILE_NAME
          The configuration file name.
static String CONFIG_FOLDER_NAME
          The content folder name.
static String CONFIG_FOLDER_TYPE
          The name of the sitemap configuration file type.
static String CONFIG_SUFFIX
          The path for sitemap configuration files relative from the base path.
static String CONFIG_TYPE
          The name of the sitemap configuration file type.
static int DEFAULT_FAVORITE_LIST_SIZE
          Default favorite list size constant.
static int DEFAULT_RECENT_LIST_SIZE
          Default recent list size constant.
static String MODULE_CONFIG_TYPE
          The name of the module configuration file type.
static String PATH_SITEMAP_EDITOR_JSP
          The path to the sitemap editor JSP.
 
Fields inherited from interface org.opencms.main.I_CmsEventListener
EVENT_BEFORE_PUBLISH_PROJECT, EVENT_CLEAR_CACHES, EVENT_CLEAR_OFFLINE_CACHES, EVENT_CLEAR_ONLINE_CACHES, EVENT_CLEAR_PRINCIPAL_CACHES, EVENT_FLEX_CACHE_CLEAR, EVENT_FLEX_PURGE_JSP_REPOSITORY, EVENT_FULLSTATIC_EXPORT, EVENT_GROUP_MODIFIED, EVENT_LOGIN_USER, EVENT_OU_MODIFIED, EVENT_PROJECT_MODIFIED, EVENT_PROPERTY_DEFINITION_CREATED, EVENT_PROPERTY_DEFINITION_MODIFIED, EVENT_PROPERTY_MODIFIED, EVENT_PUBLISH_PROJECT, EVENT_REBUILD_SEARCHINDEXES, EVENT_RESOURCE_AND_PROPERTIES_MODIFIED, EVENT_RESOURCE_COPIED, EVENT_RESOURCE_CREATED, EVENT_RESOURCE_DELETED, EVENT_RESOURCE_MODIFIED, EVENT_RESOURCE_MOVED, EVENT_RESOURCES_AND_PROPERTIES_MODIFIED, EVENT_RESOURCES_MODIFIED, EVENT_SITEMAP_CHANGED, EVENT_UPDATE_EXPORTS, EVENT_USER_MODIFIED, KEY_CHANGE, KEY_DBCONTEXT, KEY_GROUP_ID, KEY_GROUP_NAME, KEY_INDEX_NAMES, KEY_OU_ID, KEY_OU_NAME, KEY_PROJECTID, KEY_PUBLISHID, KEY_PUBLISHLIST, KEY_REPORT, KEY_RESOURCE, KEY_RESOURCES, KEY_USER_ACTION, KEY_USER_ID, KEY_USER_NAME, LISTENERS_FOR_ALL_EVENTS, VALUE_GROUP_MODIFIED_ACTION_CREATE, VALUE_GROUP_MODIFIED_ACTION_DELETE, VALUE_GROUP_MODIFIED_ACTION_WRITE, VALUE_OU_MODIFIED_ACTION_CREATE, VALUE_OU_MODIFIED_ACTION_DELETE, VALUE_USER_MODIFIED_ACTION_ADD_USER_TO_GROUP, VALUE_USER_MODIFIED_ACTION_CREATE_USER, VALUE_USER_MODIFIED_ACTION_DELETE_USER, VALUE_USER_MODIFIED_ACTION_REMOVE_USER_FROM_GROUP, VALUE_USER_MODIFIED_ACTION_RESET_PASSWORD, VALUE_USER_MODIFIED_ACTION_SET_OU, VALUE_USER_MODIFIED_ACTION_WRITE_USER
 
Constructor Summary
CmsADEManager(CmsObject adminCms, CmsMemoryMonitor memoryMonitor, CmsSystemConfiguration systemConfiguration)
          Creates a new ADE manager.
 
Method Summary
 void cmsEvent(CmsEvent event)
          Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.
protected  CmsContainerElementBean elementFromJson(JSONObject data)
          Creates an element from its serialized data.
protected  JSONObject elementToJson(CmsContainerElementBean element)
          Converts the given element to JSON.
 String findEntryPoint(CmsObject cms, String openPath)
          Finds the entry point to a sitemap.
 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.
 String getDetailPage(CmsObject cms, String pageRootPath, String originPath)
          Gets the detail page for a content element.
 I_CmsDetailPageFinder getDetailPageFinder()
          Gets the detail page finder.
 List<String> getDetailPages(CmsObject cms, String type)
          Returns the main detail pages for a type in all of the VFS tree.
 Map<String,CmsXmlContentProperty> getElementSettings(CmsObject cms, CmsResource resource)
          Returns the element settings for a given resource.
 List<CmsContainerElementBean> getFavoriteList(CmsObject cms)
          Returns the favorite list, or creates it if not available.
 int getMaxSitemapDepth()
          Gets the maximum sitemap depth.
 I_CmsResourceType getModuleConfigurationType()
          Gets the module configuration resource type.
 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  String getRootPath(CmsUUID structureId, boolean online)
          Gets the root path for a given resource structure id.
 String getSubSiteRoot(CmsObject cms, 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 initialize()
          Initializes the configuration by reading all configuration files and caching their data.
protected  CmsADEConfigData internalLookupConfiguration(CmsObject cms, String rootPath)
          Internal configuration lookup method.
 boolean isInitialized()
          Checks whether the ADE manager is initialized (this should usually be the case except during the setup).
 CmsADEConfigData lookupConfiguration(CmsObject cms, String rootPath)
          Looks up the configuration data for a given sitemap path.
 void refresh()
          Reloads the configuration.
 boolean saveDetailPages(CmsObject cms, String rootPath, List<CmsDetailPageInfo> detailPages, CmsUUID newId)
          Saves a list of detail pages.
 void saveFavoriteList(CmsObject cms, List<CmsContainerElementBean> favoriteList)
          Saves the favorite list, user based.
 void saveRecentList(CmsObject cms, 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 String ADDINFO_ADE_FAVORITE_LIST_SIZE
User additional info key constant.

See Also:
Constant Field Values

ADDINFO_ADE_RECENT_LIST_SIZE

public static final String ADDINFO_ADE_RECENT_LIST_SIZE
User additional info key constant.

See Also:
Constant Field Values

ADDINFO_ADE_SEARCH_PAGE_SIZE

public static final String ADDINFO_ADE_SEARCH_PAGE_SIZE
User additional info key constant.

See Also:
Constant Field Values

CLIENT_ID_SEPERATOR

public static final String CLIENT_ID_SEPERATOR
The client id separator.

See Also:
Constant Field Values

CONFIG_FILE_NAME

public static final String CONFIG_FILE_NAME
The configuration file name.

See Also:
Constant Field Values

CONFIG_FOLDER_NAME

public static final String CONFIG_FOLDER_NAME
The content folder name.

See Also:
Constant Field Values

CONFIG_FOLDER_TYPE

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

See Also:
Constant Field Values

CONFIG_SUFFIX

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

See Also:
Constant Field Values

CONFIG_TYPE

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

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 String MODULE_CONFIG_TYPE
The name of the module configuration file type.

See Also:
Constant Field Values

PATH_SITEMAP_EDITOR_JSP

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

See Also:
Constant Field Values

ADDINFO_ADE_FAVORITE_LIST

protected static final String ADDINFO_ADE_FAVORITE_LIST
User additional info key constant.

See Also:
Constant Field Values

ADDINFO_ADE_RECENT_LIST

protected static final 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

cmsEvent

public void cmsEvent(CmsEvent event)
Description copied from interface: I_CmsEventListener
Acknowledge the occurrence of the specified event, implement this method to check for CmsEvents in your class.

Specified by:
cmsEvent in interface I_CmsEventListener
Parameters:
event - CmsEvent that has occurred
See Also:
I_CmsEventListener.cmsEvent(org.opencms.main.CmsEvent)

findEntryPoint

public String findEntryPoint(CmsObject cms,
                             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

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 String getDetailPage(CmsObject cms,
                            String pageRootPath,
                            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 List<String> getDetailPages(CmsObject cms,
                                   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

getElementSettings

public Map<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 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

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 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 String getSubSiteRoot(CmsObject cms,
                             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

initialize

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


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,
                                            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,
                               String rootPath,
                               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,
                             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

saveRecentList

public void saveRecentList(CmsObject cms,
                           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)
Converts the given element to JSON.

Parameters:
element - the element to convert
Returns:
the JSON representation

getRootPath

protected 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,
                                                       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