From: <pb...@fe...> - 2013-02-03 22:27:45
|
Author: pboy Date: 2013-02-03 22:27:36 +0000 (Sun, 03 Feb 2013) New Revision: 2492 Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentCenter.java trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java trunk/ccm-portalserver/pdl/com/arsdigita/portalserver/Workspace.pdl trunk/ccm-portalworkspace/pdl/com/arsdigita/portalworkspace/Workspace.pdl Log: PDL adjusted to removal of old style application code, backwards compatibility to contentcenter page handling added. Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentCenter.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ContentCenter.java 2013-02-03 22:23:49 UTC (rev 2491) +++ trunk/ccm-cms/src/com/arsdigita/cms/ContentCenter.java 2013-02-03 22:27:36 UTC (rev 2492) @@ -27,7 +27,6 @@ import org.apache.log4j.Logger; - /** * Application domain class for the CMS module user entry page (content-center) * @@ -38,11 +37,9 @@ /** A logger instance, primarily to assist debugging . */ private static final Logger s_log = Logger.getLogger(ContentSection.class); - // pdl stuff (constants) public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.ContentCenter"; - // general constants public static final String PACKAGE_KEY = "content-center"; public static final String INSTANCE_NAME = "Content Center"; @@ -66,7 +63,7 @@ * @param id The <code>id</code> for the retrieved * <code>DataObject</code>. */ - public ContentCenter(BigDecimal key) throws DataObjectNotFoundException { + public ContentCenter(BigDecimal key) throws DataObjectNotFoundException { this(new OID(BASE_DATA_OBJECT_TYPE, key)); } @@ -95,15 +92,13 @@ Application parent) { ContentCenter app = - (ContentCenter) Application.createApplication - (BASE_DATA_OBJECT_TYPE, urlName, title, parent); + (ContentCenter) Application.createApplication(BASE_DATA_OBJECT_TYPE, urlName, title, parent); app.save(); return app; } - /** * Fetch the URL of the CMS ContentCenter. * @@ -115,20 +110,20 @@ */ public static String getURL() { // quick 'nd dirty! - return "/"+PACKAGE_KEY; + return "/" + PACKAGE_KEY + "/"; - // Doesn't work as expected - // see c.ad.ui.login.UserInfo for a working (hopefully) example. - // ApplicationCollection apps = Application - // .retrieveAllApplications(BASE_DATA_OBJECT_TYPE); - // if (apps.next()) { - // // Note: Currently only one Content Center application is allowed! - // s_log.error("Instance of ContentCenter found!"); - // return apps.getPrimaryURL(); - // } else { - // s_log.error("No instance of ContentCenter could be found!"); - // return null; - // } + // Doesn't work as expected + // see c.ad.ui.login.UserInfo for a working (hopefully) example. + // ApplicationCollection apps = Application + // .retrieveAllApplications(BASE_DATA_OBJECT_TYPE); + // if (apps.next()) { + // // Note: Currently only one Content Center application is allowed! + // s_log.error("Instance of ContentCenter found!"); + // return apps.getPrimaryURL(); + // } else { + // s_log.error("No instance of ContentCenter could be found!"); + // return null; + // } } /** Modified: trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java =================================================================== --- trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java 2013-02-03 22:23:49 UTC (rev 2491) +++ trunk/ccm-cms/src/com/arsdigita/cms/ContentCenterServlet.java 2013-02-03 22:27:36 UTC (rev 2492) @@ -16,12 +16,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - package com.arsdigita.cms; import com.arsdigita.bebop.Page; -import com.arsdigita.cms.SecurityManager; +import com.arsdigita.cms.dispatcher.CMSPage; import com.arsdigita.cms.dispatcher.SimpleCache; +import com.arsdigita.cms.ui.ItemSearchPage; import com.arsdigita.cms.ui.contentcenter.MainPage; import com.arsdigita.developersupport.DeveloperSupport; import com.arsdigita.dispatcher.AccessDeniedException; @@ -60,38 +60,28 @@ /** Logger instance for debugging */ private static Logger s_log = Logger - .getLogger(ContentCenterServlet.class.getName()); - + .getLogger(ContentCenterServlet.class.getName()); // DEPRECATED STUFF follows. Should be no longer used, deleted in future! /** The path of the file that maps resources. */ public final static String DEFAULT_MAP_FILE = "/WEB-INF/resources/content-center-old-map.xml"; - /** Mapping between a relative URL and the class name of a ResourceHandler.*/ // private static HashMap s_pageClasses = ContentCenterSetup.getURLToClassMap(); private static HashMap s_pageURLs = ContentCenterSetup.getClassToURLMap(); - /** Instantiated ResourceHandlers cache. This allows for lazy loading. */ private static SimpleCache s_pages = new SimpleCache(); - private ArrayList m_trailingSlashList = new ArrayList(); - // NEW STUFF here used to process the pages in this servlet - /** URL (pathinfo) -> Page object mapping. Based on it (and the http * request url) the doService method to selects a page to display */ private final Map m_pages = new HashMap(); - - // STUFF to use for JSP extension, i.e. jsp's to try for URLs which are not // handled by the this servlet directly. /** Path to directory containg ccm-cms template files */ private String m_templatePath; - /** Resolvers to find templates (JSP) and other stuff stored in file system.*/ private ApplicationFileResolver m_resolver; - /** * Use parent's class initialization extension point to perform additional * initialisation tasks. @@ -110,9 +100,10 @@ // Addresses previously noted in WEB-INF/resources/content-center-map.xml // Obviously not required. addPage("/", new MainPage()); // index page at address ~/ds - // addPage("/index/", new MainPage()); - // addPage("/ItemSearchPage/", new CCItemSearchPage()); - // addPage("/SearchResultRedirector/", new CCSearchResultRedirector()); + // addPage("/index/", new MainPage()); + //addPage("/ItemSearchPage/", new ItemSearchPage()); + addPage("/item-search", new ItemSearchPage()); + // addPage("/SearchResultRedirector/", new CCSearchResultRedirector()); // STUFF to use for JSP extension, i.e. jsp's to try for URLs which are not @@ -123,14 +114,13 @@ m_templatePath = "/templates/ccm-cms/content-center"; Assert.exists(m_templatePath, String.class); Assert.isTrue(m_templatePath.startsWith("/"), - "template-path must start with '/'"); + "template-path must start with '/'"); Assert.isTrue(!m_templatePath.endsWith("/"), - "template-path must not end with '/'"); + "template-path must not end with '/'"); /** Set TemplateResolver class */ m_resolver = Web.getConfig().getApplicationFileResolver(); } - /** * Implements the (abstract) doService method of BaseApplicationServlet to * create the ContentCenter page. @@ -138,10 +128,10 @@ * @see com.arsdigita.web.BaseApplicationServlet#doService * (HttpServletRequest, HttpServletResponse, Application) */ - protected void doService( HttpServletRequest sreq, - HttpServletResponse sresp, - Application app) - throws ServletException, IOException { + protected void doService(HttpServletRequest sreq, + HttpServletResponse sresp, + Application app) + throws ServletException, IOException { if (s_log.isDebugEnabled()) { s_log.info("starting doService method"); @@ -170,13 +160,13 @@ sections.close(); if (!hasAccess) { // user has no access privilege throw new AccessDeniedException( - "User is not entitled to access any content section"); + "User is not entitled to access any content section"); // throw new LoginSignal(sreq); // send to login page } - - - RequestContext ctx = DispatcherHelper.getRequestContext(); + + + RequestContext ctx = DispatcherHelper.getRequestContext(); String url = ctx.getRemainingURLPart(); // here SiteNodeRequestContext String originalUrl = ctx.getOriginalURL(); @@ -191,31 +181,39 @@ * trailing '/' if a "virtual" page, i.e. not a real jsp, but * result of a servlet mapping. But Application requires url * NOT to end with a trailing '/' for legacy free applications. */ - pathInfo = pathInfo.substring(0, pathInfo.length()-1); + pathInfo = pathInfo.substring(0, pathInfo.length() - 1); } // An empty remaining URL or a URL which doesn't end in trailing slash: // probably want to redirect. // Probably DEPRECATED with new access method or only relevant for jsp // extension - if ( m_trailingSlashList.contains(url) && !originalUrl.endsWith("/") ) { + if (m_trailingSlashList.contains(url) && !originalUrl.endsWith("/")) { DispatcherHelper.sendRedirect(sresp, originalUrl + "/"); return; } final Page page = (Page) m_pages.get(pathInfo); - if ( page != null ) { + if (page != null) { // Check user access. checkUserAccess(sreq, sresp); - // Serve the page. - final Document doc = page.buildDocument(sreq, sresp); - PresentationManager pm = Templating.getPresentationManager(); - pm.servePage(doc, sreq, sresp); - // page.init(); - // page.dispatch(sreq, sresp, ctx); + //Lock the page + if (page instanceof CMSPage) { + final CMSPage cmsPage = (CMSPage) page; + cmsPage.init(); + cmsPage.dispatch(sreq, sresp, ctx); + } else { + page.lock(); + // Serve the page. + final Document doc = page.buildDocument(sreq, sresp); + + PresentationManager pm = Templating.getPresentationManager(); + pm.servePage(doc, sreq, sresp); + } + } else { // Fall back on the JSP application dispatcher. // NOTE: The JSP must ensure the proper authentication and @@ -223,7 +221,7 @@ if (s_log.isInfoEnabled()) { s_log.info("NO page registered to serve the requst url."); } - + RequestDispatcher rd = m_resolver.resolve(m_templatePath, sreq, sresp, app); if (rd != null) { @@ -231,21 +229,20 @@ s_log.debug("Got dispatcher " + rd); } sreq = DispatcherHelper.restoreOriginalRequest(sreq); - rd.forward(sreq,sresp); + rd.forward(sreq, sresp); } else { sresp.sendError(404, requestUri + " not found on this server."); } } - + DeveloperSupport.endStage("ContentCenterServlet.doService"); if (s_log.isDebugEnabled()) { s_log.info("doService method completed"); } } // END doService() - /** * Adds one pair of Url - Page to the internal hash map, used as a cache. * @@ -264,7 +261,6 @@ m_pages.put(pathInfo, page); } - /** * Service Method returns the URL stub for the class name, * can return null if not mapped @@ -274,11 +270,10 @@ s_log.debug("Getting URL Stub for : " + classname); Iterator itr = s_pageURLs.keySet().iterator(); while (itr.hasNext()) { - String classname2 = (String)itr.next(); - s_log.debug("key: " + classname + " value: " + - (String)s_pageURLs.get(classname2)); + String classname2 = (String) itr.next(); + s_log.debug("key: " + classname + " value: " + (String) s_pageURLs.get(classname2)); } - String url = (String)s_pageURLs.get(classname); + String url = (String) s_pageURLs.get(classname); return url; } @@ -293,7 +288,6 @@ s_pages.remove(url); } - /** * Verify that the user is logged in and is able to view the * page. Subclasses can override this method if they need to, but @@ -305,10 +299,10 @@ **/ protected void checkUserAccess(final HttpServletRequest request, final HttpServletResponse response //, -/// final RequestContext actx - ) - throws ServletException { - + /// final RequestContext actx + ) + throws ServletException { + if (!Web.getUserContext().isLoggedIn()) { throw new LoginSignal(request); @@ -324,11 +318,11 @@ **/ protected void redirectToLoginPage(HttpServletRequest req, HttpServletResponse resp) - throws ServletException { + throws ServletException { String url = Util.getSecurityHelper() - .getLoginURL(req) - +"?"+LoginHelper.RETURN_URL_PARAM_NAME - +"="+UserContext.encodeReturnURL(req); + .getLoginURL(req) + + "?" + LoginHelper.RETURN_URL_PARAM_NAME + + "=" + UserContext.encodeReturnURL(req); try { LoginHelper.sendRedirect(req, resp, url); } catch (IOException e) { Modified: trunk/ccm-portalserver/pdl/com/arsdigita/portalserver/Workspace.pdl =================================================================== --- trunk/ccm-portalserver/pdl/com/arsdigita/portalserver/Workspace.pdl 2013-02-03 22:23:49 UTC (rev 2491) +++ trunk/ccm-portalserver/pdl/com/arsdigita/portalserver/Workspace.pdl 2013-02-03 22:27:36 UTC (rev 2492) @@ -86,7 +86,7 @@ workspace.displayName = acs_objects.display_name; workspace.defaultDomainClass = acs_objects.default_domain_class; workspace.parentResource.id = applications.parent_application_id; - workspace.packageInstance.id = applications.package_id; +// workspace.packageInstance.id = applications.package_id; (Old stype app code removed in 6.6.5) workspace.title = applications.title; workspace.description = applications.description; workspace.primaryURL = applications.primary_url; @@ -106,7 +106,7 @@ acs_objects.display_name, acs_objects.default_domain_class, applications.parent_application_id, - applications.package_id, +// applications.package_id, applications.title, applications.description, applications.primary_url, @@ -129,7 +129,7 @@ workspace.displayName = acs_objects.display_name; workspace.defaultDomainClass = acs_objects.default_domain_class; workspace.parentResource.id = applications.parent_application_id; - workspace.packageInstance.id = applications.package_id; +// workspace.packageInstance.id = applications.package_id; workspace.title = applications.title; workspace.description = applications.description; workspace.primaryURL = applications.primary_url; @@ -139,50 +139,50 @@ } } -query workspaceForSiteNodeID { - Workspace workspace; +// (pb) query workspaceForSiteNodeID { +// (pb) Workspace workspace; +// (pb) +// (pb) do { +// (pb) select +// (pb) acs_objects.object_id, +// (pb) acs_objects.object_type, +// (pb) acs_objects.display_name, +// (pb) acs_objects.default_domain_class, +// (pb) applications.parent_application_id, +// (pb) applications.package_id, +// (pb) applications.title, +// (pb) applications.description, +// (pb) applications.primary_url, +// (pb) ps_workspaces.ready_p, +// (pb) ps_workspaces.mission +// (pb) from +// (pb) site_nodes, +// (pb) apm_packages, +// (pb) applications, +// (pb) acs_objects, +// (pb) ps_workspaces +// (pb) where +// (pb) site_nodes.node_id = :siteNodeID +// (pb) -- joins +// (pb) and site_nodes.object_id = apm_packages.package_id +// (pb) and apm_packages.package_id = applications.package_id +// (pb) and applications.application_id = acs_objects.object_id +// (pb) and applications.application_id = ps_workspaces.workspace_id +// (pb) } map { +// (pb) workspace.id = acs_objects.object_id; +// (pb) workspace.objectType = acs_objects.object_type; +// (pb) workspace.displayName = acs_objects.display_name; +// (pb) workspace.defaultDomainClass = acs_objects.default_domain_class; +// (pb) workspace.parentResource.id = applications.parent_application_id; +// (pb) workspace.packageInstance.id = applications.package_id; +// (pb) workspace.title = applications.title; +// (pb) workspace.description = applications.description; +// (pb) workspace.primaryURL = applications.primary_url; +// (pb) workspace.isReady = ps_workspaces.ready_p; +// (pb) workspace.mission = ps_workspaces.mission; +// (pb) } +// (pb) } - do { - select - acs_objects.object_id, - acs_objects.object_type, - acs_objects.display_name, - acs_objects.default_domain_class, - applications.parent_application_id, - applications.package_id, - applications.title, - applications.description, - applications.primary_url, - ps_workspaces.ready_p, - ps_workspaces.mission - from - site_nodes, - apm_packages, - applications, - acs_objects, - ps_workspaces - where - site_nodes.node_id = :siteNodeID - -- joins - and site_nodes.object_id = apm_packages.package_id - and apm_packages.package_id = applications.package_id - and applications.application_id = acs_objects.object_id - and applications.application_id = ps_workspaces.workspace_id - } map { - workspace.id = acs_objects.object_id; - workspace.objectType = acs_objects.object_type; - workspace.displayName = acs_objects.display_name; - workspace.defaultDomainClass = acs_objects.default_domain_class; - workspace.parentResource.id = applications.parent_application_id; - workspace.packageInstance.id = applications.package_id; - workspace.title = applications.title; - workspace.description = applications.description; - workspace.primaryURL = applications.primary_url; - workspace.isReady = ps_workspaces.ready_p; - workspace.mission = ps_workspaces.mission; - } -} - query RolesForUser { BigDecimal groupID; do { Modified: trunk/ccm-portalworkspace/pdl/com/arsdigita/portalworkspace/Workspace.pdl =================================================================== --- trunk/ccm-portalworkspace/pdl/com/arsdigita/portalworkspace/Workspace.pdl 2013-02-03 22:23:49 UTC (rev 2491) +++ trunk/ccm-portalworkspace/pdl/com/arsdigita/portalworkspace/Workspace.pdl 2013-02-03 22:27:36 UTC (rev 2492) @@ -74,7 +74,7 @@ workspace.displayName = acs_objects.display_name; workspace.defaultDomainClass = acs_objects.default_domain_class; workspace.parentResource.id = applications.parent_application_id; - workspace.packageInstance.id = applications.package_id; +// workspace.packageInstance.id = applications.package_id; (Old style app code removed) workspace.title = applications.title; workspace.primaryURL = applications.primary_url; workspace.description = applications.description; |