diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/CMSDispatcher.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/CMSDispatcher.java deleted file mode 100755 index d5a83e93d..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/CMSDispatcher.java +++ /dev/null @@ -1,718 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.dispatcher; - -import com.arsdigita.dispatcher.ChainedDispatcher; -import com.arsdigita.dispatcher.Dispatcher; -import com.arsdigita.dispatcher.DispatcherHelper; -import com.arsdigita.dispatcher.JSPApplicationDispatcher; -import com.arsdigita.dispatcher.RedirectException; -import com.arsdigita.dispatcher.RequestContext; -import com.arsdigita.util.UncheckedWrapperException; -import com.arsdigita.web.LoginSignal; -import com.arsdigita.web.URL; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.shiro.authz.AuthorizationException; -import org.libreccm.cdi.utils.CdiUtil; -import org.libreccm.core.UnexpectedErrorException; -import org.libreccm.security.PermissionChecker; -import org.libreccm.security.Shiro; -import org.libreccm.security.User; -import org.librecms.CmsConstants; -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentSection; -import org.librecms.contentsection.ContentSectionManager; -import org.librecms.contentsection.ContentSectionRepository; -import org.librecms.contentsection.privileges.ItemPrivileges; -import org.librecms.dispatcher.ItemResolver; - -/** - *
- * The CMS Dispatcher serves all request made within a content section. This - * dispatcher is called by the Subsite dispatcher.
- * - *- * Here are the steps for a request to - * http://yourserver/cms/cheese in excruciating detail:
- * - *- * A client sends a request to the web server, which passes it on to the global - * ACS dispatcher.
- * The global ACS dispatcher examines the first part of the URL, notices that - * CMS is mounted at /cms and hands the request to the CMS - * dispatcher.
- * The CMS dispatcher determines whether a Page has been registered to - * the URL /cheese in this section via its - * {@link com.arsdigita.cms.dispatcher.PageResolver}.
- * Since no page is registered to the URL, the CMS dispatcher asks the content - * section (via its {@link com.arsdigita.cms.dispatcher.ItemResolver}) for a - * content item for /cheese in this content section. The result of this - * process is a {@link com.arsdigita.cms.ContentItem} object.
- * The CMS dispatcher asks the content section for a Page - * to use as the "master template" for this item. The content section may apply - * item-, type-, or request-specific rules to make this decision (for example, - * check a user preference for normal or accessible style, or a query parameter - * for a printable version).
- * The CMS dispatcher hands the master Page object to the - * {@link com.arsdigita.sitenode.SiteNodePresentationManager} to serve the - * page.
- * The presentation manager asks the master Page object for an XML - * document representing the data for the page.
- * The master template begins walking through its component hierarchy, - * converting each component to XML by calling its - * generateXML method. The component responsible for rendering the - * content item uses an {@link com.arsdigita.cms.dispatcher.XMLGenerator} to - * convert the content item to XML.
- * The presentation manager receives the completed XML document, and selects an - * XSL transformer to use for generating the HTML. The stylesheet on which the - * transformer is based contains templates for all styles and all content types - * in the content section, in particular those from the file - * cms-item.xsl.
- * A CMSPage is a Bebop {@link com.arsdigita.bebop.Page} implementation - * of the {@link com.arsdigita.cms.dispatcher.ResourceHandler} interface.
- * - *- * It stores the current {@link com.arsdigita.cms.ContentSection} and, if - * applicable, the {@link com.arsdigita.cms.ContentItem} in the page state as - * request local objects. Components that are part of the CMSPage - * may access these objects by calling:
- *
- * getContentSection(PageState state);
- *
- *
- * @author Michael Pih (pihman@arsdigita.com)
- * @author Uday Mathur (umathur@arsdigita.com)
- */
-public class CMSPage extends Page implements ResourceHandler {
-
- private static final Logger LOGGER = LogManager.getLogger(CMSPage.class);
-
- /**
- * The global assets URL stub XML parameter name.
- */
- public final static String ASSETS = "ASSETS";
-
- /**
- * The XML page class.
- */
- public final static String PAGE_CLASS = "CMS";
-
- /**
- * Map of XML parameters
- */
- private HashMap m_params;
-
- /**
- * */
- private PageTransformer m_transformer;
-
- public CMSPage() {
- super();
- buildPage();
- }
-
- public CMSPage(String title) {
- super(title);
- buildPage();
- }
-
- public CMSPage(String title, Container panel) {
- super(title, panel);
- buildPage();
- }
-
- public CMSPage(Label title) {
- super(title);
- buildPage();
- }
-
- public CMSPage(Label title, Container panel) {
- super(title, panel);
- buildPage();
- }
-
- /**
- * Builds the page.
- */
- protected void buildPage() {
- // Set the class attribute value. May be overwritten by child class
- // to hold a more specific value
- setClassAttr(PAGE_CLASS);
-
- // Global XML params.
- // MP: This only works with older versions of Xalan.
- m_params = new HashMap();
- setXMLParameter(ASSETS, Utilities.getGlobalAssetsURL());
-
- // MP: This is a hack to so that the XML params work with the newer
- // version of Xalan.
- // Sets attribute in SimpleComponent, attributes of the same name will
- // be overweritten.
- setAttribute(ASSETS, Utilities.getGlobalAssetsURL());
-
- // Make sure the error display gets rendered.
- getErrorDisplay().setIdAttr("page-body");
-
- final Class
- * This ContentPanel component fetches the
- * {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content
- * section.
XMLGenerator registered to the current
- * {@link com.arsdigita.cms.ContentSection}.
- *
- * @param state The page state
- *
- * @return The XMLGenerator used by this Content Panel
- */
- protected XMLGenerator getXMLGenerator(PageState state) {
- ContentSection section = CMS.getContext().getContentSection();
- Assert.exists(section);
- try {
- return (XMLGenerator) Class.forName(section.getXmlGeneratorClass())
- .newInstance();
- } catch (ClassNotFoundException |
- InstantiationException |
- IllegalAccessException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Generates XML that represents a content item.
- *
- * @param state The page state
- * @param parent The parent DOM element
- *
- * @see com.arsdigita.cms.dispatcher.XMLGenerator
- */
- @Override
- public void generateXML(PageState state, Element parent) {
- if (isVisible(state)) {
- Element content = parent.newChildElement("cms:contentPanel",
- CMS.CMS_XML_NS);
- exportAttributes(content);
-
- // Generate path information about the content item
- generatePathInfoXML(state, content);
-
- // Take advantage of caching in the CMS Dispatcher.
- XMLGenerator xmlGenerator = getXMLGenerator(state);
-
- xmlGenerator.generateXML(state, content, null);
- }
- }
-
- /**
- * Generate information about the path to this content item.
- *
- * @param state the page state
- * @param parent the element that will contain the path info
- */
- protected void generatePathInfoXML(PageState state, Element parent) {
- Element pathInfo = parent
- .newChildElement("cms:pathInfo", CMS.CMS_XML_NS);
-
- if (CMS.getContext().hasContentSection()) {
- pathInfo.newChildElement("cms:sectionPath", CMS.CMS_XML_NS).setText(
- CMS.getContext().getContentSection().getPrimaryUrl());
- }
- String url = DispatcherHelper.getRequestContext().getRemainingURLPart();
- if (url.startsWith(CMSDispatcher.PREVIEW)) {
- pathInfo.newChildElement("cms:previewPath", CMS.CMS_XML_NS).setText(
- "preview");
- }
- pathInfo.newChildElement("cms:templatePrefix", CMS.CMS_XML_NS).setText(
- "/" + ItemResolver.TEMPLATE_CONTEXT_PREFIX);
-
- if (CMS.getContext().hasContentItem()) {
- ContentItem item = CMS.getContext().getContentItem();
- pathInfo.newChildElement("cms:itemPath", CMS.CMS_XML_NS).setText("/"
- + item.getName());
- }
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java
deleted file mode 100755
index b77290f96..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.dispatcher;
-
-import com.arsdigita.dispatcher.Dispatcher;
-import com.arsdigita.dispatcher.DispatcherChain;
-import com.arsdigita.dispatcher.RequestContext;
-import com.arsdigita.util.Assert;
-import com.arsdigita.web.Web;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.web.ApplicationManager;
-import org.librecms.CmsConstants;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.privileges.ItemPrivileges;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Unsupported Refactored content section
- * dispatcher (under development).
- *
- * @author Karl Goldstein (karlg@arsdigita.com)
- * @version $Revision$ $DateTime: 2004/08/17 23:15:09 $
- * @version $Id$
- */
-public class ContentSectionDispatcher implements Dispatcher {
-
- public static final String CONTENT_ITEM
- = "com.arsdigita.cms.dispatcher.item";
-
- static final String CONTENT_SECTION = "com.arsdigita.cms.dispatcher.section";
-
- private DispatcherChain dispatcherChain = new DispatcherChain();
-
- public ContentSectionDispatcher() {
-
-// dispatcherChain.addChainedDispatcher(new CMSDispatcher(true));
-// dispatcherChain.addChainedDispatcher(new FileDispatcher());
-// dispatcherChain.addChainedDispatcher(new ItemDispatcher());
-// dispatcherChain.addChainedDispatcher(new CMSDispatcher());
- }
-
- public void dispatch(HttpServletRequest request,
- HttpServletResponse response,
- RequestContext context)
- throws IOException, ServletException {
-
- setContentSection(request, context);
- dispatcherChain.dispatch(request, response, context);
- }
-
- /**
- * Fetches the content section from the request attributes.
- *
- * @param request The HTTP request
- *
- * @return The content section
- *
- * @pre ( request != null )
- */
- public static ContentSection getContentSection(HttpServletRequest request) {
- return (ContentSection) request.getAttribute(CONTENT_SECTION);
- }
-
- /**
- * Fetches the content item from the request attributes.
- *
- * @param request The HTTP request
- *
- * @return The content item
- *
- * @pre ( request != null )
- */
- public static ContentItem getContentItem(HttpServletRequest request) {
- return (ContentItem) request.getAttribute(CONTENT_ITEM);
- }
-
- /**
- * Looks up the current content section using the remaining URL stored in
- * the request context object and the SiteNode class.
- *
- * @param url The section URL stub
- *
- * @return The current Content Section
- */
- private void setContentSection(HttpServletRequest request,
- // SiteNodeRequestContext actx)
- RequestContext actx)
- throws ServletException {
-
- final ContentSection section = (ContentSection) Web.getWebContext()
- .getApplication();
- request.setAttribute(CONTENT_SECTION, section);
- }
-
- /**
- * Checks that the current user has permission to access the admin pages.
- *
- * @param request
- * @param section
- */
- public static boolean checkAdminAccess(HttpServletRequest request,
- ContentSection section) {
-
- return CdiUtil.createCdiUtil().findBean(PermissionChecker.class)
- .isPermitted(ItemPrivileges.EDIT, section
- .getRootDocumentsFolder());
- }
-
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemDispatcher.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemDispatcher.java
deleted file mode 100755
index 1d4ea4cb4..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemDispatcher.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.dispatcher;
-
-import com.arsdigita.dispatcher.ChainedDispatcher;
-import com.arsdigita.dispatcher.DispatcherHelper;
-import com.arsdigita.dispatcher.RequestContext;
-import com.arsdigita.web.LoginSignal;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.libreccm.cdi.utils.CdiUtil;
-import org.libreccm.security.PermissionChecker;
-import org.libreccm.security.Shiro;
-import org.librecms.contentsection.ContentItem;
-import org.librecms.contentsection.ContentSection;
-import org.librecms.contentsection.ContentSectionManager;
-import org.librecms.contentsection.ContentSectionServlet;
-import org.librecms.contentsection.privileges.ItemPrivileges;
-import org.librecms.dispatcher.ItemResolver;
-
-/**
- * Dispatches to the JSP or Servlet for rendering a content item.
- *
- * @author Karl Goldstein (karlg@arsdigita.com)
- *
- */
-public class ItemDispatcher implements ChainedDispatcher {
-
- private static Logger LOGGER = LogManager.getLogger(ItemDispatcher.class);
-
- public static Map s_itemResolverCache = Collections.synchronizedMap(
- new HashMap());
- public static Map s_templateResolverCache = Collections.synchronizedMap(
- new HashMap());
-
- public static final String FILE_SUFFIX = ".jsp";
- public static final String INDEX_FILE = "/index";
-// public static final String TEMPLATE_ROOT =
-// "/packages/content-section/templates";
-// public static final String DEFAULT_ITEM_TEMPLATE = "/default/item.jsp";
-// public static final String DEFAULT_FOLDER_TEMPLATE = "/default/folder.jsp";
-
- public static final String XML_SUFFIX = ".xml";
- public static final String XML_MODE = "xmlMode";
-
- private static boolean m_cacheItems = true;
-
- /**
- * The context for previewing items
- */
- public static final String PREVIEW = "/preview";
-
- protected ItemXML m_itemXML;
-
- public ItemDispatcher() {
- super();
- m_itemXML = new ItemXML();
- }
-
- public static void setCacheItems(boolean value) {
- m_cacheItems = value;
- }
-
- public int chainedDispatch(final HttpServletRequest request,
- final HttpServletResponse response,
- final RequestContext actx)
- throws IOException, ServletException {
- String queryString = request.getQueryString();
- String url = actx.getRemainingURLPart();
-
- LOGGER.info("Resolving item URL " + url);
-
- if (url.endsWith(XML_SUFFIX)) {
- request.setAttribute(XML_MODE, Boolean.TRUE);
- LOGGER.debug("StraightXML Requested");
- url = "/" + url.substring(0, url.length() - XML_SUFFIX.length());
- } else {
- request.setAttribute(XML_MODE, Boolean.FALSE);
- // it's neither a .jsp or a .xml, thus its an error
- if (url.endsWith(FILE_SUFFIX)) {
- url = "/" + url
- .substring(0, url.length() - FILE_SUFFIX.length());
- } else if (url.endsWith("/")) {
- url = "/" + url.substring(0, url.length() - 1);
- } else {
- LOGGER.warn("Fail: URL doesn't have right suffix.");
- return ChainedDispatcher.DISPATCH_CONTINUE;
- }
- }
-
- final ContentSection section = ContentSectionServlet.getContentSection(
- request);
- // ContentSectionDispatcher.getContentSection(request);
-
- final ContentItem item = getItem(section, url);
- if (item == null) {
- LOGGER.warn("Fail: No live item found matching " + url);
- return ChainedDispatcher.DISPATCH_CONTINUE;
- }
-
- request.setAttribute(ContentSectionDispatcher.CONTENT_ITEM, item);
-
- LOGGER.debug("MATCHED " + item.getObjectId());
-
- // Work out how long to cache for....
- // We take minimum(default timeout, lifecycle expiry)
- //ToDo
-// Lifecycle cycle = item.getLifecycle();
- int expires = DispatcherHelper.getDefaultCacheExpiry();
-// if (cycle != null) {
-// Date endDate = cycle.getEndDate();
-//
-// if (endDate != null) {
-// int maxAge = (int) ( ( endDate.getTime() - System.currentTimeMillis() ) / 1000l );
-// if (maxAge < expires) {
-// expires = maxAge;
-// }
-// }
-// }
-//ToDo end
- // NB, this is not the same as the security check previously
- // We are checking if anyone can access - ie can we allow
- // this page to be publically cached
- if (m_cacheItems && !url.startsWith(PREVIEW)) {
-// if (sm.canAccess((User)null, SecurityManager.PUBLIC_PAGES, item)) {
- if (CdiUtil.createCdiUtil().findBean(PermissionChecker.class)
- .isPermitted(
- ItemPrivileges.VIEW_PUBLISHED, item)) {
- DispatcherHelper.cacheForWorld(response, expires);
- } else {
- DispatcherHelper.cacheForUser(response, expires);
- }
- } else {
- DispatcherHelper.cacheDisable(response);
- }
-
- if (((Boolean) request.getAttribute(XML_MODE)).booleanValue()) {
- m_itemXML.dispatch(request, response, actx);
- return ChainedDispatcher.DISPATCH_BREAK;
- } else {
-
- // normal dispatching
- // This part assumes the template is JSP.
-// final String templateURL = getTemplateURL(section, item, request,
-// actx);
-// s_log.debug("TEMPLATE " + templateURL);
- DispatcherHelper.setRequestContext(request, actx);
- DispatcherHelper.forwardRequestByPath(null, request,
- response);
- return ChainedDispatcher.DISPATCH_BREAK;
- }
- }
-
- public ContentItem getItem(ContentSection section, String url) {
-
- ItemResolver itemResolver = getItemResolver(section);
- ContentItem item;
- // Check if the user has access to view public or preview pages
- boolean hasPermission = true;
- HttpServletRequest request = DispatcherHelper.getRequest();
-
- // If the remaining URL starts with "preview/", then try and
- // preview this item. Otherwise look for the live item.
- boolean preview = false;
- if (url.startsWith(PREVIEW)) {
- url = url.substring(PREVIEW.length());
- preview = true;
- }
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final PermissionChecker permissionChecker = cdiUtil.findBean(
- PermissionChecker.class);
-
- if (preview) {
- item = itemResolver.getItem(section, url, "draft");
- if (item != null) {
- hasPermission = permissionChecker.isPermitted(
- ItemPrivileges.PREVIEW, item);
- }
- } else {
- item = itemResolver.getItem(section, url, "live");
- if (item != null) {
- hasPermission = permissionChecker.isPermitted(
- ItemPrivileges.VIEW_PUBLISHED, item);
- }
- }
-
- if (item == null && url.endsWith(INDEX_FILE)) {
-
- // look up folder if it's an index
- url = url.substring(0, url.length() - INDEX_FILE.length());
- LOGGER.info("Attempting to match folder " + url);
- item = itemResolver.getItem(section, url, "live");
- if (item != null) {
- hasPermission = permissionChecker.isPermitted(
- ItemPrivileges.VIEW_PUBLISHED, item);
- }
- }
- // chris.gilbert@westsussex.gov.uk - if user is not logged in, give them a chance to do that, else show them the door
- if (!hasPermission && !cdiUtil.findBean(Shiro.class).getSubject()
- .isAuthenticated()) {
- throw new LoginSignal(request);
- }
- if (!hasPermission) {
- throw new com.arsdigita.dispatcher.AccessDeniedException();
- }
-
- return item;
- }
-
- /**
- * Fetches the ItemResolver for a content section.
- *
- * @param section The content section
- *
- * @return The ItemResolver associated with the content section
- */
- public ItemResolver getItemResolver(ContentSection section) {
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ContentSectionManager sectionManager = cdiUtil.findBean(
- ContentSectionManager.class);
-
- return sectionManager.getItemResolver(section);
- }
-
- /**
- * Fetches the ItemResolver for a content section. Checks cache first.
- *
- * @param section The content section
- *
- * @return The ItemResolver associated with the content section
- */
-// public TemplateResolver getTemplateResolver(ContentSection section) {
-//
-// String name = section.getName();
-// TemplateResolver ir = (TemplateResolver) s_templateResolverCache.get(
-// name);
-//
-// if (ir == null) {
-// ir = section.getTemplateResolver();
-// s_templateResolverCache.put(name, ir);
-// }
-//
-// return ir;
-// }
- /**
- * Fetches the URL of a template for an item. The returned URL is relative
- * to the webapp context.
- */
-// public String getTemplateURL(ContentSection section,
-// ContentItem item,
-// HttpServletRequest request,
-// RequestContext actx) {
-//
-// String templateURL = getTemplateResolver(section).getTemplate(section,
-// item,
-// request);
-//
-// return templateURL;
-// }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemXML.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemXML.java
deleted file mode 100755
index d859ef41e..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ItemXML.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.dispatcher;
-
-
-import com.arsdigita.cms.CMS;
-import com.arsdigita.dispatcher.RequestContext;
-import com.arsdigita.xml.Document;
-import com.arsdigita.xml.Element;
-
-import org.librecms.contentsection.ContentItem;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
-/***
- *
- * XMLPage
- *
- * Designed to allow you to output straight XML directly from the ContentItem
- * that implements XMLGenerator, with none of the surrounding headers, footers, etc
- *
- * @author slater@arsdigita.com
- *
- ***/
-
-public class ItemXML extends ResourceHandlerImpl {
-
- public ItemXML() {
- super();
- }
-
- public void dispatch(HttpServletRequest request,
- HttpServletResponse response,
- RequestContext actx)
- throws IOException, ServletException {
-
- ContentItem item = getContentItem(request);
-
- Element content = new Element("cms:item", CMS.CMS_XML_NS);
-
-// ContentItemXMLRenderer renderer =
-// new ContentItemXMLRenderer(content);
- //ToDo
-// renderer.setWrapAttributes(true);
-// renderer.setWrapRoot(false);
-// renderer.setWrapObjects(false);
-//
-// renderer.walk(item, SimpleXMLGenerator.ADAPTER_CONTEXT);
-//ToDo End
-
- Document doc;
- try {
- doc = new Document(content);
- } catch (javax.xml.parsers.ParserConfigurationException e) {
- throw new javax.servlet.ServletException(e);
- }
-
- OutputStream out = response.getOutputStream();
- try {
- out.write(doc.toString(true).getBytes());
- } catch (IOException e) {
- throw new ServletException(e);
- } finally {
- out.close();
- }
- }
-}
diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/MasterPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/MasterPage.java
deleted file mode 100755
index 2278982b1..000000000
--- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/MasterPage.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- */
-package com.arsdigita.cms.dispatcher;
-
-import com.arsdigita.bebop.SimpleContainer;
-import com.arsdigita.util.Assert;
-
-import org.librecms.contentsection.ContentSection;
-
-import javax.servlet.http.HttpServletRequest;
-
-
-/**
- * A {@link com.arsdigita.cms.dispatcher.CMSPage} used for serving - * content items.
- * - *This page contains a ContentPanel component which fetches
- * the {@link com.arsdigita.cms.dispatcher.XMLGenerator} for the content
- * section.
This class contains methods for registering and resolving {@link - * ResourceHandler CMS resources} in a specific content section.
- * - *The PageResolver includes methods for caching resource - * mappings.
- * - * @author Michael Pih (pihman@arsdigita.com) - * @version $Revision$ $Date$ - * @version $Id$ - */ -public abstract class PageResolver { - - private BigDecimal m_sectionID; - - // Used for caching pages - private HashMap m_pages; - - - public PageResolver() { - m_pages = new HashMap(); - } - - public void setContentSectionID(BigDecimal id) { - m_sectionID = id; - } - - protected BigDecimal getContentSectionID() { - return m_sectionID; - } - - - /** - * Fetch the page associated with the request URL. - * - * @param url The content section-relative URL stub - * @return The resource - */ - public ResourceHandler getPage(String url) { - return (ResourceHandler) m_pages.get(url); - } - - /** - * Register a page to the content section. - * - * @param page The master page - * @param url The desired URL of the page - */ - public abstract void registerPage(ResourceHandler page, String url); - - - /** - * Register a page to the content section. - * - * @param page The master page - * @param url The desired URL of the page - */ - public abstract void unregisterPage(ResourceHandler page, String url); - - - /** - * Loads a page into the page resolver cache. - * - * @param url The URL of the resource to load into the cache - * @param page The resource - */ - public void loadPage(String url, ResourceHandler page) { - m_pages.put(url, page); - } - - /** - * Flushes a page from the page resolver cache. - * - * @param url The URL of the resource to remove from the cache - */ - public void releasePage(String url) { - m_pages.remove(url); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ResourceHandler.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ResourceHandler.java deleted file mode 100755 index 72efec6dd..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ResourceHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.dispatcher; - -import com.arsdigita.dispatcher.Dispatcher; - -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentSection; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - - -/** - * An interface for resources that can be served. - * - * @author Michael Pih (pihman@arsdigita.com) - * @version $Revision$ $DateTime: 2004/08/17 23:15:09 $ - * @version $Id$ - **/ -public interface ResourceHandler extends Dispatcher { - - /** - * This method is called by the {@link com.arsdigita.dispatcher.Dispatcher} - * that initializes this page. - */ - public void init() throws ServletException; - - /** - * Fetches the content section context for this resource. - * - * @param request The HTTP request - * @return A content section or null if there is none - * @pre ( request != null ) - */ - public ContentSection getContentSection(HttpServletRequest request); - - /** - * Fetches the content item context for this resource. - * - * @param request The HTTP request - * @return A content item or null if there is none - * @pre ( request != null ) - */ - public ContentItem getContentItem(HttpServletRequest request); - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ResourceHandlerImpl.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ResourceHandlerImpl.java deleted file mode 100755 index 5ba96df8a..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ResourceHandlerImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.dispatcher; - -import com.arsdigita.dispatcher.RequestContext; -import com.arsdigita.util.Assert; - -import org.apache.shiro.authz.AuthorizationException; -import org.libreccm.cdi.utils.CdiUtil; -import org.libreccm.security.PermissionChecker; -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentSection; -import org.librecms.contentsection.privileges.ItemPrivileges; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * An interface for resources that can be served. - * - * @author Michael Pih (pihman@arsdigita.com) - * @version $Revision$ $DateTime: 2004/08/17 23:15:09 $ - * @version $Id$ - * - */ -public abstract class ResourceHandlerImpl implements ResourceHandler { - - /** - * This method is called by the {@link com.arsdigita.dispatcher.Dispatcher} - * that initializes this page. - */ - public void init() throws ServletException { - // Do nothing. - } - - /** - * Fetch the request-local content section. - * - * @param request The HTTP request - * - * @return The current content section - */ - public ContentSection getContentSection(HttpServletRequest request) { - // resets all content sections associations - ContentSection section = CMSDispatcher.getContentSection(request); - Assert.exists(section); - return section; - } - - /** - * Fetch the request-local content item. - * - * @param request The HTTP request - * - * @return The current content item - */ - public ContentItem getContentItem(HttpServletRequest request) { - // resets all content item associations - return CMSDispatcher.getContentItem(request); - } - - public void checkUserAccess(HttpServletRequest request, - HttpServletResponse response, - RequestContext actx, - ContentItem item) { - if (!CdiUtil.createCdiUtil().findBean(PermissionChecker.class) - .isPermitted(ItemPrivileges.VIEW_PUBLISHED, item)) { - throw new AuthorizationException( - "cms.dispatcher.no_permission_to_access_resource"); - } - } - - /** - * Services this resource. - * - * @param request The servlet request object - * @param response the servlet response object - * @param actx The request context - */ - public abstract void dispatch(HttpServletRequest request, - HttpServletResponse response, - RequestContext actx) - throws IOException, ServletException; - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/Utilities.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/Utilities.java deleted file mode 100755 index 4a2956d50..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/Utilities.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.dispatcher; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.cms.CMS; -import com.arsdigita.dispatcher.DispatcherHelper; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import javax.servlet.http.HttpServletResponse; - -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.librecms.CmsConstants; -import org.librecms.assets.BinaryAsset; -import org.librecms.assets.Image; -import org.librecms.contentsection.ContentSection; - -/** - *- * This class provides many utility functions for the Content Management - * System.
- * Specifically used by various JSP templates. - * - * @author Michael Pih (pihman@arsdigita.com) - */ -public class Utilities { - - public static final Logger LOGGER = LogManager.getLogger(Utilities.class); - - // Used for caching util lookups - private static HashMap m_cache = new HashMap(); - - private static Date s_lastSectionRefresh = null; - private static Map s_sectionRefreshTimes = Collections.synchronizedMap( - new HashMap()); - - /** - * Fetch the location of the CMS ContentCenter package. - * - * @return The URL of the CMS ContentCenter package - * - * @deprecated use ContentCenter.getURL() instead - */ - public static String getWorkspaceURL() { - - return CmsConstants.CONTENT_CENTER_URL; - - } - - /** - * Fetch the location (URL) of the CMS Services package. Caches the result. - * - * @return The URL of the CMS Services package - * - * @deprecated Use Service.getURL( instead - */ - public static String getServiceURL() { - String url = (String) m_cache.get(CmsConstants.SERVICE_PACKAGE_KEY); - if (url == null) { - // chris.gilbert@westsussex.gov.uk - // We don't want application context in this url, especially when - // it gets cached in a static variable - if I have a - // file that is maintained by a non cms application eg - // forum, then I can end up with a url that doesn't work - // and so breaks file links everywhere - // url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY); - url = CmsConstants.SERVICE_URL; - m_cache.put(CmsConstants.SERVICE_PACKAGE_KEY, url); - } - - return url; - } - - /** - * The URL to log out. - * - * @return The logout URL - */ - public static String getLogoutURL() { - //StringBuffer buf = new StringBuffer(getServiceURL()); - StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL); - buf.append("logout"); - return buf.toString(); - } - - /** - * Construct a URL which serves a binary asset. - * - * @param asset The binary asset - * - * @return the URL which will serve the specified binary asset - * - * @deprecated Use Service.getAssetURL(BinaryAsset asset) instead - */ - public static String getAssetURL(BinaryAsset asset) { - return getAssetURL(asset.getObjectId()); - } - - /** - * Constuct a URL which serves a binary asset. - * - * @param assetId The asset ID - * - * @return the URL which will serve the specified binary asset - * - * @deprecated Use Service.getAssetURL(BigDecimal assetId) instead - */ - public static String getAssetURL(long assetId) { - // StringBuffer buf = new StringBuffer(getServiceURL()); - StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL); - buf.append("stream/asset?"); - buf.append(CmsConstants.ASSET_ID).append("=").append(assetId); - return buf.toString(); - } - - /** - * Construct a URL which serves an image. - * - * @param asset The image asset whose image is to be served - * - * @return the URL which will serve the specified image asset - * - * @deprecated Use Service.getImageURL(ImageAsset) instead! - */ - public static String getImageURL(Image asset) { - // StringBuffer buf = new StringBuffer(getServiceURL()); - StringBuilder buf = new StringBuilder(CmsConstants.SERVICE_URL); - buf.append("stream/image/?"); - buf.append(CmsConstants.IMAGE_ID).append("=") - .append(asset.getObjectId()); - return buf.toString(); - } - - public static String getGlobalAssetsURL() { - return getWebappContext(); - } - - /** - * Fetch the context path of the request. This is typically "/". - * - * @return The webapp context path - */ - public static String getWebappContext() { - return DispatcherHelper.getWebappContext(); - } - - /** - * Check for the last refresh on authoring kits or content types in a - * section. - * - */ - public static synchronized Date - getLastSectionRefresh(ContentSection section) { - - // cache by URL string instead of by section object to avoid - // holding the reference. - String sectionURL = section.getPrimaryUrl(); - - Date lastModified = (Date) s_sectionRefreshTimes.get(sectionURL); - if (lastModified == null) { - lastModified = new Date(); - s_lastSectionRefresh = lastModified; - s_sectionRefreshTimes.put(sectionURL, lastModified); - } - - return lastModified; - } - - /** - * Check for the last refresh on authoring kits or content types in any - * section. - * - */ - public static Date getLastSectionRefresh() { - - // instantiate last refresh lazily to ensure that first result is - // predictable. - if (s_lastSectionRefresh == null) { - s_lastSectionRefresh = new Date(); - } - return s_lastSectionRefresh; - } - - /** - * Force the authoring UI to reload. This should be done every time an - * authoring kit or a content type are updated. - */ - public static void refreshItemUI(PageState state) { - // Drop the authoring kit UI to force it to refresh - // THE URL SHOULD NOT BE HARDCODED ! - - ContentSection section = CMS.getContext().getContentSection(); - - // OLD APPROACH: used in conjunction with CMSDispatcher. This - // shouldn't do any harm even if CMSDispatcher is not being used. - CMSDispatcher.releaseResource(section, "admin/item"); - refreshAdminUI(state); - - // NEW APPROACH: used in conjunction with - // ContentSectionDispatcher. cache by URL string instead of by - // section object to avoid holding the reference. This shouldn't - // do any harm even if ContentSectionDispatcher is not being used. - s_lastSectionRefresh = new Date(); - s_sectionRefreshTimes.put(section.getPrimaryUrl(), - s_lastSectionRefresh); - } - - /** - * Force the authoring UI to reload. This should be done every time an - * authoring kit or a content type are updated. - */ - public static void refreshAdminUI(PageState state) { - // Drop the admin UI to force it to refresh - // THE URL SHOULD NOT BE HARDCODED ! - - ContentSection section = CMS.getContext().getContentSection(); - - CMSDispatcher.releaseResource(section, "admin"); - CMSDispatcher.releaseResource(section, "admin/index"); - CMSDispatcher.releaseResource(section, ""); - } - - /** - * Add the "pragma: no-cache" header to the HTTP response to make sure the - * browser does not cache tha page - * - * @param response The HTTP response - * - * @deprecated use - * com.arsdigita.dispatcher.DispatcherHelper.cacheDisable(HttpServletResponse) - */ - public static void disableBrowserCache(HttpServletResponse response) { - response.addHeader("pragma", "no-cache"); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/XMLGenerator.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/XMLGenerator.java deleted file mode 100755 index dabc5e599..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/XMLGenerator.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ -package com.arsdigita.cms.dispatcher; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.xml.Element; - - -/** - *Generates XML representing a Content Item.
- * - *As the last step of servicing a page, the
- * {@link com.arsdigita.cms.dispatcher.MasterPage} will go through the
- * hierarchy of its components and ask each of them to convert themselves
- * to XML. A MasterPage contains a special component that knows how to ask
- * its content section for the XML generator that should be applied. The
- * XML generator's generateXML method in turn asks the
- * containing page for the content item, the one that the
- * {@link com.arsdigita.cms.dispatcher.ItemResolver} found before, and
- * formats it as an XML document.
- * The name of the state parameter which indicates the content type of the - * item the user wishes to create. or edit.
- * - *- * The parameter must be a BigDecimalParameter which encodes the id of the - * content type.
- */ - public static final String CONTENT_TYPE = "content_type"; - - public static final int AUTHORING_TAB = 1; - - public static final int LANGUAGE_TAB = 2; - - public static final int WORKFLOW_TAB = 3; - - public static final int PUBLISHING_TAB = 4; - - public static final int HISTORY_TAB = 5; - - public static final int TEMPLATES_TAB = 6; - - private final TabbedPane tabbedPane; - - private final StringParameter returnUrlParameter; - - private final ItemSelectionModel itemSelectionModel; -// private final SingleSelectionModel- * Global navigation elements for the CMS admin UIs.
- * - * @author Justin Ross <jross@redhat.com> - */ -// Made public (instead of unspecified, resulting in protected) in 6.6.8 -public class GlobalNavigation extends SimpleComponent { - - - private final String m_adminPath; - private final String m_centerPath; - private final String m_changePasswordPath; - private final String m_helpPath; - private final String m_signOutPath; - private final String m_wspcPath; - - /** - * - */ - public GlobalNavigation() { - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ApplicationManager appManager = cdiUtil.findBean( - ApplicationManager.class); - final ApplicationRepository appRepo = cdiUtil.findBean( - ApplicationRepository.class); - final Map- * The simple use pattern for this component is as follows: - * - *
- * - * @author Michael Pih (pihman@arsdigita.com) - * @author Stanislav Freidin (sfreidin@arsdigita.com) - * @author Jens Pelzetter - */ -public class SecurityPropertyEditor extends PropertyEditor { - - private final Map- * SecurityPropertyEditor editor = new SecurityPropertyEditor(); - * editor.setDisplayComponent(new FooComponent()); - * NameEditForm n = new NameEditForm(); - * ComponentAccess ca1 = new ComponentAccess(n); - * ca1.addAccessCheck(WORKFLOW_ADMIN); - * ca1.addAccessCheck(CATEGORY_ADMIN); - * editor.add("name", "Edit Name", ca, n.getCancelButton()); - * AddressEditForm a = new AddressEditForm(); - * ComponentAccess ca2 = new ComponentAccess(a); - * editor.add("address", "Edit Address", ca2, a.getCancelButton()); - *
PropertyEditor. The {@link
- * #setDisplayComponent(Component)} method must be called before this
- * component is locked.
- */
- public SecurityPropertyEditor() {
- this(null);
- }
-
- /**
- * Construct a new, PropertyEditor with the given display
- * component
- *
- * @param display The display component
- */
- public SecurityPropertyEditor(final Component display) {
- super(display);
- accessChecks = new HashMap<>();
- setModelBuilder(new AccessListModelBuilder());
- }
-
- /**
- * Add a component to the property editor. The component will be completely
- * invisible; it is up to the user to call {@link #showComponent(PageState,
- * String)} to display the component, and to call {@link
- * #showDisplayPane(PageState)} when the component needs to be hidden.
- *
- * @param key The symbolic key for the component; must be unique for this
- * PropertyEditor
- * @param componentAccess The {@link ComponentAccess} object which contains
- * the child component, along with security restrictions
- */
- public void addComponent(final String key,
- final ComponentAccess componentAccess) {
- super.addComponent(key, componentAccess.getComponent());
- accessChecks.put(key, componentAccess);
- }
-
- /**
- * Add a component to the list of links. It is up to the component to
- * correctly call showDisplayPane when it's done.
- *
- * @param key The symbolic key for the component; must be unique for this
- * PropertyEditor
- * @param label The label for the link
- * @param componentAccess The component access
- * @deprecated use addComponent(String,GlobalizedMessage,ComponentAccess)
- * instead.
- */
- public void addComponent(final String key,
- final String label,
- final ComponentAccess componentAccess) {
- addComponent(key, componentAccess);
- getLabelsMap().put(key, label);
- }
-
- /**
- * Add a component to the list of links. It is up to the component to
- * correctly call showDisplayPane when it's done.
- *
- * @param key The symbolic key for the component; must be unique for this
- * PropertyEditor
- * @param label The label for the link
- * @param componentAccess The component access
- */
- public void addComponent(final String key,
- final GlobalizedMessage label,
- final ComponentAccess componentAccess) {
- addComponent(key, componentAccess);
- getLabelsMap().put(key, label);
- }
-
- /**
- * Specify a new {@link ComponentAccess} for a component which has already
- * been added to the SecurityPropertyEditor.
- *
- * @param key the key under which the component was added
- * @param componentAccess the ComponentAccess instance that
- * will determine when the link for the specified component should be
- * visible
- * @pre access.getComponent() == m_forms.get(key)
- */
- public void setComponentAccess(final String key,
- final ComponentAccess componentAccess) {
- Assert.isUnlocked(this);
- final Component component = getComponent(key);
- Assert.exists(component, "the specified component");
- Assert.isTrue(componentAccess.getComponent().equals(component),
- "The specified component does not match the component that"
- + " id already in the PropertyEditor");
- accessChecks.put(key, componentAccess);
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the
- * properties.
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form
- * @param componentAccess The form ComponentAccess
- *
- * @deprecated use add(String,GlobalizedMessage,ComponentAccess)
- */
- public void add(final String key,
- final String label,
- final ComponentAccess componentAccess) {
- final Component component = componentAccess.getComponent();
- if (component instanceof Form) {
- final Form form = (Form) component;
- accessChecks.put(key, componentAccess);
- add(key, label, form);
- addSecurityListener(form);
- } else if (component instanceof FormSection) {
- final FormSection section = (FormSection) componentAccess.
- getComponent();
- accessChecks.put(key, componentAccess);
- add(key, label, section);
- addSecurityListener(section);
- } else {
- throw new IllegalArgumentException(
- "The ComponentAccess object does "
- + "not contain a form section.");
- }
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the
- * properties.
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form
- * @param componentAccess The form ComponentAccess
- */
- public void add(final String key,
- final GlobalizedMessage label,
- final ComponentAccess componentAccess) {
- final Component component = componentAccess.getComponent();
- if (component instanceof Form) {
- final Form form = (Form) component;
- accessChecks.put(key, componentAccess);
- add(key, label, form);
- addSecurityListener(form);
- } else if (component instanceof FormSection) {
- final FormSection section = (FormSection) componentAccess.
- getComponent();
- accessChecks.put(key, componentAccess);
- add(key, label, section);
- addSecurityListener(section);
- } else {
- throw new IllegalArgumentException(
- "The ComponentAccess object does "
- + "not contain a form section.");
- }
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the properties
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form.
- * @param componentAccess The form ComponentAccess
- * @param cancelButton The Cancel button on the form.
- *
- * @deprecated use add(String,GlobalizedMessage,ComponentAccess,Submit)
- * instead
- */
- public void add(final String key,
- final String label,
- final ComponentAccess componentAccess,
- final Submit cancelButton) {
- add(key, label, componentAccess);
- addCancelListener((FormSection) componentAccess.getComponent(),
- cancelButton);
- }
-
- /**
- * Add a form to the set of forms which could be used to edit the properties
- *
- * @param key The symbolic key for the form; must be unique for this
- * PropertyEditor
- * @param label The label for the link to access the form.
- * @param componentAccess The form ComponentAccess
- * @param cancelButton The Cancel button on the form.
- */
- public void add(final String key,
- final GlobalizedMessage label,
- final ComponentAccess componentAccess,
- final Submit cancelButton) {
- add(key, label, componentAccess);
- addCancelListener((FormSection) componentAccess.getComponent(),
- cancelButton);
- }
-
- /**
- * Add a submission listener to the form that will hide all components and
- * show the display pane. This method should be used to add submission
- * listeners to forms which are buried deep inside some component, and are
- * not members of this PropertyEditor.
- *
- * @param form The form
- */
- public void addSecurityListener(final FormSection form) {
- form.addSubmissionListener(new FormSubmissionListener() {
-
- @Override
- public void submitted(final FormSectionEvent event) throws
- FormProcessException {
-
- final PageState state = event.getPageState();
-
- // Cancel the form if the user does not pass the access checks.
- final String key = (String) getList().getSelectedKey(state);
- final ComponentAccess componentAccess
- = (ComponentAccess) accessChecks.get(key);
-
- if (key == null || componentAccess == null) {
- // no components currently selected and therefore
- // no access checks to run for visibility
- // or
- // there are no access restrictions on the form
- return;
- }
-
- if (!componentAccess.canAccess()) {
- showDisplayPane(state);
- throw new FormProcessException(new GlobalizedMessage(
- "cms.ui.insufficient_privileges",
- CmsConstants.CMS_BUNDLE));
- }
- }
- });
- }
-
- /**
- * Add all required listeners to the form to ensure that if the form is
- * submitted successfully or cancelled, the display pane will be shown. This
- * method should be used to add listeners to forms which are buried deep
- * inside some component, and are not members of this
- * PropertyEditor.
- *
- * @param form The form
- * @param cancelButton the "Cancel" button on the form
- */
- @Override
- public void addListeners(final FormSection form,
- final Submit cancelButton) {
- addSecurityListener(form);
- super.addListeners(form, cancelButton);
- }
-
- /**
- * Return the map of keys to access checks
- *
- * @return Map of keys to access check
- */
- protected final Map- * - * This constructor will be called when the component is automatically - * instantiated by the- * public TheClass(ItemSelectionModel model, AuthoringKitWizard parent) { ... } - *
AuthoringKitWizard.
- *
- */
-public class AuthoringKitWizard extends LayoutPanel implements Resettable {
-
- /**
- * Private Logger instance for this class
- */
- private static final Logger LOGGER = LogManager
- .getLogger(AuthoringKitWizard.class);
-
- private final static Class>[] ARGUMENTS = new Class>[]{
- ItemSelectionModel.class,
- AuthoringKitWizard.class,
- StringParameter.class
- };
-
- private static final Class>[] USER_DEFINED_ARGS = new Class>[]{
- ItemSelectionModel.class,
- AuthoringKitWizard.class,
- ContentType.class
- };
-
- private final Object[] values;
-
- private final ContentTypeInfo typeInfo;
-
- private final AuthoringKitInfo kitInfo;
-
- private final ItemSelectionModel selectionModel;
-
-
-
- private final SequentialMap labels;
-
- private final List list;
-
- private String defaultKey;
-
- private final GridPanel leftPanel;
-
- private final ModalPanel bodyPanel;
-
- private final SimpleContainer stepsContainer;
-
-
- private final StringParameter selectedLanguageParam;
-
- /**
- * The name of the state parameter that determines whether the wizard is in
- * item creation mode or item editing mode.
- */
- public static final String IS_EDITING = "is_edit";
-
- /**
- * The key for the item creation step.
- */
- public static final String CREATION = "_creation_";
-
- private final static String SEC_PAGE_EDIT_DYN
- = "com.arsdigita.cms.ui.authoring.SecondaryPageEditDynamic";
-
- private final static String PAGE_EDIT_DYN
- = "com.arsdigita.cms.ui.authoring.PageEditDynamic";
-
- /**
- * Construct a new AuthoringKitWizard. Add all the steps in the authoring
- * kit to the wizard.
- *
- * @param typeInfo The content type of the items that this wizard will
- * handle
- * @param selectionModel
- */
- public AuthoringKitWizard(final ContentTypeInfo typeInfo,
- final ItemSelectionModel selectionModel) {
- LOGGER.debug("Authoring kit wizard for type {} undergoing creation...",
- Objects.toString(typeInfo));
-
- final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
- final ConfigurationManager confManager = cdiUtil.findBean(
- ConfigurationManager.class);
-
- selectedLanguageParam = new StringParameter(
- ContentItemPage.SELECTED_LANGUAGE);
- final GlobalizationHelper globalizationHelper = cdiUtil
- .findBean(GlobalizationHelper.class);
- selectedLanguageParam.setDefaultValue(globalizationHelper
- .getNegotiatedLocale()
- .toString());
-
- this.typeInfo = typeInfo;
- kitInfo = typeInfo.getAuthoringKit();
- this.selectionModel = selectionModel;
- values = new Object[]{selectionModel, this, selectedLanguageParam};
- labels = new SequentialMap();
-
- leftPanel = new GridPanel(1);
- setLeft(leftPanel);
-
- final Section stepSection = new Section(
- new GlobalizedMessage("cms.ui.authoring.steps",
- CmsConstants.CMS_BUNDLE));
- leftPanel.add(stepSection);
-
- list = new List();
- stepSection.setBody(list);
-
- list.setListData(labels);
- list.setCellRenderer(new ListCellRenderer() {
-
- @Override
- public Component getComponent(final List list,
- final PageState state,
- final Object value,
- final String key,
- final int index,
- final boolean isSelected) {
- final Label label;
- if (value instanceof GlobalizedMessage) {
- label = new Label((GlobalizedMessage) value);
- } else {
- label = new Label((String) value);
- }
- if (isSelected) {
- label.setFontWeight(Label.BOLD);
- return label;
- }
- return new ControlLink(label);
- }
-
- });
-
- bodyPanel = new ModalPanel();
- setBody(bodyPanel);
-
- stepsContainer = new SimpleContainer();
- bodyPanel.add(stepsContainer);
- bodyPanel.setDefault(stepsContainer);
-
- final java.util.List