diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java index 5520e18dd..bf16c7f14 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/FileAttachmentConfig.java @@ -11,6 +11,9 @@ public class FileAttachmentConfig extends AbstractConfig { Parameter editFormClass; Parameter showAssetID; + /** + * Constructor, don't use is directly! + */ public FileAttachmentConfig() { editFormClass = new ClassParameter ("com.arsdigita.cms.contentassets.file_edit_form", Parameter.REQUIRED, diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/EventResources_de.properties b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/EventResources_de.properties index 738a0701b..4682465a4 100755 --- a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/EventResources_de.properties +++ b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/EventResources_de.properties @@ -1,9 +1,9 @@ # EventResources_de.properties # Alle deutschem Umlaute muessen als UTF-8 eingetragen werden: -# ä = \u00e4 Ä = \u00c4 -# ü = \u00fc Ü = \u00dc -# ö = \u00f6 Ö = \u00d6 -# ß = \u00df +# \u00C3\u00A4 = \u00E4 \u00C3\u0084 = \u00C4 +# \u00C3\u00BC = \u00FC \u00C3\u009C = \u00DC +# \u00C3\u00B6 = \u00F6 \u00C3\u0096 = \u00D6 +# \u00C3\u009F = \u00DF event.authoring.basic_properties.description=Bearbeitung des Titels, Namens, Datums, Zeit, Ort, Haupt- Mitarbeiter, Typ, Link zur Karte und Kosten # # useless here, must be transferred to CMSResources @@ -16,7 +16,7 @@ cms.contenttypes.ui.event.start_date=Anfangs-Datum: cms.contenttypes.ui.event.start_time=Begin: cms.contenttypes.ui.event.end_date=End-Datum: cms.contenttypes.ui.event.end_time=Ende: -cms.contenttypes.ui.event.end_date_after_start_date=Das Anfangs-Datum ist sp\u00c4ter als das End-Datum +cms.contenttypes.ui.event.end_date_after_start_date=Das Anfangs-Datum ist sp\u00E4ter als das End-Datum # cms.contenttypes.ui.event.date_description=Termin Zusatz: cms.contenttypes.ui.event.location=Ort: diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/package.html b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/package.html index ffd807e54..fc2eadcf9 100755 --- a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/package.html +++ b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/package.html @@ -1,6 +1,7 @@
+diff --git a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/util/EventGlobalizationUtil.java b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/util/EventGlobalizationUtil.java index 0696381da..dcd285fc3 100755 --- a/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/util/EventGlobalizationUtil.java +++ b/ccm-cms-types-event/src/com/arsdigita/cms/contenttypes/util/EventGlobalizationUtil.java @@ -22,7 +22,6 @@ import com.arsdigita.globalization.GlobalizedMessage; /** *
- * . * Contains methods to simplify globalizing keys *
* diff --git a/ccm-cms-types-filestorageitem/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/FileStorageItem.xml b/ccm-cms-types-filestorageitem/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/FileStorageItem.xml index 2782746ac..afa1ea8dc 100755 --- a/ccm-cms-types-filestorageitem/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/FileStorageItem.xml +++ b/ccm-cms-types-filestorageitem/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/FileStorageItem.xml @@ -1,5 +1,8 @@ -
diff --git a/ccm-cms/src/ccm-cms.config b/ccm-cms/src/ccm-cms.config
index 40467cbe6..33c205a29 100755
--- a/ccm-cms/src/ccm-cms.config
+++ b/ccm-cms/src/ccm-cms.config
@@ -2,4 +2,6 @@
- public boolean indexObject (DomainObject dobj) {
- FileAttachment file = (FileAttachment) dobj;
- ContentPage owner = (ContentPage) file.getFileOwner();
- s_log.debug("index this file attachment? " + !owner.indexAssetsWithPage());
- return !owner.indexAssetsWithPage();
- }
-
- * @return
- */
- public boolean indexAssetsWithPage() {
- return false;
- }
-
+ /**
+ * Decides whether plugged in assets should be indexed with the
+ * page or separately. Default is false (assets are ONLY indexed
+ * as separate items) Subtypes may override this method to
+ * provide the logic that decides whether or not assets should
+ * be indexed separately. If true, content of assets is ONLY
+ * included in the page, not as a separate item. This method only provides
+ * guidance to assets. Writers of plug in assets should
+ * refer to this method in relation to the object that
+ * owns the asset and make a decision based on the answer.
+ *
+ * Best course of action is for assets to provide their
+ * own MetadataProvider which refers to this method in the
+ * indexObject method eg.
+ *
+ *
+ *
+
+ public boolean indexObject (DomainObject dobj) {
+ FileAttachment file = (FileAttachment) dobj;
+ ContentPage owner = (ContentPage) file.getFileOwner();
+ s_log.debug("index this file attachment? " + !owner.indexAssetsWithPage());
+ return !owner.indexAssetsWithPage();
+ }
+
+ * @return
+ */
+ public boolean indexAssetsWithPage() {
+ return false;
+ }
+
public final ContentBundle getContentBundle() {
final ACSObject parent = getParent();
@@ -206,12 +204,12 @@ public class ContentPage extends ContentItem {
set(LAUNCH_DATE, ldate);
}
- public void setDescription(String description) {
- set(DESCRIPTION, description);
- }
- public String getDescription() {
- return (String)get(DESCRIPTION);
- }
+ public void setDescription(String description) {
+ set(DESCRIPTION, description);
+ }
+ public String getDescription() {
+ return (String)get(DESCRIPTION);
+ }
// Set parameters on the pagesInFolder data query
/**
@@ -336,12 +334,12 @@ public class ContentPage extends ContentItem {
// These could be protected, but public may make it easier to
// debug
- /**
- * default behaviour is to return the description. Subtypes should
- * override to change use some other attribute
- */
+ /**
+ * default behaviour is to return the description. Subtypes should
+ * override to change use some other attribute
+ */
public String getSearchSummary() {
- return getDescription();
+ return getDescription();
}
}
diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java
index dc8434a12..6aa931733 100755
--- a/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java
+++ b/ccm-cms/src/com/arsdigita/cms/ContentSectionConfig.java
@@ -95,10 +95,6 @@ import org.apache.log4j.Logger;
* @version $Id: ContentSectionConfig.java 1689 2007-10-26 11:06:23Z chrisg23 $
*/
public final class ContentSectionConfig extends AbstractConfig {
- public static final String versionId =
- "$Id: ContentSectionConfig.java 1689 2007-10-26 11:06:23Z chrisg23 $" +
- "$Author: chrisg23 $" +
- "$DateTime: $";
private static final Logger s_log = Logger.getLogger(ContentSectionConfig.class);
@@ -160,9 +156,7 @@ public final class ContentSectionConfig extends AbstractConfig {
* @see ContentSection#getConfig()
**/
public ContentSectionConfig() {
- m_templateRootPath = new StringParameter
- ("com.arsdigita.cms.template_root_path",
- Parameter.REQUIRED, "/packages/content-section/templates");
+
m_defaultItemTemplatePath = new StringParameter
("com.arsdigita.cms.default_item_template_path",
Parameter.REQUIRED, "/default/item.jsp");
@@ -172,11 +166,6 @@ public final class ContentSectionConfig extends AbstractConfig {
m_languages = new StringParameter
("com.arsdigita.cms.languages",
Parameter.REQUIRED, "en,de,fr,nl,it,pt,es");
- m_publishToFileClass = new SpecificClassParameter
- ("com.arsdigita.cms.publish_to_file_class",
- Parameter.REQUIRED,
- PublishToFile.class,
- PublishToFileListener.class);
m_linksOnlyInSameSubsite = new BooleanParameter
("com.arsdigita.cms.browse_links_in_same_subsite_only",
@@ -211,12 +200,9 @@ public final class ContentSectionConfig extends AbstractConfig {
ItemCategoryForm.class,
SimpleComponent.class);
- // XXX: temporary parameter. will be removed when MapParameter
- // works and the p2fs initializer is converted away from the
- // legacy init
- m_disableItemPfs = new BooleanParameter
- ("com.arsdigita.cms.disable_item_pfs",
- Parameter.REQUIRED, new Boolean(false));
+ m_templateRootPath = new StringParameter
+ ("com.arsdigita.cms.template_root_path",
+ Parameter.REQUIRED, "/packages/content-section/templates");
// XXX: temporary parameter. will be removed when
// SectionInitializer is replaced with a separate Section
@@ -374,10 +360,6 @@ public final class ContentSectionConfig extends AbstractConfig {
("com.arsdigita.cms.mandatory_descriptions",
Parameter.OPTIONAL, new Boolean(false));
- m_deleteLifecycleWhenComplete = new BooleanParameter
- ("com.arsdigita.cms.delete_lifecycle_when_complete",
- Parameter.OPTIONAL, new Boolean(false));
-
m_deleteExpiryNotificationsWhenSent = new BooleanParameter
("com.arsdigita.cms.delete_expiry_notification_when_sent",
Parameter.OPTIONAL, new Boolean(false));
@@ -409,6 +391,27 @@ public final class ContentSectionConfig extends AbstractConfig {
Parameter.REQUIRED,
new Boolean(true));
+ // Lifecycle package
+
+ m_deleteLifecycleWhenComplete = new BooleanParameter
+ ("com.arsdigita.cms.delete_lifecycle_when_complete",
+ Parameter.OPTIONAL, new Boolean(false));
+
+ // PublishToFile package
+ m_publishToFileClass = new SpecificClassParameter
+ ("com.arsdigita.cms.publish_to_file_class",
+ Parameter.REQUIRED,
+ PublishToFile.class,
+ PublishToFileListener.class);
+
+ // XXX: temporary parameter. will be removed when MapParameter
+ // works and the p2fs initializer is converted away from the
+ // legacy init
+ m_disableItemPfs = new BooleanParameter
+ ("com.arsdigita.cms.disable_item_pfs",
+ Parameter.REQUIRED, new Boolean(false));
+
+
register(m_templateRootPath);
register(m_defaultItemTemplatePath);
register(m_defaultFolderTemplatePath);
diff --git a/ccm-cms/src/com/arsdigita/cms/ContentType.java b/ccm-cms/src/com/arsdigita/cms/ContentType.java
index 0d5c268d3..ac2ef0392 100755
--- a/ccm-cms/src/com/arsdigita/cms/ContentType.java
+++ b/ccm-cms/src/com/arsdigita/cms/ContentType.java
@@ -52,12 +52,10 @@ import java.net.MalformedURLException;
*
* @author Michael Pih (pihman@arsdigita.com)
* @author Jack Chung (flattop@arsdigita.com)
- * @version $Revision: #17 $ $Date: 2004/08/17 $
+ * @version $Id: ContentType.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class ContentType extends ACSObject {
- public static final String versionId = "$Id: ContentType.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/17 23:15:09 $";
-
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.ContentType";
diff --git a/ccm-cms/src/com/arsdigita/cms/Initializer.java b/ccm-cms/src/com/arsdigita/cms/Initializer.java
index 03def664b..9bdef0caa 100755
--- a/ccm-cms/src/com/arsdigita/cms/Initializer.java
+++ b/ccm-cms/src/com/arsdigita/cms/Initializer.java
@@ -96,6 +96,11 @@ public class Initializer extends CompoundInitializer {
("ccm-cms.pdl.mf",
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
+ // add(new LegacyInitializer("com/arsdigita/cms/publishToFile/enterprise.init"));
+
+ add(new com.arsdigita.cms.publishToFile.Initializer());
+ add(new com.arsdigita.cms.lifecycle.Initializer());
+
add(new LegacyInitializer("com/arsdigita/cms/enterprise.init"));
}
/**
diff --git a/ccm-cms/src/com/arsdigita/cms/Loader.java b/ccm-cms/src/com/arsdigita/cms/Loader.java
index e8c8085e7..6b1aa242b 100755
--- a/ccm-cms/src/com/arsdigita/cms/Loader.java
+++ b/ccm-cms/src/com/arsdigita/cms/Loader.java
@@ -29,10 +29,6 @@ import org.apache.log4j.Logger;
* @version $Id: Loader.java 754 2005-09-02 13:26:17Z sskracic $
*/
public class Loader extends PackageLoader {
- public final static String versionId =
- "$Id: Loader.java 754 2005-09-02 13:26:17Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/17 23:15:09 $";
private static final Logger s_log = Logger.getLogger(Loader.class);
diff --git a/ccm-cms/src/com/arsdigita/cms/SearchFormatter.java b/ccm-cms/src/com/arsdigita/cms/SearchFormatter.java
index 70039c3d7..2c5429345 100755
--- a/ccm-cms/src/com/arsdigita/cms/SearchFormatter.java
+++ b/ccm-cms/src/com/arsdigita/cms/SearchFormatter.java
@@ -30,8 +30,6 @@ import java.util.StringTokenizer;
public class SearchFormatter {
- public static final String versionId = "$Id: SearchFormatter.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/17 23:15:09 $";
-
/**
* A list of all the special characters which will
* be filtered out
@@ -111,7 +109,7 @@ public class SearchFormatter {
* and to the left of each keyword
*/
public static String createIntermediaClause(
- String words, String joinClause, String wildcard
+ String words, String joinClause, String wildcard
) {
StringTokenizer tokenizer = new StringTokenizer(words, SPECIAL_CHARS);
diff --git a/ccm-cms/src/com/arsdigita/cms/TextPage.java b/ccm-cms/src/com/arsdigita/cms/TextPage.java
index fc7873e80..3a456cd6e 100755
--- a/ccm-cms/src/com/arsdigita/cms/TextPage.java
+++ b/ccm-cms/src/com/arsdigita/cms/TextPage.java
@@ -32,11 +32,10 @@ import java.math.BigDecimal;
* @author Jack Chung (flattop@arsdigita.com)
* @author Michael Pih (pihman@arsdigita.com)
* @version $Revision: #20 $ $DateTime: 2004/08/17 23:15:09 $
+ * @version $Id: TextPage.java 287 2005-02-22 00:29:02Z sskracic $
**/
public class TextPage extends ContentPage {
- public static final String versionId = "$Id: TextPage.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/17 23:15:09 $";
-
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.TextPage";
@@ -44,7 +43,7 @@ public class TextPage extends ContentPage {
protected static final int SUMMARY_SIZE = 1024;
- private static final Logger s_log = Logger.getLogger(TextPage.class);
+ private static final Logger s_log = Logger.getLogger(TextPage.class);
/**
diff --git a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContentTypeInitializer.java b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContentTypeInitializer.java
index c99e148ea..6bca4710c 100755
--- a/ccm-cms/src/com/arsdigita/cms/contenttypes/ContentTypeInitializer.java
+++ b/ccm-cms/src/com/arsdigita/cms/contenttypes/ContentTypeInitializer.java
@@ -40,7 +40,7 @@ public abstract class ContentTypeInitializer extends CompoundInitializer {
public static final String[] EMPTY_ARRAY = new String[0];
protected ContentTypeInitializer(final String manifestFile,
- final String objectType) {
+ final String objectType) {
final String url = RuntimeConfig.getConfig().getJDBCURL();
final int database = DbHelper.getDatabaseFromURL(url);
@@ -53,6 +53,10 @@ public abstract class ContentTypeInitializer extends CompoundInitializer {
m_objectType = objectType;
}
+ /**
+ *
+ * @param evt Type of initialization
+ */
public void init(LegacyInitEvent evt) {
super.init(evt);
@@ -87,10 +91,21 @@ public abstract class ContentTypeInitializer extends CompoundInitializer {
}
+ /**
+ * Should be overwritten by each content type to provide its TraversalXML
+ *
+ * @return
+ */
public String getTraversalXML() {
return "";
}
+ /**
+ * Should be overwritten by each content types initializer to provide the
+ * correct location of is stylesheets.
+ *
+ * @return
+ */
public String[] getStylesheets() {
return EMPTY_ARRAY;
}
diff --git a/ccm-cms/src/com/arsdigita/cms/enterprise.init b/ccm-cms/src/com/arsdigita/cms/enterprise.init
index ab35a2faf..d0f6f32e6 100755
--- a/ccm-cms/src/com/arsdigita/cms/enterprise.init
+++ b/ccm-cms/src/com/arsdigita/cms/enterprise.init
@@ -15,7 +15,7 @@ init com.arsdigita.cms.installer.xml.ContentTypeInitializer {
};
}
-init com.arsdigita.cms.publishToFile.Initializer {
+//-- init com.arsdigita.cms.publishToFile.LegacyInitializer {
// List of publish destinations for content types
// Each element is a four-element list in the format
// '{ "content type", "root directory", "shared storage",
@@ -28,58 +28,58 @@ init com.arsdigita.cms.publishToFile.Initializer {
// directory is shared NFS storage, _false_ otherwise. "URL stub"
// must be the path component of the URL from which the live server
// will serve from this directory.
- destination = {
- { "com.arsdigita.cms.ContentItem",
- "p2fs",
- false,
- "/p2fs" },
+//-- destination = {
+//-- { "com.arsdigita.cms.ContentItem",
+//-- "p2fs",
+//-- false,
+//-- "/p2fs" },
// (pboy): starting with webapps refers to the CCM_HOME env variable which
// points to the installation root of the servlet container. This is not
// used anymore, all specifications are relative to webapplication base.
// So the following may have to be changed to "packages/content-section/templates"
// if someone tries to use p2fs
- { "com.arsdigita.cms.Template",
- // "webapps/ROOT/packages/content-section/templates",
- "packages/content-section/templates",
- false,
- "/templates" }
- };
+//-- { "com.arsdigita.cms.Template",
+//-- // "webapps/ROOT/packages/content-section/templates",
+//-- "packages/content-section/templates",
+//-- false,
+//-- "/templates" }
+//-- };
// Class which implements PublishToFileListener used to perform
// additional actions when publishing or unpublishing to the file system.
- publishListener = "com.arsdigita.cms.publishToFile.PublishToFile";
+//-- publishListener = "com.arsdigita.cms.publishToFile.PublishToFile";
// Queue management parameters.
// Set startupDelay to 0 to disable the processing of the queue
// Time (seconds) before starting to monitor the
// queue after a server start
- startupDelay = 30;
+//-- startupDelay = 30;
// Time (in seconds) between checking if there are entries in the
// publishToFile queue.
// A value <= 0 disables processing the queue on this server.
- pollDelay = 5;
+//-- pollDelay = 5;
// Time to wait (seconds) before retrying
// to process a failed entry
- retryDelay = 120;
+//-- retryDelay = 120;
// Number of queue entries to process at once.
- blockSize = 40;
+//-- blockSize = 40;
// Number of times a failed queue entry will be
// reprocessed. If processing has failed more than
// that number of times, the entry will be
// ignored.
- maximumFailCount = 10;
+//-- maximumFailCount = 10;
// Method used to select entries for processing.
// 'QueuedOrder'-in queued order.
// 'GroupByParent'-group entries according to parent when selecting items
// (allows optimizations if a listener task required for all elements in a folder
// can be done only once for the folder).
- blockSelectMethod = "GroupByParent";
-}
+//-- blockSelectMethod = "GroupByParent";
+//-- }
init com.arsdigita.cms.installer.SectionInitializer {
@@ -346,25 +346,6 @@ init com.arsdigita.formbuilder.installer.Initializer {
//
//}
-init com.arsdigita.cms.lifecycle.Initializer {
- // How long do we wait (in seconds) after system startup
- // before we start processing lifecycles?
- delay = 60;
- // How often (in seconds) does the system look for pending
- // items to make live and live items to expire
- frequency = 600;
-}
-
-// This is no longer needed. Item adapters are now set via standard
-// initializers. Legacy initializer is still available if you need
-// to register multiple adapter files.
-//init com.arsdigita.domain.installer.DomainObjectTraversalInitializer {
-// adapters = {
-// "/WEB-INF/resources/cms-item-adapters.xml"
-// };
-//
-//}
-
//Used when running CMS in conjunction with a Portal
init com.arsdigita.cms.installer.portlet.Initializer {}
@@ -393,3 +374,35 @@ init com.arsdigita.cms.installer.portlet.Initializer {}
// numUsers = 10;
// }
+
+
+// //////////////////////////////////////////////////////////
+//
+// Initializer replaced by new initialization system
+//
+// //////////////////////////////////////////////////////////
+
+
+// No longer needed, refactored as a sub-initializer of ccm initializer
+// (following the new initializer system)
+//
+// init com.arsdigita.cms.lifecycle.LegacyInitializer {
+// // How long do we wait (in seconds) after system startup
+// // before we start processing lifecycles?
+// delay = 60;
+// // How often (in seconds) does the system look for pending
+// // items to make live and live items to expire
+// frequency = 600;
+// }
+
+
+// This is no longer needed. Item adapters are now set via standard
+// initializers. Legacy initializer is still available if you need
+// to register multiple adapter files.
+//init com.arsdigita.domain.installer.DomainObjectTraversalInitializer {
+// adapters = {
+// "/WEB-INF/resources/cms-item-adapters.xml"
+// };
+//
+//}
+
diff --git a/ccm-cms/src/com/arsdigita/cms/installer/SectionInitializer.java b/ccm-cms/src/com/arsdigita/cms/installer/SectionInitializer.java
index 93e7c3541..6bad7ce30 100755
--- a/ccm-cms/src/com/arsdigita/cms/installer/SectionInitializer.java
+++ b/ccm-cms/src/com/arsdigita/cms/installer/SectionInitializer.java
@@ -47,6 +47,11 @@ import java.util.Timer;
* @author Daniel Berrange (berrange@redhat.com)
* @author Michael Pih
* @version $Revision: #43 $ $DateTime: 2004/08/17 23:15:09 $
+ *
+ * XXX As of version 6.5 (pboy):
+ * Commented out in cms.enterprise.init since several versions. Not invoked by
+ * any other package of trunk. Some Parameters (as ITEM_RESOLVER_CLASS) are
+ * configured in ContentSectionConfig.java as a temporary measure.
*/
public class SectionInitializer extends com.arsdigita.kernel.BaseInitializer {
diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/Initializer.java b/ccm-cms/src/com/arsdigita/cms/lifecycle/Initializer.java
index 27901e818..166b4a05f 100755
--- a/ccm-cms/src/com/arsdigita/cms/lifecycle/Initializer.java
+++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/Initializer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
+ * Copyright (C) 2003-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
@@ -18,72 +18,74 @@
*/
package com.arsdigita.cms.lifecycle;
-import com.arsdigita.initializer.Configuration;
-import com.arsdigita.initializer.InitializationException;
+import com.arsdigita.runtime.ContextInitEvent;
+import com.arsdigita.runtime.ContextCloseEvent;
+
import org.apache.log4j.Logger;
/**
- * Initializes the scheduler thread to fire all the events for the
- * lifecycles or phases that have just began or ended.
+ * Initializes the Lifecycle package.
*
- * Where the initializer is registered, you need to include the
- * delay and frequency in seconds
+ * Initializes the scheduler thread to fire all the events for the lifecycles
+ * or phases that have just began or ended.
+ *
+ * A value of 0 for the delay parameter (see below) disables LC background thread.
+ * This initializer is a sub-initializer of the cms initializer which adds it
+ * to the list of initializers to be executed
+ *
+ * @author Peter Boy (pboy@barkhof.uni-bremen.de)
+ * @version $Id: $
*
- * @author Jack Chung
- * @version $Revision: #9 $ $DateTime: 2004/08/17 23:15:09 $
*/
+public class Initializer extends com.arsdigita.runtime.GenericInitializer {
-public class Initializer
- implements com.arsdigita.initializer.Initializer {
+ // Creates a s_logging category with name = to the full name of class
+ public static final Logger s_log = Logger.getLogger(Initializer.class);
- public static final String versionId = "$Id: Initializer.java 1292 2006-08-25 17:55:03Z apevec $ by $Author: apevec $, $DateTime: 2004/08/17 23:15:09 $";
-
- private static Logger s_log =
- Logger.getLogger(Initializer.class);
-
- private Configuration m_conf = new Configuration();
-
- private Scheduler scheduler;
-
- public Initializer() throws InitializationException {
- // XXX move to ccm registry
- m_conf.initParameter("delay",
- "The delay of the scheduler in seconds, 0 to disable LC background thread",
- Integer.class);
- m_conf.initParameter("frequency",
- "The frequency of the scheduler in seconds",
- Integer.class);
- }
/**
- * Returns the configuration object used by this initializer.
- **/
- public Configuration getConfiguration() {
- return m_conf;
+ *
+ */
+ public Initializer() {
}
/**
- * Called on startup.
- **/
- public void startup() {
+ * Implementation of the {@link Initializer#init(ContextInitEvent)}
+ * method.
+ *
+ * Initializes the scheduler thread to fire all the events for the
+ * lifecycles or phases that have just began or ended.
+ *
+ * A delay value of 0 inhibits start of processing.
+ * @param evt The context init event.
+ */
+ public void init(ContextInitEvent evt) {
+ s_log.debug("lifecycle background startup beginn.");
- long delay = ((Integer) m_conf.getParameter("delay")).longValue();
- long frequency = ((Integer) m_conf.getParameter("frequency")).longValue();
+ LifecycleConfig conf = LifecycleConfig.getConfig();
+ s_log.debug("lifecycle configuration loaded.");
+
+ Integer delay = conf.getDelay();
+ s_log.debug("delay configuration loaded. Value: " + delay );
+ Integer frequency = conf.getFrequency();
+ s_log.debug("frequency configuration loaded. Value: " + frequency );
if (delay > 0) {
- Scheduler.s_timerDelay = delay * (long) 1000;
- Scheduler.s_timerFrequency = frequency * (long) 1000;
+ Scheduler.setTimerDelay(delay);
+ Scheduler.setTimerFrequency(frequency);
Scheduler.startTimer();
}
- }
+
+ s_log.debug("lifecycle background processing started");
+ }
/**
- * Called on shutdown. It's probably not a good idea to depend on this
- * being called.
- **/
- public void shutdown() {
+ *
+ */
+ public void close(ContextCloseEvent evt) {
Scheduler.stopTimer();
+ s_log.debug("lifecycle background processing stopped");
}
}
diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/LegacyInitializer.java.nolongerInUse b/ccm-cms/src/com/arsdigita/cms/lifecycle/LegacyInitializer.java.nolongerInUse
new file mode 100755
index 000000000..dfacc654d
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/LegacyInitializer.java.nolongerInUse
@@ -0,0 +1,89 @@
+/*
+ * 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.lifecycle;
+
+import com.arsdigita.initializer.Configuration;
+import com.arsdigita.initializer.InitializationException;
+import org.apache.log4j.Logger;
+
+/**
+ * Initializes the scheduler thread to fire all the events for the
+ * lifecycles or phases that have just began or ended.
+ *
+ * Where the initializer is registered, you need to include the
+ * delay and frequency in seconds
+ *
+ * @author Jack Chung
+ * @version $Revision: #9 $ $DateTime: 2004/08/17 23:15:09 $
+ */
+
+public class LegacyInitializer
+ implements com.arsdigita.initializer.Initializer {
+
+ public static final String versionId = "$Id: Initializer.java 1292 2006-08-25 17:55:03Z apevec $ by $Author: apevec $, $DateTime: 2004/08/17 23:15:09 $";
+
+ private static Logger s_log =
+ Logger.getLogger(LegacyInitializer.class);
+
+ private Configuration m_conf = new Configuration();
+
+ private Scheduler scheduler;
+
+ public LegacyInitializer() throws InitializationException {
+ // XXX move to ccm registry
+ m_conf.initParameter("delay",
+ "The delay of the scheduler in seconds, 0 to disable LC background thread",
+ Integer.class);
+ m_conf.initParameter("frequency",
+ "The frequency of the scheduler in seconds",
+ Integer.class);
+ }
+
+ /**
+ * Returns the configuration object used by this initializer.
+ **/
+ public Configuration getConfiguration() {
+ return m_conf;
+ }
+
+
+ /**
+ * Called on startup.
+ **/
+ public void startup() {
+
+ long delay = ((Integer) m_conf.getParameter("delay")).longValue();
+ long frequency = ((Integer) m_conf.getParameter("frequency")).longValue();
+
+ if (delay > 0) {
+ Scheduler.s_timerDelay = delay * (long) 1000;
+ Scheduler.s_timerFrequency = frequency * (long) 1000;
+ Scheduler.startTimer();
+ }
+ }
+
+ /**
+ * Called on shutdown. It's probably not a good idea to depend on this
+ * being called.
+ **/
+ public void shutdown() {
+ Scheduler.stopTimer();
+ }
+
+}
diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/LifecycleConfig.java b/ccm-cms/src/com/arsdigita/cms/lifecycle/LifecycleConfig.java
new file mode 100644
index 000000000..6d0ff3636
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/LifecycleConfig.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2003-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.lifecycle;
+
+import com.arsdigita.runtime.AbstractConfig;
+// import com.arsdigita.runtime.CCMResourceManager;
+// import com.arsdigita.util.UncheckedWrapperException;
+import com.arsdigita.util.parameter.IntegerParameter;
+import com.arsdigita.util.parameter.Parameter;
+// import com.arsdigita.util.parameter.StringParameter;
+
+import org.apache.log4j.Logger;
+
+// import java.io.File;
+
+/**
+ * LifecycleConfig
+ *
+ * @author Peter Boy <pboy@barkhof.uni-bremen.de>
+ * @version $Id: $
+ **/
+
+public class LifecycleConfig extends AbstractConfig {
+
+ private static final Logger s_log = Logger.getLogger(LifecycleConfig.class);
+
+ private static LifecycleConfig s_conf;
+
+ /**
+ * Gain a LifecycleConfig object.
+ *
+ * Singelton pattern, don't instantiate a lifecacle object using the
+ * constructor directly.
+ * @return
+ */
+ static synchronized LifecycleConfig getConfig() {
+ if (s_conf == null) {
+ s_conf = new LifecycleConfig();
+ s_conf.load();
+ }
+
+ return s_conf;
+ }
+
+ /**
+ * How long do we wait (in seconds) after system startup before we start
+ * processing lifecycles?
+ */
+ private IntegerParameter m_delay = new IntegerParameter
+ ("com.arsdigita.cms.lifecycle.delay", Parameter.REQUIRED,
+ new Integer(60));
+ /**
+ * How often (in seconds) does the system look for pending items to make
+ * live and live items to expire? A value of 0 disables LC background thread.
+ */
+ private IntegerParameter m_frequency = new IntegerParameter
+ ("com.arsdigita.cms.lifecycle.frequency", Parameter.REQUIRED,
+ new Integer(600));
+
+ /**
+ * Constructor.
+ * Do not use it directly!
+ */
+ public LifecycleConfig() {
+ register(m_delay);
+ register(m_frequency);
+
+ loadInfo();
+ }
+
+ /**
+ * Retrieve delay between triggering lifecycle timer and system startup.
+ * @return delay, in seconds. A value of 0 disables LC background thread.
+ */
+ public int getDelay() {
+ s_log.debug("delay time retrieved.");
+ return ((Integer) get(m_delay)).intValue();
+ }
+
+ /**
+ * Retrieve frequency to look for pending items to make live or expire.
+ * @return delay, in seconds
+ */
+ public int getFrequency() {
+ s_log.debug("frequency time retrieved.");
+ return ((Integer) get(m_frequency)).intValue();
+ }
+
+}
diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/LifecycleConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/lifecycle/LifecycleConfig_parameter.properties
new file mode 100644
index 000000000..f9d926bc6
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/LifecycleConfig_parameter.properties
@@ -0,0 +1,8 @@
+com.arsdigita.cms.lifecycle.delay.title=Delay
+com.arsdigita.cms.lifecycle.delay.purpose=How long to wait (in seconds) after system startup before start lifecycle processing A value of 0 disables LC background thread..
+com.arsdigita.cms.lifecycle.delay.example=60
+com.arsdigita.cms.lifecycle.delay.format=[integer]
+com.arsdigita.cms.lifecycle.frequency.title=Frequency
+com.arsdigita.cms.lifecycle.frequency.purpose=How often (in seconds) does the system look for pending items to make them live and live items to expire.
+com.arsdigita.cms.lifecycle.frequency.example=600
+com.arsdigita.cms.lifecycle.frequency.format=[integer]
diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/Scheduler.java b/ccm-cms/src/com/arsdigita/cms/lifecycle/Scheduler.java
index d28681bd9..66007688b 100755
--- a/ccm-cms/src/com/arsdigita/cms/lifecycle/Scheduler.java
+++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/Scheduler.java
@@ -44,17 +44,16 @@ import org.apache.log4j.Logger;
* @author Stanislav Freidin (stas@arsdigita.com)
* @author Michael Pih (pihman@arsdigita.com)
* @version $Revision: #20 $ $DateTime: 2004/08/17 23:15:09 $
+ * @version $Id: Scheduler.java 1583 2007-05-25 15:32:13Z chrisgilbert23 $
*/
public class Scheduler {
- public static final String versionId = "$Id: Scheduler.java 1583 2007-05-25 15:32:13Z chrisgilbert23 $ by $Author: chrisgilbert23 $, $DateTime: 2004/08/17 23:15:09 $";
-
private static final String CYCLE_ID = "cycleId";
private static final String PHASE_ID = "phaseId";
// Time in milliseconds
- protected static long s_timerDelay;
- protected static long s_timerFrequency;
+ private static long s_timerDelay;
+ private static long s_timerFrequency;
// For storing timer which runs a method periodically to fire
// begin and end events
@@ -62,8 +61,7 @@ public class Scheduler {
private static boolean s_running = false;
// Creates a s_logging category with name = to the full name of class
- private static Logger s_log =
- Logger.getLogger( Scheduler.class.getName() );
+ private static Logger s_log = Logger.getLogger( Scheduler.class.getName() );
// A noop listener used when the listener in the DB is null. This ensures
// that lifecycles and phases with no listener are still properly marked
@@ -74,6 +72,22 @@ public class Scheduler {
public void end(LifecycleEvent e) { }
};
+ /**
+ * Sets timer startup delay to delay seconds.
+ */
+ public static void setTimerDelay(int delay) {
+ s_timerDelay = delay * 1000; // Timer measures in milliseconds!
+ s_log.debug( "s_timerDelay set to " + s_timerDelay + " ms.");
+ }
+
+ /**
+ * Sets timer frequency to freq seconds.
+ */
+ public static void setTimerFrequency(int freq) {
+ s_timerFrequency = freq * 1000;
+ s_log.debug( "s_timerFrequency set to " + s_timerFrequency + " ms.");
+ }
+
/**
* startTimer - starts the timer
*/
@@ -115,12 +129,12 @@ public class Scheduler {
txn = SessionManager.getSession().getTransactionContext();
- // Notes: loop through the query and add the objects to the LinkedList
- // then for each object in the LinkedList:
- // begin the transaction,
- // perform any operations from the listener,
- // update the hasBegun or hasEnded column, and
- // close the transaction (or abort if there are any errors)
+ // Notes: loop through the query and add the objects to the
+ // LinkedList then for each object in the LinkedList:
+ // - begin the transaction,
+ // - perform any operations from the listener,
+ // - update the hasBegun or hasEnded column, and
+ // - close the transaction (or abort if there are any errors)
// Lifecycle Start Events
txn.beginTxn();
@@ -273,7 +287,7 @@ public class Scheduler {
* Returns an iterator of pending events.
*/
private static synchronized Iterator getPendingEvents(
- DataQuery query, int eventType, String idColumn
+ DataQuery query, int eventType, String idColumn
) {
try {
LinkedList rowList = new LinkedList();
@@ -320,7 +334,10 @@ public class Scheduler {
cycle = new Lifecycle(id);
} catch (DataObjectNotFoundException e) {
txn.abortTxn();
- throw new UncheckedWrapperException( (String) GlobalizationUtil.globalize("cms.lifecycle.could_not_fetch_lifecycle").localize() + id, e);
+ throw new UncheckedWrapperException(
+ (String) GlobalizationUtil.globalize(
+ "cms.lifecycle.could_not_fetch_lifecycle").localize()
+ + id, e);
}
try {
@@ -333,10 +350,11 @@ public class Scheduler {
listener.end(event);
cycle.stop();
if (ContentSection.getConfig().deleteFinishedLifecycles()) {
- // this seems to be the best place to do this - after any other
- // activities associated with the end of the cycle have been
- // completed
- s_log.debug("Lifecycle " + cycle.getID() + " has ended - now deleting it");
+ // this seems to be the best place to do this - after
+ // any other activities associated with the end of the
+ // cycle have been completed
+ s_log.debug("Lifecycle " + cycle.getID() +
+ " has ended - now deleting it");
cycle.delete();
}
}
@@ -348,8 +366,8 @@ public class Scheduler {
txn.commitTxn();
} catch (Exception e) {
txn.abortTxn();
- // TODO: Shouldn't this re-throw? The transaction is aborted, so some other error
- // will occur...
+ // TODO: Shouldn't this re-throw? The transaction is aborted,
+ // so some other error will occur...
s_log.error( "Error in LifecycleEvent: " + e.getMessage(), e);
}
}
@@ -379,7 +397,10 @@ public class Scheduler {
phase = new Phase(phaseID);
} catch (DataObjectNotFoundException e) {
txn.abortTxn();
- throw new UncheckedWrapperException( (String) GlobalizationUtil.globalize("cms.lifecycle.could_not_fetch_phase").localize() + phaseID, e);
+ throw new UncheckedWrapperException(
+ (String) GlobalizationUtil.globalize(
+ "cms.lifecycle.could_not_fetch_phase").localize()
+ + phaseID, e);
}
try {
@@ -394,8 +415,8 @@ public class Scheduler {
txn.commitTxn();
} catch (Exception e) {
txn.abortTxn();
- // TODO: Shouldn't this re-throw? The transaction is aborted, so some other error
- // will occur...
+ // TODO: Shouldn't this re-throw? The transaction is aborted,
+ // so some other error will occur...
s_log.error("Error in LifecycleEvent: " + e.getMessage(), e);
}
}
diff --git a/ccm-cms/src/com/arsdigita/cms/lifecycle/SchedulerTask.java b/ccm-cms/src/com/arsdigita/cms/lifecycle/SchedulerTask.java
index d4bffe946..ed5946091 100755
--- a/ccm-cms/src/com/arsdigita/cms/lifecycle/SchedulerTask.java
+++ b/ccm-cms/src/com/arsdigita/cms/lifecycle/SchedulerTask.java
@@ -25,17 +25,19 @@ import java.util.TimerTask;
/**
- * The SchedulerTask class provides the method that is scheduled
- * by the timer created by Scheduler. It simply calls the
- * run method of Scheduler.
+ * The SchedulerTask class provides the method that is scheduled by the timer
+ * created by Scheduler. It simply calls the run method of Scheduler.
*
* @author Jack Chung (flattop@arsdigita.com)
- * @version $Revision: #7 $ $DateTime: 2004/08/17 23:15:09 $
+ * @version $Id: SchedulerTask.java 754 2005-09-02 13:26:17Z sskracic $
**/
class SchedulerTask extends TimerTask {
- public static final String versionId = "$Id: SchedulerTask.java 754 2005-09-02 13:26:17Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/17 23:15:09 $";
private static final Logger s_log = Logger.getLogger(SchedulerTask.class);
+
+ /**
+ *
+ */
public void run() {
try {
Scheduler.run();
diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/Initializer.java b/ccm-cms/src/com/arsdigita/cms/publishToFile/Initializer.java
index e7f38de64..18125721a 100755
--- a/ccm-cms/src/com/arsdigita/cms/publishToFile/Initializer.java
+++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/Initializer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved.
+ * Copyright (C) 2003-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
@@ -16,350 +16,89 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
-package com.arsdigita.cms.publishToFile;
+package com.arsdigita.cms.publishToFile;
-import com.arsdigita.cms.ContentSection;
-import com.arsdigita.cms.Template;
-
-import com.arsdigita.initializer.Configuration;
-import com.arsdigita.initializer.InitializationException;
-
-import com.arsdigita.domain.DomainObject;
-import com.arsdigita.domain.DomainObjectInstantiator;
-import com.arsdigita.domain.DomainObjectFactory;
-
-import com.arsdigita.persistence.DataObject;
-import com.arsdigita.persistence.SessionManager;
-import com.arsdigita.persistence.TransactionContext;
-import com.arsdigita.persistence.metadata.MetadataRoot;
-import com.arsdigita.persistence.metadata.ObjectType;
-import com.arsdigita.runtime.CCMResourceManager;
+import com.arsdigita.db.DbHelper;
+import com.arsdigita.runtime.CompoundInitializer;
+import com.arsdigita.runtime.ContextCloseEvent;
+import com.arsdigita.runtime.DataInitEvent;
+import com.arsdigita.runtime.DomainInitEvent;
+import com.arsdigita.runtime.LegacyInitEvent;
+import com.arsdigita.runtime.LegacyInitializer;
+import com.arsdigita.runtime.RuntimeConfig;
import org.apache.log4j.Logger;
-
-import java.io.*;
-// import java.io.File;
-
-import java.util.List;
-import java.util.Iterator;
-
/**
- * Initializes the publish-to-file service. The configuration is described in
- * the {@link com.arsdigita.cms.publishToFile} page.
+ * The CMS PublishT0File initializer.
*
- * (pboy) ToDo: Adjusting the initialisation to the new configuration method
- * without enterprise.init file.
+ * Initializer is invoked by the add-method in the CMS initializer.
*
- * @author Jeff Teeters (teeters@arsdigita.com)
- * @version $Revision: #24 $ $Date: 2004/08/17 $
+ * @author Justin Ross <jross@redhat.com>
+ * @author Peter Boy <pb@zes.uni-bremen.de>
+ * @version $Id: Initializer.java 1428 2007-01-24 12:39:56Z sskracic $
*/
-public class Initializer implements com.arsdigita.initializer.Initializer {
+public class Initializer extends CompoundInitializer {
+ // Creates a s_logging category with name = to the full name of class
private static Logger s_log = Logger.getLogger(Initializer.class);
- private final static String PUBLISH_DESTINATIONS = "destination";
- private final static String PUBLISH_TO_FILE_LISTENER = "publishListener";
- private final static String QUEUE_POLL_STARTUP_DELAY = "startupDelay";
- private final static String QUEUE_POLL_DELAY = "pollDelay";
- private final static String RETRY_DELAY = "retryDelay";
- private final static String REQUEST_TIMEOUT = "requestTimeout";
- private final static String BLOCK_SIZE = "blockSize";
- private final static String BLOCK_SELECT_METHOD = "blockSelectMethod";
- private final static String MAXIMUM_FAIL_COUNT = "maximumFailCount";
- private Configuration m_conf = new Configuration();
+ public Initializer() {
+ final String url = RuntimeConfig.getConfig().getJDBCURL();
+ final int database = DbHelper.getDatabaseFromURL(url);
+
+ // Left over from CMS initializer
+ // add(new PDLInitializer
+ // (new ManifestSource
+ // ("ccm-cms.pdl.mf",
+ // new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
+
+ add(new LegacyInitializer("com/arsdigita/cms/publishToFile/enterprise.init"));
- public Initializer() throws InitializationException {
- m_conf.initParameter(
- PUBLISH_DESTINATIONS,
- "List of publish destinations for content types" +
- "Each element is a four-element list in the format " +
- "'{ \"content type\", \"root directory\", \"shared storage\", " +
- "\"url stub\" }'. " +
- "Content type is the object type of the content type." +
- "Root directory must be a path to a writable directory, relative" +
- "to the webapp root. Shared storage must be true if the root " +
- "directory is shared NFS storage, false otherwise. URL stub is " +
- "must be the path component of the URL from which the live server " +
- "will serve from this directory.",
- List.class);
- m_conf.initParameter(
- PUBLISH_TO_FILE_LISTENER,
- "Class which implements PublishToFileListener used to " +
- "perform additional actions when publishing or unpublishing " +
- "to the file system.",
- String.class);
- m_conf.initParameter(
- QUEUE_POLL_STARTUP_DELAY,
- "Time (in seconds) after system startup to wait before " +
- "starting to monitor publishToFile queue. A value < 0 " +
- "disables processing of the queue on this server.",
- Integer.class, new Integer(30));
- m_conf.initParameter(
- QUEUE_POLL_DELAY,
- "Time (in seconds) between checking if there are entries " +
- "in the publishToFile queue. A value <= 0 disables processing " +
- "the queue on this server.",
- Integer.class, new Integer(1));
- m_conf.initParameter(
- RETRY_DELAY,
- "Time to wait (seconds) before retrying to process a " +
- "failed entry.",
- Integer.class, new Integer(120));
- m_conf.initParameter(
- REQUEST_TIMEOUT,
- "Time to wait (seconds) before aborting item request.",
- Integer.class, new Integer(PublishToFile.DEFAULT_TIMEOUT));
- m_conf.initParameter(
- BLOCK_SIZE, "number of queue entries to process in one txn."
- , Integer.class, new Integer(20));
- m_conf.initParameter(
- BLOCK_SELECT_METHOD,
- "Method used to select entries for processing. " +
- "'QueuedOrder'-in queued order. 'GroupByParent'-group " +
- "entries according to parent when selecting items " +
- "(allows optimizations if a listener task required for " +
- "all elements in a folder can be done only once for the " +
- "folder).",
- String.class, "QueuedOrder");
- m_conf.initParameter(
- MAXIMUM_FAIL_COUNT,
- "Maximum Fail Count for actions in Queue Manager. " +
- "If Fail Count in Database is more than Specified " +
- "Limit, Queue Manager will ignore the action. The " +
- "Default Value -1 will ignore this parameter.",
- Integer.class, new Integer(-1));
}
- public Configuration getConfiguration() {
- return m_conf;
- }
-
-
- public void startup() {
- TransactionContext txn =
- SessionManager.getSession().getTransactionContext();
- txn.beginTxn();
- setupPublishToFileSystem();
-
- QueueManager.requeueMissingFiles();
-
- txn.commitTxn();
- }
-
- public void shutdown() {
- QueueManager.stopWatchingQueue();
- }
-
-
/**
- * initialize source and destinations for publishing to the file system
+ * An empty implementation of {@link Initializer#init(DataInitEvent)}.
+ *
+ * @param evt The data init event.
*/
- private void setupPublishToFileSystem() throws InitializationException {
- DomainObjectInstantiator inst = new DomainObjectInstantiator() {
- public DomainObject doNewInstance(DataObject dobj) {
- return new PublishedFile(dobj);
- }
- };
- DomainObjectFactory.registerInstantiator(
- PublishedFile.BASE_DATA_OBJECT_TYPE,
- inst);
-
-
- processDestination((List) m_conf.getParameter(PUBLISH_DESTINATIONS));
-
- PublishToFile.setRequestTimeout(getInteger(REQUEST_TIMEOUT).intValue());
-
- QueueManager.setRetryDelay(getInteger(RETRY_DELAY));
- QueueManager.setBlockSize(getInteger(BLOCK_SIZE));
- QueueManager.setBlockSelectMethod(getString(BLOCK_SELECT_METHOD));
- QueueManager.setMaximumFailCount(getInteger(MAXIMUM_FAIL_COUNT));
-
-
- // setup listener if specified
- String listenerName = getString( PUBLISH_TO_FILE_LISTENER );
- if (listenerName != null) {
- PublishToFileListener listener = null;
- Class listenerClass = null;
- try {
- listenerClass = Class.forName(listenerName);
- } catch (ClassNotFoundException ex) {
- invalidParam(PUBLISH_TO_FILE_LISTENER,
- "could not find listener class " + listenerClass);
- }
-
- try {
- listener = (PublishToFileListener)listenerClass.newInstance();
- } catch (InstantiationException ex) {
- invalidParam(PUBLISH_TO_FILE_LISTENER,
- "could not find instantiate listener class " +
- listenerClass + " (" + ex.getMessage() + ")");
- } catch (IllegalAccessException ex) {
- invalidParam(PUBLISH_TO_FILE_LISTENER,
- "could not find instantiate listener class " +
- listenerClass + " (" + ex.getMessage() + ")");
- }
- QueueManager.setListener(listener);
- }
-
- // start thread for monitoring queue
- int startupDelay = getInteger(QUEUE_POLL_STARTUP_DELAY).intValue();
- int pollDelay = getInteger(QUEUE_POLL_DELAY).intValue();
- QueueManager.startWatchingQueue(startupDelay, pollDelay);
+ public void init(DataInitEvent evt) {
}
- //
- // Process publishing destinations
- //
+ /**
+ * Initializes domain-coupling machinery, usually consisting of
+ * registering object instantiators and observers.
+ *
+ * In the future: This starts up the search threads according to the values in the
+ * properties file
+ */
+ public void init(DomainInitEvent e) {
- private static void processDestination(List dest)
- throws InitializationException {
- if (dest == null) {
- invalidParam(PUBLISH_DESTINATIONS,
- "publish destinations must not be null");
- }
- if (dest.size() < 1) {
- invalidParam(PUBLISH_DESTINATIONS,
- "publish destinations must contain at " +
- "least one entry");
- }
-
- Iterator entries = dest.iterator();
- while (entries.hasNext()) {
- processDestinationEntry((List)entries.next());
- }
}
- private static void processDestinationEntry(List entry)
- throws InitializationException {
+ /**
+ * An empty implementation of {@link Initializer#init(LegacyInitEvent)}.
+ *
+ * @param evt The legacy init event.
+ */
+ public void init(LegacyInitEvent evt) {}
- if ( entry.size() != 4 ) {
- invalidParam(PUBLISH_DESTINATIONS,
- "publish destinations entry must contain " +
- "four elements: '{ \n" +
- " \"content type\",\n" +
- " \"root directory\", \n" +
- " \"is shared\", \n" +
- " \"url stub\" \n" +
- "};\n");
- }
+ /**
+ * Implementation of the {@link Initializer#close()} method.
+ *
+ * This implementation proceeds through the list of sub
+ * initializers in order and invokes the close()
+ * method of each sub initializer in turn.
+ *
+ * @param evt The legacy init event.
+ **/
+ public void close(ContextCloseEvent evt) {
+ s_log.info("publishToFile.Initializer.destroy() invoked");
- String contentType = (String)entry.get(0);
- // destRoot is here relative to webapp root!
- String destRoot = (String) entry.get(1);
- Boolean sharedRoot = (Boolean) entry.get(2);
- String destURL = (String) entry.get(3);
+ QueueManager.stopWatchingQueue();
- if ( contentType == null || contentType.trim().length() == 0) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination content type must not be null");
- }
-
- ObjectType type = MetadataRoot.getMetadataRoot().getObjectType(contentType);
- if (type == null) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination content type cannot be found");
- }
-
- if (destRoot == null || destRoot.trim().length() == 0) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination root must not be null");
- }
- if (destRoot.endsWith("/")) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination root '" + destRoot +
- "' must not end with a '/'");
- }
-
- // Does destRoot really now turns into an absolute fully pathname
- destRoot = new File(CCMResourceManager.getBaseDirectory().getPath(),
- destRoot).getPath();
- s_log.info("Destination Root is set to : " + destRoot);
-
-
-
- if (sharedRoot == null) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination shared flag must not be null");
- }
-
-
- if (destURL == null || "".equals(destURL.trim())) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination URL must not be null");
- }
- if (!destURL.startsWith("/")) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination URL '" + destURL +
- "' must start with a '/'");
- }
- if (destURL.endsWith("/")) {
- invalidParam(PUBLISH_DESTINATIONS,
- "the destination URL '" + destURL +
- "' must not end with a '/'");
- }
-
- DestinationStub dest = new DestinationStub(destRoot,
- sharedRoot.booleanValue(),
- destURL);
-
- File file = dest.getFile();
- if (!file.exists()) {
- file.mkdirs();
- s_log.info(file.getPath() + " created");
- }
- boolean writable = false;
- FileWriter fl;
- File fname = new File(file.getPath(),"placeholder.txt");
- s_log.info("Try to create : " + destRoot);
- try {
- writable = file.canWrite() && file.isDirectory();
- try {
- fl = new FileWriter(fname.getPath());
- fl.write("Location for the p2fs module to store static content. \n");
- fl.close();
- } catch ( IOException e ) {
- // Will be reported as an initalization error
- s_log.warn("Error creating file " + fname.getPath());
- }
-
-
- } catch ( SecurityException ex ) {
- // Will be reported as an initalization error
- }
- if ( ! writable ) {
- // HACK: Let's see if we can write to the config directory. If we can,
- // then we're running as ccmadmin inside of ccm load, and there is no
- // need to thrown an exception.
- File conf = CCMResourceManager.getConfigDirectory();
- if (conf.isDirectory() && conf.canWrite()) {
- // we're ok
- } else {
- invalidParam(PUBLISH_DESTINATIONS, " the document root '" + file
- +"' must be a writable directory");
- }
- }
-
- if (Template.BASE_DATA_OBJECT_TYPE.equals(contentType) ||
- !ContentSection.getConfig().getDisableItemPfs()) {
- PublishToFile.addDestination(contentType,
- dest);
- }
+ s_log.info("publishToFile.Initializer.destroy() completed");
}
- private Integer getInteger(String paramName) {
- return (Integer) m_conf.getParameter(paramName);
- }
-
- private String getString(String paramName) {
- return (String) m_conf.getParameter(paramName);
- }
-
- private static void invalidParam(String param, String msg)
- throws InitializationException {
-
- throw new InitializationException(
- "publishToFile: parameter " + param +": " + msg);
- }
}
diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/LegacyInitializer.java b/ccm-cms/src/com/arsdigita/cms/publishToFile/LegacyInitializer.java
new file mode 100755
index 000000000..ff3f248f9
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/LegacyInitializer.java
@@ -0,0 +1,365 @@
+/*
+ * 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.publishToFile;
+
+import com.arsdigita.cms.ContentSection;
+import com.arsdigita.cms.Template;
+
+import com.arsdigita.initializer.Configuration;
+import com.arsdigita.initializer.InitializationException;
+
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.domain.DomainObjectInstantiator;
+import com.arsdigita.domain.DomainObjectFactory;
+
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.SessionManager;
+import com.arsdigita.persistence.TransactionContext;
+import com.arsdigita.persistence.metadata.MetadataRoot;
+import com.arsdigita.persistence.metadata.ObjectType;
+import com.arsdigita.runtime.CCMResourceManager;
+
+import org.apache.log4j.Logger;
+
+
+import java.io.*;
+// import java.io.File;
+
+import java.util.List;
+import java.util.Iterator;
+
+/**
+ * Initializes the publish-to-file service. The configuration is described in
+ * the {@link com.arsdigita.cms.publishToFile} page.
+ *
+ * (pboy) ToDo: Adjusting the initialisation to the new configuration method
+ * without enterprise.init file.
+ *
+ * @author Jeff Teeters (teeters@arsdigita.com)
+ * @version $Revision: #24 $ $Date: 2004/08/17 $
+ */
+public class LegacyInitializer implements com.arsdigita.initializer.Initializer {
+
+ private static Logger s_log = Logger.getLogger(LegacyInitializer.class);
+
+ private final static String PUBLISH_DESTINATIONS = "destination";
+ private final static String PUBLISH_TO_FILE_LISTENER = "publishListener";
+ private final static String QUEUE_POLL_STARTUP_DELAY = "startupDelay";
+ private final static String QUEUE_POLL_DELAY = "pollDelay";
+ private final static String RETRY_DELAY = "retryDelay";
+ private final static String REQUEST_TIMEOUT = "requestTimeout";
+ private final static String BLOCK_SIZE = "blockSize";
+ private final static String BLOCK_SELECT_METHOD = "blockSelectMethod";
+ private final static String MAXIMUM_FAIL_COUNT = "maximumFailCount";
+
+ private Configuration m_conf = new Configuration();
+
+ public LegacyInitializer() throws InitializationException {
+ m_conf.initParameter(
+ PUBLISH_DESTINATIONS,
+ "List of publish destinations for content types" +
+ "Each element is a four-element list in the format " +
+ "'{ \"content type\", \"root directory\", \"shared storage\", " +
+ "\"url stub\" }'. " +
+ "Content type is the object type of the content type." +
+ "Root directory must be a path to a writable directory, relative" +
+ "to the webapp root. Shared storage must be true if the root " +
+ "directory is shared NFS storage, false otherwise. URL stub is " +
+ "must be the path component of the URL from which the live server " +
+ "will serve from this directory.",
+ List.class);
+ m_conf.initParameter(
+ PUBLISH_TO_FILE_LISTENER,
+ "Class which implements PublishToFileListener used to " +
+ "perform additional actions when publishing or unpublishing " +
+ "to the file system.",
+ String.class);
+ m_conf.initParameter(
+ QUEUE_POLL_STARTUP_DELAY,
+ "Time (in seconds) after system startup to wait before " +
+ "starting to monitor publishToFile queue. A value < 0 " +
+ "disables processing of the queue on this server.",
+ Integer.class, new Integer(30));
+ m_conf.initParameter(
+ QUEUE_POLL_DELAY,
+ "Time (in seconds) between checking if there are entries " +
+ "in the publishToFile queue. A value <= 0 disables processing " +
+ "the queue on this server.",
+ Integer.class, new Integer(1));
+ m_conf.initParameter(
+ RETRY_DELAY,
+ "Time to wait (seconds) before retrying to process a " +
+ "failed entry.",
+ Integer.class, new Integer(120));
+ m_conf.initParameter(
+ REQUEST_TIMEOUT,
+ "Time to wait (seconds) before aborting item request.",
+ Integer.class, new Integer(PublishToFile.DEFAULT_TIMEOUT));
+ m_conf.initParameter(
+ BLOCK_SIZE, "number of queue entries to process in one txn."
+ , Integer.class, new Integer(20));
+ m_conf.initParameter(
+ BLOCK_SELECT_METHOD,
+ "Method used to select entries for processing. " +
+ "'QueuedOrder'-in queued order. 'GroupByParent'-group " +
+ "entries according to parent when selecting items " +
+ "(allows optimizations if a listener task required for " +
+ "all elements in a folder can be done only once for the " +
+ "folder).",
+ String.class, "QueuedOrder");
+ m_conf.initParameter(
+ MAXIMUM_FAIL_COUNT,
+ "Maximum Fail Count for actions in Queue Manager. " +
+ "If Fail Count in Database is more than Specified " +
+ "Limit, Queue Manager will ignore the action. The " +
+ "Default Value -1 will ignore this parameter.",
+ Integer.class, new Integer(-1));
+ }
+
+ public Configuration getConfiguration() {
+ return m_conf;
+ }
+
+
+ public void startup() {
+ TransactionContext txn =
+ SessionManager.getSession().getTransactionContext();
+ txn.beginTxn();
+ setupPublishToFileSystem();
+
+ QueueManager.requeueMissingFiles();
+
+ txn.commitTxn();
+ }
+
+ public void shutdown() {
+ QueueManager.stopWatchingQueue();
+ }
+
+
+ /**
+ * initialize source and destinations for publishing to the file system
+ */
+ private void setupPublishToFileSystem() throws InitializationException {
+ DomainObjectInstantiator inst = new DomainObjectInstantiator() {
+ public DomainObject doNewInstance(DataObject dobj) {
+ return new PublishedFile(dobj);
+ }
+ };
+ DomainObjectFactory.registerInstantiator(
+ PublishedFile.BASE_DATA_OBJECT_TYPE,
+ inst);
+
+
+ processDestination((List) m_conf.getParameter(PUBLISH_DESTINATIONS));
+
+ PublishToFile.setRequestTimeout(getInteger(REQUEST_TIMEOUT).intValue());
+
+ QueueManager.setRetryDelay(getInteger(RETRY_DELAY));
+ QueueManager.setBlockSize(getInteger(BLOCK_SIZE));
+ QueueManager.setBlockSelectMethod(getString(BLOCK_SELECT_METHOD));
+ QueueManager.setMaximumFailCount(getInteger(MAXIMUM_FAIL_COUNT));
+
+
+ // setup listener if specified
+ String listenerName = getString( PUBLISH_TO_FILE_LISTENER );
+ if (listenerName != null) {
+ PublishToFileListener listener = null;
+ Class listenerClass = null;
+ try {
+ listenerClass = Class.forName(listenerName);
+ } catch (ClassNotFoundException ex) {
+ invalidParam(PUBLISH_TO_FILE_LISTENER,
+ "could not find listener class " + listenerClass);
+ }
+
+ try {
+ listener = (PublishToFileListener)listenerClass.newInstance();
+ } catch (InstantiationException ex) {
+ invalidParam(PUBLISH_TO_FILE_LISTENER,
+ "could not find instantiate listener class " +
+ listenerClass + " (" + ex.getMessage() + ")");
+ } catch (IllegalAccessException ex) {
+ invalidParam(PUBLISH_TO_FILE_LISTENER,
+ "could not find instantiate listener class " +
+ listenerClass + " (" + ex.getMessage() + ")");
+ }
+ QueueManager.setListener(listener);
+ }
+
+ // start thread for monitoring queue
+ int startupDelay = getInteger(QUEUE_POLL_STARTUP_DELAY).intValue();
+ int pollDelay = getInteger(QUEUE_POLL_DELAY).intValue();
+ QueueManager.startWatchingQueue(startupDelay, pollDelay);
+ }
+
+ //
+ // Process publishing destinations
+ //
+
+ private static void processDestination(List dest)
+ throws InitializationException {
+ if (dest == null) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "publish destinations must not be null");
+ }
+ if (dest.size() < 1) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "publish destinations must contain at " +
+ "least one entry");
+ }
+
+ Iterator entries = dest.iterator();
+ while (entries.hasNext()) {
+ processDestinationEntry((List)entries.next());
+ }
+ }
+
+ private static void processDestinationEntry(List entry)
+ throws InitializationException {
+
+ if ( entry.size() != 4 ) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "publish destinations entry must contain " +
+ "four elements: '{ \n" +
+ " \"content type\",\n" +
+ " \"root directory\", \n" +
+ " \"is shared\", \n" +
+ " \"url stub\" \n" +
+ "};\n");
+ }
+
+ String contentType = (String)entry.get(0);
+ // destRoot is here relative to webapp root!
+ String destRoot = (String) entry.get(1);
+ Boolean sharedRoot = (Boolean) entry.get(2);
+ String destURL = (String) entry.get(3);
+
+ if ( contentType == null || contentType.trim().length() == 0) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination content type must not be null");
+ }
+
+ ObjectType type = MetadataRoot.getMetadataRoot().getObjectType(contentType);
+ if (type == null) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination content type cannot be found");
+ }
+
+ if (destRoot == null || destRoot.trim().length() == 0) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination root must not be null");
+ }
+ if (destRoot.endsWith("/")) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination root '" + destRoot +
+ "' must not end with a '/'");
+ }
+
+ // Does destRoot really now turns into an absolute fully pathname
+ destRoot = new File(CCMResourceManager.getBaseDirectory().getPath(),
+ destRoot).getPath();
+ s_log.info("Destination Root is set to : " + destRoot);
+
+
+
+ if (sharedRoot == null) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination shared flag must not be null");
+ }
+
+
+ if (destURL == null || "".equals(destURL.trim())) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination URL must not be null");
+ }
+ if (!destURL.startsWith("/")) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination URL '" + destURL +
+ "' must start with a '/'");
+ }
+ if (destURL.endsWith("/")) {
+ invalidParam(PUBLISH_DESTINATIONS,
+ "the destination URL '" + destURL +
+ "' must not end with a '/'");
+ }
+
+ DestinationStub dest = new DestinationStub(destRoot,
+ sharedRoot.booleanValue(),
+ destURL);
+
+ File file = dest.getFile();
+ if (!file.exists()) {
+ file.mkdirs();
+ s_log.info(file.getPath() + " created");
+ }
+ boolean writable = false;
+ FileWriter fl;
+ File fname = new File(file.getPath(),"placeholder.txt");
+ s_log.info("Try to create : " + destRoot);
+ try {
+ writable = file.canWrite() && file.isDirectory();
+ try {
+ fl = new FileWriter(fname.getPath());
+ fl.write("Location for the p2fs module to store static content. \n");
+ fl.close();
+ } catch ( IOException e ) {
+ // Will be reported as an initalization error
+ s_log.warn("Error creating file " + fname.getPath());
+ }
+
+
+ } catch ( SecurityException ex ) {
+ // Will be reported as an initalization error
+ }
+ if ( ! writable ) {
+ // HACK: Let's see if we can write to the config directory. If we can,
+ // then we're running as ccmadmin inside of ccm load, and there is no
+ // need to thrown an exception.
+ File conf = CCMResourceManager.getConfigDirectory();
+ if (conf.isDirectory() && conf.canWrite()) {
+ // we're ok
+ } else {
+ invalidParam(PUBLISH_DESTINATIONS, " the document root '" + file
+ +"' must be a writable directory");
+ }
+ }
+
+ if (Template.BASE_DATA_OBJECT_TYPE.equals(contentType) ||
+ !ContentSection.getConfig().getDisableItemPfs()) {
+ PublishToFile.addDestination(contentType,
+ dest);
+ }
+ }
+
+ private Integer getInteger(String paramName) {
+ return (Integer) m_conf.getParameter(paramName);
+ }
+
+ private String getString(String paramName) {
+ return (String) m_conf.getParameter(paramName);
+ }
+
+ private static void invalidParam(String param, String msg)
+ throws InitializationException {
+
+ throw new InitializationException(
+ "publishToFile: parameter " + param +": " + msg);
+ }
+}
diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/PublishToFileConfig.java b/ccm-cms/src/com/arsdigita/cms/publishToFile/PublishToFileConfig.java
new file mode 100644
index 000000000..2b3ba1eea
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/PublishToFileConfig.java
@@ -0,0 +1,335 @@
+/*
+ * Copyright (C) 2003-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.publishToFile;
+
+import com.arsdigita.runtime.AbstractConfig;
+import com.arsdigita.util.parameter.ClassParameter;
+import com.arsdigita.util.parameter.IntegerParameter;
+import com.arsdigita.util.parameter.Parameter;
+import com.arsdigita.util.parameter.StringParameter;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Configuration object for the publish-to-file service.
+ *
+ * UNFINISHED WORK - NOT USABLE YET!
+ * ToDO: Parameter destination is a list, but we have no ListParameter type for now.
+ * We have either to develop a ListParameter class or treat this parameter as
+ * a set of StringArrayParameter.
+ *
+ * @author Peter Boy <pboy@barkhof.uni-bremen.de>
+ * @version $Id: $
+ */
+public class PublishToFileConfig extends AbstractConfig {
+
+ private static final Logger s_log = Logger.getLogger(PublishToFileConfig.class);
+
+ private static PublishToFileConfig s_conf;
+
+ /**
+ * List of publish destinations for content types.
+ * Each element is a four-element list in the format
+ * { "content type", "root directory", "shared storage", "url stub" }.
+ *
+ * Content type is the object type of the content type.
+ * Root directory must be a path to a writable directory, relative to the
+ * webapp root.
+ * Shared storage must be true if the root directory is shared NFS storage,
+ * false otherwise.
+ * URL stub is the path component of the URL from which the live
+ * server will serve from this directory.
+ */
+ private final Parameter m_destination;
+
+ /**
+ * Class which implements PublishToFileListener used to perform
+ * additional actions when publishing or unpublishing to the file system.
+ */
+ private final Parameter m_publishListener;
+
+ /**
+ * Time (in seconds) after system startup to wait before starting to monitor
+ * publishToFile queue.
+ *
+ * Set startupDelay to 0 to disable the processing of the queue. This
+ * disables the processing of templates as well so it will affect a basic
+ * functionality of the system and is not recommended under normal
+ * conditions.
+ */
+ private final Parameter m_startupDelay;
+
+ /**
+ * Time (in seconds) between checking if there are entries in the
+ * publishToFile queue.
+ *
+ * A value <= 0 disables processing the queue on this server.
+ */
+ private final Parameter m_pollDelay;
+
+ /**
+ * Time to wait (seconds) before retrying to process a failed entry.
+ */
+ private final Parameter m_retryDelay;
+
+ /**
+ * Time to wait (seconds) before aborting item request.
+ */
+ private final Parameter m_requestTimeout;
+
+ /**
+ * Number of queue entries to process at once.
+ */
+ private final Parameter m_blockSize;
+
+ /**
+ * Number of times a failed queue entry will be reprocessed.
+ * Maximum Fail Count for actions in Queue Manager.
+ * If Fail Count in database is more than specified limit, Queue Manager
+ * will ignore the action.
+ * The default value -1 will ignore this parameter.
+ */
+ private final Parameter m_maximumFailCount;
+
+ /**
+ * Method used to select entries for processing.
+ * 'QueuedOrder' - in queued order.
+ * 'GroupByParent'- group entries according to parent when selecting items
+ * (allows optimizations if a listener task required for
+ * all elements in a folder can be done only once for the
+ * folder).
+ */
+ private final Parameter m_blockSelectMethod;
+
+
+
+ /**
+ * Get a PublishToFileConfig instance.
+ *
+ * Singelton pattern, don't instantiate a notificationConfig object using
+ * the constructor directly.
+ * @return
+ */
+ static synchronized PublishToFileConfig getConfig() {
+ if (s_conf == null) {
+ s_conf = new PublishToFileConfig();
+ s_conf.load();
+ }
+
+ return s_conf;
+ }
+
+ /**
+ * Constructor.
+ *
+ * Do not use it directly!
+ */
+ public PublishToFileConfig() {
+
+ /**
+ * List of publish destinations for content types.
+ * Each element is a four-element list in the format
+ * { "content type", "root directory", "shared storage", "url stub" }.
+ *
+ * Content type is the object type of the content type.
+ * Root directory must be a path to a writable directory, relative to the
+ * webapp root.
+ * Shared storage must be true if the root directory is shared NFS storage,
+ * false otherwise.
+ * URL stub is the path component of the URL from which the live
+ * server will serve from this directory.
+ */
+ // Unfinished work! Not usable!
+ // Parameter is a list, but we have currently no ListParameter type.
+ m_destination = new StringParameter
+ ("com.arsdigita.cms.publishToFile.destination", Parameter.REQUIRED,
+ "{ " +
+ " { 'com.arsdigita.cms.ContentItem', " +
+ " 'p2fs', " +
+ " false, " +
+ " '/p2fs' }, " +
+ " { 'com.arsdigita.cms.Template', " +
+ " 'packages/content-section/templates', " +
+ " false, " +
+ " '/templates' } " +
+ "} "
+ );
+
+ /**
+ * Class which implements PublishToFileListener used to perform
+ * additional actions when publishing or unpublishing to the file system.
+ */
+ // publishListener = "com.arsdigita.cms.publishToFile.PublishToFile";
+ m_publishListener = new ClassParameter
+ ("com.arsdigita.cms.publishToFile.publish_listener", Parameter.REQUIRED,
+ PublishToFile.class);
+
+ // Queue management parameters.
+
+ /**
+ * Time (in seconds) after system startup to wait before starting to
+ * monitor publishToFile queue.
+ *
+ * Set startupDelay to 0 to disable the processing of the queue. This
+ * disables the processing of templates as well so it will affect a basic
+ * functionality of the system and is not recommended under normal
+ * conditions.
+ */
+ m_startupDelay = new IntegerParameter
+ ("com.arsdigita.cms.publishToFile.startup_delay", Parameter.REQUIRED,
+ new Integer(30));
+
+ /**
+ * Time (in seconds) between checking if there are entries in the
+ * publishToFile queue.
+ *
+ * A value <= 0 disables processing the queue on this server.
+ */
+ m_pollDelay = new IntegerParameter
+ ("com.arsdigita.cms.publishToFile.poll_delay", Parameter.REQUIRED,
+ new Integer(5));
+
+ /**
+ * Time to wait (seconds) before retrying to process a failed entry
+ */
+ m_retryDelay = new IntegerParameter
+ ("com.arsdigita.cms.publishToFile.retry_delay", Parameter.REQUIRED,
+ new Integer(120));
+
+ /**
+ * Time to wait (seconds) before aborting item request.
+ */
+ m_requestTimeout = new IntegerParameter
+ ("com.arsdigita.cms.publishToFile.request_timeout", Parameter.REQUIRED,
+ new Integer(120));
+
+ /**
+ * Number of queue entries to process at once (in one transaction).
+ */
+ m_blockSize = new IntegerParameter
+ ("com.arsdigita.cms.publishToFile.block_size", Parameter.REQUIRED,
+ new Integer(40));
+
+ /**
+ * Number of times a failed queue entry will be reprocessed.
+ * Maximum Fail Count for actions in Queue Manager.
+ * If Fail Count in database is more than specified limit, Queue Manager
+ * will ignore the action.
+ * A value -1 will ignore this parameter.
+ */
+ m_maximumFailCount = new IntegerParameter
+ ("com.arsdigita.cms.publishToFile.maximum_fail_count", Parameter.REQUIRED,
+ new Integer(10));
+
+ /**
+ * Method used to select entries for processing.
+ * 'QueuedOrder' - in queued order.
+ * 'GroupByParent'- group entries according to parent when selecting items
+ * (allows optimizations if a listener task required for
+ * all elements in a folder can be done only once for the
+ * folder).
+ */
+ m_blockSelectMethod = new StringParameter
+ ("com.arsdigita.cms.publishToFile.block_select_method", Parameter.REQUIRED,
+ "GroupByParent");
+
+
+ register(m_destination);
+ register(m_publishListener);
+ register(m_startupDelay);
+ register(m_pollDelay);
+ register(m_retryDelay);
+ register(m_requestTimeout);
+ register(m_blockSize);
+ register(m_maximumFailCount);
+ register(m_blockSelectMethod);
+
+ loadInfo();
+ }
+
+
+ /**
+ * Retrieve the class which implements PublishToFileListener used to perform
+ * additional actions when publishing or unpublishing to the file system.
+ *
+ * @return PublishToFileListener implementation class
+ */
+ public Class getpublishListenerClass() {
+ return (Class) get(m_publishListener);
+ }
+
+ /**
+ * Retrieve request manager's delay in seconds.
+ * @return delay, in seconds.
+ */
+ public int getStartupDelay() {
+ s_log.debug("Retrieving m_startupDelay.");
+ return ((Integer) get(m_startupDelay)).intValue();
+ }
+
+ /**
+ * Retrieve time (in seconds) between checking if there are entries in the
+ * publishToFile queue.
+ *
+ * A value <= 0 disables processing the queue on this server.
+ *
+ * @return time, in seconds
+ */
+ public int getPollDelay() {
+ s_log.debug("Retrieving m_pollDelay.");
+ return ((Integer) get(m_pollDelay)).intValue();
+ }
+
+ /**
+ * Retrieve time to wait (seconds) before retrying to process a failed entry
+ * @return delay, in seconds.
+ */
+ public int getRetryDelay() {
+ s_log.debug("Retrieving m_retryDelay.");
+ return ((Integer) get(m_retryDelay)).intValue();
+ }
+
+ /**
+ * Retrieve simple queue's period in seconds
+ * @return period, in seconds
+ */
+ public int getBlockSize() {
+ s_log.debug("Retrieving m_blockSize.");
+ return ((Integer) get(m_blockSize)).intValue();
+ }
+
+ /**
+ * Retrieve digest queue's delay in seconds.
+ * @return delay, in seconds.
+ */
+ public int getMaximumFailCount() {
+ s_log.debug("Retrieving m_maximumFailCount.");
+ return ((Integer) get(m_maximumFailCount)).intValue();
+ }
+
+ /**
+ * Retrieve digest queue's period in seconds
+ * @return period, in seconds
+ */
+ public String getBlockSelectMethod() {
+ s_log.debug("Retrieving m_blockSelectMethod.");
+ return ( (String) get(m_blockSelectMethod));
+ }
+
+}
diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/PublishToFileConfig_parameter.properties b/ccm-cms/src/com/arsdigita/cms/publishToFile/PublishToFileConfig_parameter.properties
new file mode 100644
index 000000000..b47dc7337
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/PublishToFileConfig_parameter.properties
@@ -0,0 +1,29 @@
+waf.notification.request_manager_delay.title=Request Manager Delay
+waf.notification.request_manager_delay.purpose=Start of request manager's delay in seconds.
+waf.notification.request_manager_delay.example=900
+waf.notification.request_manager_delay.format=[integer]
+
+waf.notification.request_manager_period.title=Request Manager Period
+waf.notification.request_manager_period.purpose=Request manager's activities period in seconds
+waf.notification.request_manager_period.example=900
+waf.notification.request_manager_period.format=[integer]
+
+waf.notification.simple_queue.title=Simple Queue Delay
+waf.notification.simple_queue_delay.purpose=Start of Simple Queue's delay in seconds.
+waf.notification.simple_queue_delay.example=900
+waf.notification.simple_queue_delay.format=[integer]
+
+waf.notification.simple_queue_period.title=Simple Queue Period
+waf.notification.simple_queue_period.purpose=Simple Queue 's activities period in seconds
+waf.notification.simple_queue_period.example=900
+waf.notification.simple_queue_period.format=[integer]
+
+waf.notification.digest_queue.title=Digest Queue Delay
+waf.notification.digest_queue_delay.purpose=Start of Digest Queue's delay in seconds.
+waf.notification.digest_queue_delay.example=900
+waf.notification.digest_queue_delay.format=[integer]
+
+waf.notification.digest_queue_period.title=Digest Queue Period
+waf.notification.digest_queue_period.purpose=Digest Queue 's activities period in seconds
+waf.notification.digest_queue_period.example=900
+waf.notification.digest_queue_period.format=[integer]
diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/QueueManager.java b/ccm-cms/src/com/arsdigita/cms/publishToFile/QueueManager.java
index eade5b186..1b18876c3 100755
--- a/ccm-cms/src/com/arsdigita/cms/publishToFile/QueueManager.java
+++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/QueueManager.java
@@ -65,8 +65,7 @@ import java.io.File;
public class QueueManager implements Runnable {
// Creates a s_logging category with name = to the full name of class
- private static Logger s_log =
- Logger.getLogger(QueueManager.class);
+ private static Logger s_log = Logger.getLogger(QueueManager.class);
// Should probably use these constants. Are hardcoded for now because
// matches DataQuery suffex.
@@ -91,6 +90,15 @@ public class QueueManager implements Runnable {
// Class implementing methods run when publishing or unpublishing to file.
private static PublishToFileListener s_publishListener = null;
+ ////////////////////////////////////////////////////////////////////
+ // Constructor related code.
+ //
+
+ /**
+ *
+ * @param startupDelay
+ * @param pollDelay
+ */
private QueueManager(int startupDelay, int pollDelay) {
m_startupDelay = startupDelay;
m_pollDelay = pollDelay;
@@ -445,15 +453,19 @@ public class QueueManager implements Runnable {
/**
* Stop watching and processing the queue. The background thread that
- * processes the queue will terminate after this method has been called.
- * Termination is not immediate, since the queue may be in the middle of
- * processing a block of entries.
+ * processes the queue will terminate after this method has been
+ * called. Termination is not immediate, since the queue may be in the
+ * middle of processing a block of entries.
*/
public static void stopWatchingQueue() {
if (s_log.isInfoEnabled()) {
- s_log.info("Going to stop queue processing.");
+ s_log.info("Sending signal to stop queue processing.");
}
s_keepWatchingQueue = false;
+
+ s_log.debug("Going to sleep.");
+ sleep(45);
+ s_log.debug("Resume processing.");
}
@@ -470,7 +482,7 @@ public class QueueManager implements Runnable {
HashSet failedItems = new HashSet();
while ( sleep(m_pollDelay) && s_keepWatchingQueue ) {
-// synchronized( Scheduler.class ) {
+// synchronized( Scheduler.class ) {
//while there are more entries in queue process them.HashSet
//is used to store the failed items and for checking that
//they do not get processed again.
@@ -479,8 +491,9 @@ public class QueueManager implements Runnable {
// clear failed items
failedItems.clear();
+// }
}
-// }
+ s_log.info("Start polling queue in " + m_startupDelay + "s.");
}
/***
diff --git a/ccm-cms/src/com/arsdigita/cms/publishToFile/enterprise.init b/ccm-cms/src/com/arsdigita/cms/publishToFile/enterprise.init
new file mode 100644
index 000000000..11b911196
--- /dev/null
+++ b/ccm-cms/src/com/arsdigita/cms/publishToFile/enterprise.init
@@ -0,0 +1,75 @@
+// CMS publishToFile initialization file
+//
+// $Id: enterprise.init 1357 2006-11-06 13:02:24Z sskracic $
+//
+
+// Modified CMS enterprise.init: Contains just the publishToFile elements
+
+
+init com.arsdigita.cms.publishToFile.LegacyInitializer {
+ // List of publish destinations for content types
+ // Each element is a four-element list in the format
+ // '{ "content type", "root directory", "shared storage",
+ // "url stub" }'.
+ // "Content type" is the object type of the content type.
+ // "Root directory" must be a path to a writable directory, relative
+ // to the file-system root.
+ // (pboy): "Root directory here is relative to application base!
+ // "Shared storage" must be _true_ if the root
+ // directory is shared NFS storage, _false_ otherwise. "URL stub"
+ // must be the path component of the URL from which the live server
+ // will serve from this directory.
+ destination = {
+ { "com.arsdigita.cms.ContentItem",
+ "p2fs",
+ false,
+ "/p2fs" },
+ // (pboy): starting with webapps refers to the CCM_HOME env variable which
+ // points to the installation root of the servlet container. This is not
+ // used anymore, all specifications are relative to webapplication base.
+ // So the following may have to be changed to "packages/content-section/templates"
+ // if someone tries to use p2fs
+ { "com.arsdigita.cms.Template",
+ // "webapps/ROOT/packages/content-section/templates",
+ "packages/content-section/templates",
+ false,
+ "/templates" }
+ };
+
+ // Class which implements PublishToFileListener used to perform
+ // additional actions when publishing or unpublishing to the file system.
+ publishListener = "com.arsdigita.cms.publishToFile.PublishToFile";
+
+ // Queue management parameters.
+
+ // Set startupDelay to 0 to disable the processing of the queue
+ // Time (seconds) before starting to monitor the
+ // queue after a server start
+ startupDelay = 30;
+
+ // Time (in seconds) between checking if there are entries in the
+ // publishToFile queue.
+ // A value <= 0 disables processing the queue on this server.
+ pollDelay = 5;
+
+ // Time to wait (seconds) before retrying
+ // to process a failed entry
+ retryDelay = 120;
+
+ // Number of queue entries to process at once.
+ blockSize = 40;
+ // Number of times a failed queue entry will be
+ // reprocessed. If processing has failed more than
+ // that number of times, the entry will be
+ // ignored.
+ maximumFailCount = 10;
+
+ // Method used to select entries for processing.
+ // 'QueuedOrder'-in queued order.
+ // 'GroupByParent'-group entries according to parent when selecting items
+ // (allows optimizations if a listener task required for all elements in a folder
+ // can be done only once for the folder).
+ blockSelectMethod = "GroupByParent";
+}
+
+
diff --git a/ccm-cms/src/com/arsdigita/cms/ui/revision/package.html b/ccm-cms/src/com/arsdigita/cms/ui/revision/package.html
index 5c285a9c9..69a2616a0 100755
--- a/ccm-cms/src/com/arsdigita/cms/ui/revision/package.html
+++ b/ccm-cms/src/com/arsdigita/cms/ui/revision/package.html
@@ -1,5 +1,8 @@
+
+ Provides UI components for administering and displaying the diff --git a/ccm-cms/src/com/arsdigita/cms/ui/user/package.html b/ccm-cms/src/com/arsdigita/cms/ui/user/package.html index 6a713a36c..babe33d3a 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/user/package.html +++ b/ccm-cms/src/com/arsdigita/cms/ui/user/package.html @@ -1,6 +1,9 @@ -
+ +UI components for publically-facing pages (i.e., pages that display content outside of the CMS administration UI). diff --git a/ccm-cms/src/com/arsdigita/cms/ui/util/package.html b/ccm-cms/src/com/arsdigita/cms/ui/util/package.html index 800d879f2..5f15cb426 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/util/package.html +++ b/ccm-cms/src/com/arsdigita/cms/ui/util/package.html @@ -1,6 +1,7 @@ -
+ +Provides a set of server-side user interface components for obtaining user input. These components are based on HTML forms. -
diff --git a/ccm-core/src/com/arsdigita/bebop/package.html b/ccm-core/src/com/arsdigita/bebop/package.html index 681e37315..3fdb0e39c 100755 --- a/ccm-core/src/com/arsdigita/bebop/package.html +++ b/ccm-core/src/com/arsdigita/bebop/package.html @@ -47,8 +47,8 @@ all the requests to the page. This initialization is typically done in theinit method of a servlet. Classes that
contain only static information implement the interface {@link
- com.arsdigita.bebop.util.Lockable}.
- Request-specific data structures + com.arsdigita.bebop.util.Lockable}.
+Request-specific data structures
are built within the doPost or doGet
methods of a servlet. Corresponding to the static Page,
there is a {@link com.arsdigita.bebop.PageState} class that will
@@ -101,7 +101,7 @@
The {@link com.arsdigita.bebop.Page#process Page.process} method will initiate all the steps that are necessary to process the request. It notifies the form that a request has been made and prints - the page that results from the form that processes the request.
+ the page that results from the form that processes the request.To process the request, the form extracts the parameter values from the request, runs validation listeners, and either runs process listeners (if the request was a valid submission) or displays the form together @@ -115,7 +115,7 @@ Swing. -
Installer for domain system. diff --git a/ccm-core/src/com/arsdigita/formbuilder/installer/package.html b/ccm-core/src/com/arsdigita/formbuilder/installer/package.html index 2c9fbf47a..ffa244e88 100755 --- a/ccm-core/src/com/arsdigita/formbuilder/installer/package.html +++ b/ccm-core/src/com/arsdigita/formbuilder/installer/package.html @@ -1,5 +1,8 @@ +
+Installer for formbuilder service. diff --git a/ccm-core/src/com/arsdigita/globalization/GlobalizedMessage.java b/ccm-core/src/com/arsdigita/globalization/GlobalizedMessage.java index 5d140ae58..de10ed0e2 100755 --- a/ccm-core/src/com/arsdigita/globalization/GlobalizedMessage.java +++ b/ccm-core/src/com/arsdigita/globalization/GlobalizedMessage.java @@ -41,10 +41,9 @@ import org.apache.log4j.Logger; * @see java.util.Locale * @see java.util.ResourceBundle * - * @version $Revision: #13 $ $Date: 2004/08/16 $ + * @version $Id: GlobalizedMessage.java 287 2005-02-22 00:29:02Z sskracic $ */ public class GlobalizedMessage { - public final static String versionId = "$Id: GlobalizedMessage.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $"; private static final Logger s_cat = Logger.getLogger(GlobalizedMessage.class.getName()); diff --git a/ccm-core/src/com/arsdigita/loader/CoreLoader.java b/ccm-core/src/com/arsdigita/loader/CoreLoader.java index 260f5b0ef..027dc6535 100755 --- a/ccm-core/src/com/arsdigita/loader/CoreLoader.java +++ b/ccm-core/src/com/arsdigita/loader/CoreLoader.java @@ -210,7 +210,21 @@ public class CoreLoader extends PackageLoader { Host.create(hhost.getName(), hhost.getPort()); } + // Loader for lucene search engine. + // Used to invoke static class LoaderImpl - method load() in + // com.arsdigita.search.lucene.IndexId. Same procedure is invoked by + // the initializer each time the system starts. So it's redundant here. + // Using initializer code is favourable because it may be conditionally + // performed, depending on configuration (Lucene or Intermedia). + // But the currently given implementation requires the the loader + // instruction here to let the code initialization time (i.e. at each + // startup) work properly. If left out here instantiation in + // c.ad.search.lucene.Initializer (public final static Loader LOADER) + // doesn't work! com.arsdigita.search.lucene.Initializer.LOADER.load(); + // + // As of version 6.6.0 release 2 refactored to the new initializer system + //--com.arsdigita.search.lucene.LegacyInitializer.LOADER.load(); } private SiteNode loadKernel() { diff --git a/ccm-core/src/com/arsdigita/localization/demo/Initializer.java b/ccm-core/src/com/arsdigita/localization/demo/Initializer.java.nolongerInUse similarity index 100% rename from ccm-core/src/com/arsdigita/localization/demo/Initializer.java rename to ccm-core/src/com/arsdigita/localization/demo/Initializer.java.nolongerInUse diff --git a/ccm-core/src/com/arsdigita/localization/demo/package.html b/ccm-core/src/com/arsdigita/localization/demo/package.html index 580b95c7d..1e6135630 100755 --- a/ccm-core/src/com/arsdigita/localization/demo/package.html +++ b/ccm-core/src/com/arsdigita/localization/demo/package.html @@ -6,10 +6,10 @@
- Example A demonstration of how to localize the login and registration pages of the ACS without touching the code. Localization uses German as the target locale, and includes three files: +
Classes for converting between specific mimetypes. diff --git a/ccm-core/src/com/arsdigita/notification/BaseSubscription.java b/ccm-core/src/com/arsdigita/notification/BaseSubscription.java index 9452bc20f..7de4c5d1f 100755 --- a/ccm-core/src/com/arsdigita/notification/BaseSubscription.java +++ b/ccm-core/src/com/arsdigita/notification/BaseSubscription.java @@ -31,10 +31,10 @@ import com.arsdigita.util.StringUtils; import org.apache.log4j.Logger; /** - * The abstract BaseSubscription class provides the ability for Users - * to sign up for email notifications. Subclasses will specify - * the object to which the notifications apply and messages that should - * be sent along with the notifications. + * The abstract BaseSubscription class provides the ability for Users to sign up + * for email notifications. Subclasses will specify the object to which the + * notifications apply and messages that should be sent along with the + * notifications. * * The default implementation provides instant notifications. Subclasses * should override sendNotification() to alter this behavior. @@ -56,9 +56,9 @@ public abstract class BaseSubscription extends ACSObject { /** * A separator to use between the body and signature of an alert. */ - protected final static String SEPARATOR = getSeparator(); + protected final static String ALERT_BLURB = "This is an automated alert from the Discussion Forum system. "; protected final static String REPLY_BLURB = @@ -90,9 +90,9 @@ public abstract class BaseSubscription extends ACSObject { } /** - * default implementation returns a generic group name + * Default implementation, returns a generic group name. * - * subtypes should override this method to provide a meaningful name + * Subtypes should override this method to provide a meaningful name. * @return */ protected String getSubscriptionGroupName() { @@ -142,10 +142,10 @@ public abstract class BaseSubscription extends ACSObject { } /** - * This method will send immediate notifications to subscribed - * users with the header and signature specified by getHeader() - * and getSignature. Subclasses which desire different behavior - * should override one or more of these methods. + * This method will send immediate notifications to subscribed users with + * the header and signature specified by getHeader() and getSignature(). + * Subclasses which desire different behavior should override one or more + * of these methods. */ public void sendNotification(ThreadedMessage post) { sendNotification(post, false); diff --git a/ccm-core/src/com/arsdigita/notification/Digest.java b/ccm-core/src/com/arsdigita/notification/Digest.java index 4ff253299..05f600776 100755 --- a/ccm-core/src/com/arsdigita/notification/Digest.java +++ b/ccm-core/src/com/arsdigita/notification/Digest.java @@ -30,12 +30,12 @@ import java.util.Calendar; import java.util.Date; /** - * Models the envelope information associated with a - * digest. When a digest is processed, all notifications associated - * with it are grouped for delivery as a single unit to each receiver. - * The outbound email generated for the receivers has a common - * subject, header, separator between the individual messages, and - * signature. + * Models the envelope information associated with a digest. + * + * When a digest is processed, all notifications associated with it are grouped + * for delivery as a single unit to each receiver. The outbound email generated + * for the receivers has a common subject, header, separator between the + * individual messages, and signature. * * @author Ron Henderson * @author David Dao @@ -63,7 +63,6 @@ public class Digest extends ACSObject implements NotificationConstants { * consisting of 78 dashes (-). * */ - public Digest () { super(BASE_DATA_OBJECT_TYPE); @@ -81,7 +80,6 @@ public class Digest extends ACSObject implements NotificationConstants { * @param header the common header * @param signature the common signature */ - public Digest (Party from, String subject, String header, @@ -89,10 +87,10 @@ public class Digest extends ACSObject implements NotificationConstants { { this(); - Assert.assertNotNull(from, "Party from"); - Assert.assertNotNull(subject, "String subject"); - Assert.assertNotNull(header, "String header"); - Assert.assertNotNull(signature, "String signature"); + Assert.exists(from, "Party from"); + Assert.exists(subject, "String subject"); + Assert.exists(header, "String header"); + Assert.exists(signature, "String signature"); setFrom(from); setSubject(subject); @@ -105,7 +103,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @param oid the OID of the digest */ - public Digest (OID oid) throws DataObjectNotFoundException { @@ -117,7 +114,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @param dataObj the DataObject the Digest will wrap */ - public Digest(DataObject dataObj) { super(dataObj); } @@ -127,7 +123,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @param id the id for the DataObject to retrieve. */ - public Digest (BigDecimal id) throws DataObjectNotFoundException { @@ -138,7 +133,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Gets the sender of the digest. * @return the sender. */ - public Party getFrom() throws DataObjectNotFoundException { @@ -152,7 +146,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @return the sender's email address as a String. */ - public String getFromEmail() { try { return getFrom().getPrimaryEmail().toString(); @@ -165,9 +158,8 @@ public class Digest extends ACSObject implements NotificationConstants { * Sets the common sender for the digest. * @param from the common sender */ - public void setFrom (Party from) { - Assert.assertNotNull(from, "Party from"); + Assert.exists(from, "Party from"); set(PARTY_FROM, from.getID()); } @@ -176,7 +168,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Gets the common subject for the digest. * @return the common subject for the digest. */ - public String getSubject () { return (String) get(SUBJECT); } @@ -185,7 +176,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Sets the common subject for the digest. * @param subject the common subject */ - public void setSubject (String subject) { set(SUBJECT, subject); } @@ -194,7 +184,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Gets the common header for the digest. * @return the common header for the digest. */ - public String getHeader () { return (String) get(HEADER); } @@ -203,7 +192,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Set the common header for the digest. * @param header the common header */ - public void setHeader (String header) { set(HEADER, header); } @@ -212,7 +200,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Gets the current separator for elements of the digest. * @return the separator */ - public String getSeparator () { return (String) get(SEPARATOR); } @@ -224,7 +211,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @param separator the value of the separator */ - public void setSeparator (String separator) { set(SEPARATOR, separator); } @@ -237,7 +223,6 @@ public class Digest extends ACSObject implements NotificationConstants { * @param s the separator character * @param n the repeat count */ - public void setSeparator (char s, int n) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < n; i++) @@ -249,7 +234,6 @@ public class Digest extends ACSObject implements NotificationConstants { * Gets the signature used for this digest. * @return the signature for this digest. */ - public String getSignature () { return (String) get(SIGNATURE); } @@ -259,7 +243,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @param signature the signature for the digest */ - public void setSignature (String signature) { set(SIGNATURE, signature); } @@ -269,7 +252,6 @@ public class Digest extends ACSObject implements NotificationConstants { * digest. * @return the processing frequency for this digest. */ - public Integer getFrequency () { return (Integer) get(FREQUENCY); } @@ -279,7 +261,6 @@ public class Digest extends ACSObject implements NotificationConstants { * * @param frequency the processing frequency in minutes */ - public void setFrequency (int frequency) { set(FREQUENCY, new Integer(frequency)); } @@ -287,7 +268,6 @@ public class Digest extends ACSObject implements NotificationConstants { /** * Sets the date when this digest will next be processed. */ - private void setNextRun (Date nextRun) { set(NEXT_RUN, nextRun); } @@ -297,7 +277,6 @@ public class Digest extends ACSObject implements NotificationConstants { cal.add(Calendar.MINUTE, getFrequency().intValue()); setNextRun(cal.getTime()); } - /** * Get the date when this digest will next be processed. */ @@ -311,7 +290,6 @@ public class Digest extends ACSObject implements NotificationConstants { * notifications. Verifies that all required parameters have been * specified before saving. */ - protected void beforeSave() { String message = diff --git a/ccm-core/src/com/arsdigita/notification/DigestQueueManager.java b/ccm-core/src/com/arsdigita/notification/DigestQueueManager.java index c732f052f..6108bd20c 100755 --- a/ccm-core/src/com/arsdigita/notification/DigestQueueManager.java +++ b/ccm-core/src/com/arsdigita/notification/DigestQueueManager.java @@ -47,10 +47,8 @@ import java.util.TimerTask; class DigestQueueManager extends TimerTask implements NotificationConstants { - public static final String versionId = "$Id: DigestQueueManager.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $Date: 2004/08/16 $"; - private static final Logger log = - Logger.getLogger(DigestQueueManager.class); + private static final Logger log = Logger.getLogger(DigestQueueManager.class); // String catalog for digest message. Should be globalized. @@ -60,7 +58,6 @@ class DigestQueueManager extends TimerTask /** * Processes one sweep of the DigestQueueManager. */ - public void run() { log.info("processing current requests"); @@ -74,11 +71,9 @@ class DigestQueueManager extends TimerTask try { - /** - * Retrieve all digests to be processed during this run. - * Store all notifications in double hash map using - * digestID and partyTo as key. - */ + // Retrieve all digests to be processed during this run. + // Store all notifications in double hash map using + // digestID and partyTo as key. DataQuery query = session.retrieveQuery(GET_DIGEST_QUEUED_NOTIFICATIONS); diff --git a/ccm-core/src/com/arsdigita/notification/Initializer.java b/ccm-core/src/com/arsdigita/notification/Initializer.java index 8b5aeade7..c8ebdc0ee 100755 --- a/ccm-core/src/com/arsdigita/notification/Initializer.java +++ b/ccm-core/src/com/arsdigita/notification/Initializer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. + * Copyright (C) 2003-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 @@ -18,14 +18,19 @@ */ package com.arsdigita.notification; +import com.arsdigita.runtime.ContextCloseEvent; +import com.arsdigita.runtime.ContextInitEvent; +import com.arsdigita.runtime.GenericInitializer; + import java.util.Timer; -import com.arsdigita.initializer.Configuration; -import com.arsdigita.initializer.InitializationException; + import org.apache.log4j.Logger; /** - * Initializes three timer tasks to maintain the notification - * service. These tasks handle the following: + * Initializes the Notification package. + * + * Initializes three timer tasks to maintain the notification service. These + * tasks handle the following: *
Notification. This constructor
- * is invoked by all others to initialize the following default
- * parameters:
+ * Creates an empty Notification. This constructor is invoked
+ * by all others to initialize the following default parameters:
*
* true so the internal object is deleted when
- * the notification is deleted. Also sets the isPermanent flag to
- * false so the notification will be deleted after
- * processing.
+ * Creates a notification by supplying the sender, receiver, subject, and
+ * body of the message. Creates an internal {@link Message} object to store
+ * this information and sets the MessageDelete flag to true so
+ * the internal object is deleted when the notification is deleted.
+ * Also sets the isPermanent flag to false so the
+ * notification will be deleted after processing.
*
* @param to the party receiving the message
* @param from the party sending the message
* @param subject the subject of the message
* @param body the body of the message
*/
-
public Notification(Party to, Party from, String subject, String body) {
this();
@@ -174,13 +168,12 @@ public class Notification extends ACSObject implements NotificationConstants {
/**
* Creates a notification by supplying the receiver and an existing
- * message to send. All other information (subject, body, and
- * sender) is encapsulated by the message.
+ * message to send. All other information (subject, body, and sender)
+ * is encapsulated by the message.
*
* @param to the party recieving the message
* @param msg the message to send
*/
-
public Notification(Party to, Message msg) {
this();
@@ -190,12 +183,10 @@ public class Notification extends ACSObject implements NotificationConstants {
/**
- * Retrieves an existing notification from the database using its
- * OID.
+ * Retrieves an existing notification from the database using its OID.
*
* @param oid the OID of the notification
*/
-
public Notification(OID oid) throws DataObjectNotFoundException {
super(oid);
}
@@ -206,7 +197,6 @@ public class Notification extends ACSObject implements NotificationConstants {
*
* @param id the BigDecimal ID of the notification
*/
-
public Notification(BigDecimal id) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE,id));
}
@@ -215,7 +205,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* Sets the sender of the notification.
* @param to the sender of the notification
*/
-
public void setTo(Party to) {
set(PARTY_TO, to.getID());
}
@@ -224,7 +213,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* Gets the message object contained by this notification, which
* may be null.
*/
-
private Message getMessage() {
BigDecimal id = (BigDecimal) get(MESSAGE_ID);
Message msg = null;
@@ -247,7 +235,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* Note: should we disable this for anything not isNew()?
* @param msg the message of this notification
*/
-
public void setMessage(Message msg) {
if (msg.isNew()) {
@@ -260,7 +247,6 @@ public class Notification extends ACSObject implements NotificationConstants {
/**
* Get the status of this notification.
*/
-
public String getStatus() {
return (String) get(STATUS);
}
@@ -273,13 +259,12 @@ public class Notification extends ACSObject implements NotificationConstants {
}
/**
- * Gets the flag for whether this notification remains in the
- * database after processing.
+ * Gets the flag for whether this notification remains in the database
+ * after processing.
*
- * @return true if this notification remains in the
- * database after processing; false otherwise.
+ * @return true if this notification remains in the database
+ * after processing; false otherwise.
*/
-
public Boolean getIsPermanent() {
return new Boolean(!((Boolean) get(EXPUNGE_P)).booleanValue());
}
@@ -292,7 +277,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* @param permanent true if this notification should
* remain in the database after processing
*/
-
public void setIsPermanent(Boolean permanent) {
set(EXPUNGE_P, new Boolean(!permanent.booleanValue()));
}
@@ -302,7 +286,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* @return true if the MessageDelete flag is set;
* false otherwise.
*/
-
public Boolean getMessageDelete() {
return (Boolean) get(EXPUNGE_MSG_P);
}
@@ -313,7 +296,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* @param value true if the underlying message should be
* deleted when this request is deleted
*/
-
public void setMessageDelete(Boolean value) {
set(EXPUNGE_MSG_P, value);
}
@@ -340,7 +322,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* @return the digest of this notification, or null if
* there is no digest.
*/
-
public Digest getDigest()
throws DataObjectNotFoundException
{
@@ -358,7 +339,6 @@ public class Notification extends ACSObject implements NotificationConstants {
*
* @param digest the digest this message belongs to
*/
-
public void setDigest(Digest digest) {
set(DIGEST_ID, digest.getID());
}
@@ -398,7 +378,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* @param header the header of the alert
* @since 4.8.1
*/
-
public void setHeader(String header) {
set(HEADER, header);
}
@@ -411,19 +390,17 @@ public class Notification extends ACSObject implements NotificationConstants {
* @param signature the signature of the alert
* @since 4.8.1
*/
-
public void setSignature(String signature) {
set(SIGNATURE, signature);
}
/**
- * Returns true if the primary MIME type of the
- * contained message matches the specified MIME type. Always
- * returns false if a message has not been specified.
+ * Returns true if the primary MIME type of the contained
+ * message matches the specified MIME type. Always returns false if a
+ * message has not been specified.
*
* @return true if the contained Message is of the specified type.
*/
-
private boolean isMimeType(String type) {
Message msg = getMessage();
if (msg == null) {
@@ -435,9 +412,8 @@ public class Notification extends ACSObject implements NotificationConstants {
protected void beforeSave() {
- // Check to see if we need to save the underlying
- // message. This could be the case if we generated an internal
- // message.
+ // Check to see if we need to save the underlying message. This
+ // could be the case if we generated an internal message.
Message msg = getMessage();
if (msg != null) {
@@ -455,7 +431,6 @@ public class Notification extends ACSObject implements NotificationConstants {
* Deletes the notification. This also checks to see if the
* corresponding message should be deleted at the same time.
*/
-
public void delete() {
boolean msgDelete = getMessageDelete().booleanValue();
diff --git a/ccm-core/src/com/arsdigita/notification/NotificationConfig.java b/ccm-core/src/com/arsdigita/notification/NotificationConfig.java
new file mode 100644
index 000000000..6ea7d807b
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/notification/NotificationConfig.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2003-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.notification;
+
+import com.arsdigita.runtime.AbstractConfig;
+import com.arsdigita.util.parameter.IntegerParameter;
+import com.arsdigita.util.parameter.Parameter;
+
+import org.apache.log4j.Logger;
+
+/**
+ * NotificationConfig
+ *
+ * FixMe:
+ * invoking load() breaks for some reason the container startup process.
+ * As a temporary measure it is disabled and we return constants.
+ *
+ * @author Peter Boy <pboy@barkhof.uni-bremen.de>
+ * @version $Id: $
+ */
+public class NotificationConfig extends AbstractConfig {
+
+ private static final Logger s_log = Logger.getLogger(NotificationConfig.class);
+
+ private static NotificationConfig s_conf;
+
+
+ /**
+ * Request manager's delay in seconds.
+ */
+ private IntegerParameter m_requestManagerDelay = new IntegerParameter
+ ("waf.notification.request_manager_delay", Parameter.REQUIRED,
+ new Integer(900));
+
+ /**
+ * Request manager's period in seconds
+ */
+ private IntegerParameter m_requestManagerPeriod = new IntegerParameter
+ ("waf.notification.request_manager_period", Parameter.REQUIRED,
+ new Integer(900));
+
+ /**
+ * Digest queue's delay in seconds.
+ */
+ private IntegerParameter m_digestQueueDelay = new IntegerParameter
+ ("waf.notification.digest_queue_delay", Parameter.REQUIRED,
+ new Integer(900));
+
+ /**
+ * Digest queue's period in seconds
+ */
+ private IntegerParameter m_digestQueuePeriod = new IntegerParameter
+ ("waf.notification.digest_queue_period", Parameter.REQUIRED,
+ new Integer(900));
+
+ /**
+ * Simple queue's delay in seconds.
+ */
+ private IntegerParameter m_simpleQueueDelay = new IntegerParameter
+ ("waf.notification.simple_queue_delay", Parameter.REQUIRED,
+ new Integer(900));
+
+ /**
+ * Simple queue's period in seconds
+ */
+ private IntegerParameter m_simpleQueuePeriod = new IntegerParameter
+ ("waf.notification.simple_queue_period", Parameter.REQUIRED,
+ new Integer(900));
+
+ /**
+ * Constructor.
+ * Do not use it directly!
+ */
+ public NotificationConfig() {
+ s_log.debug("Executing NotificationConfig Constructor.");
+ register(m_requestManagerDelay);
+ register(m_requestManagerPeriod);
+ register(m_simpleQueueDelay);
+ register(m_simpleQueuePeriod);
+ register(m_digestQueueDelay);
+ register(m_digestQueuePeriod);
+ s_log.debug("NotificationConfig register executed.");
+
+ s_log.debug("Executing NotificationConfig loadinfo.");
+ loadInfo();
+ s_log.debug("Leaving NotificationConfig Constructor.");
+ }
+
+ /**
+ * Get a NotificationConfig instance.
+ *
+ * Singelton pattern, don't instantiate a notificationConfig object using
+ * the constructor directly.
+ * @return
+ */
+ static synchronized NotificationConfig getConfig() {
+ s_log.debug("NotificationConfig object requested.");
+ if (s_conf == null) {
+ s_log.debug("Instantiating NotificationConfig object.");
+ s_conf = new NotificationConfig();
+ s_log.debug("Got NotificationConfig object.");
+ // FixMe:
+ // invoking load() breaks for some reason the container startup
+ // process.
+ // As a temporary measure it is disabled and we return constants.
+ // s_conf.load();
+ s_log.debug("NotificationConfig object instantiated.");
+ }
+
+ return s_conf;
+ }
+
+ /**
+ * Retrieve request manager's delay in seconds.
+ * @return delay, in seconds.
+ */
+ public int getRequestManagerDelay() {
+ s_log.debug("m_requestManagerDelay retrieved.");
+ // return ((Integer) get(m_requestManagerDelay)).intValue();
+ return 900;
+ }
+
+ /**
+ * Retrieve request manager's period in seconds
+ * @return period, in seconds
+ */
+ public int getRequestManagerPeriod() {
+ s_log.debug("m_requestManagerPeriod retrieved.");
+ // return ((Integer) get(m_requestManagerPeriod)).intValue();
+ return 900;
+ }
+
+ /**
+ * Retrieve digest queue's delay in seconds.
+ * @return delay, in seconds.
+ */
+ public int getDigestQueueDelay() {
+ s_log.debug("m_digestQueueDelay retrieved.");
+ // return ((Integer) get(m_digestQueueDelay)).intValue();
+ return 900;
+ }
+
+ /**
+ * Retrieve digest queue's period in seconds
+ * @return period, in seconds
+ */
+ public int getDigestQueuePeriod() {
+ s_log.debug("m_digestQueuePeriod retrieved.");
+ // return ((Integer) get(m_digestQueuePeriod)).intValue();
+ return 900;
+ }
+
+ /**
+ * Retrieve simple queue's delay in seconds.
+ * @return delay, in seconds.
+ */
+ public int getSimpleQueueDelay() {
+ s_log.debug("m_simpleQueueDelay retrieved.");
+ // return ((Integer) get(m_simpleQueueDelay)).intValue();
+ return 900;
+ }
+
+ /**
+ * Retrieve simple queue's period in seconds
+ * @return period, in seconds
+ */
+ public int getSimpleQueuePeriod() {
+ s_log.debug("m_simpleQueuePeriod retrieved.");
+ // return ((Integer) get(m_simpleQueuePeriod)).intValue();
+ return 900;
+ }
+
+}
diff --git a/ccm-core/src/com/arsdigita/notification/NotificationConfig_parameter.properties b/ccm-core/src/com/arsdigita/notification/NotificationConfig_parameter.properties
new file mode 100644
index 000000000..a7d7486ea
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/notification/NotificationConfig_parameter.properties
@@ -0,0 +1,29 @@
+waf.notification.request_manager_delay.title=Request Manager Delay
+waf.notification.request_manager_delay.purpose=Start of request manager's delay in seconds.
+waf.notification.request_manager_delay.example=900
+waf.notification.request_manager_delay.format=[integer]
+
+waf.notification.request_manager_period.title=Request Manager Period
+waf.notification.request_manager_period.purpose=Request manager's activities period in seconds
+waf.notification.request_manager_period.example=900
+waf.notification.request_manager_period.format=[integer]
+
+waf.notification.digest_queue_delay.title=Digest Queue Delay
+waf.notification.digest_queue_delay.purpose=Start of Digest Queue's delay in seconds.
+waf.notification.digest_queue_delay.example=900
+waf.notification.digest_queue_delay.format=[integer]
+
+waf.notification.digest_queue_period.title=Digest Queue Period
+waf.notification.digest_queue_period.purpose=Digest Queue's activities period in seconds
+waf.notification.digest_queue_period.example=900
+waf.notification.digest_queue_period.format=[integer]
+
+waf.notification.simple_queue_delay.title=Simple Queue Delay
+waf.notification.simple_queue_delay.purpose=Start of Simple Queue's delay in seconds.
+waf.notification.simple_queue_delay.example=900
+waf.notification.simple_queue_delay.format=[integer]
+
+waf.notification.simple_queue_period.title=Simple Queue Period
+waf.notification.simple_queue_period.purpose=Simple Queue's activities period in seconds
+waf.notification.simple_queue_period.example=900
+waf.notification.simple_queue_period.format=[integer]
diff --git a/ccm-core/src/com/arsdigita/notification/QueueItem.java b/ccm-core/src/com/arsdigita/notification/QueueItem.java
index 1d26003a2..5be7c653f 100755
--- a/ccm-core/src/com/arsdigita/notification/QueueItem.java
+++ b/ccm-core/src/com/arsdigita/notification/QueueItem.java
@@ -61,16 +61,14 @@ class QueueItem extends ObservableDomainObject
new HtmlToText();
/**
- * The message object contained by this notification. Retrieved
- * once from the database and cached.
+ * The message object contained by this notification. Retrieved once
+ * from the database and cached.
*/
-
private Message m_message;
/**
* Creates a QueueItem from an OID.
*/
-
QueueItem(OID oid) throws DataObjectNotFoundException {
super(oid);
}
@@ -78,7 +76,6 @@ class QueueItem extends ObservableDomainObject
/**
* Creates a QueueItem from a Notification and recipient.
*/
-
QueueItem(Notification n, Party to) {
super(BASE_DATA_OBJECT_TYPE);
set(REQUEST_ID, n.getID());
@@ -88,7 +85,6 @@ class QueueItem extends ObservableDomainObject
/**
* Set the success flag for this notification.
*/
-
void setSuccess(Boolean b) {
set(SUCCESS, b);
}
@@ -96,7 +92,6 @@ class QueueItem extends ObservableDomainObject
/**
* Gets the message object contained by this notification.
*/
-
Message getMessage()
throws DataObjectNotFoundException
{
@@ -109,7 +104,6 @@ class QueueItem extends ObservableDomainObject
/**
* Returns the email address of the recipient as a String.
*/
-
String getTo() {
return (String) get(PARTY_TO_ADDR);
}
@@ -117,7 +111,6 @@ class QueueItem extends ObservableDomainObject
/**
* Returns the email address of the sender as a String.
*/
-
String getFrom()
throws DataObjectNotFoundException
{
@@ -127,7 +120,6 @@ class QueueItem extends ObservableDomainObject
/**
* Returns the subject of the notification.
*/
-
String getSubject()
throws DataObjectNotFoundException
{
@@ -137,7 +129,6 @@ class QueueItem extends ObservableDomainObject
/**
* Gets the header for this notification.
*/
-
private String getHeader() {
return StringUtils.nullToEmptyString((String) get(HEADER));
}
@@ -145,7 +136,6 @@ class QueueItem extends ObservableDomainObject
/**
* Gets the signature for this notification.
*/
-
private String getSignature() {
return StringUtils.nullToEmptyString((String) get(SIGNATURE));
}
@@ -159,7 +149,6 @@ class QueueItem extends ObservableDomainObject
*
* @return a plain text message to send as email to a user
*/
-
String getBody() throws DataObjectNotFoundException {
Message msg = getMessage();
@@ -178,6 +167,10 @@ class QueueItem extends ObservableDomainObject
return sb.toString();
}
+ /**
+ *
+ * @param mail
+ */
void setBody(Mail mail) {
Message msg = getMessage();
String altBody = getBody();
@@ -206,7 +199,6 @@ class QueueItem extends ObservableDomainObject
*
* @param mail the Mail to add attachments to
*/
-
void addAttachments(Mail mail)
throws MessagingException
{
@@ -229,18 +221,34 @@ class QueueItem extends ObservableDomainObject
}
}
+ /**
+ *
+ * @return
+ */
BigDecimal getRetryCount() {
return (BigDecimal) get(RETRY_COUNT);
}
+ /**
+ *
+ * @param i
+ */
void setRetryCount(BigDecimal i) {
set(RETRY_COUNT, i);
}
+ /**
+ *
+ */
void incrRetryCount() {
set(RETRY_COUNT, getRetryCount().add(new BigDecimal(1)));
}
+ /**
+ *
+ * @param body
+ * @return
+ */
private StringBuffer qualifyImageTags (StringBuffer body) {
s_log.debug("qualify image tags");
boolean inTagTest = false;
@@ -258,8 +266,10 @@ class QueueItem extends ObservableDomainObject
// start of an image attribute value (or end)
if (converted.toString().endsWith("src=" + nextChar)) {
s_log.debug("In fact, the start of the src attribute");
- converted.append("http://" + Web.getConfig().getServer().toString());
- s_log.debug("inserting server name " + Web.getConfig().getServer().toString());
+ converted.append("http://" +
+ Web.getConfig().getServer().toString());
+ s_log.debug("inserting server name " +
+ Web.getConfig().getServer().toString());
inImageTag = false;
inTagTest = false;
}
diff --git a/ccm-core/src/com/arsdigita/notification/RequestManager.java b/ccm-core/src/com/arsdigita/notification/RequestManager.java
index b5e99edd8..290208697 100755
--- a/ccm-core/src/com/arsdigita/notification/RequestManager.java
+++ b/ccm-core/src/com/arsdigita/notification/RequestManager.java
@@ -38,9 +38,10 @@ import org.apache.log4j.Logger;
/**
* The RequestManager is a child of TimerTask. It is scheduled for periodic
- * execution in the Initializer. RequestManager sweeps through the list of notification
- * requests and queues them for sending. Once a request is in the queue, its
- * status is updated each time together and any necessary clean-up work is performed.
+ * execution in the Initializer. RequestManager sweeps through the list of
+ * notification requests and queues them for sending. Once a request is in
+ * the queue, its status is updated each time together and any necessary
+ * clean-up work is performed.
*
* @author David Dao
* @version $Id: RequestManager.java 287 2005-02-22 00:29:02Z sskracic $
@@ -48,9 +49,6 @@ import org.apache.log4j.Logger;
class RequestManager extends TimerTask {
- public static final String versionId =
- "$Id: RequestManager.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $Date: 2004/08/16 $";
-
private static final Logger s_log =
Logger.getLogger(RequestManager.class.getName());
@@ -74,8 +72,8 @@ class RequestManager extends TimerTask {
"com.arsdigita.notification.GetCompleteNotifications";
/**
- * Implements the run method of TimerTask. This is the execution block each time
- * the RequestManager runs. The following actions are performed:
+ * Implements the run method of TimerTask. This is the execution block each
+ * time the RequestManager runs. The following actions are performed:
* init to the set of initializers to be
- * initialized by this CompoundInitializer. The most recently
- * added initializers will be invoked last.
+ * Adds init to the set of initializers to be initialized by
+ * this CompoundInitializer.
+ *
+ * The most recently added initializers will be invoked last.
*
* @param init The initializer to add to this CompoundInitializer
- **/
-
+ */
public void add(Initializer init) {
m_inits.add(init);
}
/**
- * Implementation of the {@link Initializer#init(DataInitEvent)}
- * method. This implementation proceeds through the list of sub
- * initializers in order and invokes the init(DataInitEvent)
- * method of each sub initializer in turn.
+ * Implementation of the {@link Initializer#init(DataInitEvent)} method.
+ * This implementation proceeds through the list of sub initializers in order
+ * and invokes the init(DataInitEvent) method of each sub initializer in turn.
*
* @param evt The data init event.
- **/
-
+ */
public void init(DataInitEvent evt) {
int i = 1;
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
@@ -100,14 +95,13 @@ public class CompoundInitializer implements Initializer {
}
/**
- * Implementation of the {@link Initializer#init(DomainInitEvent)}
- * method. This implementation proceeds through the list of sub
- * initializers in order and invokes the init(DomainInitEvent)
- * method of each sub initializer in turn.
+ * Implementation of the {@link Initializer#init(DomainInitEvent)} method.
+ * This implementation proceeds through the list of sub initializers in
+ * order and invokes the init(DomainInitEvent) method of each sub initializer
+ * in turn.
*
* @param evt The domain init event.
- **/
-
+ */
public void init(DomainInitEvent evt) {
int i = 1;
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
@@ -121,14 +115,13 @@ public class CompoundInitializer implements Initializer {
}
/**
- * Implementation of the {@link Initializer#init(LegacyInitEvent)}
- * method. This implementation proceeds through the list of sub
- * initializers in order and invokes the init(LegacyInitEvent)
- * method of each sub initializer in turn.
+ * Implementation of the {@link Initializer#init(LegacyInitEvent)} method.
+ * This implementation proceeds through the list of sub initializers in
+ * order and invokes the init(LegacyInitEvent) method of each sub initializer
+ * in turn.
*
* @param evt The legacy init event.
- **/
-
+ */
public void init(LegacyInitEvent evt) {
int i = 1;
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
@@ -141,4 +134,52 @@ public class CompoundInitializer implements Initializer {
}
}
+ /**
+ * Implementation of the {@link Initializer#init(ContextInitEvent)} method.
+ * This implementation proceeds through the list of sub initializers in
+ * order and invokes the init(LegacyInitEvent) method of each sub initializer
+ * in turn.
+ *
+ * @param evt The legacy init event.
+ */
+ public void init(ContextInitEvent evt) {
+ int i = 1;
+ for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
+ Initializer init = (Initializer) it.next();
+ if (m_log.isInfoEnabled()) {
+ m_log.info("Running Context Init for " + init.getClass() +
+ " (" + i + " out of " + m_inits.size() + ")");
+ }
+ init.init(evt);
+ }
+ }
+
+ /**
+ * Implementation of the {@link Initializer#close(ContextCloseEvent)} method.
+ *
+ * This implementation proceeds through the list of sub initializers in order
+ * and invokes the close(ContextCloseEvent) method of each sub initializer
+ * in turn.
+ *
+ *
+ * @param evt The context close event.
+ */
+ public void close(ContextCloseEvent evt) {
+ s_log.info("CompoundInitializer.close(ContextCloseEvent) invoked");
+
+ if (m_inits.isEmpty()) {
+ s_log.info("m_inits is empty");
+ }
+ int i = 1;
+ for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
+ Initializer init = (Initializer) it.next();
+ if (m_log.isInfoEnabled()) {
+ m_log.info("Closing " + init.getClass() +
+ " (" + i + " out of " + m_inits.size() + ")");
+ }
+ init.close(null);
+ }
+ s_log.info("CompoundInitializer.close(ContextCloseEvent) completed");
+ }
+
}
diff --git a/ccm-core/src/com/arsdigita/runtime/ConfigError.java b/ccm-core/src/com/arsdigita/runtime/ConfigError.java
index 43fc5963a..41c8893dc 100755
--- a/ccm-core/src/com/arsdigita/runtime/ConfigError.java
+++ b/ccm-core/src/com/arsdigita/runtime/ConfigError.java
@@ -26,14 +26,12 @@ import org.apache.log4j.Logger;
*
* An error to indicate invalid configurations.
*
+ * Usage: throw new ConfigError( "message" );
+ *
* @author Justin Ross <jross@redhat.com>
* @version $Id: ConfigError.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class ConfigError extends Error {
- public final static String versionId =
- "$Id: ConfigError.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger
(ConfigError.class);
diff --git a/ccm-core/src/com/arsdigita/runtime/ContextCloseEvent.java b/ccm-core/src/com/arsdigita/runtime/ContextCloseEvent.java
new file mode 100644
index 000000000..2ae5eda2b
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/runtime/ContextCloseEvent.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2003-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.runtime;
+
+import java.util.EventObject;
+
+/**
+ *
+ * @author pb
+ */
+public class ContextCloseEvent extends EventObject {
+
+
+ /**
+ * Constructor
+ */
+ public ContextCloseEvent( Object source) {
+ super(source);
+
+ }
+
+ /**
+ * Constructor
+ */
+ public ContextCloseEvent( EventObject evt) {
+ super(evt.getSource());
+
+ }
+}
diff --git a/ccm-core/src/com/arsdigita/runtime/ContextInitEvent.java b/ccm-core/src/com/arsdigita/runtime/ContextInitEvent.java
new file mode 100644
index 000000000..7a036c07a
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/runtime/ContextInitEvent.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2003-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.runtime;
+
+import java.util.EventObject;
+
+/**
+ *
+ * @author pb
+ */
+public class ContextInitEvent extends EventObject {
+
+
+ /**
+ * Constructor
+ */
+ public ContextInitEvent( Object source) {
+ super(source);
+
+ }
+
+ /**
+ * Constructor
+ */
+ public ContextInitEvent( EventObject evt) {
+ super(evt.getSource());
+
+ }
+}
diff --git a/ccm-core/src/com/arsdigita/runtime/DataInitEvent.java b/ccm-core/src/com/arsdigita/runtime/DataInitEvent.java
index 4a5b079cd..bf94f0184 100755
--- a/ccm-core/src/com/arsdigita/runtime/DataInitEvent.java
+++ b/ccm-core/src/com/arsdigita/runtime/DataInitEvent.java
@@ -21,20 +21,15 @@ package com.arsdigita.runtime;
import com.arsdigita.persistence.pdl.PDLCompiler;
/**
- * A DataInitEvent is passed to the {@link
- * Initializer#init(DataInitEvent)} method in order to provide the
- * target Initializer access to the objects necessary to properly
- * initialize the data layer.
+ * A DataInitEvent is passed to the {@link Initializer#init(DataInitEvent)}
+ * method in order to provide the target Initializer access to the objects
+ * necessary to properly initialize the data layer.
*
* @author Rafael Schloming <rhs@mit.edu>
* @author Justin Ross <jross@redhat.com>
* @version $Id: DataInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
*/
public final class DataInitEvent {
- public final static String versionId =
- "$Id: DataInitEvent.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
private final PDLCompiler m_compiler;
diff --git a/ccm-core/src/com/arsdigita/runtime/DomainInitEvent.java b/ccm-core/src/com/arsdigita/runtime/DomainInitEvent.java
index 24c02e758..1acb21a2e 100755
--- a/ccm-core/src/com/arsdigita/runtime/DomainInitEvent.java
+++ b/ccm-core/src/com/arsdigita/runtime/DomainInitEvent.java
@@ -30,10 +30,6 @@ import com.arsdigita.domain.DomainObjectFactory;
* @version $Id: DomainInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
*/
public final class DomainInitEvent {
- public final static String versionId =
- "$Id: DomainInitEvent.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
private final DomainObjectFactory m_factory;
diff --git a/ccm-core/src/com/arsdigita/runtime/GenericInitializer.java b/ccm-core/src/com/arsdigita/runtime/GenericInitializer.java
new file mode 100644
index 000000000..fd6362857
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/runtime/GenericInitializer.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 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.runtime;
+
+/**
+ * Provides an empty implementation of the initializer interface.
+ *
+ * Sub-initializers of a module, which provide specific initialization for a
+ * Java package of the module, should extend this class if they do not need
+ * to implement each of the initializer interface classes.
+ *
+ * The main initializer of module should extend {@link CompoundInitializer} as
+ * it provides a way to add sub-initializers to the list of initializers during
+ * startup and a generic pdl initialization, which most main-initializers will
+ * need, but sub-subinitializers generally not.
+ *
+ * It also facilitates the migration to the new initializer system.
+ *
+ * @author Peter Boy <pboy@barkhof.uni-bremen.de>
+ */
+public abstract class GenericInitializer implements Initializer {
+
+ // private final Configuration m_config = new Configuration();
+ // private final String m_name;
+
+ public GenericInitializer() {
+ }
+
+
+ /**
+ * An empty implementation of {@link Initializer#init(DataInitEvent)}.
+ *
+ * @param evt The data init event.
+ **/
+ public void init(DataInitEvent evt) {
+ }
+
+
+ /**
+ * An empty implementation of {@link Initializer#init(DomainInitEvent)}.
+ *
+ * @param evt The domain init event.
+ **/
+ public void init(DomainInitEvent evt) {
+ }
+
+
+ /**
+ * An empty implementation of {@link Initializer#init(LegacyInitEvent)}
+ * method.
+ *
+ * @param evt The legacy init event.
+ **/
+ public void init(LegacyInitEvent evt) {
+ }
+
+ /**
+ * An empty implementation of {@link Initializer#init(ContextInitEvent)}
+ * method.
+ *
+ * @param evt The context init event.
+ **/
+ public void init(ContextInitEvent evt) {
+ }
+
+ /**
+ * An empty implementation of {@link Initializer#close(ContextCloseEvent)}
+ * method.
+ *
+ * @param evt The context close event.
+ **/
+ public void close(ContextCloseEvent evt) {
+ }
+
+}
diff --git a/ccm-core/src/com/arsdigita/runtime/Initializer.java b/ccm-core/src/com/arsdigita/runtime/Initializer.java
index a616c5019..c02f19d7d 100755
--- a/ccm-core/src/com/arsdigita/runtime/Initializer.java
+++ b/ccm-core/src/com/arsdigita/runtime/Initializer.java
@@ -22,14 +22,26 @@ package com.arsdigita.runtime;
/**
* The Initializer interface is used to prepare the CCM runtime for
- * interaction with the CCM database. This is done in two phases.
- * First the data layer is initialized by loading any
- * object-relational mapping metadata. Secondly the domain layer is
- * initialized by registering any domain metadata. This usually
- * consists of domain object instantiators and observers. It is not
- * safe for CCM code to interact with a CCM database until these
+ * interaction with the CCM database as well as cleanly shutdown a running CCM.
+ *
+ * Every CCM module usually provides an implementation of the initializer
+ * interface (specified in
+ * Runtime runtime = new Runtime();
+ * if ( !runtime.hasRun() ) {
+ * runtime.startup();
+ * }
+ *
+ *
+ * In a servlet container runtime environment this should be done either in the
+ * first loaded servlet (BaseServlet in CCM) or in a special application
+ * listener servlet invoked by the servlet container at startup time and before
+ * any other operation takes place (CCMApplicationListener in CCM, prefered).
+ *
+ * In a command line JVM environment (installation & maintenace procedures) it
+ * has to be performed once at the very beginning (e.g. package c.a.packaging)
+ *
+ * @author Rafael Schloming <rhs@mit.edu>
+ * @author Justin Ross <jross@redhat.com>
+ * @author Peter Boy <pboy@barkhof.uni-bremen.de>
+ * @version $Id: Runtime.java 738 2005-09-01 12:36:52Z sskracic $
+ */
+public class Runtime extends CompoundInitializer {
+
+ private static final Logger s_log = Logger.getLogger(Runtime.class);
+
+ private static final String s_model = "com/arsdigita/runtime/Initializer.pdl";
+ private static final String INIT = "com.arsdigita.runtime.Initializer";
+
+ private final ConnectionSource m_source;
+
+ private static final Parameter s_init = new StringParameter
+ ("waf.runtime.init", Parameter.OPTIONAL, null);
+
+ private static boolean s_hasRun = false;
+
+ // ///////////////////
+ // Constructor section
+ // ///////////////////
+
+ /**
+ * Default instantiation, which determines the database connection
+ * information and delegates to a detailed constructor.
+ */
+ public Runtime() {
+ this(new PooledConnectionSource
+ (RuntimeConfig.getConfig().getJDBCURL(),
+ RuntimeConfig.getConfig().getJDBCPoolSize(),
+ RuntimeConfig.getConfig().getJDBCPingInterval()));
+ s_log.debug("Default instantiation performed");
+ }
+
+ /**
+ * Detailed Constructor taking a ConnectionSource to instantiate a
+ * Runtime Object.
+ *
+ * Using the super class it creates a new and empty compound initializer that
+ * uses the log Logger to log progress through initialization.
+ * Additionally it stores the caller-provided connection source to be able
+ * to retrieve the list of initializsers from the database later.
+ *
+ * @param source The connection source used to recover the list of
+ * initializers from the database; it cannot be null.
+ **/
+
+ public Runtime(ConnectionSource source) {
+ super(s_log);
+
+ s_log.debug("Detailed constructor instantiation performed");
+
+ Assert.exists(source, ConnectionSource.class);
+ m_source = source;
+ }
+
+
+ // ///////////////////
+ // Public API
+ // ///////////////////
+
+ /**
+ * Executes the startup process using default parameter values.
+ *
+ * Because ContextInitEvent can not be detected, only the base initialization
+ * (i.e. data init, domain init) is done, not the context specific
+ * initialization (i.e. various background threads). This variant is
+ * specifically used by command line invocations, e.g. installation or
+ * various maintenance tasks which are done outside a servlet container
+ * context.
+ */
+ public final void startup() {
+ // run shutdown with ContextCLoseEvent null, i.e. perform a base close
+ startup(null);
+ }
+
+ /**
+ * This variant is especially for unit testing where session and initializer
+ * are given by the test task.
+ *
+ * Because ContextInitEvent can not be detected, only the base initialization
+ * (i.e. data init, domain init) is done, not the context specific
+ * initialization (i.e. various background threads).
+ *
+ * @param session
+ * @param init
+ */
+ public static final void startup(final Session session,
+ final Initializer init) {
+ startup(session, init, null);
+ }
+
+ /**
+ * Executes the initialization process using the default session (this) and
+ * global metadata root for a given ContextInitEvent.
+ *
+ * This variant is specifically used when run in a servlet container context
+ * and usually invoked by the ApplicationContextListener class
+ * (@see CCMApplicationContextListener).
+ *
+ * Collects a list of Initializers to run from the database,
+ * determines the current session and global metadata root, and delegates
+ * to an initialization method..
+ *
+ * @see MetadataRoot#getMetadataRoot()
+ * @see SessionManager#getSession()
+ */
+ public final void startup(final ContextInitEvent evt) {
+ s_log.info("Initializing WAF runtime");
+
+ DbHelper.setDatabase
+ (DbHelper.getDatabaseFromURL(RuntimeConfig.
+ getConfig().getJDBCURL()));
+ addRuntimeInitializers();
+
+ final MetadataRoot root = MetadataRoot.getMetadataRoot();
+ // XXX It shouldn't be necessary to do this until the legacy
+ // init step, but SessionManager.getMetadataRoot depends on
+ // the session, and the DomainObjectFactory calls it.
+ final Session session = session("default", root);
+
+ startup(session, this, evt);
+
+ s_log.info("Initialization complete");
+ }
+
+
+ /**
+ * Initialization worker method.
+ *
+ * Executes the various initialization tasks.
+ *
+ * This method is going to move.
+ */
+ public static final void startup(final Session session,
+ final Initializer init,
+ final ContextInitEvent evt) {
+
+ Assert.exists(session, Session.class);
+ Assert.exists(init, Initializer.class);
+
+ s_hasRun = true;
+
+ final PDLCompiler compiler = new PDLCompiler();
+ final MetadataRoot root = session.getMetadataRoot();
+
+ Assert.exists(root, MetadataRoot.class);
+
+ init.init(new DataInitEvent(compiler));
+
+ compiler.emit(root);
+
+ init.init(new DomainInitEvent(new DomainObjectFactory()));
+
+ init.init(new LegacyInitEvent(session));
+
+ if(evt != null) {
+ init.init(evt);
+ }
+
+ }
+
+
+ /**
+ * Returns whether the run method had already been invoked.
+ *
+ * @return true if run() has been invoked
+ */
+ public static boolean hasRun() {
+ return s_hasRun;
+ }
+
+
+ /**
+ * Executes the shutdown process using the default parameter values
+ */
+ public final void shutdown() {
+ // run shutdown with ContextCLoseEvent null, i.e. perform a base close
+ shutdown(null);
+ }
+
+ /**
+ * Executes the shutdown process for a given context using the default session
+ * and global metadata root.
+ *
+ * Collects a list of Initializers to run from the database,
+ * determines the current dession and global metadata root, and delegates
+ * to an initialization method..
+ *
+ * @see MetadataRoot#getMetadataRoot()
+ * @see SessionManager#getSession()
+ */
+ public final void shutdown(final ContextCloseEvent evt) {
+
+ s_log.info("Shutting down WAF runtime using defaults");
+
+ // DbHelper.setDatabase
+ // (DbHelper.getDatabaseFromURL(RuntimeConfig.
+ // getConfig().getJDBCURL()));
+ // s_log.info("Going to collect list of Initializers.");
+ // addRuntimeInitializers();
+
+ s_log.debug("Going to execute MetadataRoot.getMetadataRoot().");
+ final MetadataRoot root = MetadataRoot.getMetadataRoot();
+ // XXX It shouldn't be necessary to do this until the legacy
+ // init step, but SessionManager.getMetadataRoot depends on
+ // the session, and the DomainObjectFactory calls it.
+ s_log.debug("Going to execute session().");
+ final Session session = session("default", root);
+
+ s_log.info("Going to execute shutdown worker method.");
+ shutdown(session, this, evt);
+
+
+ s_log.info("Shutdown complete");
+ }
+
+ public static final void shutdown(final Session session,
+ final Initializer init) {
+ // run shutdown with ContextCLoseEvent null, i.e. perform a base close
+ shutdown(session,init,null);
+ }
+
+ /**
+ * Executes the initialization process.
+ *
+ * This method is going to move.
+ */
+ public static final void shutdown(final Session session,
+ final Initializer init,
+ final ContextCloseEvent evt) {
+
+ Assert.exists(session, Session.class);
+ Assert.exists(init, Initializer.class);
+
+ // s_hasRun = true;
+ if (s_hasRun == true) {
+
+ // final PDLCompiler compiler = new PDLCompiler();
+ final MetadataRoot root = session.getMetadataRoot();
+
+ Assert.exists(root, MetadataRoot.class);
+
+ // init.init(new DataInitEvent(compiler));
+ // compiler.emit(root);
+ // init.init(new DomainInitEvent(new DomainObjectFactory()));
+ // init.init(new LegacyInitEvent(session));
+
+ s_log.info("Going to call CompoundInitializer.destroy()");
+ init.close(evt);
+ } else {
+ s_log.warn("Shutdown must only be run AFTER startup. Skipped.");
+ }
+
+ }
+
+ /**
+ *
+ * @param args
+ * @throws SQLException
+ */
+ // public static final void main(final String[] args) throws SQLException {
+ public static void main(final String[] args) throws SQLException {
+ final String url;
+ final int size;
+ if (args.length == 0) {
+ url = RuntimeConfig.getConfig().getJDBCURL();
+ } else {
+ url = args[0];
+ }
+
+ new Runtime(new DedicatedConnectionSource(url)).startup();
+ }
+
+ // ////////////////////////////////
+ // Private section / helper methods
+ // ////////////////////////////////
+
+ /**
+ * Adds the runtime initializers from the database.
+ */
+ protected void addRuntimeInitializers() {
+
+ s_log.debug("Method addRuntimeInitializers invoked.");
+
+ Collection names = getRuntimeInitializerNames();
+
+ s_log.info("Converting DataCollection names to StringArray inits. ");
+ String[] inits = (String[]) names.toArray(new String[0]);
+ s_log.info("Create MetadataRoot mroot. ");
+ MetadataRoot mroot = root();
+ s_log.info("Going to sort Stringarray inits. ");
+ sort(inits, session("initializer", mroot), mroot);
+
+ s_log.info("Going to process StringArray inits.");
+ for (int i = 0; i < inits.length; i++) {
+ if (s_log.isDebugEnabled()) {
+ s_log.debug("adding: " + inits[i]);
+ }
+ // Fill initilizer list in @see CompoundInitializer#add
+ s_log.info("adding: " + inits[i]);
+ add((Initializer) Classes.newInstance(inits[i]));
+ }
+
+ s_log.info("Going to call addWafInitializer()");
+ addWafInitializer();
+
+ s_log.info("Method addRuntimeInitializers completed.");
+ }
+
+ /**
+ *
+ */
+ private void addWafInitializer() {
+ String claas = (String)SystemProperties.get(s_init);
+ if (claas != null) {
+ if (s_log.isDebugEnabled()) {
+ s_log.debug("adding: " + claas);
+ }
+ add((Initializer) Classes.newInstance(claas));
+ }
+ }
+
+ /**
+ * Fetches the names of initializers loaded into the database.
+ *
+ * Made protected so that test code can override the initializers
+ * loaded at test startup.
+ *
+ * @return Collection of initializer names.
+ */
+ protected Collection getRuntimeInitializerNames() {
+
+ s_log.debug("Method getRuntimeInitializerNames invoked.");
+
+ final Session session = session("startup", root());
+
+ LinkedList initNames = new LinkedList();
+ final DataCollection inits = session.retrieve
+ ("com.arsdigita.runtime.Initializer");
+
+ if (inits.isEmpty()) {
+ s_log.debug("DataCollection inits is empty!");
+ }
+
+ try {
+ while (inits.next()) {
+ final String initName = (String) inits.get("className");
+ s_log.debug("Got: " + initName );
+ initNames.add(initName);
+ }
+ } finally {
+ inits.close();
+ }
+
+ s_log.debug("Leaving method getRuntimeInitializerNames.");
+ return initNames;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private static MetadataRoot root() {
+ final MetadataRoot root = new MetadataRoot();
+ final PDLCompiler compiler = new PDLCompiler();
+
+ final InputStream in = Runtime.class.getClassLoader
+ ().getResourceAsStream(s_model);
+
+ compiler.parse(new InputStreamReader(in), s_model);
+ compiler.emit(root);
+
+ return root;
+ }
+
+ /**
+ *
+ * @param key
+ * @param root
+ * @return
+ */
+ private Session session(final String key, final MetadataRoot root) {
+ Assert.exists(key, String.class);
+ Assert.exists(root, MetadataRoot.class);
+
+ if ( !SessionManager.hasSession(key) ) {
+ SessionManager.configure(key, root, m_source);
+ }
+ final Session session = SessionManager.getSession(key);
+
+ Assert.exists(session, Session.class);
+
+ return session;
+ }
+
+
+ /**
+ *
+ * @param inits
+ * @param session
+ * @param mroot
+ */
+ private static void sort(String[] inits, Session session, MetadataRoot mroot) {
+ s_log.debug("Method Runtime.sort invoked.");
+
+ Set all = new HashSet(Arrays.asList(inits));
+ Set provided = new HashSet();
+ List sorted = new ArrayList();
+ List in = new ArrayList(Arrays.asList(inits));
+ int before;
+ s_log.debug("Starting to sort.");
+ do {
+ before = in.size();
+ for (Iterator it = in.iterator(); it.hasNext(); ) {
+ Set required = new HashSet();
+ String init = (String) it.next();
+ DataObject dataobject = session.retrieve(
+ new OID(mroot.getObjectType(INIT), init));
+ DataAssociation da = (DataAssociation)dataobject.get("requirements");
+ DataAssociationCursor cursor = da.cursor();
+ while (cursor.next()) {
+ required.add((String)(cursor.getDataObject().get("className")));
+ }
+ cursor.close();
+ required.retainAll(all);
+ if (provided.containsAll(required)) {
+ sorted.add(init);
+ provided.add(init);
+ it.remove();
+ }
+ }
+ } while (in.size() < before);
+
+ s_log.debug("Checking List in.");
+ if (in.size() > 0) {
+ throw new IllegalStateException
+ ("circular dependencies: " + in);
+ }
+
+ int index = 0;
+ s_log.debug("Constructing inits.");
+ for (Iterator it = sorted.iterator(); it.hasNext(); ) {
+ inits[index++] = (String) it.next();
+ }
+
+ s_log.debug("Method Runtime.sort completed.");
+ }
+}
diff --git a/ccm-core/src/com/arsdigita/runtime/Startup.java b/ccm-core/src/com/arsdigita/runtime/Startup.java
index 22b5ecfe8..fa8e5f63a 100755
--- a/ccm-core/src/com/arsdigita/runtime/Startup.java
+++ b/ccm-core/src/com/arsdigita/runtime/Startup.java
@@ -18,41 +18,19 @@
*/
package com.arsdigita.runtime;
-import com.arsdigita.db.DbHelper;
-import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.ConnectionSource;
-import com.arsdigita.persistence.DataAssociation;
-import com.arsdigita.persistence.DataAssociationCursor;
-import com.arsdigita.persistence.DataCollection;
-import com.arsdigita.persistence.DataObject;
-import com.arsdigita.persistence.DedicatedConnectionSource;
-import com.arsdigita.persistence.OID;
-import com.arsdigita.persistence.PooledConnectionSource;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.metadata.MetadataRoot;
-import com.arsdigita.persistence.pdl.PDLCompiler;
-import com.arsdigita.util.Assert;
-import com.arsdigita.util.Classes;
-import com.arsdigita.util.SystemProperties;
-import com.arsdigita.util.parameter.Parameter;
-import com.arsdigita.util.parameter.StringParameter;
-import java.io.InputStreamReader;
-import java.io.InputStream;
import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
import org.apache.log4j.Logger;
/**
+ * Wrapper for Runtime to retain backwards compatibility. Deprecated (Dec. 2009)!
+ * Will be removed soon.
+ *
* An entry point initializer for the CCM runtime used to bootstrap the CCM
* runtime environment into a state where it is safe to perform database I/O.
* It does this by accessing a persistent list of all the initializers
@@ -81,32 +59,22 @@ import org.apache.log4j.Logger;
* @author Rafael Schloming <rhs@mit.edu>
* @author Justin Ross <jross@redhat.com>
* @version $Id: Startup.java 738 2005-09-01 12:36:52Z sskracic $
+ * @deprecated use Runtime instead
*/
-public class Startup extends CompoundInitializer {
+public class Startup extends Runtime {
private static final Logger s_log = Logger.getLogger(Startup.class);
- private static final String s_model = "com/arsdigita/runtime/Initializer.pdl";
- private static final String INIT = "com.arsdigita.runtime.Initializer";
-
- private final ConnectionSource m_source;
-
- private static final Parameter s_init = new StringParameter
- ("waf.runtime.init", Parameter.OPTIONAL, null);
-
- private static boolean s_hasRun = false;
// Constructor section
/**
- * Default startup method. Determines the database connection information
- * and delegates to a startup worker methods.
+ * Default startup method, which determines the database connection information
+ * and delegates to a detailed constructor.
+ * @deprecated use Runtime() instead
*/
public Startup() {
- this(new PooledConnectionSource
- (RuntimeConfig.getConfig().getJDBCURL(),
- RuntimeConfig.getConfig().getJDBCPoolSize(),
- RuntimeConfig.getConfig().getJDBCPingInterval()));
+ super();
}
/**
@@ -117,14 +85,11 @@ public class Startup extends CompoundInitializer {
*
* @param source The connection source used to recover the list of
* initializers from the database; it cannot be null.
+ *
+ * @deprecated use Runtime.startup(ConnectionSource source) instead
**/
-
public Startup(ConnectionSource source) {
- super(s_log);
-
- Assert.exists(source, ConnectionSource.class);
-
- m_source = source;
+ super(source);
}
@@ -137,193 +102,47 @@ public class Startup extends CompoundInitializer {
*
* @see MetadataRoot#getMetadataRoot()
* @see SessionManager#getSession()
+ * @deprecated use Runtime.startup() instead
**/
-
public final void run() {
- s_log.info("Initializing WAF runtime");
-
- DbHelper.setDatabase
- (DbHelper.getDatabaseFromURL(RuntimeConfig.
- getConfig().getJDBCURL()));
- addRuntimeInitializers();
- //addWafInitializer();
-
- final MetadataRoot root = MetadataRoot.getMetadataRoot();
- // XXX It shouldn't be necessary to do this until the legacy
- // init step, but SessionManager.getMetadataRoot depends on
- // the session, and the DomainObjectFactory calls it.
- final Session session = session("default", root);
-
- run(session, this);
-
- s_log.info("Initialization complete");
+ super.startup();
}
/**
* Executes the initialization process.
*
* This method is going to move.
+ * @deprecated use Runtimestartup(session.init) instead
*/
- public static final void run(final Session session,
- final Initializer init) {
+ // public static final void run(final Session session,
+ public static void run(final Session session,
+ final Initializer init) {
- Assert.exists(session, Session.class);
- Assert.exists(init, Initializer.class);
+ Runtime.startup(session, init);
- s_hasRun = true;
-
- final PDLCompiler compiler = new PDLCompiler();
- final MetadataRoot root = session.getMetadataRoot();
-
- Assert.exists(root, MetadataRoot.class);
-
- init.init(new DataInitEvent(compiler));
-
- compiler.emit(root);
-
- init.init(new DomainInitEvent(new DomainObjectFactory()));
-
- init.init(new LegacyInitEvent(session));
-
- }
-
- public static boolean hasRun() {
- return s_hasRun;
- }
-
- public static final void main(final String[] args) throws SQLException {
- final String url;
- final int size;
- if (args.length == 0) {
- url = RuntimeConfig.getConfig().getJDBCURL();
- } else {
- url = args[0];
- }
-
- new Startup(new DedicatedConnectionSource(url)).run();
- }
-
- // ////////////////////////////////
- // Private section / helper methods
- // ////////////////////////////////
-
- /*
- * Adds the runtime initializers from the database.
- */
- protected void addRuntimeInitializers() {
- Collection names = getRuntimeInitializerNames();
- String[] inits = (String[]) names.toArray(new String[0]);
- MetadataRoot mroot = root();
- sort(inits, session("initializer", mroot), mroot);
- for (int i = 0; i < inits.length; i++) {
- if (s_log.isDebugEnabled()) {
- s_log.debug("adding: " + inits[i]);
- }
- add((Initializer) Classes.newInstance(inits[i]));
- }
-
- addWafInitializer();
- }
-
- private void addWafInitializer() {
- String claas = (String)SystemProperties.get(s_init);
- if (claas != null) {
- if (s_log.isDebugEnabled()) {
- s_log.debug("adding: " + claas);
- }
- add((Initializer) Classes.newInstance(claas));
- }
}
/**
- * Fetches the names of initializers loaded into the database.
- * Made protected so that test code can override the initializers
- * loaded at test startup.
- *
- * @return Collection of initializer names.
+ * Returns whether the run method had already been invoked.
+ *
+ * @return true if run() has been invoked
+ * @deprecated use Runtime.hasRun() instead
*/
- protected Collection getRuntimeInitializerNames() {
- final Session session = session("startup", root());
-
- LinkedList initNames = new LinkedList();
- final DataCollection inits = session.retrieve
- ("com.arsdigita.runtime.Initializer");
-
- try {
- while (inits.next()) {
- final String initName = (String) inits.get("className");
- initNames.add(initName);
- }
- } finally {
- inits.close();
- }
-
- return initNames;
+ public static boolean hasRun() {
+ return Runtime.hasRun();
}
- private static MetadataRoot root() {
- final MetadataRoot root = new MetadataRoot();
- final PDLCompiler compiler = new PDLCompiler();
+ /**
+ *
+ * @param args
+ * @throws SQLException
+ *
+ * @deprecated use Runtime.main(args) instead
+ */
+ public static final void main(final String[] args) throws SQLException {
- final InputStream in = Startup.class.getClassLoader
- ().getResourceAsStream(s_model);
+ Runtime.main(args);
- compiler.parse(new InputStreamReader(in), s_model);
- compiler.emit(root);
-
- return root;
}
- private Session session(final String key, final MetadataRoot root) {
- Assert.exists(key, String.class);
- Assert.exists(root, MetadataRoot.class);
-
- if ( !SessionManager.hasSession(key) ) {
- SessionManager.configure(key, root, m_source);
- }
- final Session session = SessionManager.getSession(key);
-
- Assert.exists(session, Session.class);
-
- return session;
- }
-
-
- private static void sort(String[] inits, Session session, MetadataRoot mroot) {
- Set all = new HashSet(Arrays.asList(inits));
- Set provided = new HashSet();
- List sorted = new ArrayList();
- List in = new ArrayList(Arrays.asList(inits));
- int before;
- do {
- before = in.size();
- for (Iterator it = in.iterator(); it.hasNext(); ) {
- Set required = new HashSet();
- String init = (String) it.next();
- DataObject dataobject = session.retrieve(new OID(mroot.getObjectType(INIT), init));
- DataAssociation da = (DataAssociation)dataobject.get("requirements");
- DataAssociationCursor cursor = da.cursor();
- while (cursor.next()) {
- required.add((String)(cursor.getDataObject().get("className")));
- }
- cursor.close();
- required.retainAll(all);
- if (provided.containsAll(required)) {
- sorted.add(init);
- provided.add(init);
- it.remove();
- }
- }
- } while (in.size() < before);
-
- if (in.size() > 0) {
- throw new IllegalStateException
- ("circular dependencies: " + in);
- }
-
- int index = 0;
- for (Iterator it = sorted.iterator(); it.hasNext(); ) {
- inits[index++] = (String) it.next();
- }
- }
-}
+}
\ No newline at end of file
diff --git a/ccm-core/src/com/arsdigita/search/Initializer.java b/ccm-core/src/com/arsdigita/search/Initializer.java
index 78cd41ef9..c3679042c 100755
--- a/ccm-core/src/com/arsdigita/search/Initializer.java
+++ b/ccm-core/src/com/arsdigita/search/Initializer.java
@@ -18,45 +18,48 @@
*/
package com.arsdigita.search;
-import com.arsdigita.initializer.Configuration;
-import com.arsdigita.initializer.InitializationException;
-
import com.arsdigita.domain.GlobalObserverManager;
+import com.arsdigita.runtime.DomainInitEvent;
import org.apache.log4j.Logger;
/**
- * This initializer (which will soon go away) activates
- * the appropriate search engine.
- * There are no APIs intended for public use in this class
+ * Activates the appropriate search engine.
+ *
+ * There are no APIs intended for public use in this class.
+ *
+ * @author Peter Boy (pboy@barkhof.uni-bremen.de)
+ * @version $Id: $
*/
-@Deprecated
-public class Initializer
- implements com.arsdigita.initializer.Initializer {
+public class Initializer extends com.arsdigita.runtime.GenericInitializer {
- private Configuration m_conf = new Configuration();
+ private static final Logger s_log = Logger.getLogger(Initializer.class);
- private static final Logger s_log =
- Logger.getLogger(Initializer.class);
- public Initializer() throws InitializationException {
+ /**
+ * Default (empty) Constructor
+ */
+ public Initializer() {
}
- public Configuration getConfiguration() {
- return m_conf;
- }
- public void startup() {
+ /**
+ * An implementation of {@link Initializer#init(DomainInitEvent)}.
+ *
+ * @param evt The domain init event.
+ **/
+ public void init(DomainInitEvent evt) {
+ s_log.debug("domain init procedure started ");
+
if (Search.getConfig().getIndexerType().getObserver() != null) {
- s_log.info("registering observer for indexer: " + Search.getConfig().getIndexerType());
+ s_log.info("registering observer for indexer: " +
+ Search.getConfig().getIndexerType());
GlobalObserverManager gom = GlobalObserverManager.getManager();
gom.addObserver(new SearchObserver());
} else {
s_log.info("Not registering a search observer");
}
-
+
+ s_log.debug("domain init procedure finished ");
}
-
- public void shutdown() {}
-
}
diff --git a/ccm-core/src/com/arsdigita/search/LegacyInitializer.java.nolongerInUse b/ccm-core/src/com/arsdigita/search/LegacyInitializer.java.nolongerInUse
new file mode 100755
index 000000000..5f5921cab
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/search/LegacyInitializer.java.nolongerInUse
@@ -0,0 +1,62 @@
+/*
+ * 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.search;
+
+import com.arsdigita.initializer.Configuration;
+import com.arsdigita.initializer.InitializationException;
+
+import com.arsdigita.domain.GlobalObserverManager;
+
+import org.apache.log4j.Logger;
+
+/**
+ * This initializer (which will soon go away) activates
+ * the appropriate search engine.
+ * There are no APIs intended for public use in this class
+ */
+@Deprecated
+public class LegacyInitializer
+ implements com.arsdigita.initializer.Initializer {
+
+ private Configuration m_conf = new Configuration();
+
+ private static final Logger s_log =
+ Logger.getLogger(LegacyInitializer.class);
+
+ public LegacyInitializer() throws InitializationException {
+ }
+
+ public Configuration getConfiguration() {
+ return m_conf;
+ }
+
+ public void startup() {
+ if (Search.getConfig().getIndexerType().getObserver() != null) {
+ s_log.info("registering observer for indexer: " + Search.getConfig().getIndexerType());
+ GlobalObserverManager gom = GlobalObserverManager.getManager();
+ gom.addObserver(new SearchObserver());
+ } else {
+ s_log.info("Not registering a search observer");
+ }
+
+ }
+
+ public void shutdown() {}
+
+}
diff --git a/ccm-core/src/com/arsdigita/search/Search.java b/ccm-core/src/com/arsdigita/search/Search.java
index f3ca4ecc3..8b81d0e86 100755
--- a/ccm-core/src/com/arsdigita/search/Search.java
+++ b/ccm-core/src/com/arsdigita/search/Search.java
@@ -91,19 +91,19 @@ public class Search {
CACHE_SIZE,
CACHE_LIFETIME);
- /**
- * Constant for intermedia search indexer
- * @deprecated use IndexerType.INTERMEDIA.getKey()
- */
- public static final String INDEXER_INTERMEDIA =
- IndexerType.INTERMEDIA.getKey();
+// /**
+// * Constant for intermedia search indexer
+// * @deprecated use IndexerType.INTERMEDIA.getKey()
+// */
+// public static final String INDEXER_INTERMEDIA =
+// IndexerType.INTERMEDIA.getKey();
- /**
- * Constant for lucene search indexer
- * @deprecated use IndexerType.LUCENE.getKey()
- */
- public static final String INDEXER_LUCENE =
- IndexerType.LUCENE.getKey();
+// /**
+// * Constant for lucene search indexer
+// * @deprecated use IndexerType.LUCENE.getKey()
+// */
+// public static final String INDEXER_LUCENE =
+// IndexerType.LUCENE.getKey();
/**
* Constant for serach XML namespace prefix
diff --git a/ccm-core/src/com/arsdigita/search/SearchConfig.java b/ccm-core/src/com/arsdigita/search/SearchConfig.java
index a33d8d45e..547df288f 100755
--- a/ccm-core/src/com/arsdigita/search/SearchConfig.java
+++ b/ccm-core/src/com/arsdigita/search/SearchConfig.java
@@ -38,7 +38,6 @@ public final class SearchConfig extends AbstractConfig {
private Parameter m_lazyUpdates;
private Parameter m_xmlContentWeight;
private Parameter m_rawContentWeight;
- private Parameter m_stemming;
public SearchConfig() {
@@ -66,16 +65,11 @@ public final class SearchConfig extends AbstractConfig {
("waf.search.intermedia.raw_content_weight",
Parameter.REQUIRED,
new Integer(1));
- m_stemming = new BooleanParameter
- ("waf.search.intermedia.stemming",
- Parameter.REQUIRED,
- Boolean.FALSE);
register(m_indexer);
register(m_lazyUpdates);
register(m_xmlContentWeight);
register(m_rawContentWeight);
- register(m_stemming);
loadInfo();
}
@@ -137,23 +131,6 @@ public final class SearchConfig extends AbstractConfig {
public ContentType[] getContent() {
return getIndexerType().getContent();
}
- /**
- * If intermedia is used, applies stemming operator to each
- * individual word in the contains clause. So for example a search
- * for guitars will return documents containing guitar. Search
- * for ran returns documents containing run.
- *
- * The stemming operator is not applied to compound phrases
- * (included in quotes by the user) as assume that user wants
- * exact phrase. Also allows user to override stemming by
- * including single word in quotes
- *
- * @return
- */
- public boolean includeStemming() {
- return ((Boolean)get(m_stemming)).booleanValue();
-
- }
/**
* Determines if raw binary content is supported
diff --git a/ccm-core/src/com/arsdigita/search/SearchConfig_parameter.properties b/ccm-core/src/com/arsdigita/search/SearchConfig_parameter.properties
index 001b16b48..f8c274f90 100755
--- a/ccm-core/src/com/arsdigita/search/SearchConfig_parameter.properties
+++ b/ccm-core/src/com/arsdigita/search/SearchConfig_parameter.properties
@@ -14,7 +14,3 @@ waf.search.intermedia.raw_content_weight.title=Raw Content Weight
waf.search.intermedia.raw_content_weight.purpose=The relative weight given to raw content when ranking search results (only used by interMedia)
waf.search.intermedia.raw_content_weight.example=1
waf.search.intermedia.raw_content_weight.format=[integer]
-waf.search.intermedia.stemming.title=Allow Stemming
-waf.search.intermedia.stemming.purpose=Flag to turn on stemming option on search terms (ie prepend with $)(only used by interMedia)
-waf.search.intermedia.stemming.example=true
-waf.search.intermedia.stemming.format=[boolean]
diff --git a/ccm-core/src/com/arsdigita/search/SearchDataQuery.java b/ccm-core/src/com/arsdigita/search/SearchDataQuery.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SearchDataQuery.java
rename to ccm-core/src/com/arsdigita/search/SearchDataQuery.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/SearchIndexHelp.java b/ccm-core/src/com/arsdigita/search/SearchIndexHelp.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SearchIndexHelp.java
rename to ccm-core/src/com/arsdigita/search/SearchIndexHelp.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/SearchIndexHelpCustomize.java b/ccm-core/src/com/arsdigita/search/SearchIndexHelpCustomize.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SearchIndexHelpCustomize.java
rename to ccm-core/src/com/arsdigita/search/SearchIndexHelpCustomize.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/SearchSpecification.java b/ccm-core/src/com/arsdigita/search/SearchSpecification.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SearchSpecification.java
rename to ccm-core/src/com/arsdigita/search/SearchSpecification.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/Searchable.java b/ccm-core/src/com/arsdigita/search/Searchable.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/Searchable.java
rename to ccm-core/src/com/arsdigita/search/Searchable.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/SearchableACSObject.java b/ccm-core/src/com/arsdigita/search/SearchableACSObject.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SearchableACSObject.java
rename to ccm-core/src/com/arsdigita/search/SearchableACSObject.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/SearchableObserver.java b/ccm-core/src/com/arsdigita/search/SearchableObserver.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SearchableObserver.java
rename to ccm-core/src/com/arsdigita/search/SearchableObserver.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/SimpleSearchSpecification.java b/ccm-core/src/com/arsdigita/search/SimpleSearchSpecification.java.nolongerInUse
similarity index 100%
rename from ccm-core/src/com/arsdigita/search/SimpleSearchSpecification.java
rename to ccm-core/src/com/arsdigita/search/SimpleSearchSpecification.java.nolongerInUse
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/BuildIndex.java b/ccm-core/src/com/arsdigita/search/intermedia/BuildIndex.java
index 950d34797..3453cac87 100755
--- a/ccm-core/src/com/arsdigita/search/intermedia/BuildIndex.java
+++ b/ccm-core/src/com/arsdigita/search/intermedia/BuildIndex.java
@@ -30,18 +30,15 @@ import java.util.Timer;
/**
- * The BuildIndex class provides methods to keep track of when
- * the index should be rebuilt and to automatically rebuild
- * the index.
+ * The BuildIndex class provides methods to keep track of when the index should
+ * be rebuilt and to automatically rebuild the index.
*
- * All the methods in the class are called either directly or
- * indirectly from method checkState, which is called periodically by
- * a timer. The object and timer are initialized at server startup by
- * a call to the Initializer (see Initializer.java) from
- * enterprise.init.
+ * All the methods in the class are called either directly or indirectly from
+ * method checkState, which is called periodically by a timer.
+ * The object and timer are initialized at server startup by the Initializer
+ * (see Initializer.java)
*
- * A summary of how this class controls the index rebuilding is
- * given below:
+ * A summary of how this class controls the index rebuilding is given below:
*
* When content that is searchable is changed or added, the
* SearchableObserver object for the content creates and saves
@@ -64,9 +61,9 @@ import java.util.Timer;
* @author Jeff Teeters
* @author Joseph Bank
* @version 1.0
- **/
+ * @version $Id: BuildIndex.java 560 2005-06-10 17:01:14Z apevec $
+ */
class BuildIndex {
- public static final String versionId = "$Id: BuildIndex.java 560 2005-06-10 17:01:14Z apevec $ by $Author: apevec $, $DateTime: 2004/08/16 18:10:38 $";
// Creates a s_logging category with name = to the full name of class
private static final Logger s_log =
@@ -106,10 +103,9 @@ class BuildIndex {
/**
* setParametersValues - initialize delay and time values.
- * Values must be specified in milliseconds. This called by
- * the Initializer and also by tests (which
- * use values much shorter than the defaults).
- **/
+ * Values must be specified in milliseconds. This called by the Initializer
+ * and also by tests (which use values much shorter than the defaults).
+ */
static void setParameterValues(int timerDelay,
int syncDelay,
int maxSyncDelay,
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java b/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java
index 6ca68fd85..2b856ad8a 100755
--- a/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java
+++ b/ccm-core/src/com/arsdigita/search/intermedia/Initializer.java
@@ -19,8 +19,13 @@
package com.arsdigita.search.intermedia;
import com.arsdigita.db.DbHelper;
-import com.arsdigita.initializer.Configuration;
-import com.arsdigita.initializer.InitializationException;
+// import com.arsdigita.initializer.Configuration;
+// import com.arsdigita.initializer.InitializationException;
+import com.arsdigita.runtime.ConfigError;
+import com.arsdigita.runtime.ContextCloseEvent;
+import com.arsdigita.runtime.DataInitEvent;
+import com.arsdigita.runtime.DomainInitEvent;
+import com.arsdigita.runtime.ContextInitEvent;
import com.arsdigita.search.FilterType;
import com.arsdigita.search.IndexerType;
import com.arsdigita.search.QueryEngineRegistry;
@@ -29,128 +34,58 @@ import com.arsdigita.search.filters.CategoryFilterType;
import com.arsdigita.search.filters.ObjectTypeFilterType;
import com.arsdigita.search.filters.PermissionFilterType;
-/**
- * Initializer
- *
- * Initializes the BuildIndex object for search. This includes
- * a timer that runs periodically and checks if the index needs
- * to be resynced.
- *
- * @author Jeff Teeters
- * @version $Revision: #5 $ $Date: 2004/08/16 $ */
-
-// Support for Logging.
import org.apache.log4j.Logger;
-public class Initializer
- implements com.arsdigita.initializer.Initializer {
+/**
+ * Initializes the Intermedia package.
+ *
+ * This initializer is a sub-initializer of the core initializer which adds it
+ * to the list of initializers to be executed
+ *
+ * @author Peter Boy (pboy@barkhof.uni-bremen.de)
+ * @version $Id: $
+ *
+ */
+public class Initializer extends com.arsdigita.runtime.GenericInitializer {
- private Configuration m_conf = new Configuration();
+ // Creates a s_logging category with name = to the full name of class
+ public static final Logger s_log = Logger.getLogger(Initializer.class);
- private static final Logger s_log =
- Logger.getLogger(Initializer.class);
-
- public final static String versionId = "$Id";
-
- private static final String TIMER_DELAY = "timerDelay";
- private static final String TIMER_DELAY_DESCRIPTION =
- "Delay between triggering " +
- "of search indexing Timer, in seconds.";
-
- private static final String SYNC_DELAY = "syncDelay";
- private static final String SYNC_DELAY_DESCRIPTION = "Time (in seconds) " +
- "after which if a content change is made the index should be resynced " +
- "if there are no other changes during that time.";
-
- private static final String MAX_SYNC_DELAY = "maxSyncDelay";
- private static final String MAX_SYNC_DELAY_DESCRIPTION =
- "Time (in seconds) after which a change is made, " +
- "the index will be resynced, regardless of " +
- "whether or not any changes have subsequently been made.";
-
- private static final String MAX_INDEXING_TIME = "maxIndexingTime";
- private static final String MAX_INDEXING_TIME_DESCRIPTION =
- "Time (in seconds) after which a indexing operation " +
- "that has not finished is considered to have failed.";
-
- private static final String INDEXING_RETRY_DELAY = "indexingRetryDelay";
- private static final String INDEXING_RETRY_DELAY_DESCRIPTION =
- "Time (in seconds) after which an indexing " +
- "operation that failed will be retried.";
-
-
- public Initializer() throws InitializationException {
- m_conf.initParameter(TIMER_DELAY,
- TIMER_DELAY_DESCRIPTION,
- Integer.class,
- new Integer(60));
-
- m_conf.initParameter(SYNC_DELAY,
- SYNC_DELAY_DESCRIPTION,
- Integer.class,
- new Integer(60));
-
- m_conf.initParameter(MAX_SYNC_DELAY,
- MAX_SYNC_DELAY_DESCRIPTION,
- Integer.class,
- new Integer(7200));
-
- m_conf.initParameter(MAX_INDEXING_TIME,
- MAX_INDEXING_TIME_DESCRIPTION,
- Integer.class,
- new Integer(7200));
-
- m_conf.initParameter(INDEXING_RETRY_DELAY,
- INDEXING_RETRY_DELAY_DESCRIPTION,
- Integer.class,
- new Integer(60));
- }
/**
- * Returns the configuration object used by this initializer.
- **/
- public Configuration getConfiguration() {
- return m_conf;
+ *
+ */
+ public Initializer() {
}
/**
- * Called on startup.
+ * Implementation of the {@link Initializer#init(ContextInitEvent)}
+ * method.
+ *
+ * @param evt The context init event.
**/
- // void startup() throws InitializationException;
- public void startup() {
+ public void init(ContextInitEvent evt) {
if (Search.getConfig().isIntermediaEnabled()) {
+
if (DbHelper.getDatabase() != DbHelper.DB_ORACLE) {
- throw new InitializationException(
- "Intermedia searching only works on Oracle, not " +
+ throw new ConfigError(
+ "Intermedia searching only works on Oracle, not " +
DbHelper.getDatabaseName(DbHelper.getDatabase()));
}
- // Multiply by 1000 to convert from seconds to milliseconds
- int timerDelay = ((Integer) m_conf.getParameter(
- TIMER_DELAY
- )).intValue() * 1000;
- int syncDelay = ((Integer) m_conf.getParameter(
- TIMER_DELAY
- )).intValue() * 1000;
- int maxSyncDelay = ((Integer) m_conf.getParameter(
- MAX_SYNC_DELAY
- )).intValue() * 1000;
- int maxIndexingTime = ((Integer) m_conf.getParameter(
- MAX_INDEXING_TIME
- )).intValue() * 1000;
- int indexingRetryDelay = ((Integer) m_conf.getParameter(
- INDEXING_RETRY_DELAY
- )).intValue() * 1000;
+ IntermediaConfig conf = IntermediaConfig.getConfig();
- BuildIndex.setParameterValues(timerDelay,
- syncDelay,
- maxSyncDelay,
- maxIndexingTime,
- indexingRetryDelay);
+ // Multiply by 1000 to convert from seconds to milliseconds
+ BuildIndex.setParameterValues( conf.getTimerDelay() * 1000,
+ conf.getSyncDelay() * 1000,
+ conf.getMaxSyncDelay() * 1000,
+ conf.getMaxIndexingTime() * 1000,
+ conf.getIndexingRetryDelay() * 1000 );
BuildIndex.startTimer();
+
s_log.debug("Registering query engines");
QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA,
new FilterType[] {
@@ -159,15 +94,19 @@ public class Initializer
new CategoryFilterType()
},
new BaseQueryEngine());
+ } else {
+ s_log.debug("Intermedia search engine not enabled. Initialization skipped.");
+ }
+ }
+
+ /**
+ *
+ */
+ public void close(ContextCloseEvent evt) {
+ if (Search.getConfig().isIntermediaEnabled()) {
+ BuildIndex.stopTimer();
}
}
- /**
- * Stops the search indexing timer.
- **/
- public void shutdown() {
- if (Search.getConfig().isIntermediaEnabled()) {
- BuildIndex.stopTimer();
- }
- }
+
}
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/IntermediaConfig.java b/ccm-core/src/com/arsdigita/search/intermedia/IntermediaConfig.java
new file mode 100644
index 000000000..ca40ecfe8
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/search/intermedia/IntermediaConfig.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2003-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.search.intermedia;
+
+import com.arsdigita.runtime.AbstractConfig;
+// import com.arsdigita.runtime.CCMResourceManager;
+// import com.arsdigita.util.UncheckedWrapperException;
+import com.arsdigita.util.parameter.BooleanParameter;
+import com.arsdigita.util.parameter.IntegerParameter;
+import com.arsdigita.util.parameter.Parameter;
+// import com.arsdigita.util.parameter.StringParameter;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * IntermediaConfig
+ *
+ * @author Peter Boy <pboy@barkhof.uni-bremen.de>
+ * @version $Id: $
+ **/
+
+public class IntermediaConfig extends AbstractConfig {
+
+ private static final Logger s_log = Logger.getLogger(IntermediaConfig.class);
+
+ private static IntermediaConfig s_conf;
+
+ static synchronized IntermediaConfig getConfig() {
+ if (s_conf == null) {
+ s_conf = new IntermediaConfig();
+ s_conf.load();
+ }
+
+ return s_conf;
+ }
+ // see com.arsdigita.search.intermedia.BuildIndex.java for definitions.
+ // All units are time in seconds!
+ private IntegerParameter m_timerDelay = new IntegerParameter
+ ("waf.intermedia.timer_delay", Parameter.REQUIRED,
+ new Integer(60) );
+ private IntegerParameter m_syncDelay = new IntegerParameter
+ ("waf.intermedia.sync_delay", Parameter.REQUIRED,
+ new Integer(60) );
+ private IntegerParameter m_maxSyncDelay = new IntegerParameter
+ ("waf.intermedia.max_sync_delay", Parameter.REQUIRED,
+ new Integer(7200) );
+ private IntegerParameter m_maxIndexingTime = new IntegerParameter
+ ("waf.intermedia.max_indexing_time", Parameter.REQUIRED,
+ new Integer(7200) );
+ private IntegerParameter m_indexingRetryDelay = new IntegerParameter
+ ("waf.intermedia.indexing_retry_delay", Parameter.REQUIRED,
+ new Integer(60) );
+ private BooleanParameter m_stemming = new BooleanParameter
+ ("waf.intermedia.stemming", Parameter.REQUIRED,
+ Boolean.FALSE);
+
+
+ public IntermediaConfig() {
+ register(m_timerDelay);
+ register(m_syncDelay);
+ register(m_maxSyncDelay);
+ register(m_maxIndexingTime);
+ register(m_indexingRetryDelay);
+ register(m_stemming);
+
+ loadInfo();
+ }
+
+ /**
+ * Retrieve delay between triggering of search indexing Timer.
+ * @return delay, in seconds
+ */
+ public int getTimerDelay() {
+ return ((Integer) get(m_timerDelay)).intValue();
+ }
+
+ /**
+ * Retrieve time after which, if a content change is made, the index should
+ * be resynced if there are no other changes during that time.
+ * @return delay, in seconds
+ */
+ public int getSyncDelay() {
+ return ((Integer) get(m_syncDelay)).intValue();
+ }
+
+ /*'
+ * Retrieve time after which a change is made, the index will be resynced,
+ * regardless of whether or not any changes have subsequently been made.
+ * @return delay, in seconds
+ */
+ public int getMaxSyncDelay() {
+ return ((Integer) get(m_maxSyncDelay)).intValue();
+ }
+
+ /**
+ * Retrieve time after which a indexing operation that has not finished is
+ * considered to have failed.
+ * @return time, in seconds
+ */
+ public int getMaxIndexingTime() {
+ return ((Integer) get(m_maxIndexingTime)).intValue();
+ }
+
+ /**
+ * Retrieve time after which an indexing operation that failed will be retried.
+ * @return delay, in seconds
+ */
+ public int getIndexingRetryDelay() {
+ return ((Integer) get(m_indexingRetryDelay)).intValue();
+ }
+
+ /**
+ * If intermedia is used, applies stemming operator to each individual word
+ * in the contains clause. So for example a search for guitars will return
+ * documents containing guitar. Search for ran returns documents containing
+ * run.
+ *
+ * The stemming operator is not applied to compound phrases (included in
+ * quotes by the user) as assume that user wants exact phrase. Also allows
+ * user to override stemming by including single word in quotes
+ *
+ * @return
+ */
+ public boolean includeStemming() {
+ return ((Boolean)get(m_stemming)).booleanValue();
+
+ }
+
+}
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/IntermediaConfig_parameter.properties b/ccm-core/src/com/arsdigita/search/intermedia/IntermediaConfig_parameter.properties
new file mode 100644
index 000000000..9e1848dfb
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/search/intermedia/IntermediaConfig_parameter.properties
@@ -0,0 +1,24 @@
+waf.intermedia.timer_delay.title=Timer Delay
+waf.intermedia.timer_delay.purpose=Delay between triggering of search indexing Timer, in seconds.
+waf.intermedia.timer_delay.example=60
+waf.intermedia.timer_delay.format=[integer]
+waf.intermedia.sync_delay.title=Synchronization Delay
+waf.intermedia.sync_delay.purpose=Time (in seconds) after which, if a content change is made, the index should be resynced if there are no other changes during that time.
+waf.intermedia.sync_delay.example=60
+waf.intermedia.sync_delay.format=[integer]
+waf.intermedia.max_sync_delay.title=Maximum Synchronization Delay
+waf.intermedia.max_sync_delay.purpose=Time (in seconds) after which a change is made, the index will be resynced, regardless of whether or not any changes have subsequently been made.
+waf.intermedia.max_sync_delay.example=7200
+waf.intermedia.max_sync_delay.format=[integer]
+waf.intermedia.max_indexing_time.title=Maximum Indexing Time
+waf.intermedia.max_indexing_time.purpose=Time (in seconds) after which a indexing operation that has not finished is considered to have failed.
+waf.intermedia.max_indexing_time.example=7200
+waf.intermedia.max_indexing_time.format=[integer]
+waf.intermedia.indexing_retry_delay.title=Maximum Indexing Time
+waf.intermedia.indexing_retry_delay.purpose=Time (in seconds) after which an indexing operation that failed will be retried.
+waf.intermedia.indexing_retry_delay.example=60
+waf.intermedia.indexing_retry_delay.format=[integer]
+waf.intermedia.stemming.title=Allow Stemming
+waf.intermedia.stemming.purpose=Flag to turn on stemming option on search terms (ie prepend with $)(only used by interMedia)
+waf.intermedia.stemming.example=true
+waf.intermedia.stemming.format=[boolean]
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/LegacyInitializer.java.nolongerInUse b/ccm-core/src/com/arsdigita/search/intermedia/LegacyInitializer.java.nolongerInUse
new file mode 100755
index 000000000..bf3f05537
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/search/intermedia/LegacyInitializer.java.nolongerInUse
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2003-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.search.intermedia;
+
+import com.arsdigita.db.DbHelper;
+import com.arsdigita.initializer.Configuration;
+import com.arsdigita.initializer.InitializationException;
+import com.arsdigita.search.FilterType;
+import com.arsdigita.search.IndexerType;
+import com.arsdigita.search.QueryEngineRegistry;
+import com.arsdigita.search.Search;
+import com.arsdigita.search.filters.CategoryFilterType;
+import com.arsdigita.search.filters.ObjectTypeFilterType;
+import com.arsdigita.search.filters.PermissionFilterType;
+// Support for Logging.
+import org.apache.log4j.Logger;
+
+/**
+ * LegacyInitializer
+ *
+ * Initializes the BuildIndex object for search. This includes
+ * a timer that runs periodically and checks if the index needs
+ * to be resynced.
+ *
+ * @author Jeff Teeters
+ * @version $Revision: #5 $ $Date: 2004/08/16 $
+ */
+public class LegacyInitializer
+ implements com.arsdigita.initializer.Initializer {
+
+ private Configuration m_conf = new Configuration();
+
+ private static final Logger s_log =
+ Logger.getLogger(LegacyInitializer.class);
+
+ private static final String TIMER_DELAY = "timerDelay";
+ private static final String TIMER_DELAY_DESCRIPTION =
+ "Delay between triggering " +
+ "of search indexing Timer, in seconds.";
+
+ private static final String SYNC_DELAY = "syncDelay";
+ private static final String SYNC_DELAY_DESCRIPTION = "Time (in seconds) " +
+ "after which if a content change is made the index should be resynced " +
+ "if there are no other changes during that time.";
+
+ private static final String MAX_SYNC_DELAY = "maxSyncDelay";
+ private static final String MAX_SYNC_DELAY_DESCRIPTION =
+ "Time (in seconds) after which a change is made, " +
+ "the index will be resynced, regardless of " +
+ "whether or not any changes have subsequently been made.";
+
+ private static final String MAX_INDEXING_TIME = "maxIndexingTime";
+ private static final String MAX_INDEXING_TIME_DESCRIPTION =
+ "Time (in seconds) after which a indexing operation " +
+ "that has not finished is considered to have failed.";
+
+ private static final String INDEXING_RETRY_DELAY = "indexingRetryDelay";
+ private static final String INDEXING_RETRY_DELAY_DESCRIPTION =
+ "Time (in seconds) after which an indexing " +
+ "operation that failed will be retried.";
+
+
+ public LegacyInitializer() throws InitializationException {
+ m_conf.initParameter(TIMER_DELAY,
+ TIMER_DELAY_DESCRIPTION,
+ Integer.class,
+ new Integer(60));
+
+ m_conf.initParameter(SYNC_DELAY,
+ SYNC_DELAY_DESCRIPTION,
+ Integer.class,
+ new Integer(60));
+
+ m_conf.initParameter(MAX_SYNC_DELAY,
+ MAX_SYNC_DELAY_DESCRIPTION,
+ Integer.class,
+ new Integer(7200));
+
+ m_conf.initParameter(MAX_INDEXING_TIME,
+ MAX_INDEXING_TIME_DESCRIPTION,
+ Integer.class,
+ new Integer(7200));
+
+ m_conf.initParameter(INDEXING_RETRY_DELAY,
+ INDEXING_RETRY_DELAY_DESCRIPTION,
+ Integer.class,
+ new Integer(60));
+ }
+
+ /**
+ * Returns the configuration object used by this initializer.
+ **/
+ public Configuration getConfiguration() {
+ return m_conf;
+ }
+
+
+ /**
+ * Called on startup.
+ **/
+
+ // void startup() throws InitializationException;
+ public void startup() {
+ if (Search.getConfig().isIntermediaEnabled()) {
+ if (DbHelper.getDatabase() != DbHelper.DB_ORACLE) {
+ throw new InitializationException(
+ "Intermedia searching only works on Oracle, not " +
+ DbHelper.getDatabaseName(DbHelper.getDatabase()));
+ }
+
+ // Multiply by 1000 to convert from seconds to milliseconds
+ int timerDelay = ((Integer) m_conf.getParameter(
+ TIMER_DELAY
+ )).intValue() * 1000;
+ int syncDelay = ((Integer) m_conf.getParameter(
+ TIMER_DELAY
+ )).intValue() * 1000;
+ int maxSyncDelay = ((Integer) m_conf.getParameter(
+ MAX_SYNC_DELAY
+ )).intValue() * 1000;
+ int maxIndexingTime = ((Integer) m_conf.getParameter(
+ MAX_INDEXING_TIME
+ )).intValue() * 1000;
+ int indexingRetryDelay = ((Integer) m_conf.getParameter(
+ INDEXING_RETRY_DELAY
+ )).intValue() * 1000;
+
+ BuildIndex.setParameterValues(timerDelay,
+ syncDelay,
+ maxSyncDelay,
+ maxIndexingTime,
+ indexingRetryDelay);
+
+ BuildIndex.startTimer();
+ s_log.debug("Registering query engines");
+ QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA,
+ new FilterType[] {
+ new PermissionFilterType(),
+ new ObjectTypeFilterType(),
+ new CategoryFilterType()
+ },
+ new BaseQueryEngine());
+ }
+ }
+
+ /**
+ * Stops the search indexing timer.
+ **/
+ public void shutdown() {
+ if (Search.getConfig().isIntermediaEnabled()) {
+ BuildIndex.stopTimer();
+ }
+ }
+}
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/SearchSpecification.java b/ccm-core/src/com/arsdigita/search/intermedia/SearchSpecification.java
index 3fa2ef520..00d53d191 100755
--- a/ccm-core/src/com/arsdigita/search/intermedia/SearchSpecification.java
+++ b/ccm-core/src/com/arsdigita/search/intermedia/SearchSpecification.java
@@ -402,7 +402,7 @@ public class SearchSpecification {
//String sql_for_page = reformatSqlForPage(page);
String sql_for_page = m_sql;
- SearchDataQuery dq = new com.arsdigita.search.SearchDataQuery(
+ SearchDataQuery dq = new SearchDataQuery(
SessionManager.getSession(),
sql_for_page, m_columns);
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/SimpleSearchSpecification.java b/ccm-core/src/com/arsdigita/search/intermedia/SimpleSearchSpecification.java
index 10173f16b..8a516c96a 100755
--- a/ccm-core/src/com/arsdigita/search/intermedia/SimpleSearchSpecification.java
+++ b/ccm-core/src/com/arsdigita/search/intermedia/SimpleSearchSpecification.java
@@ -55,10 +55,9 @@ import com.arsdigita.util.StringUtils;
* @see com.arsdigita.search.intermedia.SearchDataQuery
*
* @author Joseph A. Bank (jbank@alum.mit.edu)
- * @version 1.0
+ * @version $Id: SimpleSearchSpecification.java 1431 2007-02-05 16:40:16Z chrisgilbert23 $
**/
public class SimpleSearchSpecification extends SearchSpecification {
- public static final String versionId = "$Id: SimpleSearchSpecification.java 1431 2007-02-05 16:40:16Z chrisgilbert23 $ by $Author: chrisgilbert23 $, $DateTime: 2004/08/16 18:10:38 $";
private static final Logger s_log = Logger.getLogger(SimpleSearchSpecification.class);
final static String WORD_ESCAPE_BEGIN = "\"";
@@ -265,7 +264,7 @@ public class SimpleSearchSpecification extends SearchSpecification {
public static String cleanSearchString(String searchString, String joinString) {
StringBuffer sb = new StringBuffer();
StringBuffer word_sb = new StringBuffer();
- String stemmingOperator = Search.getConfig().includeStemming() ? "$" : "";
+ String stemmingOperator = IntermediaConfig.getConfig().includeStemming() ? "$" : "";
boolean skip_whitespace = true;
boolean in_quotes = false;
String next_joinString = "";
@@ -337,7 +336,7 @@ public class SimpleSearchSpecification extends SearchSpecification {
public DataQuery getPage(int page) {
// Reformat SQL to specify the rows on the page
String sql_for_page = reformatSqlForPage(page);
- SearchDataQuery sdq = new com.arsdigita.search.SearchDataQuery(
+ SearchDataQuery sdq = new SearchDataQuery(
SessionManager.getSession(),
sql_for_page, s_columns);
// XXX: Removed by rhs@mit.edu. See apology above.
diff --git a/ccm-core/src/com/arsdigita/search/intermedia/SyncInitializer.java b/ccm-core/src/com/arsdigita/search/intermedia/SyncInitializer.java
index b6d5b28f6..48c921ea5 100755
--- a/ccm-core/src/com/arsdigita/search/intermedia/SyncInitializer.java
+++ b/ccm-core/src/com/arsdigita/search/intermedia/SyncInitializer.java
@@ -23,6 +23,9 @@ import com.arsdigita.initializer.InitializationException;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;
+// Support for Logging.
+import org.apache.log4j.Logger;
+
/**
* SyncInitializer
*
@@ -33,10 +36,9 @@ import com.arsdigita.persistence.TransactionContext;
* or it doesn't.
*
* @author David Eison
- * @version $Revision: #4 $ */
+ * @version $Id: $
+ */
-// Support for Logging.
-import org.apache.log4j.Logger;
public class SyncInitializer
implements com.arsdigita.initializer.Initializer {
@@ -44,9 +46,7 @@ public class SyncInitializer
private Configuration m_conf = new Configuration();
private static final Logger s_log =
- Logger.getLogger(Initializer.class);
-
- public final static String versionId = "$Id";
+ Logger.getLogger(SyncInitializer.class);
public SyncInitializer() throws InitializationException {
}
diff --git a/ccm-core/src/com/arsdigita/search/lucene/Index.java b/ccm-core/src/com/arsdigita/search/lucene/Index.java
index b94b1af7f..acabab22e 100755
--- a/ccm-core/src/com/arsdigita/search/lucene/Index.java
+++ b/ccm-core/src/com/arsdigita/search/lucene/Index.java
@@ -26,19 +26,18 @@ import org.apache.log4j.Logger;
* Index
*
* @author rhs@mit.edu
- * @version $Revision: #5 $ $Date: 2004/08/16 $
+ * @version $Id: Index.java 738 2005-09-01 12:36:52Z sskracic $
**/
class Index {
- public final static String versionId =
- "$Id: Index.java 738 2005-09-01 12:36:52Z sskracic $" +
- " by $Author: sskracic $, " +
- "$DateTime: 2004/08/16 18:10:38 $";
-
private static final Logger s_log = Logger.getLogger(Index.class);
private static String s_location;
+
+ /**
+ *
+ */
private static final Timer TIMER = new Timer(true);
private static Integer s_id;
diff --git a/ccm-core/src/com/arsdigita/search/lucene/IndexId.java b/ccm-core/src/com/arsdigita/search/lucene/IndexId.java
index e996e9bd3..b3758dbbb 100755
--- a/ccm-core/src/com/arsdigita/search/lucene/IndexId.java
+++ b/ccm-core/src/com/arsdigita/search/lucene/IndexId.java
@@ -45,6 +45,7 @@ class IndexId extends DomainObject {
private IndexId() {
super(SessionManager.getSession().create(oid()));
+ s_log.debug( "Constructor invoked. " );
set(HOST, getHost());
int id = 0;
@@ -60,14 +61,16 @@ class IndexId extends DomainObject {
ids.close();
- Assert.truth(id >= 0, "id greater than or equal to 0");
- Assert.truth(id <= 30, "id less than or equal to 30");
+ Assert.isTrue(id >= 0, "id greater than or equal to 0");
+ Assert.isTrue(id <= 30, "id less than or equal to 30");
set(INDEX_ID, new Integer(id));
if( s_log.isDebugEnabled() ) {
s_log.debug( "New Index ID " + id );
}
+ s_log.debug( "Constructor finished. " );
+
}
private static OID oid() {
@@ -88,9 +91,18 @@ class IndexId extends DomainObject {
static class LoaderImpl implements Initializer.Loader {
public void load() {
+ s_log.debug( "LoadImpl.load() invoked. " );
+
if (IndexId.retrieveIndexID() == null ) {
+ s_log.debug( "Invoking IndexId(). " );
new IndexId();
- }
+ s_log.debug( "IndexId() has been invoked. " ); }
+ else {
+ s_log.debug( "IndexId() has been skipped. " );
+ }
+
+ s_log.debug( "LoadImpl.load() finished. " );
}
}
+
}
diff --git a/ccm-core/src/com/arsdigita/search/lucene/Indexer.java b/ccm-core/src/com/arsdigita/search/lucene/Indexer.java
index f88bcf8dc..e709bdd5f 100755
--- a/ccm-core/src/com/arsdigita/search/lucene/Indexer.java
+++ b/ccm-core/src/com/arsdigita/search/lucene/Indexer.java
@@ -45,15 +45,11 @@ import com.arsdigita.runtime.RuntimeConfig;
* Indexer.
*
* @author rhs@mit.edu
- * @version $Revision: #9 $ $Date: 2004/08/16 $
+ * @version $Id: Indexer.java 1845 2009-03-05 13:39:09Z terry $
**/
class Indexer extends TimerTask {
- public final static String versionId =
- "$Id: Indexer.java 1845 2009-03-05 13:39:09Z terry $" +
- " by $Author: terry $, $DateTime: 2004/08/16 18:10:38 $";
-
private static final Logger LOG =
Logger.getLogger(Indexer.class);
diff --git a/ccm-core/src/com/arsdigita/search/lucene/Initializer.java b/ccm-core/src/com/arsdigita/search/lucene/Initializer.java
index 8e2f52345..c9cbfdcd9 100755
--- a/ccm-core/src/com/arsdigita/search/lucene/Initializer.java
+++ b/ccm-core/src/com/arsdigita/search/lucene/Initializer.java
@@ -18,8 +18,17 @@
*/
package com.arsdigita.search.lucene;
-import com.arsdigita.initializer.Configuration;
-import com.arsdigita.initializer.InitializationException;
+// import com.arsdigita.initializer.Configuration;
+// import com.arsdigita.initializer.InitializationException;
+// import com.arsdigita.runtime.CompoundInitializer;
+import com.arsdigita.runtime.ConfigError;
+import com.arsdigita.runtime.ContextInitEvent;
+import com.arsdigita.runtime.ContextCloseEvent;
+// import com.arsdigita.runtime.DataInitEvent;
+//import com.arsdigita.runtime.DomainInitEvent;
+import com.arsdigita.runtime.GenericInitializer;
+// import com.arsdigita.runtime.LegacyInitializer;
+// import com.arsdigita.runtime.LegacyInitEvent;
import com.arsdigita.search.FilterType;
import com.arsdigita.search.IndexerType;
import com.arsdigita.search.QueryEngineRegistry;
@@ -28,7 +37,7 @@ import com.arsdigita.search.filters.CategoryFilterType;
import com.arsdigita.search.filters.ObjectTypeFilterType;
import com.arsdigita.search.filters.PermissionFilterType;
import java.io.File;
-import java.io.IOException;
+// import java.io.IOException;
import java.util.Date;
import org.apache.log4j.Logger;
import org.apache.lucene.analysis.Analyzer;
@@ -37,88 +46,198 @@ import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.BooleanQuery;
/**
- * Initializer
+ * Initializes the Lucene package.
*
- * Initializes the Lucene package
+ * This initializer is a sub-initializer of the core initializer which adds it
+ * to the list of initializers to be executed
*
* @author Richard Su (richard.su@alum.mit.edu)
* @version $Id: Initializer.java 1044 2005-12-09 13:21:16Z sskracic $
*
*/
-public class Initializer implements com.arsdigita.initializer.Initializer {
+public class Initializer extends GenericInitializer {
- private static final Logger LOG = Logger.getLogger(Initializer.class);
+ // Creates a s_logging category with name = to the full name of class
+ public static final Logger s_log = Logger.getLogger(Initializer.class);
public final static Loader LOADER = new IndexId.LoaderImpl();
- private Configuration m_conf = new Configuration();
-
- public Initializer() {}
-
- public Configuration getConfiguration() {
- return m_conf;
+ /**
+ *
+ */
+ public Initializer() {
}
- /*
- * Called on startup.
- * @throws InitializationException
+ /**
+ * An empty implementation of {@link Initializer#init(DataInitEvent)}.
+ *
+ * @param evt The data init event.
+ **/
+// public void init(DataInitEvent evt) {
+// }
+
+
+ /**
+ * An empty implementation of {@link Initializer#init(DomainInitEvent)}.
+ *
+ * @param evt The domain init event.
+ **/
+// public void init(DomainInitEvent evt) {
+// }
+
+
+ /**
+ * Implementation of the {@link Initializer#init(LegacyInitEvent)}
+ * method.
+ *
+ * @param evt The legacy init event.
+ */
+// public void init(LegacyInitEvent evt) {
+// if (Search.getConfig().isLuceneEnabled()) {
+// // startup();
+// } else {
+// s_log.debug("Lucene search engine not enabled. Initialization skipped.");
+// }
+// }
+
+ /**
+ * Implementation of the {@link Initializer#init(ContextInitEvent)}
+ * method.
+ *
+ * @param evt The context init event.
+ */
+ public void init(ContextInitEvent evt) {
+ if (Search.getConfig().isLuceneEnabled()) {
+ // startup();
+
+ LuceneConfig conf = LuceneConfig.getConfig();
+
+ String location = conf.getIndexLocation();
+ int interval = conf.getIndexerInterval();
+ Analyzer analyzer = conf.getAnalyzer();
+ s_log.info("Lucene index location: " + location);
+ s_log.info("Lucene Analyzer = " + analyzer.getClass().getName());
+ BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
+
+ try {
+ if (!IndexReader.indexExists(location)) {
+ File f = new File(location);
+ f.mkdirs();
+ IndexWriter iw = new IndexWriter
+ (location, analyzer, true);
+ iw.close();
+ s_log.info("Lucene created index directory");
+ }
+ } catch (Exception ex) {
+ s_log.warn("Lucene initialization: No index directory!");
+ throw new ConfigError("lucene index id has not been initialized");
+ }
+
+ Index.setLocation(location);
+ // FIXME: This is a hack. Delay the start of the timer task by 5
+ // seconds and keep your fingers crosses in hopes that
+ // Index.getIndexerID() will be ready to return a valid value by
+ // then. -- vadimn@redhat.com, 2004-01-07
+ Date delayedStart = new Date(System.currentTimeMillis() + 5000L);
+
+ s_log.debug("Lucene initialization: Starting index timer!");
+ Index.getTimer().schedule
+ (new Indexer(Index.getLocation()),
+ delayedStart,
+ ((long)interval * 1000l));
+
+ QueryEngineRegistry.registerEngine
+ (IndexerType.LUCENE, new FilterType[] {
+ new CategoryFilterType(),
+ new ObjectTypeFilterType(),
+ new PermissionFilterType()
+ },
+ new BaseQueryEngine());
+
+ } else {
+ s_log.debug("Lucene search engine not enabled. Initialization skipped.");
+ }
+ }
+
+ /**
+ *
+ */
+ public void close(ContextCloseEvent evt) {
+ if (Search.getConfig().isLuceneEnabled()) {
+ shutdown();
+ } else {
+ s_log.debug("Lucene search engine not enabled. Shutdown skipped.");
+ }
+ }
+
+
+ /**
+ * Starts the search indexing timer
+ *
*/
public void startup() {
- if (Search.getConfig().isLuceneEnabled()) {
- LuceneConfig conf = LuceneConfig.getConfig();
- String location = conf.getIndexLocation();
- int interval = conf.getIndexerInterval();
- Analyzer analyzer = conf.getAnalyzer();
- LOG.info("Lucene index location: " + location);
- LOG.info("Lucene Analyzer = " + analyzer.getClass().getName());
- BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
- try {
- if (!IndexReader.indexExists(location)) {
- File f = new File(location);
- f.mkdirs();
- IndexWriter iw = new IndexWriter
- (location, analyzer, true);
- iw.close();
- LOG.info("Lucene created index directory");
- }
- } catch (IOException ex) {
- throw new InitializationException
- ("lucene index id has not been initialized", ex);
+ LuceneConfig conf = LuceneConfig.getConfig();
+
+ String location = conf.getIndexLocation();
+ int interval = conf.getIndexerInterval();
+ Analyzer analyzer = conf.getAnalyzer();
+ s_log.info("Lucene index location: " + location);
+ s_log.info("Lucene Analyzer = " + analyzer.getClass().getName());
+ BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
+
+ try {
+ if (!IndexReader.indexExists(location)) {
+ File f = new File(location);
+ f.mkdirs();
+ IndexWriter iw = new IndexWriter
+ (location, analyzer, true);
+ iw.close();
+ s_log.info("Lucene created index directory");
}
-
- Index.setLocation(location);
- // FIXME: This is a hack. Delay the start of the timer task by 5
- // seconds and keep your fingers crosses in hopes that
- // Index.getIndexerID() will be ready to return a valid value by
- // then. -- vadimn@redhat.com, 2004-01-07
- Date delayedStart = new Date(System.currentTimeMillis() + 5000L);
- Index.getTimer().schedule
- (new Indexer(Index.getLocation()),
- delayedStart,
- ((long)interval * 1000l));
-
- QueryEngineRegistry.registerEngine
- (IndexerType.LUCENE, new FilterType[] {
- new CategoryFilterType(),
- new ObjectTypeFilterType(),
- new PermissionFilterType()
- },
- new BaseQueryEngine());
+ } catch (Exception ex) {
+ s_log.warn("Lucene initialization: No index directory!");
+ throw new ConfigError("lucene index id has not been initialized");
}
+
+ Index.setLocation(location);
+ // FIXME: This is a hack. Delay the start of the timer task by 5
+ // seconds and keep your fingers crosses in hopes that
+ // Index.getIndexerID() will be ready to return a valid value by
+ // then. -- vadimn@redhat.com, 2004-01-07
+ Date delayedStart = new Date(System.currentTimeMillis() + 5000L);
+
+ s_log.debug("Lucene initialization: Starting index timer!");
+ Index.getTimer().schedule
+ (new Indexer(Index.getLocation()),
+ delayedStart,
+ ((long)interval * 1000l));
+
+ QueryEngineRegistry.registerEngine
+ (IndexerType.LUCENE, new FilterType[] {
+ new CategoryFilterType(),
+ new ObjectTypeFilterType(),
+ new PermissionFilterType()
+ },
+ new BaseQueryEngine());
}
+
/**
- * Called on shutdown. It's probably not a good idea to depend on this
- * being called.
- **/
+ * Stopps the search indexing timer
+ *
+ */
public void shutdown() {
+ s_log.debug("Lucene initialization: Trying to stop index timer!");
+ Index.getTimer().cancel();
+ s_log.debug("Lucene initialization: Index timer stopped!");
}
/**
- * Only used by CoreLoader.
- **/
+ * Only used by com.arsdigita.loader.CoreLoader.
+ */
public interface Loader {
void load();
}
+
}
diff --git a/ccm-core/src/com/arsdigita/search/lucene/LegacyInitializer.java.nolongerInUse b/ccm-core/src/com/arsdigita/search/lucene/LegacyInitializer.java.nolongerInUse
new file mode 100755
index 000000000..9f5892ba3
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/search/lucene/LegacyInitializer.java.nolongerInUse
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2003-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.search.lucene;
+
+import com.arsdigita.initializer.Configuration;
+import com.arsdigita.initializer.InitializationException;
+import com.arsdigita.search.FilterType;
+import com.arsdigita.search.IndexerType;
+import com.arsdigita.search.QueryEngineRegistry;
+import com.arsdigita.search.Search;
+import com.arsdigita.search.filters.CategoryFilterType;
+import com.arsdigita.search.filters.ObjectTypeFilterType;
+import com.arsdigita.search.filters.PermissionFilterType;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import org.apache.log4j.Logger;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.search.BooleanQuery;
+
+/**
+ * LegacyInitializer
+ *
+ * Initializes the Lucene package
+ *
+ * @author Richard Su (richard.su@alum.mit.edu)
+ * @version $Id: LegacyInitializer.java 1044 2005-12-09 13:21:16Z sskracic $
+ *
+ * @deprecated no longer in use, replaced by new Initializer. May be deleted.
+ */
+public class LegacyInitializer implements com.arsdigita.initializer.Initializer {
+
+ private static final Logger LOG = Logger.getLogger(LegacyInitializer.class);
+
+ // public final static Loader LOADER = new IndexId.LoaderImpl();
+
+ private Configuration m_conf = new Configuration();
+
+ /**
+ *
+ */
+ public LegacyInitializer() {}
+
+ /**
+ *
+ * @return
+ */
+ public Configuration getConfiguration() {
+ return m_conf;
+ }
+
+ /*
+ * Called on startup.
+ * @throws InitializationException
+ */
+ public void startup() {
+ if (Search.getConfig().isLuceneEnabled()) {
+ LuceneConfig conf = LuceneConfig.getConfig();
+ String location = conf.getIndexLocation();
+ int interval = conf.getIndexerInterval();
+ Analyzer analyzer = conf.getAnalyzer();
+ LOG.info("Lucene index location: " + location);
+ LOG.info("Lucene Analyzer = " + analyzer.getClass().getName());
+ BooleanQuery.setMaxClauseCount(Integer.MAX_VALUE);
+
+ try {
+ if (!IndexReader.indexExists(location)) {
+ File f = new File(location);
+ f.mkdirs();
+ IndexWriter iw = new IndexWriter
+ (location, analyzer, true);
+ iw.close();
+ LOG.info("Lucene created index directory");
+ }
+ } catch (IOException ex) {
+ throw new InitializationException
+ ("lucene index id has not been initialized", ex);
+ }
+
+ Index.setLocation(location);
+ // FIXME: This is a hack. Delay the start of the timer task by 5
+ // seconds and keep your fingers crosses in hopes that
+ // Index.getIndexerID() will be ready to return a valid value by
+ // then. -- vadimn@redhat.com, 2004-01-07
+ Date delayedStart = new Date(System.currentTimeMillis() + 5000L);
+ Index.getTimer().schedule
+ (new Indexer(Index.getLocation()),
+ delayedStart,
+ ((long)interval * 1000l));
+
+ QueryEngineRegistry.registerEngine
+ (IndexerType.LUCENE, new FilterType[] {
+ new CategoryFilterType(),
+ new ObjectTypeFilterType(),
+ new PermissionFilterType()
+ },
+ new BaseQueryEngine());
+ }
+ }
+
+ /**
+ * Called on shutdown. It's probably not a good idea to depend on this
+ * being called.
+ **/
+ public void shutdown() {
+ }
+
+// /**
+// * Only used by CoreLoader.
+// **/
+// public interface Loader {
+// void load();
+// }
+}
diff --git a/ccm-core/src/com/arsdigita/search/lucene/LuceneConfig.java b/ccm-core/src/com/arsdigita/search/lucene/LuceneConfig.java
index 6792297d9..b231a0d16 100755
--- a/ccm-core/src/com/arsdigita/search/lucene/LuceneConfig.java
+++ b/ccm-core/src/com/arsdigita/search/lucene/LuceneConfig.java
@@ -43,15 +43,6 @@ public class LuceneConfig extends AbstractConfig {
private static LuceneConfig s_conf;
- static synchronized LuceneConfig getConfig() {
- if (s_conf == null) {
- s_conf = new LuceneConfig();
- s_conf.load();
- }
-
- return s_conf;
- }
-
private Class m_analyzerClass;
private StringParameter m_location = new StringParameter
@@ -63,6 +54,9 @@ public class LuceneConfig extends AbstractConfig {
("waf.lucene.analyzer", Parameter.REQUIRED,
"org.apache.lucene.analysis.standard.StandardAnalyzer");
+ /**
+ * Constructor - don't use it directly! Use getconfig()
+ */
public LuceneConfig() {
register(m_location);
register(m_interval);
@@ -70,6 +64,15 @@ public class LuceneConfig extends AbstractConfig {
loadInfo();
}
+ static synchronized LuceneConfig getConfig() {
+ if (s_conf == null) {
+ s_conf = new LuceneConfig();
+ s_conf.load();
+ }
+
+ return s_conf;
+ }
+
public String getIndexLocation() {
return (String) get(m_location);
}
diff --git a/ccm-core/src/com/arsdigita/search/lucene/enterprise.init.nolongerInUse b/ccm-core/src/com/arsdigita/search/lucene/enterprise.init.nolongerInUse
new file mode 100644
index 000000000..bc396b01e
--- /dev/null
+++ b/ccm-core/src/com/arsdigita/search/lucene/enterprise.init.nolongerInUse
@@ -0,0 +1,7 @@
+// file: com.arsdigita.search.lucene.enterprise.init
+
+
+
+// As of version 6.5.x still in use!
+init com.arsdigita.search.lucene.LegacyInitializer {}
+
diff --git a/ccm-core/src/com/arsdigita/templating/jsp/IncludeTag.jsp b/ccm-core/src/com/arsdigita/templating/jsp/IncludeTag.jsp
index 8d96c5d73..573bf30bd 100755
--- a/ccm-core/src/com/arsdigita/templating/jsp/IncludeTag.jsp
+++ b/ccm-core/src/com/arsdigita/templating/jsp/IncludeTag.jsp
@@ -12,7 +12,7 @@ import javax.servlet.jsp.*;
*
* Usage:
* - *<acs:include path="path/to/component.jsp" />
+ * <acs:include path="path/to/component.jsp" />
**/
public class IncludeTag extends TagSupport {
diff --git a/ccm-core/src/com/arsdigita/util/cmd/package.html b/ccm-core/src/com/arsdigita/util/cmd/package.html
index 0fafde2e1..38a4469ee 100755
--- a/ccm-core/src/com/arsdigita/util/cmd/package.html
+++ b/ccm-core/src/com/arsdigita/util/cmd/package.html
@@ -1,6 +1,7 @@
-
+
+ Package com.arsdigita.util.cmd
diff --git a/ccm-core/src/com/arsdigita/util/parameter/CSVParameterReader.java b/ccm-core/src/com/arsdigita/util/parameter/CSVParameterReader.java
index 1aca506e0..5a76b30d6 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/CSVParameterReader.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/CSVParameterReader.java
@@ -38,10 +38,6 @@ import java.util.List;
* @version $Id: CSVParameterReader.java 287 2005-02-22 00:29:02Z sskracic $
*/
public final class CSVParameterReader implements ParameterReader {
- public final static String versionId =
- "$Id: CSVParameterLoader.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
private final LineNumberReader m_reader;
private final Parameter[] m_params;
diff --git a/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java b/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java
index 4ffea0b09..8cc228173 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/ClassParameter.java
@@ -31,10 +31,6 @@ import org.apache.commons.beanutils.converters.ClassConverter;
* @version $Id: ClassParameter.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class ClassParameter extends AbstractParameter {
- public final static String versionId =
- "$Id: ClassParameter.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
static {
Converters.set(Class.class, new ClassConverter());
diff --git a/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java b/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java
index 372d18cec..89597a737 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/IntegerParameter.java
@@ -31,10 +31,6 @@ import org.apache.commons.beanutils.converters.IntegerConverter;
* @version $Id: IntegerParameter.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class IntegerParameter extends AbstractParameter {
- public final static String versionId =
- "$Id: IntegerParameter.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
static {
Converters.set(Integer.class, new IntegerConverter());
diff --git a/ccm-core/src/com/arsdigita/util/parameter/MapParameter.java b/ccm-core/src/com/arsdigita/util/parameter/MapParameter.java
index b724c3f31..f3b8400d1 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/MapParameter.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/MapParameter.java
@@ -24,11 +24,11 @@ import java.util.HashMap;
import java.util.Iterator;
/**
- * Subject to change.
- *
* A parameter that manages a collection of Parameter to
* Object value mappings.
*
+ * Subject to change.
+ *
* @see java.util.Map
* @see Parameter
* @author Justin Ross <jross@redhat.com>
diff --git a/ccm-core/src/com/arsdigita/util/parameter/ParameterContext.java b/ccm-core/src/com/arsdigita/util/parameter/ParameterContext.java
index 554b4f4e9..f231bcc22 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/ParameterContext.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/ParameterContext.java
@@ -31,10 +31,6 @@ package com.arsdigita.util.parameter;
* @version $Id: ParameterContext.java 287 2005-02-22 00:29:02Z sskracic $
*/
public interface ParameterContext {
- public final static String versionId =
- "$Id: ParameterContext.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
/**
* Returns all the parameters registered on the parameter context.
diff --git a/ccm-core/src/com/arsdigita/util/parameter/ParameterInfo.java b/ccm-core/src/com/arsdigita/util/parameter/ParameterInfo.java
index a5ba1b5bc..a1343e04c 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/ParameterInfo.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/ParameterInfo.java
@@ -31,10 +31,6 @@ package com.arsdigita.util.parameter;
* @version $Id: ParameterInfo.java 287 2005-02-22 00:29:02Z sskracic $
*/
public interface ParameterInfo {
- public final static String versionId =
- "$Id: ParameterInfo.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
/**
* Gets the pretty name of the parameter.
diff --git a/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java b/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java
index 2cf4a686e..45885d076 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/ResourceParameter.java
@@ -49,11 +49,6 @@ import com.arsdigita.util.UncheckedWrapperException;
*/
public class ResourceParameter extends AbstractParameter {
- public final static String versionId =
- "$Id: ResourceParameter.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
-
private static final Logger s_log = Logger.getLogger(ResourceParameter.class);
private Object m_default = null;
diff --git a/ccm-core/src/com/arsdigita/util/parameter/SingletonParameter.java b/ccm-core/src/com/arsdigita/util/parameter/SingletonParameter.java
index 8cbf13653..54a035519 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/SingletonParameter.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/SingletonParameter.java
@@ -31,10 +31,6 @@ import com.arsdigita.util.UncheckedWrapperException;
* @version $Id: SingletonParameter.java 738 2005-09-01 12:36:52Z sskracic $
*/
public class SingletonParameter extends ClassParameter {
- public final static String versionId =
- "$Id: SingletonParameter.java 738 2005-09-01 12:36:52Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
public SingletonParameter(final String name) {
super(name);
diff --git a/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java b/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java
index a32731910..df6d7fe94 100755
--- a/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java
+++ b/ccm-core/src/com/arsdigita/util/parameter/StringParameter.java
@@ -31,10 +31,6 @@ import org.apache.commons.beanutils.converters.StringConverter;
* @version $Id: StringParameter.java 287 2005-02-22 00:29:02Z sskracic $
*/
public class StringParameter extends AbstractParameter {
- public final static String versionId =
- "$Id: StringParameter.java 287 2005-02-22 00:29:02Z sskracic $" +
- "$Author: sskracic $" +
- "$DateTime: 2004/08/16 18:10:38 $";
static {
Converters.set(String.class, new StringConverter());
diff --git a/ccm-core/src/com/arsdigita/util/parameter/package.html b/ccm-core/src/com/arsdigita/util/parameter/package.html
index feb9554fb..333409f5c 100644
--- a/ccm-core/src/com/arsdigita/util/parameter/package.html
+++ b/ccm-core/src/com/arsdigita/util/parameter/package.html
@@ -58,6 +58,7 @@ write, and validate its own value. Parameters are
Instead, a {@link com.arsdigita.util.parameter.ParameterContext}
manages a set of parameters and keeps their values.
+
Among it's most important methods are
read to read the literal (encoded / marshaled) value (usually
diff --git a/ccm-core/src/com/arsdigita/versioning/EventType.java b/ccm-core/src/com/arsdigita/versioning/EventType.java
index b2437cc29..9356e8bf2 100755
--- a/ccm-core/src/com/arsdigita/versioning/EventType.java
+++ b/ccm-core/src/com/arsdigita/versioning/EventType.java
@@ -51,6 +51,17 @@ final class EventType {
private final static String DATA_TYPE = Constants.PDL_MODEL + ".EventType";
+ // Method initialize() should only be run once.
+ // Originally it had been controlled by the package this.initializer,
+ // which uses the old initializer system and has been commented out in
+ // enterprise.ini for a long time.
+ // As a quick replacement we introduce the variable here.
+ // Fixme: It might be necessary to controle it by the core initializer, so
+ // CCM can be restarted in a servlet container using management extension
+ // (and without restarting the container itself).
+ // (2010-01-14, as of version 6.6.0)
+ private static boolean s_hasRun = false;
+
private final BigInteger m_id;
private final String m_name;
@@ -67,13 +78,20 @@ final class EventType {
}
static void initialize() {
- if (Initializer.hasRun()) {
- throw new IllegalStateException("can't be called more than once");
+ // XXX FixMe
+ // refers to the old style initializer of the package versioning which
+ // is commented out of the enterprise.ini file (since an unkown time,
+ // currently version 1.0.5
+ // Must be dealt with internally here!
+ // if (Initializer.hasRun()) {
+ if ( s_hasRun ) {
+ throw new IllegalStateException("can't be called more than once");
}
for (Iterator ii=s_types.values().iterator(); ii.hasNext(); ) {
EventType type = (EventType) ii.next();
type.getDataObject();
}
+ s_hasRun = true;
}
synchronized DataObject getDataObject() {
diff --git a/ccm-core/src/com/arsdigita/versioning/Initializer.java b/ccm-core/src/com/arsdigita/versioning/Initializer.java.nolongerInUse
similarity index 89%
rename from ccm-core/src/com/arsdigita/versioning/Initializer.java
rename to ccm-core/src/com/arsdigita/versioning/Initializer.java.nolongerInUse
index e3738240d..2709b6bf9 100755
--- a/ccm-core/src/com/arsdigita/versioning/Initializer.java
+++ b/ccm-core/src/com/arsdigita/versioning/Initializer.java.nolongerInUse
@@ -21,6 +21,8 @@ package com.arsdigita.versioning;
import com.arsdigita.initializer.Configuration;
import com.arsdigita.initializer.InitializationException;
+import org.apache.log4j.Logger;
+
/**
* Sets up observers and initializes a few disconnected data objects needed by
* versioning.
@@ -34,6 +36,8 @@ public class Initializer implements com.arsdigita.initializer.Initializer {
private static final String DEBUG_ON = "debugInterfaceOn";
private static boolean s_hasRun = false;
+ private static final Logger s_log = Logger.getLogger(Initializer.class);
+
public Initializer() throws InitializationException {
m_conf.initParameter(DEBUG_ON,
"Enable/disable the versioning servlet.",
@@ -42,10 +46,12 @@ public class Initializer implements com.arsdigita.initializer.Initializer {
}
public Configuration getConfiguration() {
+ s_log.debug("Versioning Initializer configuration loading.");
return m_conf;
}
public void startup() throws InitializationException {
+ s_log.debug("Versioning Initializer is loading.");
EventType.initialize();
Types.initialize();
s_hasRun = true;
diff --git a/ccm-core/src/com/arsdigita/versioning/Types.java b/ccm-core/src/com/arsdigita/versioning/Types.java
index 6c3c55595..3fb0db5be 100755
--- a/ccm-core/src/com/arsdigita/versioning/Types.java
+++ b/ccm-core/src/com/arsdigita/versioning/Types.java
@@ -66,6 +66,18 @@ final class Types {
public final static Types STRING = newType(14, "java.lang.String");
public final static Types TIMESTAMP = newType(15, "java.sql.Timestamp");
+ // XXX Quickfix:
+ // Method initialize() should only be run once.
+ // Originally it had been controlled by the package this.initializer,
+ // which uses the old initializer system and has been commented out in
+ // enterprise.ini for a long time.
+ // As a quick replacement we introduce the variable here.
+ // Fixme: It might be necessary to controle it by the core initializer, so
+ // CCM can be restarted in a servlet container using management extension
+ // (and without restarting the container itself).
+ // (2010-01-14, as of version 6.6.0)
+ private static boolean s_hasRun = false;
+
private BigInteger m_id;
private String m_name;
private DataObject m_dobj;
@@ -105,13 +117,20 @@ final class Types {
}
static void initialize() {
- if (Initializer.hasRun()) {
+ // XXX FixMe
+ // refers to the old style initializer of the package versioning which
+ // is commented out of the enterprise.ini file (since an unkown time,
+ // currently version 1.0.5
+ // Must be dealt with internally here!
+ // if (Initializer.hasRun()) {
+ if ( s_hasRun ) {
throw new IllegalStateException("can't be called more than once");
}
for (Iterator ii=s_typesByID.values().iterator(); ii.hasNext(); ) {
Types type = (Types) ii.next();
type.getDataObject();
}
+ s_hasRun = true;
}
/**
diff --git a/ccm-core/src/com/arsdigita/versioning/VersioningEventProcessor.java b/ccm-core/src/com/arsdigita/versioning/VersioningEventProcessor.java
index 2a35b8510..9ff09462b 100755
--- a/ccm-core/src/com/arsdigita/versioning/VersioningEventProcessor.java
+++ b/ccm-core/src/com/arsdigita/versioning/VersioningEventProcessor.java
@@ -59,6 +59,17 @@ final class VersioningEventProcessor extends EventProcessor
private final static Logger s_log =
Logger.getLogger(VersioningEventProcessor.class);
+ // VersioningEventProcessor should only be run once.
+ // Originally it had been controlled by the package this.initializer,
+ // which uses the old initializer system and has been commented out in
+ // enterprise.ini for a long time.
+ // As a quick replacement we introduce the variable here.
+ // Fixme: It might be necessary to controle it by the core initializer, so
+ // CCM can be restarted in a servlet container using management extension
+ // (and without restarting the container itself).
+ // (2010-01-14, as of version 6.6.0)
+ private static final boolean s_hasRun = false;
+
private Event.Switch m_switch;
private VersioningTxn m_vTxn;
private boolean m_suspended;
@@ -175,7 +186,13 @@ final class VersioningEventProcessor extends EventProcessor
}
private boolean canBeIgnored(ObjectEvent ev) {
- if ( !Initializer.hasRun() ) { return true; }
+ // XXX FixMe
+ // refers to the old style initializer of the package versioning which
+ // is commented out of the enterprise.ini file (since an unkown time,
+ // currently version 1.0.5
+ // Must be dealt with internally here!
+ // if ( !Initializer.hasRun() ) { return true; }
+ if ( !s_hasRun ) { return true; }
if ( m_suspended ) { return true; }
final ObjectType objType = functions.getObjectType(ev);
diff --git a/ccm-core/src/com/arsdigita/versioning/package.html b/ccm-core/src/com/arsdigita/versioning/package.html
index 5f18b6102..55cb13d10 100755
--- a/ccm-core/src/com/arsdigita/versioning/package.html
+++ b/ccm-core/src/com/arsdigita/versioning/package.html
@@ -1,6 +1,7 @@
+ Package com.arsdigita.versioning
-<--@import url("/css/tabbed-pane/tabbed-pane.css");-->
+/* Check: Chris probably forgot the ! to comment the following lines out. */
+/* <--@import url("/css/acs-master.css");--> */
+/* <--@import url("/css/tabbed-pane/tabbed-pane.css");--> */
body {
diff --git a/ccm-zes-aplaws/web/__ccm__/themes/aplaws-generic/forum-example/forum-index.css b/ccm-zes-aplaws/web/__ccm__/themes/aplaws-generic/forum-example/forum-index.css
index 31ac138af..e5d7a7156 100644
--- a/ccm-zes-aplaws/web/__ccm__/themes/aplaws-generic/forum-example/forum-index.css
+++ b/ccm-zes-aplaws/web/__ccm__/themes/aplaws-generic/forum-example/forum-index.css
@@ -1,6 +1,7 @@
@import url("css/main.css");
-<--@import url("/css/acs-master.css");-->
-<--@import url("/css/tabbed-pane/tabbed-pane.css");-->
+/* Chris presumalby forgot the ! to cemment the following 2 lines out
+/* <--@import url("/css/acs-master.css");--> */
+/* <--@import url("/css/tabbed-pane/tabbed-pane.css");--> */
body {