Package org.opencms.ade.containerpage
Class CmsModelGroupHelper
java.lang.Object
org.opencms.ade.containerpage.CmsModelGroupHelper
Handles all model group specific tasks.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the container storing the groups base element. -
Constructor Summary
ConstructorDescriptionCmsModelGroupHelper
(CmsObject cms, CmsADEConfigData configData, CmsADESessionCache sessionCache, boolean isEditingModelGroups) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic CmsResource
createModelGroup
(CmsObject cms, CmsADEConfigData configData) Creates a new model group resource.static boolean
isModelGroupResource
(CmsResource resource) Returns if the given resource is a model group resource.prepareforModelGroupContent
(Map<String, CmsContainerElementBean> elements, List<String> foundGroups, CmsContainerPageBean page, boolean alwaysCopy, Locale locale, String createContextPath) Adds the model group elements to the page.Reads the present model groups and merges their containers into the page.Removes the model group containers.saveModelGroups
(CmsContainerPageBean page, CmsResource pageResource) Saves the model groups of the given container page.static boolean
updateModelGroupResource
(CmsObject cms, CmsResource group, String baseContainerName) Updates a model group resource to the changed data structure.static void
updateModelGroupResources
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String basePath, String baseContainerName) Updates model group resources to the changed data structure.
-
Field Details
-
MODEL_GROUP_BASE_CONTAINER
The name of the container storing the groups base element.- See Also:
-
-
Constructor Details
-
CmsModelGroupHelper
public CmsModelGroupHelper(CmsObject cms, CmsADEConfigData configData, CmsADESessionCache sessionCache, boolean isEditingModelGroups) Constructor.- Parameters:
cms
- the current cms contextconfigData
- the configuration datasessionCache
- the session cacheisEditingModelGroups
- the edit model groups flag
-
-
Method Details
-
createModelGroup
public static CmsResource createModelGroup(CmsObject cms, CmsADEConfigData configData) throws CmsException Creates a new model group resource.- Parameters:
cms
- the current cms contextconfigData
- the configuration data- Returns:
- the new resource
- Throws:
CmsException
- in case creating the resource fails
-
isModelGroupResource
Returns if the given resource is a model group resource.- Parameters:
resource
- the resource- Returns:
true
if the given resource is a model group resource
-
updateModelGroupResource
public static boolean updateModelGroupResource(CmsObject cms, CmsResource group, String baseContainerName) Updates a model group resource to the changed data structure.This step is necessary when updating from version 10.0.x to 10.5.x.
- Parameters:
cms
- the cms contextgroup
- the model group resourcebaseContainerName
- the new base container name- Returns:
true
if the resource was updated
-
updateModelGroupResources
public static void updateModelGroupResources(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String basePath, String baseContainerName) throws IOException Updates model group resources to the changed data structure.This step is necessary when updating from version 10.0.x to 10.5.x.
- Parameters:
request
- the requestresponse
- the responsebasePath
- the path to the model group, or the base path to search for model groupsbaseContainerName
- the new base container name- Throws:
IOException
- in case writing to the response fails
-
prepareforModelGroupContent
public CmsContainerPageBean prepareforModelGroupContent(Map<String, CmsContainerElementBean> elements, List<String> foundGroups, CmsContainerPageBean page, boolean alwaysCopy, Locale locale, String createContextPath) throws CmsExceptionAdds the model group elements to the page.- Parameters:
elements
- the requested elementsfoundGroups
- list to add the found group element client ids topage
- the pagealwaysCopy
-true
to create element copies in case of non model groups and createNew is setlocale
- the content localecreateContextPath
- the context path to pass to CmsResourceTypeConfig#createNewElement- Returns:
- the adjusted page
- Throws:
CmsException
- in case something goes wrong
-
readModelGroups
Reads the present model groups and merges their containers into the page.- Parameters:
page
- the container page- Returns:
- the resulting container page
-
removeModelGroupContainers
Removes the model group containers.- Parameters:
page
- the container page state- Returns:
- the container page without the model group containers
-
saveModelGroups
public CmsContainerPageBean saveModelGroups(CmsContainerPageBean page, CmsResource pageResource) throws CmsException Saves the model groups of the given container page.- Parameters:
page
- the container pagepageResource
- the model group resource- Returns:
- the container page referencing the saved model groups
- Throws:
CmsException
- in case writing the page properties fails
-