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
master
pb 2013-01-13 13:19:41 +00:00
parent 47f50ad2c9
commit 690db3cde2
23 changed files with 206 additions and 143 deletions

View File

@ -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.

View File

@ -81,7 +81,8 @@ 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);
@ -206,11 +207,12 @@ public class NotifyLifecycleListener implements LifecycleListener {
if (alertRole != null) {
usersToAlert = alertRole.getContainedUsers();
Filter pFilter = PermissionService
.getObjectFilterQuery(usersToAlert.getFilterFactory(),
.getObjectFilterQuery(
usersToAlert.getFilterFactory(),
"id",
PrivilegeDescriptor.
get(SecurityManager.CMS_EDIT_ITEM),
item.getDraftVersion().getParent().getOID()); // !! see above!!
item.getDraftVersion().getParent().getOID()); // see above!!
usersToAlert.addFilter(pFilter);
}
return usersToAlert;
@ -245,19 +247,30 @@ public class NotifyLifecycleListener implements LifecycleListener {
String subject = "Content Item " + name + " is about to expire";
// term section.getSiteNode below doesn't produce any meaningful
// value, because table sitenodes is empty since all apps are
// new style, legacy free apps. Term returns null.
String publicURL = URL.there(section.getSiteNode().getURL(DispatcherHelper.getWebappContext())
+ ((ContentItem)item.getParent()).getPath(),
null).getURL();
// section.getSiteNode() get the sigenote object for the current
// contentsection in use, getURL is a sitenode method to provide
// the corresponding URL as String.
// Modification NOT test yet!
String publicURL = URL.there(
// section.getSiteNode().getURL(DispatcherHelper.getWebappContext())
section.getPath()
+ ((ContentItem)item.getParent()).getPath()
,null
).getURL();
// link to the trunk version of the item, which can be edited.
// the live item cannot!
//String adminURL = URL.there(ContentItemPage.getItemURL(item,ContentItemPage.AUTHORING_TAB), null).getURL();
ContentItem adminItem = item.getDraftVersion();
if (adminItem == null) {
adminItem = item;
}
String adminURL = URL.there(ContentItemPage.getItemURL(adminItem,
String adminURL = URL.there(ContentItemPage
.getItemURL(adminItem,
ContentItemPage.AUTHORING_TAB)
, null).getURL();

View File

@ -3,8 +3,8 @@
# "PatternStylesheetResolver". Please read the Javadoc for that file for
# the full story.
http://::host::/resource/::webapps::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::-::locale::.xsl
http://::host::/resource/::webapps::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::.xsl
http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::-::locale::.xsl
http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::.xsl
http://::host::/resource/::webapps::/themes/heirloom/apps/::application::/xsl/::url::-::locale::.xsl
http://::host::/resource/::webapps::/themes/heirloom/apps/::application::/xsl/::url::.xsl
http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::locale::.xsl
http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::.xsl

View File

@ -78,9 +78,9 @@ import org.apache.log4j.Logger;
* <table border="1">
* <tr> <th> Pattern </th> <th> Meaning </th> <th> Examples </th> </tr>
* <tr>
* <td> <code>::locale::</code> </td>
* <td> Current locale </td>
* <td> <code>fr_FR</code> </td>
* <td> <code>::host::</code> </td>
* <td> Host name </td>
* <td> <code>www.aplaws.org</code> </td>
* </tr>
* <tr>
* <td> <code>::vhost::</code> </td>
@ -88,6 +88,37 @@ import org.apache.log4j.Logger;
* <td> <code>business.camden.gov.uk</code> </td>
* </tr>
* <tr>
* <td> <code>::webapp::</code> </td>
* <td> Current web application name (ie. context or document root) </td>
* <td> <code>ccm</code> </td>
* </tr>
* <tr>
* <td> <code>::application::</code> </td>
* <td> Current application name </td>
* <td> <code>navigation</code> </td>
* </tr>
* <tr>
* <td> <code>::url::</code> </td>
* <td> URL stub of the current applications name tree</td>
* <td> <code>admin</code> </td>
* </tr>
* <tr>
* <td> <code>::prefix::</code> </td>
* <td> ??</td>
* <td> <code>??</code> </td>
* </tr>
* <tr>
* <td> <code>::outputtype::</code> </td>
* <td> Output format. </td>
* <td> <code>text_html</code> </td>
* </tr>
* <tr>
* <td> <code>::locale::</code> </td>
* <td> Current locale </td>
* <td> <code>fr_FR</code> </td>
* </tr>
* <tr>clear
*
* <td> <code>::outputtype::</code> </td>
* <td> Output format. </td>
* <td> <code>text_html</code> </td>
@ -110,6 +141,17 @@ import org.apache.log4j.Logger;
* actually exists on disk is returned.
* </p>
*
* 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
*/
public class PatternStylesheetResolver implements StylesheetResolver {
@ -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.");

View File

@ -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) };
}
else {
return new String[] { };
}
}
}

View File

@ -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

View File

@ -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.

View File

@ -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 };
}
}

View File

@ -40,6 +40,7 @@ public class ForumTermPicker extends ACSObjectCategoryPicker {
public ForumTermPicker(BigDecimalParameter root,
StringParameter mode) {
super(root, mode);
s_log.debug("instantiating ForumCategoryPicker");
@ -47,9 +48,12 @@ public class ForumTermPicker extends ACSObjectCategoryPicker {
/* (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));
}

View File

@ -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;

View File

@ -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()
// );
}
}

View File

@ -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
/**
* <p>This class provides a general purpose framework for iterating

View File

@ -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.
/**
* <p>This interface is used to control traversal of domain
* objects. Whenever a property is encountered, the {@link

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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());
}
}

View File

@ -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.

View File

@ -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) {

View File

@ -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;
/**
* <p> 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
* <code>com.arsdigita.london.terms.ui.ACSObjectCategoryPicker</code>. </p>
*
*
*
* <p>Activated by pointing the parameter
* <p> Is is activated / used by pointing the parameter
* <code>com.arsdigita.cms.category_authoring_add_form<</code> to it.</p>
*/
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();

View File

@ -48,9 +48,11 @@ public class RootCategoryPicker extends AbstractCategoryPicker {
* @param state
* @param target
*/
protected void addOptions(PageState state,
protected void addOptions( PageState state,
SingleSelect target) {
DataCollection domains = SessionManager.getSession()
DataCollection domains = SessionManager
.getSession()
.retrieve(Domain.BASE_DATA_OBJECT_TYPE);
domains.addPath("model.id");
domains.addPath("model.objectType");
@ -58,8 +60,8 @@ public class RootCategoryPicker extends AbstractCategoryPicker {
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"),

View File

@ -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.