From 690db3cde2af4b74dcddbded1800c33315176782 Mon Sep 17 00:00:00 2001 From: pb Date: Sun, 13 Jan 2013 13:19:41 +0000 Subject: [PATCH] APLAWS Integration package clean up to avoid code duplication: * Integrated WebAppPatternGenerator in Aplaws and in core into one. It is a core responsibility of templating and no APLAWS specific tasks involved anymore. * Removed unused classes ObjectTypeTrav* * Relocated ItemCategoryPicker to ldn-terms because it is a ldn-terms specific task to make terms available in cms in general, not an integration package task. * Relocated initialisation of TermCategoryListener to sync terms and core categories to terms, because is is a core terms task. * Various formatting and documentation. git-svn-id: https://svn.libreccm.org/ccm/trunk@2035 8810af33-2d31-482b-a856-94f89814c4df --- .../src/com/arsdigita/auth/http/Loader.java | 6 -- .../lifecycle/NotifyLifecycleListener.java | 75 +++++++++++-------- .../WEB-INF/resources/stylesheet-paths.txt | 8 +- .../templating/PatternStylesheetResolver.java | 50 ++++++++++++- .../templating/PrefixPatternGenerator.java | 15 +++- .../templating/PresentationManager.java | 19 +++-- .../templating/SimplePresentationManager.java | 2 +- .../templating/WebAppPatternGenerator.java | 32 ++++++-- .../forum/categorised/ForumTermPicker.java | 12 ++- .../arsdigita/aplaws/AutoCategorisation.java | 2 +- .../src/com/arsdigita/aplaws/Initializer.java | 22 ++++-- ...ctTypeSchemaGenerator.java.probablyUnused} | 0 ...> ObjectTypeTraversal.java.probablyUnused} | 1 + ...tTypeTraversalAdapter.java.probablyUnused} | 3 + ...tTypeTraversalAdapter.java.probablyUnused} | 0 ...WebAppPatternGenerator.java.nolongerInUse} | 2 + ...IndexItemTerms.java.probably.nolongerInUse | 46 ------------ .../arsdigita/london/terms/Initializer.java | 9 +++ .../london/terms/TermCategoryListener.java | 6 +- .../london/terms/ui/FlatCategoryPicker.java | 4 + .../london/terms}/ui/ItemCategoryPicker.java | 16 ++-- .../london/terms/ui/RootCategoryPicker.java | 14 ++-- .../src/com/arsdigita/shortcuts/Loader.java | 5 -- 23 files changed, 206 insertions(+), 143 deletions(-) rename ccm-ldn-aplaws/src/com/arsdigita/aplaws/{ObjectTypeSchemaGenerator.java => ObjectTypeSchemaGenerator.java.probablyUnused} (100%) rename ccm-ldn-aplaws/src/com/arsdigita/aplaws/{ObjectTypeTraversal.java => ObjectTypeTraversal.java.probablyUnused} (99%) rename ccm-ldn-aplaws/src/com/arsdigita/aplaws/{ObjectTypeTraversalAdapter.java => ObjectTypeTraversalAdapter.java.probablyUnused} (96%) rename ccm-ldn-aplaws/src/com/arsdigita/aplaws/{SimpleObjectTypeTraversalAdapter.java => SimpleObjectTypeTraversalAdapter.java.probablyUnused} (100%) rename ccm-ldn-aplaws/src/com/arsdigita/aplaws/{WebAppPatternGenerator.java => WebAppPatternGenerator.java.nolongerInUse} (96%) delete mode 100644 ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/AssignedIndexItemTerms.java.probably.nolongerInUse rename {ccm-ldn-aplaws/src/com/arsdigita/aplaws => ccm-ldn-terms/src/com/arsdigita/london/terms}/ui/ItemCategoryPicker.java (89%) diff --git a/ccm-auth-http/src/com/arsdigita/auth/http/Loader.java b/ccm-auth-http/src/com/arsdigita/auth/http/Loader.java index 3c7d8a730..31d71e71f 100755 --- a/ccm-auth-http/src/com/arsdigita/auth/http/Loader.java +++ b/ccm-auth-http/src/com/arsdigita/auth/http/Loader.java @@ -83,12 +83,6 @@ public class Loader extends PackageLoader { */ private void setupHTTPAuth() { - // ApplicationType type = ApplicationType - // .createApplicationType("auth-http", - // "CCM HTTP Authentication Admin", - // HTTPAuth.BASE_DATA_OBJECT_TYPE); - - /* Create new type legacy free application type * NOTE: The wording in the title parameter of ApplicationType * determines the name of the subdirectory for the XSL stylesheets. diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/NotifyLifecycleListener.java b/ccm-cms/src/com/arsdigita/cms/lifecycle/NotifyLifecycleListener.java index 75462757c..415407dde 100755 --- a/ccm-cms/src/com/arsdigita/cms/lifecycle/NotifyLifecycleListener.java +++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/NotifyLifecycleListener.java @@ -18,10 +18,10 @@ */ package com.arsdigita.cms.lifecycle; -import java.text.DateFormat; - -import org.apache.log4j.Logger; - +import java.text.DateFormat; + +import org.apache.log4j.Logger; + import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentPage; import com.arsdigita.cms.ContentSection; @@ -51,7 +51,7 @@ import com.arsdigita.workflow.simple.UserTask; * that the item is about to expire. * Does nothing at the end of the phase. *@author Michael Hanisch - *@version $Id: NotifyLifecycleListener.java 1583 2007-05-25 15:32:13Z chrisgilbert23 $ + *@version $Id: NotifyLifecycleListener.java 1583 2007-05-25 15:32:13Z chrisgilbert23 $ */ public class NotifyLifecycleListener implements LifecycleListener { @@ -81,11 +81,12 @@ public class NotifyLifecycleListener implements LifecycleListener { final ContentSection section = item.getContentSection(); if (s_log.isDebugEnabled()) { s_log.debug("item = " + (item == null ? "null" : item.toString())); - s_log.debug("section = "+ (section == null ? "null" : section.toString())); + s_log.debug("section = "+ (section == null ? "null" + : section.toString())); } - Assert.exists(item); - Assert.exists(section); + Assert.exists(item); + Assert.exists(section); UserCollection spamVictims = getRecipients(item); User user = null; @@ -122,13 +123,13 @@ public class NotifyLifecycleListener implements LifecycleListener { public void sendOneEmail(User user, Message message) { Notification notif = new Notification(user, message); - if (ContentSection.getConfig().deleteExpiryNotifications()) { - notif.setIsPermanent(Boolean.FALSE); - // true is set as default column value in DB for all - // notifications, but set explicitly here in case that - // changes - notif.setMessageDelete(Boolean.TRUE); - } + if (ContentSection.getConfig().deleteExpiryNotifications()) { + notif.setIsPermanent(Boolean.FALSE); + // true is set as default column value in DB for all + // notifications, but set explicitly here in case that + // changes + notif.setMessageDelete(Boolean.TRUE); + } if (s_log.isDebugEnabled()) { s_log.debug("notifying user " + user.getPrimaryEmail()); } @@ -204,13 +205,14 @@ public class NotifyLifecycleListener implements LifecycleListener { UserCollection usersToAlert = null; if (alertRole != null) { - usersToAlert = alertRole.getContainedUsers(); + usersToAlert = alertRole.getContainedUsers(); Filter pFilter = PermissionService - .getObjectFilterQuery(usersToAlert.getFilterFactory(), - "id", - PrivilegeDescriptor. - get(SecurityManager.CMS_EDIT_ITEM), - item.getDraftVersion().getParent().getOID()); // !! see above!! + .getObjectFilterQuery( + usersToAlert.getFilterFactory(), + "id", + PrivilegeDescriptor. + get(SecurityManager.CMS_EDIT_ITEM), + item.getDraftVersion().getParent().getOID()); // see above!! usersToAlert.addFilter(pFilter); } return usersToAlert; @@ -224,8 +226,8 @@ public class NotifyLifecycleListener implements LifecycleListener { *@return a Message concerning item * Pattern Meaning Examples * - * ::locale:: - * Current locale - * fr_FR + * ::host:: + * Host name + * www.aplaws.org * * * ::vhost:: @@ -88,6 +88,37 @@ import org.apache.log4j.Logger; * business.camden.gov.uk * * + * ::webapp:: + * Current web application name (ie. context or document root) + * ccm + * + * + * ::application:: + * Current application name + * navigation + * + * + * ::url:: + * URL stub of the current applications name tree + * admin + * + * + * ::prefix:: + * ?? + * ?? + * + * + * ::outputtype:: + * Output format. + * text_html + * + * + * ::locale:: + * Current locale + * fr_FR + * + * clear + * * ::outputtype:: * Output format. * text_html @@ -109,6 +140,17 @@ import org.apache.log4j.Logger; * The resolver looks at each stylesheet in turn, and the first one which * actually exists on disk is returned. *

+ * + * Developer may customize the process by writing a custom pattern generator + * and add it in a custom integration package Initializer (e.g. ccm-ldn-aplaws) + * by following code: + * // Register additional PatternStyleSheetResolver for Web app. + * // With all modules installing in one context no longer required. + * PatternStylesheetResolver.registerPatternGenerator( + * "[myKey]", + * new [My]PatternGenerator() + * ); + * * * @author Richard W.M. Jones */ @@ -147,7 +189,7 @@ public class PatternStylesheetResolver implements StylesheetResolver { registerPatternGenerator ("prefix", new PrefixPatternGenerator()); registerPatternGenerator - ("webapps", new WebAppPatternGenerator()); + ("webapp", new WebAppPatternGenerator()); registerPatternGenerator ("host", new HostPatternGenerator()); s_log.debug("Static initalizer finished."); diff --git a/ccm-core/src/com/arsdigita/templating/PrefixPatternGenerator.java b/ccm-core/src/com/arsdigita/templating/PrefixPatternGenerator.java index ef86ca25a..eac01aaeb 100755 --- a/ccm-core/src/com/arsdigita/templating/PrefixPatternGenerator.java +++ b/ccm-core/src/com/arsdigita/templating/PrefixPatternGenerator.java @@ -22,18 +22,27 @@ import com.arsdigita.dispatcher.DispatcherHelper; import javax.servlet.http.HttpServletRequest; /** - * Generates a pattern for based on the request prefix, + * Generates a pattern for based on the request dispatcher prefix, * eg /print/content/myitem.jsp -> { 'print' } * /text-only/content/myitem.jsp -> { 'text-only' } */ public class PrefixPatternGenerator implements PatternGenerator { + + /** + * + * @param key + * @param req + * @return + */ public String[] generateValues(String key, HttpServletRequest req) { String value = DispatcherHelper.getDispatcherPrefix(req); if (value != null) { return new String[] { value.substring(1) }; } - - return new String[] { }; + else { + return new String[] { }; + } } + } diff --git a/ccm-core/src/com/arsdigita/templating/PresentationManager.java b/ccm-core/src/com/arsdigita/templating/PresentationManager.java index 0d0b45872..76c4fcdc1 100755 --- a/ccm-core/src/com/arsdigita/templating/PresentationManager.java +++ b/ccm-core/src/com/arsdigita/templating/PresentationManager.java @@ -23,18 +23,21 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * Interface for styling and serving XML documents to - * the response output stream. The PresentationManager contains the - * code that determines which XSLT transformer(s) are to be applied to - * a given document. The default - * BasePresentationManager should suffice for most cases. A custom - * presentation manager is needed if an application needs to + * Interface for styling and serving XML documents to the response output + * stream. + * + * The PresentationManager contains the code that determines which + * XSLT transformer(s) are to be applied to a given document. + * + * The (default) SimplePresentationManager just links to the bebop + * implementation. It should suffice for most cases. + * + * A custom presentation manager is needed if an application needs to * dynamically apply a set of templates to an XML document in a custom * way. Typically, this occurs if the template selection * depends on the outcome of some application-specific logic. * - * @see com.arsdigita.sitenode.SiteNodePresentationManager - * @see com.arsdigita.sitenode.BasePresentationManager + * @see com.arsdigita.templating.SimplePresentationManager * * @author Bill Schneider * @version ACS 4.6 diff --git a/ccm-core/src/com/arsdigita/templating/SimplePresentationManager.java b/ccm-core/src/com/arsdigita/templating/SimplePresentationManager.java index 2e05204cb..5bd65ef20 100755 --- a/ccm-core/src/com/arsdigita/templating/SimplePresentationManager.java +++ b/ccm-core/src/com/arsdigita/templating/SimplePresentationManager.java @@ -28,7 +28,7 @@ package com.arsdigita.templating; * configuration registry. */ /* NON Javadoc comment: - * Used to be depracated in version 6.6.0. Reverted to non-deprecated in version + * Used to be deprecated in version 6.6.0. Reverted to non-deprecated in version * 6.6.0 release 3. Package templating provides the basic mechanism for CCM * templating system an should provide an implementation of the Presentation * Manager interface to be complete. diff --git a/ccm-core/src/com/arsdigita/templating/WebAppPatternGenerator.java b/ccm-core/src/com/arsdigita/templating/WebAppPatternGenerator.java index 8a8776c50..06f6cab50 100755 --- a/ccm-core/src/com/arsdigita/templating/WebAppPatternGenerator.java +++ b/ccm-core/src/com/arsdigita/templating/WebAppPatternGenerator.java @@ -29,28 +29,48 @@ import org.apache.log4j.Logger; /** * Generates a set of patterns corresponding to the current - * web application prefix + * web application prefix. */ public class WebAppPatternGenerator implements PatternGenerator { + /** Private Logger instance for debugging purpose. */ private static final Logger s_log = Logger.getLogger(WebAppPatternGenerator.class); public String[] generateValues(String key, HttpServletRequest req) { + Application app = Web.getContext().getApplication(); String ctx = app == null ? null : app.getContextPath(); - if (app == null || - ctx == null || - "".equals(ctx)) { - return new String[] { Web.ROOT_WEBAPP }; + if (s_log.isDebugEnabled()) { + s_log.debug("Generating Values key: " + key + " [" + + "Web.getContext(): " + Web.getContext() + "," + + "Application: " + Web.getContext().getApplication() + "," + + "ContextPath: " + ctx + "," + "]"); + } + + if (app == null || ctx == null || "".equals(ctx)) { + return new String[] { Web.ROOT_WEBAPP }; // Currently "ROOT" } if (ctx.startsWith("/")) { ctx = ctx.substring(1); } - return new String[] { ctx + "," + Web.ROOT_WEBAPP }; + /* "Older version: prior 6.6. Some modules used to be installed into + * its own web application context, but needed access to the main + * applications package files (e.g. bebop) which were installed into + * to ROOT web context. Therefore ROOT had to be added. + */ + // return new String[] { ctx + "," + Web.ROOT_WEBAPP }; + + /* As of version 6.6 all packages are installed in one web application + * context, therefore the ROOT entry is no longer valid. + * This variation had first be introduced with the APLAWS integration + * package, which used to register an additional WebAppPatternGenerator, + * which simply cuts ","+ Web.ROOT_WEBAPP, under a different key + * "Webapp" (singular) */ + return new String[] { ctx }; } } diff --git a/ccm-forum-categorised/src/com/arsdigita/forum/categorised/ForumTermPicker.java b/ccm-forum-categorised/src/com/arsdigita/forum/categorised/ForumTermPicker.java index 0bc81daa5..334ff4acb 100644 --- a/ccm-forum-categorised/src/com/arsdigita/forum/categorised/ForumTermPicker.java +++ b/ccm-forum-categorised/src/com/arsdigita/forum/categorised/ForumTermPicker.java @@ -40,16 +40,20 @@ public class ForumTermPicker extends ACSObjectCategoryPicker { public ForumTermPicker(BigDecimalParameter root, StringParameter mode) { - super(root, mode); - s_log.debug("instantiating ForumCategoryPicker"); + + super(root, mode); + s_log.debug("instantiating ForumCategoryPicker"); } /* (non-Javadoc) - * @see com.arsdigita.aplaws.ui.ACSObjectCategoryPicker#getForm(com.arsdigita.bebop.parameters.BigDecimalParameter, com.arsdigita.bebop.parameters.StringParameter) + * @see com.arsdigita.aplaws.ui.ACSObjectCategoryPicker#getForm + * com.arsdigita.bebop.parameters.BigDecimalParameter, + * com.arsdigita.bebop.parameters.StringParameter) */ - protected ACSObjectCategoryForm getForm(BigDecimalParameter root, StringParameter mode) { + protected ACSObjectCategoryForm getForm(BigDecimalParameter root, + StringParameter mode) { s_log.debug("getForm"); return new ForumTermForm(root, mode, new TermWidget(mode, this)); } diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java index 96e2f8641..249748598 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java +++ b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/AutoCategorisation.java @@ -26,7 +26,7 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import com.arsdigita.aplaws.ui.ItemCategoryPicker; +import com.arsdigita.london.terms.ui.ItemCategoryPicker; import com.arsdigita.categorization.Category; import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentItem; diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/Initializer.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/Initializer.java index 099ed6e3e..f3dd342fe 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/Initializer.java +++ b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/Initializer.java @@ -18,11 +18,11 @@ package com.arsdigita.aplaws; -import com.arsdigita.categorization.Categorization; -import com.arsdigita.london.terms.TermCategoryListener; +//import com.arsdigita.categorization.Categorization; +//import com.arsdigita.london.terms.TermCategoryListener; import com.arsdigita.runtime.CompoundInitializer; import com.arsdigita.runtime.DomainInitEvent; -import com.arsdigita.templating.PatternStylesheetResolver; +//import com.arsdigita.templating.PatternStylesheetResolver; import org.apache.log4j.Logger; @@ -46,11 +46,17 @@ public class Initializer extends CompoundInitializer { public void init(DomainInitEvent evt) { super.init(evt); - Categorization.addCategoryListener(new TermCategoryListener()); + // Moved to terms initializer because it is a central responsibility of + // terms itself. + // /* Create new term in the proper terms domain whenever a new category + // * is created through CMS interface, keeping both insync */ + // Categorization.addCategoryListener(new TermCategoryListener()); - PatternStylesheetResolver.registerPatternGenerator( - "webapp", - new WebAppPatternGenerator() - ); + // /* Register additional PatternStyleSheetResolver for Web app. + // * With all modules installing in one context no longer required. */ + // PatternStylesheetResolver.registerPatternGenerator( + // "webapp", + // new WebAppPatternGenerator() + // ); } } diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java.probablyUnused similarity index 100% rename from ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java rename to ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeSchemaGenerator.java.probablyUnused diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversal.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversal.java.probablyUnused similarity index 99% rename from ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversal.java rename to ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversal.java.probablyUnused index 64d21a34e..0c79a5864 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversal.java +++ b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversal.java.probablyUnused @@ -37,6 +37,7 @@ import org.apache.log4j.Logger; // At minimum the process for registering & looking up hierachical // adapters can be shared. Also the mangling of names / paths. +// Currently just used by ObjectTypeSchemaGenerator /** *

This class provides a general purpose framework for iterating diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversalAdapter.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversalAdapter.java.probablyUnused similarity index 96% rename from ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversalAdapter.java rename to ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversalAdapter.java.probablyUnused index 08c215a2b..ce9048a3c 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversalAdapter.java +++ b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ObjectTypeTraversalAdapter.java.probablyUnused @@ -26,6 +26,9 @@ import com.arsdigita.persistence.metadata.Property; // some of their logic (provided it didn't cripple / obfuscate // the API). +// Currently just used by ObjectTypeTraversal and SimpleObjectTypeAdapter +// of this package. + /** *

This interface is used to control traversal of domain * objects. Whenever a property is encountered, the {@link diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/SimpleObjectTypeTraversalAdapter.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/SimpleObjectTypeTraversalAdapter.java.probablyUnused similarity index 100% rename from ccm-ldn-aplaws/src/com/arsdigita/aplaws/SimpleObjectTypeTraversalAdapter.java rename to ccm-ldn-aplaws/src/com/arsdigita/aplaws/SimpleObjectTypeTraversalAdapter.java.probablyUnused diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/WebAppPatternGenerator.java b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/WebAppPatternGenerator.java.nolongerInUse similarity index 96% rename from ccm-ldn-aplaws/src/com/arsdigita/aplaws/WebAppPatternGenerator.java rename to ccm-ldn-aplaws/src/com/arsdigita/aplaws/WebAppPatternGenerator.java.nolongerInUse index 5c07af575..bd3708db1 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/WebAppPatternGenerator.java +++ b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/WebAppPatternGenerator.java.nolongerInUse @@ -37,11 +37,13 @@ import org.apache.log4j.Logger; */ public class WebAppPatternGenerator implements PatternGenerator { + /** Private Logger instance for debugging purpose. */ private static final Logger s_log = Logger.getLogger(WebAppPatternGenerator.class); public String[] generateValues(String key, HttpServletRequest req) { + Application app = Web.getContext().getApplication(); String ctx = app == null ? null : app.getContextPath(); diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/AssignedIndexItemTerms.java.probably.nolongerInUse b/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/AssignedIndexItemTerms.java.probably.nolongerInUse deleted file mode 100644 index 4a50487b7..000000000 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/AssignedIndexItemTerms.java.probably.nolongerInUse +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (C) 2005 Runtime Collective Ltd. 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.bundle.ui; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.cms.CMS; -import com.arsdigita.cms.ContentBundle; -import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.ContentPage; -import com.arsdigita.kernel.ACSObject; -import com.arsdigita.london.navigation.Navigation; -import com.arsdigita.london.terms.ui.AbstractAssignedTerms; - -import org.apache.log4j.Logger; - -public class AssignedIndexItemTerms extends AbstractAssignedTerms { - - private static final Logger s_log = Logger.getLogger(AssignedIndexItemTerms.class); - - protected ACSObject getObject(PageState state) { - - ACSObject obj = Navigation.getConfig().getDefaultModel().getObject(); - - if (s_log.isDebugEnabled()) { - s_log.debug("Dealing with item " + obj); - } - - return obj; - } -} diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/Initializer.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/Initializer.java index 05747bd7e..0b2f0d599 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/Initializer.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/Initializer.java @@ -18,6 +18,7 @@ package com.arsdigita.london.terms; +import com.arsdigita.categorization.Categorization; import com.arsdigita.categorization.Category; import com.arsdigita.db.DbHelper; import com.arsdigita.domain.DomainObject; @@ -51,7 +52,9 @@ public class Initializer extends CompoundInitializer { new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl")))); } + @Override public void init(DomainInitEvent e) { + DomainObjectFactory.registerInstantiator (Domain.BASE_DATA_OBJECT_TYPE, new DomainObjectInstantiator() { @@ -63,6 +66,7 @@ public class Initializer extends CompoundInitializer { DomainObjectFactory.registerInstantiator (Term.BASE_DATA_OBJECT_TYPE, new ACSObjectInstantiator() { + @Override public DomainObject doNewInstance(DataObject dataObject) { return new Term(dataObject); } @@ -71,6 +75,7 @@ public class Initializer extends CompoundInitializer { DomainObjectFactory.registerInstantiator (Terms.BASE_DATA_OBJECT_TYPE, new ACSObjectInstantiator() { + @Override public DomainObject doNewInstance(DataObject dataObject) { return new Terms(dataObject); } @@ -124,5 +129,9 @@ public class Initializer extends CompoundInitializer { XML.parse(Terms.getConfig().getTraversalAdapters(), new TraversalHandler()); + + /* Create new term in the proper terms domain whenever a new category + * is created through CMS interface, keeping both insync */ + Categorization.addCategoryListener(new TermCategoryListener()); } } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java index ea0a2a099..60d3eb83d 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/TermCategoryListener.java @@ -18,8 +18,6 @@ */ package com.arsdigita.london.terms; -import org.apache.log4j.Logger; - import com.arsdigita.categorization.Category; import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.categorization.CategoryListener; @@ -28,6 +26,8 @@ import com.arsdigita.kernel.ACSObject; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; +import org.apache.log4j.Logger; + /** * Attempts to create new term in the proper terms domain * whenever a new category is created through CMS interface. @@ -35,7 +35,7 @@ import com.arsdigita.persistence.SessionManager; public class TermCategoryListener implements CategoryListener { private static final Logger s_log = Logger.getLogger( - TermCategoryListener.class); + TermCategoryListener.class); public void onDelete(Category cat) { } diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/FlatCategoryPicker.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/FlatCategoryPicker.java index 07b4a34b6..89da0fe56 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/FlatCategoryPicker.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/FlatCategoryPicker.java @@ -27,6 +27,10 @@ import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; +/** + * + * + */ public class FlatCategoryPicker extends AbstractCategoryPicker { public FlatCategoryPicker(String name) { diff --git a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/ItemCategoryPicker.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/ItemCategoryPicker.java similarity index 89% rename from ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/ItemCategoryPicker.java rename to ccm-ldn-terms/src/com/arsdigita/london/terms/ui/ItemCategoryPicker.java index 5b4cb797f..aeb9f2624 100755 --- a/ccm-ldn-aplaws/src/com/arsdigita/aplaws/ui/ItemCategoryPicker.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/ItemCategoryPicker.java @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -package com.arsdigita.aplaws.ui; +package com.arsdigita.london.terms.ui; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.parameters.BigDecimalParameter; @@ -31,19 +31,20 @@ import com.arsdigita.london.terms.ui.TermWidget; import org.apache.log4j.Logger; + /** - *

cms specific Concrete implementation of + * Replacement for cms authoring ItemCategoryForm which replaces the + * category widget with a terms based widget. + * + * Provides a cms specific concrete implementation of * com.arsdigita.london.terms.ui.ACSObjectCategoryPicker.

* - * - * - *

Activated by pointing the parameter + *

Is is activated / used by pointing the parameter * com.arsdigita.cms.category_authoring_add_form< to it.

*/ - - public class ItemCategoryPicker extends ACSObjectCategoryPicker { + /** Private Logger instance for debugging */ private static final Logger s_log = Logger.getLogger(ItemCategoryPicker.class); @@ -71,6 +72,7 @@ public class ItemCategoryPicker extends ACSObjectCategoryPicker { * @see com.arsdigita.london.terms.ui.ACSObjectCategoryPicker#getObject() */ protected ACSObject getObject(PageState state) { + ContentItem item = CMS.getContext().getContentItem(); return item.getParent(); diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/RootCategoryPicker.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/RootCategoryPicker.java index 34cba577d..b83fe3560 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/RootCategoryPicker.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/ui/RootCategoryPicker.java @@ -48,18 +48,20 @@ public class RootCategoryPicker extends AbstractCategoryPicker { * @param state * @param target */ - protected void addOptions(PageState state, - SingleSelect target) { - DataCollection domains = SessionManager.getSession() - .retrieve(Domain.BASE_DATA_OBJECT_TYPE); + protected void addOptions( PageState state, + SingleSelect target) { + + DataCollection domains = SessionManager + .getSession() + .retrieve(Domain.BASE_DATA_OBJECT_TYPE); domains.addPath("model.id"); domains.addPath("model.objectType"); domains.addOrder("title"); target.addOption(new Option(null, "-- pick one --")); while (domains.next()) { - Domain domain = (Domain) - DomainObjectFactory.newInstance(domains.getDataObject()); + Domain domain = (Domain) DomainObjectFactory + .newInstance(domains.getDataObject()); target.addOption( new Option(new OID((String)domains.get("model.objectType"), diff --git a/ccm-shortcuts/src/com/arsdigita/shortcuts/Loader.java b/ccm-shortcuts/src/com/arsdigita/shortcuts/Loader.java index 6339a78ca..19ed34273 100755 --- a/ccm-shortcuts/src/com/arsdigita/shortcuts/Loader.java +++ b/ccm-shortcuts/src/com/arsdigita/shortcuts/Loader.java @@ -69,11 +69,6 @@ public class Loader extends PackageLoader { s_log.debug("Creating an application type for shortcuts. " + "Base Data Object Type: " + Shortcuts.BASE_DATA_OBJECT_TYPE); - /* Create legacy-campatible application type */ -/* ApplicationType type = ApplicationType - .createApplicationType("shortcuts", - "CCM Shortcuts Admin", - Shortcuts.BASE_DATA_OBJECT_TYPE); */ /* Create legacy-free application type * NOTE: The wording in the title parameter of ApplicationType * determines the name of the subdirectory for the XSL stylesheets.