Ziemlich umfangreicher Patch, der das Initializer System so modifiziert, dass alle Hintergrundprozesse beim Herunterfahren gestoppt werden und der Servlet Container sich ordnungsgemaess beenden kann. Damit ist es auch möglich, eine CCM Applikation über die Tomcat Management Applikation hoch- und runterzufahren. Das Interface initialize wurde um 2 Methoden erweitert: init(ContextInitEvent) beim Start in einem Servlet Container und close(ContextCloseIvent).
git-svn-id: https://svn.libreccm.org/ccm/trunk@324 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f36bcfd0b6
commit
3342f0dd18
|
|
@ -11,6 +11,9 @@ public class FileAttachmentConfig extends AbstractConfig {
|
||||||
Parameter editFormClass;
|
Parameter editFormClass;
|
||||||
Parameter showAssetID;
|
Parameter showAssetID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor, don't use is directly!
|
||||||
|
*/
|
||||||
public FileAttachmentConfig() {
|
public FileAttachmentConfig() {
|
||||||
editFormClass = new ClassParameter ("com.arsdigita.cms.contentassets.file_edit_form",
|
editFormClass = new ClassParameter ("com.arsdigita.cms.contentassets.file_edit_form",
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
# EventResources_de.properties
|
# EventResources_de.properties
|
||||||
# Alle deutschem Umlaute muessen als UTF-8 eingetragen werden:
|
# Alle deutschem Umlaute muessen als UTF-8 eingetragen werden:
|
||||||
# ä = \u00e4 Ä = \u00c4
|
# \u00C3\u00A4 = \u00E4 \u00C3\u0084 = \u00C4
|
||||||
# ü = \u00fc Ü = \u00dc
|
# \u00C3\u00BC = \u00FC \u00C3\u009C = \u00DC
|
||||||
# ö = \u00f6 Ö = \u00d6
|
# \u00C3\u00B6 = \u00F6 \u00C3\u0096 = \u00D6
|
||||||
# ß = \u00df
|
# \u00C3\u009F = \u00DF
|
||||||
event.authoring.basic_properties.description=Bearbeitung des Titels, Namens, Datums, Zeit, Ort, Haupt- Mitarbeiter, Typ, Link zur Karte und Kosten
|
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
|
# 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.start_time=Begin:
|
||||||
cms.contenttypes.ui.event.end_date=End-Datum:
|
cms.contenttypes.ui.event.end_date=End-Datum:
|
||||||
cms.contenttypes.ui.event.end_time=Ende:
|
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.date_description=Termin Zusatz:
|
||||||
cms.contenttypes.ui.event.location=Ort:
|
cms.contenttypes.ui.event.location=Ort:
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<title>newsitem contenttype</title>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* .
|
|
||||||
* Contains methods to simplify globalizing keys
|
* Contains methods to simplify globalizing keys
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
<ctd:content-type label="File Storage Item"
|
<ctd:content-type label="File Storage Item"
|
||||||
description="A File Storage item type"
|
description="A File Storage item type"
|
||||||
objectType="com.arsdigita.cms.contenttypes.FileStorageItem"
|
objectType="com.arsdigita.cms.contenttypes.FileStorageItem"
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||||
<!-- No need to list all the content types here. Only
|
<!-- No need to list all the content types here. Only
|
||||||
need to list a type if is adds associations that
|
need to list a type if is adds associations that
|
||||||
were not in the parent type, or to remove attributes
|
were not in the parent type, or to remove attributes
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.FileStorageItem" extends="com.arsdigita.cms.ContentPage" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.FileStorageItem"
|
||||||
|
extends="com.arsdigita.cms.ContentPage"
|
||||||
|
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
||||||
|
|
||||||
<xrd:attributes rule="exclude">
|
<xrd:attributes rule="exclude">
|
||||||
<!-- <xrd:property name="/object/file/id"/>-->
|
<!-- <xrd:property name="/object/file/id"/>-->
|
||||||
<xrd:property name="/object/file/defaultDomainClass"/>
|
<xrd:property name="/object/file/defaultDomainClass"/>
|
||||||
|
|
@ -22,11 +27,15 @@
|
||||||
<xrd:property name="/object/file"/>
|
<xrd:property name="/object/file"/>
|
||||||
</xrd:associations>
|
</xrd:associations>
|
||||||
</xrd:adapter>
|
</xrd:adapter>
|
||||||
|
|
||||||
</xrd:context>
|
</xrd:context>
|
||||||
|
|
||||||
|
|
||||||
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
|
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
|
||||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.FileStorageItem" extends="com.arsdigita.cms.ContentPage" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.FileStorageItem"
|
||||||
|
extends="com.arsdigita.cms.ContentPage"
|
||||||
|
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
||||||
|
|
||||||
<xrd:attributes rule="exclude">
|
<xrd:attributes rule="exclude">
|
||||||
<!-- <xrd:property name="/object/file/id"/> -->
|
<!-- <xrd:property name="/object/file/id"/> -->
|
||||||
<xrd:property name="/object/file/defaultDomainClass"/>
|
<xrd:property name="/object/file/defaultDomainClass"/>
|
||||||
|
|
@ -42,11 +51,14 @@
|
||||||
<xrd:property name="/object/file"/>
|
<xrd:property name="/object/file"/>
|
||||||
</xrd:associations>
|
</xrd:associations>
|
||||||
</xrd:adapter>
|
</xrd:adapter>
|
||||||
|
|
||||||
</xrd:context>
|
</xrd:context>
|
||||||
|
|
||||||
<!-- For assets, we want to pull out all HTML, or binary files -->
|
<!-- For assets, we want to pull out all HTML, or binary files -->
|
||||||
<xrd:context name="com.arsdigita.cms.search.AssetExtractor">
|
<xrd:context name="com.arsdigita.cms.search.AssetExtractor">
|
||||||
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.FileStorageItem" extends="com.arsdigita.cms.ContentPage" traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.FileStorageItem"
|
||||||
|
extends="com.arsdigita.cms.ContentPage"
|
||||||
|
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
||||||
<xrd:associations rule="include">
|
<xrd:associations rule="include">
|
||||||
<xrd:property name="/object/file"/>
|
<xrd:property name="/object/file"/>
|
||||||
</xrd:associations>
|
</xrd:associations>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<title>News Item Content Type</title>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<p>
|
<p>
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,6 @@
|
||||||
<registry>
|
<registry>
|
||||||
<config class="com.arsdigita.cms.ContentSectionConfig"
|
<config class="com.arsdigita.cms.ContentSectionConfig"
|
||||||
storage="ccm-cms/cms.properties"/>
|
storage="ccm-cms/cms.properties"/>
|
||||||
|
<config class="com.arsdigita.cms.lifecycle.LifecycleConfig"
|
||||||
|
storage="ccm-cms/lifecycle.properties"/>
|
||||||
</registry>
|
</registry>
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,10 @@ import java.math.BigDecimal;
|
||||||
*
|
*
|
||||||
* @author Jack Chung (flattop@arsdigita.com)
|
* @author Jack Chung (flattop@arsdigita.com)
|
||||||
* @version $Revision: #28 $ $Date: 2004/08/17 $
|
* @version $Revision: #28 $ $Date: 2004/08/17 $
|
||||||
|
* @version $Id: Article.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
**/
|
**/
|
||||||
public class Article extends TextPage {
|
public class Article extends TextPage {
|
||||||
|
|
||||||
public static final String versionId = "$Id: Article.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 =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.Article";
|
"com.arsdigita.cms.Article";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,18 +36,16 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class extends {@link com.arsdigita.cms.ContentItem content
|
* This class extends {@link com.arsdigita.cms.ContentItem content
|
||||||
* item} with the additional attributes name, title and description. The name
|
* item} with the additional attributes name, title and description. The name
|
||||||
* attribute is used in generating the URL for this content page.
|
* attribute is used in generating the URL for this content page.
|
||||||
*
|
*
|
||||||
* @author Uday Mathur
|
* @author Uday Mathur
|
||||||
* @author Jack Chung
|
* @author Jack Chung
|
||||||
* @author Michael Pih
|
* @author Michael Pih
|
||||||
* @version $Id: ContentPage.java 1263 2006-07-17 08:18:47Z cgyg9330 $
|
* @version $Id: ContentPage.java 1263 2006-07-17 08:18:47Z cgyg9330 $
|
||||||
*/
|
*/
|
||||||
public class ContentPage extends ContentItem {
|
public class ContentPage extends ContentItem {
|
||||||
|
|
||||||
public static final String versionId = "$Id: ContentPage.java 1263 2006-07-17 08:18:47Z cgyg9330 $ by $Author: cgyg9330 $, $DateTime: 2004/08/17 23:15:09 $";
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ContentPage.class);
|
private static final Logger s_log = Logger.getLogger(ContentPage.class);
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
|
|
@ -56,8 +54,8 @@ public class ContentPage extends ContentItem {
|
||||||
public static final String TITLE = "title";
|
public static final String TITLE = "title";
|
||||||
public static final String SUMMARY = "summary";
|
public static final String SUMMARY = "summary";
|
||||||
public static final String LAUNCH_DATE = "launchDate";
|
public static final String LAUNCH_DATE = "launchDate";
|
||||||
public static final String DESCRIPTION = "pageDescription";
|
public static final String DESCRIPTION = "pageDescription";
|
||||||
|
|
||||||
|
|
||||||
protected static final String PAGES_IN_FOLDER =
|
protected static final String PAGES_IN_FOLDER =
|
||||||
"com.arsdigita.cms.pagesInFolder";
|
"com.arsdigita.cms.pagesInFolder";
|
||||||
|
|
@ -149,37 +147,37 @@ public class ContentPage extends ContentItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decides whether plugged in assets should be indexed with the
|
* Decides whether plugged in assets should be indexed with the
|
||||||
* page or separately. Default is false (assets are ONLY indexed
|
* page or separately. Default is false (assets are ONLY indexed
|
||||||
* as separate items) Subtypes may override this method to
|
* as separate items) Subtypes may override this method to
|
||||||
* provide the logic that decides whether or not assets should
|
* provide the logic that decides whether or not assets should
|
||||||
* be indexed separately. If true, content of assets is ONLY
|
* be indexed separately. If true, content of assets is ONLY
|
||||||
* included in the page, not as a separate item. This method only provides
|
* included in the page, not as a separate item. This method only provides
|
||||||
* guidance to assets. Writers of plug in assets should
|
* guidance to assets. Writers of plug in assets should
|
||||||
* refer to this method in relation to the object that
|
* refer to this method in relation to the object that
|
||||||
* owns the asset and make a decision based on the answer.
|
* owns the asset and make a decision based on the answer.
|
||||||
*
|
*
|
||||||
* Best course of action is for assets to provide their
|
* Best course of action is for assets to provide their
|
||||||
* own MetadataProvider which refers to this method in the
|
* own MetadataProvider which refers to this method in the
|
||||||
* indexObject method eg.
|
* indexObject method eg.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
<pre>
|
<pre>
|
||||||
public boolean indexObject (DomainObject dobj) {
|
public boolean indexObject (DomainObject dobj) {
|
||||||
FileAttachment file = (FileAttachment) dobj;
|
FileAttachment file = (FileAttachment) dobj;
|
||||||
ContentPage owner = (ContentPage) file.getFileOwner();
|
ContentPage owner = (ContentPage) file.getFileOwner();
|
||||||
s_log.debug("index this file attachment? " + !owner.indexAssetsWithPage());
|
s_log.debug("index this file attachment? " + !owner.indexAssetsWithPage());
|
||||||
return !owner.indexAssetsWithPage();
|
return !owner.indexAssetsWithPage();
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean indexAssetsWithPage() {
|
public boolean indexAssetsWithPage() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ContentBundle getContentBundle() {
|
public final ContentBundle getContentBundle() {
|
||||||
final ACSObject parent = getParent();
|
final ACSObject parent = getParent();
|
||||||
|
|
||||||
|
|
@ -206,12 +204,12 @@ public class ContentPage extends ContentItem {
|
||||||
set(LAUNCH_DATE, ldate);
|
set(LAUNCH_DATE, ldate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(String description) {
|
||||||
set(DESCRIPTION, description);
|
set(DESCRIPTION, description);
|
||||||
}
|
}
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return (String)get(DESCRIPTION);
|
return (String)get(DESCRIPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set parameters on the pagesInFolder data query
|
// 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
|
// These could be protected, but public may make it easier to
|
||||||
// debug
|
// debug
|
||||||
/**
|
/**
|
||||||
* default behaviour is to return the description. Subtypes should
|
* default behaviour is to return the description. Subtypes should
|
||||||
* override to change use some other attribute
|
* override to change use some other attribute
|
||||||
*/
|
*/
|
||||||
public String getSearchSummary() {
|
public String getSearchSummary() {
|
||||||
return getDescription();
|
return getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,6 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Id: ContentSectionConfig.java 1689 2007-10-26 11:06:23Z chrisg23 $
|
* @version $Id: ContentSectionConfig.java 1689 2007-10-26 11:06:23Z chrisg23 $
|
||||||
*/
|
*/
|
||||||
public final class ContentSectionConfig extends AbstractConfig {
|
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);
|
private static final Logger s_log = Logger.getLogger(ContentSectionConfig.class);
|
||||||
|
|
||||||
|
|
@ -160,9 +156,7 @@ public final class ContentSectionConfig extends AbstractConfig {
|
||||||
* @see ContentSection#getConfig()
|
* @see ContentSection#getConfig()
|
||||||
**/
|
**/
|
||||||
public ContentSectionConfig() {
|
public ContentSectionConfig() {
|
||||||
m_templateRootPath = new StringParameter
|
|
||||||
("com.arsdigita.cms.template_root_path",
|
|
||||||
Parameter.REQUIRED, "/packages/content-section/templates");
|
|
||||||
m_defaultItemTemplatePath = new StringParameter
|
m_defaultItemTemplatePath = new StringParameter
|
||||||
("com.arsdigita.cms.default_item_template_path",
|
("com.arsdigita.cms.default_item_template_path",
|
||||||
Parameter.REQUIRED, "/default/item.jsp");
|
Parameter.REQUIRED, "/default/item.jsp");
|
||||||
|
|
@ -172,11 +166,6 @@ public final class ContentSectionConfig extends AbstractConfig {
|
||||||
m_languages = new StringParameter
|
m_languages = new StringParameter
|
||||||
("com.arsdigita.cms.languages",
|
("com.arsdigita.cms.languages",
|
||||||
Parameter.REQUIRED, "en,de,fr,nl,it,pt,es");
|
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
|
m_linksOnlyInSameSubsite = new BooleanParameter
|
||||||
("com.arsdigita.cms.browse_links_in_same_subsite_only",
|
("com.arsdigita.cms.browse_links_in_same_subsite_only",
|
||||||
|
|
@ -211,12 +200,9 @@ public final class ContentSectionConfig extends AbstractConfig {
|
||||||
ItemCategoryForm.class,
|
ItemCategoryForm.class,
|
||||||
SimpleComponent.class);
|
SimpleComponent.class);
|
||||||
|
|
||||||
// XXX: temporary parameter. will be removed when MapParameter
|
m_templateRootPath = new StringParameter
|
||||||
// works and the p2fs initializer is converted away from the
|
("com.arsdigita.cms.template_root_path",
|
||||||
// legacy init
|
Parameter.REQUIRED, "/packages/content-section/templates");
|
||||||
m_disableItemPfs = new BooleanParameter
|
|
||||||
("com.arsdigita.cms.disable_item_pfs",
|
|
||||||
Parameter.REQUIRED, new Boolean(false));
|
|
||||||
|
|
||||||
// XXX: temporary parameter. will be removed when
|
// XXX: temporary parameter. will be removed when
|
||||||
// SectionInitializer is replaced with a separate Section
|
// SectionInitializer is replaced with a separate Section
|
||||||
|
|
@ -374,10 +360,6 @@ public final class ContentSectionConfig extends AbstractConfig {
|
||||||
("com.arsdigita.cms.mandatory_descriptions",
|
("com.arsdigita.cms.mandatory_descriptions",
|
||||||
Parameter.OPTIONAL, new Boolean(false));
|
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
|
m_deleteExpiryNotificationsWhenSent = new BooleanParameter
|
||||||
("com.arsdigita.cms.delete_expiry_notification_when_sent",
|
("com.arsdigita.cms.delete_expiry_notification_when_sent",
|
||||||
Parameter.OPTIONAL, new Boolean(false));
|
Parameter.OPTIONAL, new Boolean(false));
|
||||||
|
|
@ -409,6 +391,27 @@ public final class ContentSectionConfig extends AbstractConfig {
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
new Boolean(true));
|
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_templateRootPath);
|
||||||
register(m_defaultItemTemplatePath);
|
register(m_defaultItemTemplatePath);
|
||||||
register(m_defaultFolderTemplatePath);
|
register(m_defaultFolderTemplatePath);
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,10 @@ import java.net.MalformedURLException;
|
||||||
*
|
*
|
||||||
* @author Michael Pih (pihman@arsdigita.com)
|
* @author Michael Pih (pihman@arsdigita.com)
|
||||||
* @author Jack Chung (flattop@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 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 =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.ContentType";
|
"com.arsdigita.cms.ContentType";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,11 @@ public class Initializer extends CompoundInitializer {
|
||||||
("ccm-cms.pdl.mf",
|
("ccm-cms.pdl.mf",
|
||||||
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
|
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"));
|
add(new LegacyInitializer("com/arsdigita/cms/enterprise.init"));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,6 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Id: Loader.java 754 2005-09-02 13:26:17Z sskracic $
|
* @version $Id: Loader.java 754 2005-09-02 13:26:17Z sskracic $
|
||||||
*/
|
*/
|
||||||
public class Loader extends PackageLoader {
|
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);
|
private static final Logger s_log = Logger.getLogger(Loader.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ import java.util.StringTokenizer;
|
||||||
|
|
||||||
public class SearchFormatter {
|
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
|
* A list of all the special characters which will
|
||||||
* be filtered out
|
* be filtered out
|
||||||
|
|
@ -111,7 +109,7 @@ public class SearchFormatter {
|
||||||
* and to the left of each keyword
|
* and to the left of each keyword
|
||||||
*/
|
*/
|
||||||
public static String createIntermediaClause(
|
public static String createIntermediaClause(
|
||||||
String words, String joinClause, String wildcard
|
String words, String joinClause, String wildcard
|
||||||
) {
|
) {
|
||||||
|
|
||||||
StringTokenizer tokenizer = new StringTokenizer(words, SPECIAL_CHARS);
|
StringTokenizer tokenizer = new StringTokenizer(words, SPECIAL_CHARS);
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,10 @@ import java.math.BigDecimal;
|
||||||
* @author Jack Chung (flattop@arsdigita.com)
|
* @author Jack Chung (flattop@arsdigita.com)
|
||||||
* @author Michael Pih (pihman@arsdigita.com)
|
* @author Michael Pih (pihman@arsdigita.com)
|
||||||
* @version $Revision: #20 $ $DateTime: 2004/08/17 23:15:09 $
|
* @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 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 =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.cms.TextPage";
|
"com.arsdigita.cms.TextPage";
|
||||||
|
|
||||||
|
|
@ -44,7 +43,7 @@ public class TextPage extends ContentPage {
|
||||||
|
|
||||||
|
|
||||||
protected static final int SUMMARY_SIZE = 1024;
|
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);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public abstract class ContentTypeInitializer extends CompoundInitializer {
|
||||||
public static final String[] EMPTY_ARRAY = new String[0];
|
public static final String[] EMPTY_ARRAY = new String[0];
|
||||||
|
|
||||||
protected ContentTypeInitializer(final String manifestFile,
|
protected ContentTypeInitializer(final String manifestFile,
|
||||||
final String objectType) {
|
final String objectType) {
|
||||||
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
||||||
final int database = DbHelper.getDatabaseFromURL(url);
|
final int database = DbHelper.getDatabaseFromURL(url);
|
||||||
|
|
||||||
|
|
@ -53,6 +53,10 @@ public abstract class ContentTypeInitializer extends CompoundInitializer {
|
||||||
m_objectType = objectType;
|
m_objectType = objectType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param evt Type of initialization
|
||||||
|
*/
|
||||||
public void init(LegacyInitEvent evt) {
|
public void init(LegacyInitEvent evt) {
|
||||||
super.init(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() {
|
public String getTraversalXML() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should be overwritten by each content types initializer to provide the
|
||||||
|
* correct location of is stylesheets.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String[] getStylesheets() {
|
public String[] getStylesheets() {
|
||||||
return EMPTY_ARRAY;
|
return EMPTY_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
// List of publish destinations for content types
|
||||||
// Each element is a four-element list in the format
|
// Each element is a four-element list in the format
|
||||||
// '{ "content type", "root directory", "shared storage",
|
// '{ "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"
|
// directory is shared NFS storage, _false_ otherwise. "URL stub"
|
||||||
// must be the path component of the URL from which the live server
|
// must be the path component of the URL from which the live server
|
||||||
// will serve from this directory.
|
// will serve from this directory.
|
||||||
destination = {
|
//-- destination = {
|
||||||
{ "com.arsdigita.cms.ContentItem",
|
//-- { "com.arsdigita.cms.ContentItem",
|
||||||
"p2fs",
|
//-- "p2fs",
|
||||||
false,
|
//-- false,
|
||||||
"/p2fs" },
|
//-- "/p2fs" },
|
||||||
// (pboy): starting with webapps refers to the CCM_HOME env variable which
|
// (pboy): starting with webapps refers to the CCM_HOME env variable which
|
||||||
// points to the installation root of the servlet container. This is not
|
// points to the installation root of the servlet container. This is not
|
||||||
// used anymore, all specifications are relative to webapplication base.
|
// used anymore, all specifications are relative to webapplication base.
|
||||||
// So the following may have to be changed to "packages/content-section/templates"
|
// So the following may have to be changed to "packages/content-section/templates"
|
||||||
// if someone tries to use p2fs
|
// if someone tries to use p2fs
|
||||||
{ "com.arsdigita.cms.Template",
|
//-- { "com.arsdigita.cms.Template",
|
||||||
// "webapps/ROOT/packages/content-section/templates",
|
//-- // "webapps/ROOT/packages/content-section/templates",
|
||||||
"packages/content-section/templates",
|
//-- "packages/content-section/templates",
|
||||||
false,
|
//-- false,
|
||||||
"/templates" }
|
//-- "/templates" }
|
||||||
};
|
//-- };
|
||||||
|
|
||||||
// Class which implements PublishToFileListener used to perform
|
// Class which implements PublishToFileListener used to perform
|
||||||
// additional actions when publishing or unpublishing to the file system.
|
// 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.
|
// Queue management parameters.
|
||||||
|
|
||||||
// Set startupDelay to 0 to disable the processing of the queue
|
// Set startupDelay to 0 to disable the processing of the queue
|
||||||
// Time (seconds) before starting to monitor the
|
// Time (seconds) before starting to monitor the
|
||||||
// queue after a server start
|
// queue after a server start
|
||||||
startupDelay = 30;
|
//-- startupDelay = 30;
|
||||||
|
|
||||||
// Time (in seconds) between checking if there are entries in the
|
// Time (in seconds) between checking if there are entries in the
|
||||||
// publishToFile queue.
|
// publishToFile queue.
|
||||||
// A value <= 0 disables processing the queue on this server.
|
// A value <= 0 disables processing the queue on this server.
|
||||||
pollDelay = 5;
|
//-- pollDelay = 5;
|
||||||
|
|
||||||
// Time to wait (seconds) before retrying
|
// Time to wait (seconds) before retrying
|
||||||
// to process a failed entry
|
// to process a failed entry
|
||||||
retryDelay = 120;
|
//-- retryDelay = 120;
|
||||||
|
|
||||||
// Number of queue entries to process at once.
|
// Number of queue entries to process at once.
|
||||||
blockSize = 40;
|
//-- blockSize = 40;
|
||||||
// Number of times a failed queue entry will be
|
// Number of times a failed queue entry will be
|
||||||
// reprocessed. If processing has failed more than
|
// reprocessed. If processing has failed more than
|
||||||
// that number of times, the entry will be
|
// that number of times, the entry will be
|
||||||
// ignored.
|
// ignored.
|
||||||
maximumFailCount = 10;
|
//-- maximumFailCount = 10;
|
||||||
|
|
||||||
// Method used to select entries for processing.
|
// Method used to select entries for processing.
|
||||||
// 'QueuedOrder'-in queued order.
|
// 'QueuedOrder'-in queued order.
|
||||||
// 'GroupByParent'-group entries according to parent when selecting items
|
// 'GroupByParent'-group entries according to parent when selecting items
|
||||||
// (allows optimizations if a listener task required for all elements in a folder
|
// (allows optimizations if a listener task required for all elements in a folder
|
||||||
// can be done only once for the folder).
|
// can be done only once for the folder).
|
||||||
blockSelectMethod = "GroupByParent";
|
//-- blockSelectMethod = "GroupByParent";
|
||||||
}
|
//-- }
|
||||||
|
|
||||||
|
|
||||||
init com.arsdigita.cms.installer.SectionInitializer {
|
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
|
//Used when running CMS in conjunction with a Portal
|
||||||
init com.arsdigita.cms.installer.portlet.Initializer {}
|
init com.arsdigita.cms.installer.portlet.Initializer {}
|
||||||
|
|
||||||
|
|
@ -393,3 +374,35 @@ init com.arsdigita.cms.installer.portlet.Initializer {}
|
||||||
// numUsers = 10;
|
// 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"
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,11 @@ import java.util.Timer;
|
||||||
* @author Daniel Berrange (berrange@redhat.com)
|
* @author Daniel Berrange (berrange@redhat.com)
|
||||||
* @author Michael Pih
|
* @author Michael Pih
|
||||||
* @version $Revision: #43 $ $DateTime: 2004/08/17 23:15:09 $
|
* @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 {
|
public class SectionInitializer extends com.arsdigita.kernel.BaseInitializer {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
|
@ -18,72 +18,74 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.cms.lifecycle;
|
package com.arsdigita.cms.lifecycle;
|
||||||
|
|
||||||
import com.arsdigita.initializer.Configuration;
|
import com.arsdigita.runtime.ContextInitEvent;
|
||||||
import com.arsdigita.initializer.InitializationException;
|
import com.arsdigita.runtime.ContextCloseEvent;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the scheduler thread to fire all the events for the
|
* Initializes the Lifecycle package.
|
||||||
* lifecycles or phases that have just began or ended.
|
|
||||||
*
|
*
|
||||||
* Where the initializer is registered, you need to include the
|
* Initializes the scheduler thread to fire all the events for the lifecycles
|
||||||
* delay and frequency in seconds
|
* 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
|
// Creates a s_logging category with name = to the full name of class
|
||||||
implements com.arsdigita.initializer.Initializer {
|
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() {
|
public Initializer() {
|
||||||
return m_conf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on startup.
|
* Implementation of the {@link Initializer#init(ContextInitEvent)}
|
||||||
**/
|
* method.
|
||||||
public void startup() {
|
*
|
||||||
|
* 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();
|
LifecycleConfig conf = LifecycleConfig.getConfig();
|
||||||
long frequency = ((Integer) m_conf.getParameter("frequency")).longValue();
|
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) {
|
if (delay > 0) {
|
||||||
Scheduler.s_timerDelay = delay * (long) 1000;
|
Scheduler.setTimerDelay(delay);
|
||||||
Scheduler.s_timerFrequency = frequency * (long) 1000;
|
Scheduler.setTimerFrequency(frequency);
|
||||||
Scheduler.startTimer();
|
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 close(ContextCloseEvent evt) {
|
||||||
public void shutdown() {
|
|
||||||
Scheduler.stopTimer();
|
Scheduler.stopTimer();
|
||||||
|
s_log.debug("lifecycle background processing stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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]
|
||||||
|
|
@ -44,17 +44,16 @@ import org.apache.log4j.Logger;
|
||||||
* @author Stanislav Freidin (stas@arsdigita.com)
|
* @author Stanislav Freidin (stas@arsdigita.com)
|
||||||
* @author Michael Pih (pihman@arsdigita.com)
|
* @author Michael Pih (pihman@arsdigita.com)
|
||||||
* @version $Revision: #20 $ $DateTime: 2004/08/17 23:15:09 $
|
* @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 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 CYCLE_ID = "cycleId";
|
||||||
private static final String PHASE_ID = "phaseId";
|
private static final String PHASE_ID = "phaseId";
|
||||||
|
|
||||||
// Time in milliseconds
|
// Time in milliseconds
|
||||||
protected static long s_timerDelay;
|
private static long s_timerDelay;
|
||||||
protected static long s_timerFrequency;
|
private static long s_timerFrequency;
|
||||||
|
|
||||||
// For storing timer which runs a method periodically to fire
|
// For storing timer which runs a method periodically to fire
|
||||||
// begin and end events
|
// begin and end events
|
||||||
|
|
@ -62,8 +61,7 @@ public class Scheduler {
|
||||||
private static boolean s_running = false;
|
private static boolean s_running = false;
|
||||||
|
|
||||||
// Creates a s_logging category with name = to the full name of class
|
// Creates a s_logging category with name = to the full name of class
|
||||||
private static Logger s_log =
|
private static Logger s_log = Logger.getLogger( Scheduler.class.getName() );
|
||||||
Logger.getLogger( Scheduler.class.getName() );
|
|
||||||
|
|
||||||
// A noop listener used when the listener in the DB is null. This ensures
|
// 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
|
// that lifecycles and phases with no listener are still properly marked
|
||||||
|
|
@ -74,6 +72,22 @@ public class Scheduler {
|
||||||
public void end(LifecycleEvent e) { }
|
public void end(LifecycleEvent e) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets timer startup delay to <i>delay</i> 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 <i>freq</i> 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
|
* startTimer - starts the timer
|
||||||
*/
|
*/
|
||||||
|
|
@ -115,12 +129,12 @@ public class Scheduler {
|
||||||
|
|
||||||
txn = SessionManager.getSession().getTransactionContext();
|
txn = SessionManager.getSession().getTransactionContext();
|
||||||
|
|
||||||
// Notes: loop through the query and add the objects to the LinkedList
|
// Notes: loop through the query and add the objects to the
|
||||||
// then for each object in the LinkedList:
|
// LinkedList then for each object in the LinkedList:
|
||||||
// begin the transaction,
|
// - begin the transaction,
|
||||||
// perform any operations from the listener,
|
// - perform any operations from the listener,
|
||||||
// update the hasBegun or hasEnded column, and
|
// - update the hasBegun or hasEnded column, and
|
||||||
// close the transaction (or abort if there are any errors)
|
// - close the transaction (or abort if there are any errors)
|
||||||
|
|
||||||
// Lifecycle Start Events
|
// Lifecycle Start Events
|
||||||
txn.beginTxn();
|
txn.beginTxn();
|
||||||
|
|
@ -273,7 +287,7 @@ public class Scheduler {
|
||||||
* Returns an iterator of pending events.
|
* Returns an iterator of pending events.
|
||||||
*/
|
*/
|
||||||
private static synchronized Iterator getPendingEvents(
|
private static synchronized Iterator getPendingEvents(
|
||||||
DataQuery query, int eventType, String idColumn
|
DataQuery query, int eventType, String idColumn
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
LinkedList rowList = new LinkedList();
|
LinkedList rowList = new LinkedList();
|
||||||
|
|
@ -320,7 +334,10 @@ public class Scheduler {
|
||||||
cycle = new Lifecycle(id);
|
cycle = new Lifecycle(id);
|
||||||
} catch (DataObjectNotFoundException e) {
|
} catch (DataObjectNotFoundException e) {
|
||||||
txn.abortTxn();
|
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 {
|
try {
|
||||||
|
|
@ -333,10 +350,11 @@ public class Scheduler {
|
||||||
listener.end(event);
|
listener.end(event);
|
||||||
cycle.stop();
|
cycle.stop();
|
||||||
if (ContentSection.getConfig().deleteFinishedLifecycles()) {
|
if (ContentSection.getConfig().deleteFinishedLifecycles()) {
|
||||||
// this seems to be the best place to do this - after any other
|
// this seems to be the best place to do this - after
|
||||||
// activities associated with the end of the cycle have been
|
// any other activities associated with the end of the
|
||||||
// completed
|
// cycle have been completed
|
||||||
s_log.debug("Lifecycle " + cycle.getID() + " has ended - now deleting it");
|
s_log.debug("Lifecycle " + cycle.getID() +
|
||||||
|
" has ended - now deleting it");
|
||||||
cycle.delete();
|
cycle.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -348,8 +366,8 @@ public class Scheduler {
|
||||||
txn.commitTxn();
|
txn.commitTxn();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
txn.abortTxn();
|
txn.abortTxn();
|
||||||
// TODO: Shouldn't this re-throw? The transaction is aborted, so some other error
|
// TODO: Shouldn't this re-throw? The transaction is aborted,
|
||||||
// will occur...
|
// so some other error will occur...
|
||||||
s_log.error( "Error in LifecycleEvent: " + e.getMessage(), e);
|
s_log.error( "Error in LifecycleEvent: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +397,10 @@ public class Scheduler {
|
||||||
phase = new Phase(phaseID);
|
phase = new Phase(phaseID);
|
||||||
} catch (DataObjectNotFoundException e) {
|
} catch (DataObjectNotFoundException e) {
|
||||||
txn.abortTxn();
|
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 {
|
try {
|
||||||
|
|
@ -394,8 +415,8 @@ public class Scheduler {
|
||||||
txn.commitTxn();
|
txn.commitTxn();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
txn.abortTxn();
|
txn.abortTxn();
|
||||||
// TODO: Shouldn't this re-throw? The transaction is aborted, so some other error
|
// TODO: Shouldn't this re-throw? The transaction is aborted,
|
||||||
// will occur...
|
// so some other error will occur...
|
||||||
s_log.error("Error in LifecycleEvent: " + e.getMessage(), e);
|
s_log.error("Error in LifecycleEvent: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,17 +25,19 @@ import java.util.TimerTask;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The SchedulerTask class provides the method that is scheduled
|
* The SchedulerTask class provides the method that is scheduled by the timer
|
||||||
* by the timer created by Scheduler. It simply calls the
|
* created by Scheduler. It simply calls the run method of Scheduler.
|
||||||
* run method of Scheduler.
|
|
||||||
*
|
*
|
||||||
* @author Jack Chung (flattop@arsdigita.com)
|
* @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 {
|
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);
|
private static final Logger s_log = Logger.getLogger(SchedulerTask.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Scheduler.run();
|
Scheduler.run();
|
||||||
|
|
|
||||||
|
|
@ -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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* 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
|
* 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.db.DbHelper;
|
||||||
import com.arsdigita.cms.Template;
|
import com.arsdigita.runtime.CompoundInitializer;
|
||||||
|
import com.arsdigita.runtime.ContextCloseEvent;
|
||||||
import com.arsdigita.initializer.Configuration;
|
import com.arsdigita.runtime.DataInitEvent;
|
||||||
import com.arsdigita.initializer.InitializationException;
|
import com.arsdigita.runtime.DomainInitEvent;
|
||||||
|
import com.arsdigita.runtime.LegacyInitEvent;
|
||||||
import com.arsdigita.domain.DomainObject;
|
import com.arsdigita.runtime.LegacyInitializer;
|
||||||
import com.arsdigita.domain.DomainObjectInstantiator;
|
import com.arsdigita.runtime.RuntimeConfig;
|
||||||
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 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 CMS PublishT0File initializer.
|
||||||
* the {@link com.arsdigita.cms.publishToFile} page.
|
|
||||||
*
|
*
|
||||||
* (pboy) ToDo: Adjusting the initialisation to the new configuration method
|
* Initializer is invoked by the add-method in the CMS initializer.
|
||||||
* without enterprise.init file.
|
|
||||||
*
|
*
|
||||||
* @author Jeff Teeters (teeters@arsdigita.com)
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Revision: #24 $ $Date: 2004/08/17 $
|
* @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 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 {
|
public void init(DataInitEvent evt) {
|
||||||
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
|
* 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,
|
* Implementation of the {@link Initializer#close()} method.
|
||||||
"publish destinations entry must contain " +
|
*
|
||||||
"four elements: '{ \n" +
|
* This implementation proceeds through the list of sub
|
||||||
" \"content type\",\n" +
|
* initializers in order and invokes the close()
|
||||||
" \"root directory\", \n" +
|
* method of each sub initializer in turn.
|
||||||
" \"is shared\", \n" +
|
*
|
||||||
" \"url stub\" \n" +
|
* @param evt The legacy init event.
|
||||||
"};\n");
|
**/
|
||||||
}
|
public void close(ContextCloseEvent evt) {
|
||||||
|
s_log.info("publishToFile.Initializer.destroy() invoked");
|
||||||
|
|
||||||
String contentType = (String)entry.get(0);
|
QueueManager.stopWatchingQueue();
|
||||||
// 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) {
|
s_log.info("publishToFile.Initializer.destroy() completed");
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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]
|
||||||
|
|
@ -65,8 +65,7 @@ import java.io.File;
|
||||||
public class QueueManager implements Runnable {
|
public class QueueManager implements Runnable {
|
||||||
|
|
||||||
// Creates a s_logging category with name = to the full name of class
|
// Creates a s_logging category with name = to the full name of class
|
||||||
private static Logger s_log =
|
private static Logger s_log = Logger.getLogger(QueueManager.class);
|
||||||
Logger.getLogger(QueueManager.class);
|
|
||||||
|
|
||||||
// Should probably use these constants. Are hardcoded for now because
|
// Should probably use these constants. Are hardcoded for now because
|
||||||
// matches DataQuery suffex.
|
// matches DataQuery suffex.
|
||||||
|
|
@ -91,6 +90,15 @@ public class QueueManager implements Runnable {
|
||||||
// Class implementing methods run when publishing or unpublishing to file.
|
// Class implementing methods run when publishing or unpublishing to file.
|
||||||
private static PublishToFileListener s_publishListener = null;
|
private static PublishToFileListener s_publishListener = null;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Constructor related code.
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param startupDelay
|
||||||
|
* @param pollDelay
|
||||||
|
*/
|
||||||
private QueueManager(int startupDelay, int pollDelay) {
|
private QueueManager(int startupDelay, int pollDelay) {
|
||||||
m_startupDelay = startupDelay;
|
m_startupDelay = startupDelay;
|
||||||
m_pollDelay = pollDelay;
|
m_pollDelay = pollDelay;
|
||||||
|
|
@ -445,15 +453,19 @@ public class QueueManager implements Runnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop watching and processing the queue. The background thread that
|
* Stop watching and processing the queue. The background thread that
|
||||||
* processes the queue will terminate after this method has been called.
|
* processes the queue will terminate after this method has been
|
||||||
* Termination is not immediate, since the queue may be in the middle of
|
* called. Termination is not immediate, since the queue may be in the
|
||||||
* processing a block of entries.
|
* middle of processing a block of entries.
|
||||||
*/
|
*/
|
||||||
public static void stopWatchingQueue() {
|
public static void stopWatchingQueue() {
|
||||||
if (s_log.isInfoEnabled()) {
|
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_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();
|
HashSet failedItems = new HashSet();
|
||||||
|
|
||||||
while ( sleep(m_pollDelay) && s_keepWatchingQueue ) {
|
while ( sleep(m_pollDelay) && s_keepWatchingQueue ) {
|
||||||
// synchronized( Scheduler.class ) {
|
// synchronized( Scheduler.class ) {
|
||||||
//while there are more entries in queue process them.HashSet
|
//while there are more entries in queue process them.HashSet
|
||||||
//is used to store the failed items and for checking that
|
//is used to store the failed items and for checking that
|
||||||
//they do not get processed again.
|
//they do not get processed again.
|
||||||
|
|
@ -479,8 +491,9 @@ public class QueueManager implements Runnable {
|
||||||
|
|
||||||
// clear failed items
|
// clear failed items
|
||||||
failedItems.clear();
|
failedItems.clear();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
// }
|
s_log.info("Start polling queue in " + m_startupDelay + "s.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
|
|
||||||
|
|
@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Package com.arsdigita.cms.revision.ui</title>
|
||||||
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<p>
|
<p>
|
||||||
Provides UI components for administering and displaying the
|
Provides UI components for administering and displaying the
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
<body bgcolor="white">
|
<head>
|
||||||
|
<title>Public User Interface</title>
|
||||||
|
</head>
|
||||||
|
<body bgcolor="#FFFFFF" >
|
||||||
<p>
|
<p>
|
||||||
UI components for publically-facing pages (i.e., pages that
|
UI components for publically-facing pages (i.e., pages that
|
||||||
display content outside of the CMS administration UI).
|
display content outside of the CMS administration UI).
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<title>Module ccm-cms / package com.arsdigita.cms.ui.util</title>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
name="ccm-core"
|
name="ccm-core"
|
||||||
prettyName="Core"
|
prettyName="Core"
|
||||||
version="6.6.0"
|
version="6.6.0"
|
||||||
release="1"
|
release="2"
|
||||||
shared="true"
|
shared="true"
|
||||||
webapp="ROOT"
|
webapp="ROOT"
|
||||||
buildHooks="build-hooks.xml">
|
buildHooks="build-hooks.xml">
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
-- You should have received a copy of the GNU Lesser General Public
|
-- You should have received a copy of the GNU Lesser General Public
|
||||||
-- License along with this library; if not, write to the Free Software
|
-- License along with this library; if not, write to the Free Software
|
||||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
--
|
||||||
|
-- $Id: oracle-se-create.sql 1704 2008-06-08 14:45:43Z pboy $
|
||||||
|
-- $DateTime: 2004/08/16 18:10:38 $
|
||||||
|
|
||||||
@@ oracle-se/function-currentDate.sql
|
@@ oracle-se/function-currentDate.sql
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@
|
||||||
storage="ccm-core/search.properties"/>
|
storage="ccm-core/search.properties"/>
|
||||||
<config class="com.arsdigita.search.lucene.LuceneConfig"
|
<config class="com.arsdigita.search.lucene.LuceneConfig"
|
||||||
storage="ccm-core/lucene.properties"/>
|
storage="ccm-core/lucene.properties"/>
|
||||||
|
<config class="com.arsdigita.search.intermedia.IntermediaConfig"
|
||||||
|
storage="ccm-core/intermedia.properties"/>
|
||||||
<config class="com.arsdigita.templating.TemplatingConfig"
|
<config class="com.arsdigita.templating.TemplatingConfig"
|
||||||
storage="ccm-core/templating.properties"/>
|
storage="ccm-core/templating.properties"/>
|
||||||
<config class="com.arsdigita.versioning.VersioningConfig"
|
<config class="com.arsdigita.versioning.VersioningConfig"
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,11 @@ import com.arsdigita.bebop.util.BebopConstants;
|
||||||
*/
|
*/
|
||||||
public class TextArea extends Widget implements BebopConstants {
|
public class TextArea extends Widget implements BebopConstants {
|
||||||
|
|
||||||
public static final String versionId = "$Id: TextArea.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for specifying <tt>OFF</tt> value for the
|
* Constant for specifying <tt>OFF</tt> value for the
|
||||||
* <tt>WRAP</tt> attribute of this image input. See <a
|
* <tt>WRAP</tt> attribute of this image input. See <a
|
||||||
* href="http://developer.netscape.com/docs/manuals/htmlguid/tags10.htm#1340340">here</a>
|
* href="http://developer.netscape.com/docs/manuals/htmlguid/tags10.htm#1340340">here</a>
|
||||||
* for a description of what this attribute does. */
|
* for a description of what this attribute does. */
|
||||||
|
|
||||||
public static final int OFF = 0;
|
public static final int OFF = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,7 +124,7 @@ public class TextArea extends Widget implements BebopConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the <tt>COLS</tt> attribute for the <tt>TEXTAREA</tt> tag.
|
* Sets the <tt>WRAP</tt> attribute for the <tt>TEXTAREA</tt> tag.
|
||||||
*/
|
*/
|
||||||
public void setWrap(int wrap) {
|
public void setWrap(int wrap) {
|
||||||
String wrapString = null;
|
String wrapString = null;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Bebop Forms API</title>
|
<title>ccm-core: forms</title>
|
||||||
</head>
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
|
<p>
|
||||||
Provides a set of server-side user interface components for obtaining
|
Provides a set of server-side user interface components for obtaining
|
||||||
user input. These components are based on HTML forms.
|
user input. These components are based on HTML forms.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@
|
||||||
all the requests to the page. This initialization is typically
|
all the requests to the page. This initialization is typically
|
||||||
done in the <code>init</code> method of a servlet. Classes that
|
done in the <code>init</code> method of a servlet. Classes that
|
||||||
contain only static information implement the interface {@link
|
contain only static information implement the interface {@link
|
||||||
com.arsdigita.bebop.util.Lockable}.</P>
|
com.arsdigita.bebop.util.Lockable}.</p>
|
||||||
<P>Request-specific data structures
|
<p>Request-specific data structures
|
||||||
are built within the <code>doPost</code> or <code>doGet</code>
|
are built within the <code>doPost</code> or <code>doGet</code>
|
||||||
methods of a servlet. Corresponding to the static <code>Page</code>,
|
methods of a servlet. Corresponding to the static <code>Page</code>,
|
||||||
there is a {@link com.arsdigita.bebop.PageState} class that will
|
there is a {@link com.arsdigita.bebop.PageState} class that will
|
||||||
|
|
@ -101,7 +101,7 @@
|
||||||
<p> The {@link com.arsdigita.bebop.Page#process Page.process} method
|
<p> The {@link com.arsdigita.bebop.Page#process Page.process} method
|
||||||
will initiate all the steps that are necessary to process the
|
will initiate all the steps that are necessary to process the
|
||||||
request. It notifies the form that a request has been made and prints
|
request. It notifies the form that a request has been made and prints
|
||||||
the page that results from the form that processes the request.</P>
|
the page that results from the form that processes the request.</p>
|
||||||
<p>To process the request, the form extracts the parameter values from
|
<p>To process the request, the form extracts the parameter values from
|
||||||
the request, runs validation listeners, and either runs process listeners
|
the request, runs validation listeners, and either runs process listeners
|
||||||
(if the request was a valid submission) or displays the form together
|
(if the request was a valid submission) or displays the form together
|
||||||
|
|
@ -115,7 +115,7 @@
|
||||||
Swing</a>.
|
Swing</a>.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr />
|
||||||
<font size="-2">Last modified: 2001-06-22</font>
|
<font size="-2">Last modified: 2001-06-22</font>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,6 @@ import org.apache.log4j.Logger;
|
||||||
*/
|
*/
|
||||||
public abstract class ParameterModel implements Lockable {
|
public abstract class ParameterModel implements Lockable {
|
||||||
|
|
||||||
public static final String versionId = "$Id: ParameterModel.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this ParameterModel. The constructor will throw an
|
* The name of this ParameterModel. The constructor will throw an
|
||||||
* exception if the specified name is null
|
* exception if the specified name is null
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
*/
|
*/
|
||||||
public class StringParameter extends ParameterModel {
|
public class StringParameter extends ParameterModel {
|
||||||
|
|
||||||
public static final String versionId = "$Id: StringParameter.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new parameter which is filled from the request parameter
|
* Create a new parameter which is filled from the request parameter
|
||||||
* with the given name.
|
* with the given name.
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,9 @@ import com.arsdigita.search.converter.TextConverter;
|
||||||
|
|
||||||
public class Initializer extends CompoundInitializer {
|
public class Initializer extends CompoundInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public Initializer() {
|
public Initializer() {
|
||||||
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
final String url = RuntimeConfig.getConfig().getJDBCURL();
|
||||||
final int database = DbHelper.getDatabaseFromURL(url);
|
final int database = DbHelper.getDatabaseFromURL(url);
|
||||||
|
|
@ -73,6 +76,11 @@ public class Initializer extends CompoundInitializer {
|
||||||
("ccm-core.pdl.mf",
|
("ccm-core.pdl.mf",
|
||||||
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
|
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
|
||||||
|
|
||||||
|
add(new com.arsdigita.search.Initializer());
|
||||||
|
add(new com.arsdigita.search.lucene.Initializer());
|
||||||
|
add(new com.arsdigita.search.intermedia.Initializer());
|
||||||
|
add(new com.arsdigita.notification.Initializer());
|
||||||
|
|
||||||
add(new LegacyInitializer("com/arsdigita/core/enterprise.init"));
|
add(new LegacyInitializer("com/arsdigita/core/enterprise.init"));
|
||||||
add(new OptionalLegacyInitializer("enterprise.init"));
|
add(new OptionalLegacyInitializer("enterprise.init"));
|
||||||
}
|
}
|
||||||
|
|
@ -131,8 +139,8 @@ public class Initializer extends CompoundInitializer {
|
||||||
e.getFactory().registerInstantiator
|
e.getFactory().registerInstantiator
|
||||||
(BasicAuditTrail.BASE_DATA_OBJECT_TYPE,
|
(BasicAuditTrail.BASE_DATA_OBJECT_TYPE,
|
||||||
new DomainObjectInstantiator() {
|
new DomainObjectInstantiator() {
|
||||||
public DomainObject doNewInstance(final DataObject data) {
|
public DomainObject doNewInstance(final DataObject data) {
|
||||||
return new BasicAuditTrail(data);
|
return new BasicAuditTrail(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,8 @@
|
||||||
// init com.arsdigita.versioning.Initializer { }
|
// ccm.core.enterprise.init
|
||||||
|
//
|
||||||
|
// Old initialization prozess configuration file.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
init com.arsdigita.globalization.Initializer {
|
init com.arsdigita.globalization.Initializer {
|
||||||
// See http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc
|
// See http://java.sun.com/j2se/1.3/docs/api/java/lang/package-summary.html#charenc
|
||||||
|
|
@ -40,70 +44,15 @@ init com.arsdigita.kernel.security.Initializer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// As of version 6.5.x still in use!
|
|
||||||
// May be ommitted if ccm-ldn-search is used which sets the search engine
|
|
||||||
// by its own (Lucene)
|
|
||||||
init com.arsdigita.search.Initializer {}
|
|
||||||
|
|
||||||
// As of version 6.5.x still in use!
|
// Set to true when using intermedia search
|
||||||
// Comment in to use intermedia search
|
init com.arsdigita.mimetypes.MimeTypeInitializer {
|
||||||
//init com.arsdigita.search.intermedia.Initializer {
|
INSOFilterEnabled = false;
|
||||||
// timerDelay = 60; // Parameters for search timer/indexing
|
|
||||||
// syncDelay = 60; // All units are time in seconds
|
|
||||||
// maxSyncDelay = 7200; // see com.arsdigita.search.BuildIndex.java
|
|
||||||
// maxIndexingTime = 7200; // for definitions
|
|
||||||
// indexingRetryDelay = 60;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// As of version 6.5.x still in use!
|
|
||||||
init com.arsdigita.search.lucene.Initializer {}
|
|
||||||
|
|
||||||
// As of version 6.5.x still in use!
|
|
||||||
init com.arsdigita.notification.Initializer {
|
|
||||||
RequestManagerDelay = 900; // in seconds
|
|
||||||
RequestManagerPeriod = 900; // in seconds
|
|
||||||
SimpleQueueDelay = 900; // in seconds
|
|
||||||
SimpleQueuePeriod = 900; // in seconds
|
|
||||||
DigestQueueDelay = 900; // in seconds
|
|
||||||
DigestQueuePeriod = 900; // in seconds
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// init com.arsdigita.categorization.dispatch.Initializer { }
|
|
||||||
|
|
||||||
// The formbuilder application is now deprecated and will
|
|
||||||
// be removed in the next release. Use the FormItem content
|
|
||||||
// type instead
|
|
||||||
// init com.arsdigita.formbuilder.Initializer { }
|
|
||||||
|
|
||||||
// This is an example initializer for populating
|
|
||||||
// the BebopObjectType & MetaObject stores
|
|
||||||
//init com.arsdigita.formbuilder.installer.Initializer {
|
|
||||||
// widgetTypes = {
|
|
||||||
// { "forms", "Checkbox group", "Checkbox groups",
|
|
||||||
// "com.arsdigita.formbuilder.PersistentCheckboxGroup",
|
|
||||||
// "com.arsdigita.formbuilder.ui.editors.CheckboxGroupEditor" },
|
|
||||||
// { "forms", "Date field", "Date fields",
|
|
||||||
// "com.arsdigita.formbuilder.PersistentDate",
|
|
||||||
// "com.arsdigita.formbuilder.ui.editors.DateForm" }
|
|
||||||
// };
|
|
||||||
// processListenerTypes = {
|
|
||||||
// { "forms", "Confirmation email", "Confirmation emails",
|
|
||||||
// "com.arsdigita.formbuilder.actions.ConfirmEmailListener",
|
|
||||||
// "com.arsdigita.formbuilder.ui.editors.ConfirmEmailForm" },
|
|
||||||
// { "forms", "URL redirect", "URL redirects",
|
|
||||||
// "com.arsdigita.formbuilder.actions.ConfirmRedirectListener",
|
|
||||||
// "com.arsdigita.formbuilder.ui.editors.ConfirmRedirectForm" }
|
|
||||||
// };
|
|
||||||
// dataQueries = {
|
|
||||||
// { "forms", "com.arsdigita.formbuilder.DataQueryUsers",
|
|
||||||
// "List of all registered users" },
|
|
||||||
// { "forms", "com.arsdigita.formbuilder.DataQueryPackages",
|
|
||||||
// "List of all installed packages" }
|
|
||||||
// };
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
init com.arsdigita.webdevsupport.Initializer {
|
init com.arsdigita.webdevsupport.Initializer {
|
||||||
active = false;
|
active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,6 +73,84 @@ init com.arsdigita.ui.Initializer {
|
||||||
// { "right", "com.arsdigita.x.y.z" }
|
// { "right", "com.arsdigita.x.y.z" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
init com.arsdigita.portal.Initializer { }
|
||||||
|
|
||||||
|
|
||||||
|
// The formbuilder application is now deprecated and will
|
||||||
|
// be removed in the next release. Use the FormItem content
|
||||||
|
// type instead
|
||||||
|
// Method commend says:
|
||||||
|
// /**
|
||||||
|
// * Called on startup. Note. As you can not find a call
|
||||||
|
// * to this method in enterprise.ini, this method
|
||||||
|
// * may appear to execute mysteriously.
|
||||||
|
// * However, the process that runs through enterprise.ini
|
||||||
|
// * automitically calls the startup() method of any
|
||||||
|
// * class that implements com.arsdigita.util.initializer.Initializer
|
||||||
|
// * present in enterprise.ini
|
||||||
|
// **/
|
||||||
|
// Has to be checked in detail. As of version 6.5 a lot of packages nevertheless
|
||||||
|
// are using it!
|
||||||
|
//
|
||||||
|
// init com.arsdigita.formbuilder.Initializer { }
|
||||||
|
|
||||||
|
// This is an example initializer for populating
|
||||||
|
// the BebopObjectType & MetaObject stores
|
||||||
|
//init com.arsdigita.formbuilder.installer.Initializer {
|
||||||
|
// widgetTypes = {
|
||||||
|
// { "forms", "Checkbox group", "Checkbox groups",
|
||||||
|
// "com.arsdigita.formbuilder.PersistentCheckboxGroup",
|
||||||
|
// "com.arsdigita.formbuilder.ui.editors.CheckboxGroupEditor" },
|
||||||
|
// { "forms", "Date field", "Date fields",
|
||||||
|
// "com.arsdigita.formbuilder.PersistentDate",
|
||||||
|
// "com.arsdigita.formbuilder.ui.editors.DateForm" }
|
||||||
|
// };
|
||||||
|
// processListenerTypes = {
|
||||||
|
// { "forms", "Confirmation email", "Confirmation emails",
|
||||||
|
// "com.arsdigita.formbuilder.actions.ConfirmEmailListener",
|
||||||
|
// "com.arsdigita.formbuilder.ui.editors.ConfirmEmailForm" },
|
||||||
|
// { "forms", "URL redirect", "URL redirects",
|
||||||
|
// "com.arsdigita.formbuilder.actions.ConfirmRedirectListener",
|
||||||
|
// "com.arsdigita.formbuilder.ui.editors.ConfirmRedirectForm" }
|
||||||
|
// };
|
||||||
|
// dataQueries = {
|
||||||
|
// { "forms", "com.arsdigita.formbuilder.DataQueryUsers",
|
||||||
|
// "List of all registered users" },
|
||||||
|
// { "forms", "com.arsdigita.formbuilder.DataQueryPackages",
|
||||||
|
// "List of all installed packages" }
|
||||||
|
// };
|
||||||
|
//}
|
||||||
|
|
||||||
|
// init com.arsdigita.populate.apps.Initializer {
|
||||||
|
// numApps=3;
|
||||||
|
// PopulateAppPair = {
|
||||||
|
// //populateForum args: numPosts, numMsgs per post
|
||||||
|
// { "com.arsdigita.forum.PopulateForum", {3, 5}},
|
||||||
|
// //populateDocmgr args: numFolderLevels, numFolders, numFiles
|
||||||
|
// { "com.arsdigita.docmgr.PopulateDocmgr", {3, 2, 2}},
|
||||||
|
// //populateFaq args: numQuestions
|
||||||
|
// { "com.arsdigita.faq.PopulateFaq", {5}},
|
||||||
|
// //populateGlossary args: numWords
|
||||||
|
// { "com.arsdigita.glossary.PopulateGlossary", {5}},
|
||||||
|
// //populateBookmarks args: numBookmarks
|
||||||
|
// { "com.arsdigita.bookmarks.PopulateBookmarks", {5}}
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// /////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Initializer definitely replaced by new initialization system
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Move configuration options to enterprise.init.nolongerInUse
|
||||||
|
|
||||||
|
// no longer used - old versioning system?
|
||||||
|
// init com.arsdigita.versioning.Initializer { }
|
||||||
|
|
||||||
// Application specific page components
|
// Application specific page components
|
||||||
// applicationLayouts = {
|
// applicationLayouts = {
|
||||||
// { "forums",
|
// { "forums",
|
||||||
|
|
@ -143,30 +170,3 @@ init com.arsdigita.ui.Initializer {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
}
|
|
||||||
|
|
||||||
init com.arsdigita.portal.Initializer { }
|
|
||||||
|
|
||||||
// init com.arsdigita.localization.demo.Initializer { }
|
|
||||||
// init com.arsdigita.bebop.jsp.Initializer { }
|
|
||||||
|
|
||||||
// Set to true when using intermedia search
|
|
||||||
init com.arsdigita.mimetypes.MimeTypeInitializer {
|
|
||||||
INSOFilterEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init com.arsdigita.populate.apps.Initializer {
|
|
||||||
// numApps=3;
|
|
||||||
// PopulateAppPair = {
|
|
||||||
// //populateForum args: numPosts, numMsgs per post
|
|
||||||
// { "com.arsdigita.forum.PopulateForum", {3, 5}},
|
|
||||||
// //populateDocmgr args: numFolderLevels, numFolders, numFiles
|
|
||||||
// { "com.arsdigita.docmgr.PopulateDocmgr", {3, 2, 2}},
|
|
||||||
// //populateFaq args: numQuestions
|
|
||||||
// { "com.arsdigita.faq.PopulateFaq", {5}},
|
|
||||||
// //populateGlossary args: numWords
|
|
||||||
// { "com.arsdigita.glossary.PopulateGlossary", {5}},
|
|
||||||
// //populateBookmarks args: numBookmarks
|
|
||||||
// { "com.arsdigita.bookmarks.PopulateBookmarks", {5}}
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
// ccm.core.enterprise.init.nolongerInUse
|
||||||
|
//
|
||||||
|
// Old initialization prozess configuration file.
|
||||||
|
// configurations definitely no longer used (refactored into new initializser system)
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// /////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Initializer definitely replaced by new initialization system
|
||||||
|
//
|
||||||
|
// /////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// -- As of version 6.6.0 release 12 refactored into the new initializer system
|
||||||
|
// -- and no longer in use.
|
||||||
|
// -- As of version 6.5.x still in use!
|
||||||
|
//init com.arsdigita.notification.LegacyInitializer {
|
||||||
|
// RequestManagerDelay = 900; // in seconds
|
||||||
|
// RequestManagerPeriod = 900; // in seconds
|
||||||
|
// SimpleQueueDelay = 900; // in seconds
|
||||||
|
// SimpleQueuePeriod = 900; // in seconds
|
||||||
|
// DigestQueueDelay = 900; // in seconds
|
||||||
|
// DigestQueuePeriod = 900; // in seconds
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
// As of version 6.5.x still in use!
|
||||||
|
// May be ommitted if ccm-ldn-search is used which sets the search engine
|
||||||
|
// by its own (Lucene)
|
||||||
|
// As of version 6.6.0 release 2 refactored into the new initializer system.
|
||||||
|
// Lucene is now initialized as a sub-initializer of ccm-core initializer.
|
||||||
|
// init com.arsdigita.search.LegacyInitializer {}
|
||||||
|
|
||||||
|
// As of version 6.5.x still in use!
|
||||||
|
// As of version 6.6.0 release 2 refactored into the new initializer system.
|
||||||
|
// Lucene is now initialized as a sub-initializer of ccm-core initializer.
|
||||||
|
//-- init com.arsdigita.search.lucene.LegacyInitializer {}
|
||||||
|
|
||||||
|
// As of version 6.5.x still in use!
|
||||||
|
// Comment in to use intermedia search
|
||||||
|
// As of version 6.6.0 release 2 refactored into the new initializer system.
|
||||||
|
// Intermedia is now initialized as a sub-initializer of ccm-core initializer.
|
||||||
|
// It is configured via waf.search.indexer Parameter (may be lucene or intermedia).
|
||||||
|
// If not enabled, initialization is skipped.
|
||||||
|
//init com.arsdigita.search.intermedia.LegacyInitializer {
|
||||||
|
// timerDelay = 60; // Parameters for search timer/indexing
|
||||||
|
// syncDelay = 60; // All units are time in seconds
|
||||||
|
// maxSyncDelay = 7200; // see com.arsdigita.search.BuildIndex.java
|
||||||
|
// maxIndexingTime = 7200; // for definitions
|
||||||
|
// indexingRetryDelay = 60;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Package does no longer exist.
|
||||||
|
// init com.arsdigita.categorization.dispatch.Initializer { }
|
||||||
|
|
||||||
|
// Application specific page components
|
||||||
|
// applicationLayouts = {
|
||||||
|
// { "forums",
|
||||||
|
// {
|
||||||
|
// { "top", "com.arsdigita.x.y.z" },
|
||||||
|
// { "left", "com.arsdigita.x.y.z" },
|
||||||
|
// { "bottom", "com.arsdigita.x.y.z" },
|
||||||
|
// { "right", "com.arsdigita.x.y.z" }
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// { "search",
|
||||||
|
// {
|
||||||
|
// { "top", "com.arsdigita.x.y.z" },
|
||||||
|
// { "left", "com.arsdigita.x.y.z" },
|
||||||
|
// { "bottom", "com.arsdigita.x.y.z" },
|
||||||
|
// { "right", "com.arsdigita.x.y.z" }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
// init com.arsdigita.localization.demo.Initializer { }
|
||||||
|
|
||||||
|
// Class no longer part of source code
|
||||||
|
// init com.arsdigita.bebop.jsp.Initializer { }
|
||||||
|
|
@ -27,12 +27,9 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Randy Graebner
|
* @author Randy Graebner
|
||||||
|
* @version $Id: DispatcherConfig.java 1169 2006-06-14 13:08:25Z fabrice $
|
||||||
*/
|
*/
|
||||||
public final class DispatcherConfig extends AbstractConfig {
|
public final class DispatcherConfig extends AbstractConfig {
|
||||||
public static final String versionId =
|
|
||||||
"$Id: DispatcherConfig.java 1169 2006-06-14 13:08:25Z fabrice $" +
|
|
||||||
"$Author: fabrice $" +
|
|
||||||
"$DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(DispatcherConfig.class);
|
private static final Logger s_log = Logger.getLogger(DispatcherConfig.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,22 +22,23 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The GlobalObserverManager class is a singleton class that allows observers
|
* The GlobalObserverManager class is a singleton class that allows observers
|
||||||
* implementing the GlobalObserver interface to be registered. Once such
|
* implementing the GlobalObserver interface to be registered.
|
||||||
* observers are registered they have the opportunity to observe every single
|
|
||||||
* observable domain object that is created. The
|
|
||||||
* GlobalObserver.shouldObserve(DomainObject) method can be used by an
|
|
||||||
* observer to select which objects to observe.
|
|
||||||
*
|
*
|
||||||
|
* Once such observers are registered they have the opportunity to observe
|
||||||
|
* every single observable domain object that is created. The
|
||||||
|
* GlobalObserver.shouldObserve(DomainObject) method can be used by an observer
|
||||||
|
* to select which objects to observe.
|
||||||
|
*
|
||||||
* @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a>
|
* @author <a href="mailto:rhs@mit.edu">rhs@mit.edu</a>
|
||||||
* @version $Revision: #8 $ $Date: 2004/08/16 $
|
* @version $Id: GlobalObserverManager.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public class GlobalObserverManager {
|
public class GlobalObserverManager {
|
||||||
|
|
||||||
public final static String versionId = "$Id: GlobalObserverManager.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
private static final GlobalObserverManager s_manager =
|
private static final GlobalObserverManager s_manager =
|
||||||
new GlobalObserverManager();
|
new GlobalObserverManager();
|
||||||
|
|
||||||
|
|
@ -45,12 +46,14 @@ public class GlobalObserverManager {
|
||||||
/**
|
/**
|
||||||
* Returns the global observer manager. This is a singleton class that
|
* Returns the global observer manager. This is a singleton class that
|
||||||
* allows the "global" observers, or observers of any
|
* allows the "global" observers, or observers of any
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public static final GlobalObserverManager getManager() {
|
public static final GlobalObserverManager getManager() {
|
||||||
|
s_log.debug("getInstance of GlobalObserverManager invoked.");
|
||||||
return s_manager;
|
return s_manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(GlobalObserverManager.class);
|
||||||
|
|
||||||
private List m_observers = new ArrayList();
|
private List m_observers = new ArrayList();
|
||||||
|
|
||||||
private GlobalObserverManager() {}
|
private GlobalObserverManager() {}
|
||||||
|
|
@ -60,9 +63,10 @@ public class GlobalObserverManager {
|
||||||
* Adds a new observer.
|
* Adds a new observer.
|
||||||
*
|
*
|
||||||
* @param doo the new observer
|
* @param doo the new observer
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public void addObserver(GlobalObserver go) {
|
public void addObserver(GlobalObserver go) {
|
||||||
|
s_log.debug("addObserver invoked.");
|
||||||
m_observers.add(go);
|
m_observers.add(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,8 +75,7 @@ public class GlobalObserverManager {
|
||||||
* Returns the global observers.
|
* Returns the global observers.
|
||||||
*
|
*
|
||||||
* @return The observers for the given domain object.
|
* @return The observers for the given domain object.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
Iterator getObservers() {
|
Iterator getObservers() {
|
||||||
return m_observers.iterator();
|
return m_observers.iterator();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>ccm-core: Domain Installer</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<p>
|
<p>
|
||||||
Installer for domain system.
|
Installer for domain system.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Package com.arsdigita. formbuilder.installer</title>
|
||||||
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<p>
|
<p>
|
||||||
Installer for formbuilder service.
|
Installer for formbuilder service.
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,9 @@ import org.apache.log4j.Logger;
|
||||||
* @see java.util.Locale
|
* @see java.util.Locale
|
||||||
* @see java.util.ResourceBundle
|
* @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 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 =
|
private static final Logger s_cat =
|
||||||
Logger.getLogger(GlobalizedMessage.class.getName());
|
Logger.getLogger(GlobalizedMessage.class.getName());
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,21 @@ public class CoreLoader extends PackageLoader {
|
||||||
Host.create(hhost.getName(), hhost.getPort());
|
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();
|
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() {
|
private SiteNode loadKernel() {
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
<b>Example</b> A demonstration of how to localize the login and
|
<b>Example</b> A demonstration of how to localize the login and
|
||||||
registration pages of the ACS without touching the code. Localization
|
registration pages of the ACS without touching the code. Localization
|
||||||
uses German as the target locale, and includes three files:
|
uses German as the target locale, and includes three files:
|
||||||
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>a properties file to contain the localized string
|
<li>a properties file to contain the localized string
|
||||||
|
|
@ -20,7 +20,5 @@ uses German as the target locale, and includes three files:
|
||||||
stylesheet to the German locale
|
stylesheet to the German locale
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Package com.arsdigita.mimetypes.converters</title>
|
||||||
|
</head>
|
||||||
<body bgcolor="white">
|
<body bgcolor="white">
|
||||||
<p>
|
<p>
|
||||||
Classes for converting between specific mimetypes.
|
Classes for converting between specific mimetypes.
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ import com.arsdigita.util.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The abstract BaseSubscription class provides the ability for Users
|
* The abstract BaseSubscription class provides the ability for Users to sign up
|
||||||
* to sign up for email notifications. Subclasses will specify
|
* for email notifications. Subclasses will specify the object to which the
|
||||||
* the object to which the notifications apply and messages that should
|
* notifications apply and messages that should be sent along with the
|
||||||
* be sent along with the notifications.
|
* notifications.
|
||||||
*
|
*
|
||||||
* The default implementation provides instant notifications. Subclasses
|
* The default implementation provides instant notifications. Subclasses
|
||||||
* should override sendNotification() to alter this behavior.
|
* 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.
|
* A separator to use between the body and signature of an alert.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected final static String SEPARATOR =
|
protected final static String SEPARATOR =
|
||||||
getSeparator();
|
getSeparator();
|
||||||
|
|
||||||
protected final static String ALERT_BLURB =
|
protected final static String ALERT_BLURB =
|
||||||
"This is an automated alert from the Discussion Forum system. ";
|
"This is an automated alert from the Discussion Forum system. ";
|
||||||
protected final static String REPLY_BLURB =
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
protected String getSubscriptionGroupName() {
|
protected String getSubscriptionGroupName() {
|
||||||
|
|
@ -142,10 +142,10 @@ public abstract class BaseSubscription extends ACSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will send immediate notifications to subscribed
|
* This method will send immediate notifications to subscribed users with
|
||||||
* users with the header and signature specified by getHeader()
|
* the header and signature specified by getHeader() and getSignature().
|
||||||
* and getSignature. Subclasses which desire different behavior
|
* Subclasses which desire different behavior should override one or more
|
||||||
* should override one or more of these methods.
|
* of these methods.
|
||||||
*/
|
*/
|
||||||
public void sendNotification(ThreadedMessage post) {
|
public void sendNotification(ThreadedMessage post) {
|
||||||
sendNotification(post, false);
|
sendNotification(post, false);
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,12 @@ import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Models the envelope information associated with a
|
* Models the envelope information associated with a digest.
|
||||||
* digest. When a digest is processed, all notifications associated
|
*
|
||||||
* with it are grouped for delivery as a single unit to each receiver.
|
* When a digest is processed, all notifications associated with it are grouped
|
||||||
* The outbound email generated for the receivers has a common
|
* for delivery as a single unit to each receiver. The outbound email generated
|
||||||
* subject, header, separator between the individual messages, and
|
* for the receivers has a common subject, header, separator between the
|
||||||
* signature.
|
* individual messages, and signature.
|
||||||
*
|
*
|
||||||
* @author Ron Henderson
|
* @author Ron Henderson
|
||||||
* @author David Dao
|
* @author David Dao
|
||||||
|
|
@ -63,7 +63,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* consisting of 78 dashes (-).
|
* consisting of 78 dashes (-).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Digest () {
|
public Digest () {
|
||||||
super(BASE_DATA_OBJECT_TYPE);
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
|
|
@ -81,7 +80,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* @param header the common header
|
* @param header the common header
|
||||||
* @param signature the common signature
|
* @param signature the common signature
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Digest (Party from,
|
public Digest (Party from,
|
||||||
String subject,
|
String subject,
|
||||||
String header,
|
String header,
|
||||||
|
|
@ -89,10 +87,10 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
{
|
{
|
||||||
this();
|
this();
|
||||||
|
|
||||||
Assert.assertNotNull(from, "Party from");
|
Assert.exists(from, "Party from");
|
||||||
Assert.assertNotNull(subject, "String subject");
|
Assert.exists(subject, "String subject");
|
||||||
Assert.assertNotNull(header, "String header");
|
Assert.exists(header, "String header");
|
||||||
Assert.assertNotNull(signature, "String signature");
|
Assert.exists(signature, "String signature");
|
||||||
|
|
||||||
setFrom(from);
|
setFrom(from);
|
||||||
setSubject(subject);
|
setSubject(subject);
|
||||||
|
|
@ -105,7 +103,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param oid the OID of the digest
|
* @param oid the OID of the digest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Digest (OID oid)
|
public Digest (OID oid)
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -117,7 +114,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param dataObj the DataObject the Digest will wrap
|
* @param dataObj the DataObject the Digest will wrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Digest(DataObject dataObj) {
|
public Digest(DataObject dataObj) {
|
||||||
super(dataObj);
|
super(dataObj);
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +123,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param id the id for the DataObject to retrieve.
|
* @param id the id for the DataObject to retrieve.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Digest (BigDecimal id)
|
public Digest (BigDecimal id)
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -138,7 +133,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Gets the sender of the digest.
|
* Gets the sender of the digest.
|
||||||
* @return the sender.
|
* @return the sender.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Party getFrom()
|
public Party getFrom()
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -152,7 +146,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @return the sender's email address as a String.
|
* @return the sender's email address as a String.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getFromEmail() {
|
public String getFromEmail() {
|
||||||
try {
|
try {
|
||||||
return getFrom().getPrimaryEmail().toString();
|
return getFrom().getPrimaryEmail().toString();
|
||||||
|
|
@ -165,9 +158,8 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Sets the common sender for the digest.
|
* Sets the common sender for the digest.
|
||||||
* @param from the common sender
|
* @param from the common sender
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setFrom (Party from) {
|
public void setFrom (Party from) {
|
||||||
Assert.assertNotNull(from, "Party from");
|
Assert.exists(from, "Party from");
|
||||||
|
|
||||||
set(PARTY_FROM, from.getID());
|
set(PARTY_FROM, from.getID());
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +168,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Gets the common subject for the digest.
|
* Gets the common subject for the digest.
|
||||||
* @return the common subject for the digest.
|
* @return the common subject for the digest.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getSubject () {
|
public String getSubject () {
|
||||||
return (String) get(SUBJECT);
|
return (String) get(SUBJECT);
|
||||||
}
|
}
|
||||||
|
|
@ -185,7 +176,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Sets the common subject for the digest.
|
* Sets the common subject for the digest.
|
||||||
* @param subject the common subject
|
* @param subject the common subject
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setSubject (String subject) {
|
public void setSubject (String subject) {
|
||||||
set(SUBJECT, subject);
|
set(SUBJECT, subject);
|
||||||
}
|
}
|
||||||
|
|
@ -194,7 +184,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Gets the common header for the digest.
|
* Gets the common header for the digest.
|
||||||
* @return the common header for the digest.
|
* @return the common header for the digest.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getHeader () {
|
public String getHeader () {
|
||||||
return (String) get(HEADER);
|
return (String) get(HEADER);
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +192,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Set the common header for the digest.
|
* Set the common header for the digest.
|
||||||
* @param header the common header
|
* @param header the common header
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setHeader (String header) {
|
public void setHeader (String header) {
|
||||||
set(HEADER, header);
|
set(HEADER, header);
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +200,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* Gets the current separator for elements of the digest.
|
* Gets the current separator for elements of the digest.
|
||||||
* @return the separator
|
* @return the separator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getSeparator () {
|
public String getSeparator () {
|
||||||
return (String) get(SEPARATOR);
|
return (String) get(SEPARATOR);
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +211,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param separator the value of the separator
|
* @param separator the value of the separator
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setSeparator (String separator) {
|
public void setSeparator (String separator) {
|
||||||
set(SEPARATOR, separator);
|
set(SEPARATOR, separator);
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +223,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* @param s the separator character
|
* @param s the separator character
|
||||||
* @param n the repeat count
|
* @param n the repeat count
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setSeparator (char s, int n) {
|
public void setSeparator (char s, int n) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
for (int i = 0; i < n; i++)
|
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.
|
* Gets the signature used for this digest.
|
||||||
* @return the signature for this digest.
|
* @return the signature for this digest.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getSignature () {
|
public String getSignature () {
|
||||||
return (String) get(SIGNATURE);
|
return (String) get(SIGNATURE);
|
||||||
}
|
}
|
||||||
|
|
@ -259,7 +243,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param signature the signature for the digest
|
* @param signature the signature for the digest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setSignature (String signature) {
|
public void setSignature (String signature) {
|
||||||
set(SIGNATURE, signature);
|
set(SIGNATURE, signature);
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +252,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
* digest.
|
* digest.
|
||||||
* @return the processing frequency for this digest.
|
* @return the processing frequency for this digest.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Integer getFrequency () {
|
public Integer getFrequency () {
|
||||||
return (Integer) get(FREQUENCY);
|
return (Integer) get(FREQUENCY);
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +261,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param frequency the processing frequency in minutes
|
* @param frequency the processing frequency in minutes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setFrequency (int frequency) {
|
public void setFrequency (int frequency) {
|
||||||
set(FREQUENCY, new Integer(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.
|
* Sets the date when this digest will next be processed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private void setNextRun (Date nextRun) {
|
private void setNextRun (Date nextRun) {
|
||||||
set(NEXT_RUN, nextRun);
|
set(NEXT_RUN, nextRun);
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +277,6 @@ public class Digest extends ACSObject implements NotificationConstants {
|
||||||
cal.add(Calendar.MINUTE, getFrequency().intValue());
|
cal.add(Calendar.MINUTE, getFrequency().intValue());
|
||||||
setNextRun(cal.getTime());
|
setNextRun(cal.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the date when this digest will next be processed.
|
* 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
|
* notifications. Verifies that all required parameters have been
|
||||||
* specified before saving.
|
* specified before saving.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void beforeSave() {
|
protected void beforeSave() {
|
||||||
|
|
||||||
String message =
|
String message =
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,8 @@ import java.util.TimerTask;
|
||||||
class DigestQueueManager extends TimerTask
|
class DigestQueueManager extends TimerTask
|
||||||
implements NotificationConstants
|
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 =
|
private static final Logger log = Logger.getLogger(DigestQueueManager.class);
|
||||||
Logger.getLogger(DigestQueueManager.class);
|
|
||||||
|
|
||||||
// String catalog for digest message. Should be globalized.
|
// String catalog for digest message. Should be globalized.
|
||||||
|
|
||||||
|
|
@ -60,7 +58,6 @@ class DigestQueueManager extends TimerTask
|
||||||
/**
|
/**
|
||||||
* Processes one sweep of the DigestQueueManager.
|
* Processes one sweep of the DigestQueueManager.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("processing current requests");
|
log.info("processing current requests");
|
||||||
|
|
||||||
|
|
@ -74,11 +71,9 @@ class DigestQueueManager extends TimerTask
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
/**
|
// Retrieve all digests to be processed during this run.
|
||||||
* Retrieve all digests to be processed during this run.
|
// Store all notifications in double hash map using
|
||||||
* Store all notifications in double hash map using
|
// digestID and partyTo as key.
|
||||||
* digestID and partyTo as key.
|
|
||||||
*/
|
|
||||||
|
|
||||||
DataQuery query = session.retrieveQuery(GET_DIGEST_QUEUED_NOTIFICATIONS);
|
DataQuery query = session.retrieveQuery(GET_DIGEST_QUEUED_NOTIFICATIONS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
|
@ -18,14 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.notification;
|
package com.arsdigita.notification;
|
||||||
|
|
||||||
|
import com.arsdigita.runtime.ContextCloseEvent;
|
||||||
|
import com.arsdigita.runtime.ContextInitEvent;
|
||||||
|
import com.arsdigita.runtime.GenericInitializer;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import com.arsdigita.initializer.Configuration;
|
|
||||||
import com.arsdigita.initializer.InitializationException;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes three timer tasks to maintain the notification
|
* Initializes the Notification package.
|
||||||
* service. These tasks handle the following:
|
*
|
||||||
|
* Initializes three timer tasks to maintain the notification service. These
|
||||||
|
* tasks handle the following:
|
||||||
* <UL>
|
* <UL>
|
||||||
* <LI><b>RequestManager</b> schedules new requests for a notification
|
* <LI><b>RequestManager</b> schedules new requests for a notification
|
||||||
* in the outbound mail queue, and updates the status of items in the
|
* in the outbound mail queue, and updates the status of items in the
|
||||||
|
|
@ -38,146 +43,89 @@ import org.apache.log4j.Logger;
|
||||||
* mail queue that are part of a digest.
|
* mail queue that are part of a digest.
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author David Dao
|
* @author David Dao
|
||||||
* @version $Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $
|
* @author Peter Boy (pboy@barkhof.uni-bremen.de)
|
||||||
* @since
|
* @version $Id: $
|
||||||
*/
|
*/
|
||||||
|
public class Initializer extends GenericInitializer {
|
||||||
|
|
||||||
public class Initializer
|
// Creates a s_logging category with name = to the full name of class
|
||||||
implements NotificationParameters,
|
public static final Logger s_log = Logger.getLogger(Initializer.class);
|
||||||
com.arsdigita.initializer.Initializer
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String versionId = "$Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
// Timer threads. Each one is started as a daemon.
|
||||||
/**
|
/**
|
||||||
* For logging.
|
* Schedules new requests for a notification in the outbound mail queue
|
||||||
|
* and updates the status of items in the request table that have already
|
||||||
|
* been processed..
|
||||||
*/
|
*/
|
||||||
|
private static Timer NotificationRequestManagerTimer = new Timer(true);
|
||||||
private static final Logger s_log =
|
|
||||||
Logger.getLogger(Initializer.class);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration.
|
* Processes messages in the outbound mail queue that are part of a digest.
|
||||||
*/
|
*/
|
||||||
|
private static Timer NotificationDigestQueueTimer = new Timer(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* processes messages in the outbound mail queue that are not part of a digest.
|
||||||
|
*/
|
||||||
|
private static Timer NotificationSimpleQueueTimer = new Timer(true);
|
||||||
|
|
||||||
private Configuration m_conf = new Configuration();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Timer threads. Each one is started as a daemon.
|
* Default (empty) Constructor
|
||||||
*/
|
*/
|
||||||
|
public Initializer() {
|
||||||
private static Timer timer0 = new Timer(true);
|
// s_log.debug("notification initializer instantiated.");
|
||||||
private static Timer timer1 = new Timer(true);
|
|
||||||
private static Timer timer2 = new Timer(true);
|
|
||||||
|
|
||||||
public Initializer() throws InitializationException {
|
|
||||||
m_conf.initParameter(REQUEST_MANAGER_DELAY,
|
|
||||||
REQUEST_MANAGER_DELAY_DESCRIPTION,
|
|
||||||
Integer.class,
|
|
||||||
new Integer(0));
|
|
||||||
|
|
||||||
m_conf.initParameter(REQUEST_MANAGER_PERIOD,
|
|
||||||
REQUEST_MANAGER_PERIOD_DESCRIPTION,
|
|
||||||
Integer.class,
|
|
||||||
new Integer(900));
|
|
||||||
|
|
||||||
m_conf.initParameter(SIMPLE_QUEUE_DELAY,
|
|
||||||
SIMPLE_QUEUE_DELAY_DESCRIPTION,
|
|
||||||
Integer.class,
|
|
||||||
new Integer(0));
|
|
||||||
|
|
||||||
m_conf.initParameter(SIMPLE_QUEUE_PERIOD,
|
|
||||||
SIMPLE_QUEUE_PERIOD_DESCRIPTION,
|
|
||||||
Integer.class,
|
|
||||||
new Integer(900));
|
|
||||||
|
|
||||||
|
|
||||||
m_conf.initParameter(DIGEST_QUEUE_DELAY,
|
|
||||||
DIGEST_QUEUE_DELAY_DESCRIPTION,
|
|
||||||
Integer.class,
|
|
||||||
new Integer(0));
|
|
||||||
|
|
||||||
m_conf.initParameter(DIGEST_QUEUE_PERIOD,
|
|
||||||
DIGEST_QUEUE_PERIOD_DESCRIPTION,
|
|
||||||
Integer.class,
|
|
||||||
new Integer(900));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configuration object used by this initializer.
|
* Implementation of the {@link Initializer#init(ContextInitEvent)}.
|
||||||
*/
|
|
||||||
|
|
||||||
public final Configuration getConfiguration() {
|
|
||||||
return m_conf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts up the notification service.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void startup() {
|
|
||||||
|
|
||||||
timer0.scheduleAtFixedRate(new DigestQueueManager(),
|
|
||||||
getTimeMsec(DIGEST_QUEUE_DELAY),
|
|
||||||
getTimeMsec(DIGEST_QUEUE_PERIOD));
|
|
||||||
|
|
||||||
timer1.scheduleAtFixedRate(new SimpleQueueManager(),
|
|
||||||
getTimeMsec(SIMPLE_QUEUE_DELAY),
|
|
||||||
getTimeMsec(SIMPLE_QUEUE_PERIOD));
|
|
||||||
|
|
||||||
timer2.scheduleAtFixedRate(new RequestManager(),
|
|
||||||
getTimeMsec(REQUEST_MANAGER_DELAY),
|
|
||||||
getTimeMsec(REQUEST_MANAGER_PERIOD));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to lookup a timing key and convert its value to
|
|
||||||
* milliseconds.
|
|
||||||
*
|
*
|
||||||
* @param key is the configuration parameter key
|
* Start various background threads for notification service which are
|
||||||
*/
|
* needed for a proper servlet container context operation.
|
||||||
|
*
|
||||||
|
* @param evt The context init event.
|
||||||
|
**/
|
||||||
|
public void init(ContextInitEvent evt) {
|
||||||
|
s_log.debug("notification background startup begin.");
|
||||||
|
|
||||||
private long getTimeMsec(String key) {
|
NotificationConfig conf = NotificationConfig.getConfig();
|
||||||
return ((Integer) m_conf.getParameter(key)).longValue() * 1000L;
|
s_log.debug("Notification configuration loaded.");
|
||||||
|
|
||||||
|
NotificationRequestManagerTimer.scheduleAtFixedRate(
|
||||||
|
new RequestManager(),
|
||||||
|
conf.getRequestManagerDelay(),
|
||||||
|
conf.getRequestManagerPeriod()
|
||||||
|
);
|
||||||
|
|
||||||
|
NotificationDigestQueueTimer.scheduleAtFixedRate(
|
||||||
|
new DigestQueueManager(),
|
||||||
|
conf.getDigestQueueDelay(),
|
||||||
|
conf.getDigestQueuePeriod()
|
||||||
|
);
|
||||||
|
|
||||||
|
NotificationSimpleQueueTimer.scheduleAtFixedRate(
|
||||||
|
new SimpleQueueManager(),
|
||||||
|
conf.getSimpleQueueDelay(),
|
||||||
|
conf.getSimpleQueuePeriod()
|
||||||
|
);
|
||||||
|
|
||||||
|
s_log.debug("notification background processing started");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down the notification service.
|
* Implementation of the {@link Initializer#close(ContextCloseEvent)}.
|
||||||
|
*
|
||||||
|
* Stops background threads started during initialization so the servlet
|
||||||
|
* container can terminate the applications main thread.
|
||||||
*/
|
*/
|
||||||
|
public void close(ContextCloseEvent evt) {
|
||||||
|
|
||||||
public void shutdown() {
|
NotificationSimpleQueueTimer.cancel();
|
||||||
|
NotificationDigestQueueTimer.cancel();
|
||||||
|
NotificationRequestManagerTimer.cancel();
|
||||||
|
|
||||||
|
s_log.debug("Notification background processing stopped");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private interface for storing constants
|
|
||||||
*/
|
|
||||||
|
|
||||||
interface NotificationParameters {
|
|
||||||
|
|
||||||
public final static String REQUEST_MANAGER_DELAY =
|
|
||||||
"RequestManagerDelay";
|
|
||||||
public final static String REQUEST_MANAGER_DELAY_DESCRIPTION =
|
|
||||||
"Request manager's delay in seconds.";
|
|
||||||
public final static String REQUEST_MANAGER_PERIOD =
|
|
||||||
"RequestManagerPeriod";
|
|
||||||
public final static String REQUEST_MANAGER_PERIOD_DESCRIPTION =
|
|
||||||
"Request manager's period in seconds";
|
|
||||||
public final static String SIMPLE_QUEUE_DELAY =
|
|
||||||
"SimpleQueueDelay";
|
|
||||||
public final static String SIMPLE_QUEUE_DELAY_DESCRIPTION =
|
|
||||||
"Simple queue's delay in seconds.";
|
|
||||||
public final static String SIMPLE_QUEUE_PERIOD =
|
|
||||||
"SimpleQueuePeriod";
|
|
||||||
public final static String SIMPLE_QUEUE_PERIOD_DESCRIPTION =
|
|
||||||
"Simple queue's period in seconds.";
|
|
||||||
public final static String DIGEST_QUEUE_DELAY =
|
|
||||||
"DigestQueueDelay";
|
|
||||||
public final static String DIGEST_QUEUE_DELAY_DESCRIPTION =
|
|
||||||
"Digest queue's delay in seconds.";
|
|
||||||
public final static String DIGEST_QUEUE_PERIOD =
|
|
||||||
"DigestQueuePeriod";
|
|
||||||
public final static String DIGEST_QUEUE_PERIOD_DESCRIPTION =
|
|
||||||
"Digest queue's period in seconds.";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
/*
|
||||||
|
* 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.notification;
|
||||||
|
|
||||||
|
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:
|
||||||
|
* <UL>
|
||||||
|
* <LI><b>RequestManager</b> schedules new requests for a notification
|
||||||
|
* in the outbound mail queue, and updates the status of items in the
|
||||||
|
* request table that have already been processed.
|
||||||
|
*
|
||||||
|
* <LI><b>SimpleQueueManager</b> processes messages in the outbound
|
||||||
|
* mail queue that are not part of a digest.
|
||||||
|
*
|
||||||
|
* <LI><b>DigestQueueManager</b> processes messages in the outbound
|
||||||
|
* mail queue that are part of a digest.
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @author David Dao
|
||||||
|
* @version $Id: LegacyInitializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
|
* @since
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class LegacyInitializer
|
||||||
|
implements NotificationParameters,
|
||||||
|
com.arsdigita.initializer.Initializer
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String versionId = "$Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
||||||
|
/**
|
||||||
|
* For logging.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(LegacyInitializer.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Configuration m_conf = new Configuration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Timer threads. Each one is started as a daemon.
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static Timer timer0 = new Timer(true);
|
||||||
|
private static Timer timer1 = new Timer(true);
|
||||||
|
private static Timer timer2 = new Timer(true);
|
||||||
|
|
||||||
|
public LegacyInitializer() throws InitializationException {
|
||||||
|
m_conf.initParameter(REQUEST_MANAGER_DELAY,
|
||||||
|
REQUEST_MANAGER_DELAY_DESCRIPTION,
|
||||||
|
Integer.class,
|
||||||
|
new Integer(0));
|
||||||
|
|
||||||
|
m_conf.initParameter(REQUEST_MANAGER_PERIOD,
|
||||||
|
REQUEST_MANAGER_PERIOD_DESCRIPTION,
|
||||||
|
Integer.class,
|
||||||
|
new Integer(900));
|
||||||
|
|
||||||
|
m_conf.initParameter(SIMPLE_QUEUE_DELAY,
|
||||||
|
SIMPLE_QUEUE_DELAY_DESCRIPTION,
|
||||||
|
Integer.class,
|
||||||
|
new Integer(0));
|
||||||
|
|
||||||
|
m_conf.initParameter(SIMPLE_QUEUE_PERIOD,
|
||||||
|
SIMPLE_QUEUE_PERIOD_DESCRIPTION,
|
||||||
|
Integer.class,
|
||||||
|
new Integer(900));
|
||||||
|
|
||||||
|
|
||||||
|
m_conf.initParameter(DIGEST_QUEUE_DELAY,
|
||||||
|
DIGEST_QUEUE_DELAY_DESCRIPTION,
|
||||||
|
Integer.class,
|
||||||
|
new Integer(0));
|
||||||
|
|
||||||
|
m_conf.initParameter(DIGEST_QUEUE_PERIOD,
|
||||||
|
DIGEST_QUEUE_PERIOD_DESCRIPTION,
|
||||||
|
Integer.class,
|
||||||
|
new Integer(900));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the configuration object used by this initializer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public final Configuration getConfiguration() {
|
||||||
|
return m_conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts up the notification service.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void startup() {
|
||||||
|
|
||||||
|
timer0.scheduleAtFixedRate(new DigestQueueManager(),
|
||||||
|
getTimeMsec(DIGEST_QUEUE_DELAY),
|
||||||
|
getTimeMsec(DIGEST_QUEUE_PERIOD));
|
||||||
|
|
||||||
|
timer1.scheduleAtFixedRate(new SimpleQueueManager(),
|
||||||
|
getTimeMsec(SIMPLE_QUEUE_DELAY),
|
||||||
|
getTimeMsec(SIMPLE_QUEUE_PERIOD));
|
||||||
|
|
||||||
|
timer2.scheduleAtFixedRate(new RequestManager(),
|
||||||
|
getTimeMsec(REQUEST_MANAGER_DELAY),
|
||||||
|
getTimeMsec(REQUEST_MANAGER_PERIOD));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to lookup a timing key and convert its value to
|
||||||
|
* milliseconds.
|
||||||
|
*
|
||||||
|
* @param key is the configuration parameter key
|
||||||
|
*/
|
||||||
|
|
||||||
|
private long getTimeMsec(String key) {
|
||||||
|
return ((Integer) m_conf.getParameter(key)).longValue() * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuts down the notification service.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Private interface for storing constants
|
||||||
|
*/
|
||||||
|
|
||||||
|
interface NotificationParameters {
|
||||||
|
|
||||||
|
public final static String REQUEST_MANAGER_DELAY =
|
||||||
|
"RequestManagerDelay";
|
||||||
|
public final static String REQUEST_MANAGER_DELAY_DESCRIPTION =
|
||||||
|
"Request manager's delay in seconds.";
|
||||||
|
public final static String REQUEST_MANAGER_PERIOD =
|
||||||
|
"RequestManagerPeriod";
|
||||||
|
public final static String REQUEST_MANAGER_PERIOD_DESCRIPTION =
|
||||||
|
"Request manager's period in seconds";
|
||||||
|
public final static String SIMPLE_QUEUE_DELAY =
|
||||||
|
"SimpleQueueDelay";
|
||||||
|
public final static String SIMPLE_QUEUE_DELAY_DESCRIPTION =
|
||||||
|
"Simple queue's delay in seconds.";
|
||||||
|
public final static String SIMPLE_QUEUE_PERIOD =
|
||||||
|
"SimpleQueuePeriod";
|
||||||
|
public final static String SIMPLE_QUEUE_PERIOD_DESCRIPTION =
|
||||||
|
"Simple queue's period in seconds.";
|
||||||
|
public final static String DIGEST_QUEUE_DELAY =
|
||||||
|
"DigestQueueDelay";
|
||||||
|
public final static String DIGEST_QUEUE_DELAY_DESCRIPTION =
|
||||||
|
"Digest queue's delay in seconds.";
|
||||||
|
public final static String DIGEST_QUEUE_PERIOD =
|
||||||
|
"DigestQueuePeriod";
|
||||||
|
public final static String DIGEST_QUEUE_PERIOD_DESCRIPTION =
|
||||||
|
"Digest queue's period in seconds.";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -82,15 +82,14 @@ import java.util.Date;
|
||||||
* @version $Id: Notification.java 1641 2007-09-17 13:46:27Z chrisg23 $ */
|
* @version $Id: Notification.java 1641 2007-09-17 13:46:27Z chrisg23 $ */
|
||||||
|
|
||||||
public class Notification extends ACSObject implements NotificationConstants {
|
public class Notification extends ACSObject implements NotificationConstants {
|
||||||
// Base DataObject type
|
|
||||||
|
|
||||||
|
// Base DataObject type
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
Notification.class.getName();
|
Notification.class.getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty <code>Notification</code>. This constructor
|
* Creates an empty <code>Notification</code>. This constructor is invoked
|
||||||
* is invoked by all others to initialize the following default
|
* by all others to initialize the following default parameters:
|
||||||
* parameters:
|
|
||||||
*
|
*
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>REQUEST_DATE to the current time
|
* <li>REQUEST_DATE to the current time
|
||||||
|
|
@ -104,7 +103,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* constructor or by calling the appropriate methods to change
|
* constructor or by calling the appropriate methods to change
|
||||||
* these parameter settings.
|
* these parameter settings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification() {
|
public Notification() {
|
||||||
super(BASE_DATA_OBJECT_TYPE);
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
|
|
@ -116,8 +114,8 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a notification by supplying the digest, sender,
|
* Creates a notification by supplying the digest, sender, receiver,
|
||||||
* receiver, subject, and body of the message.
|
* subject, and body of the message.
|
||||||
*
|
*
|
||||||
* @param digest the digest this notification is part of
|
* @param digest the digest this notification is part of
|
||||||
* @param to the party receiving the message
|
* @param to the party receiving the message
|
||||||
|
|
@ -125,7 +123,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* @param subject the subject of the message
|
* @param subject the subject of the message
|
||||||
* @param body the body of the message
|
* @param body the body of the message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification(Digest digest, Party to, Party from,
|
public Notification(Digest digest, Party to, Party from,
|
||||||
String subject, String body) {
|
String subject, String body) {
|
||||||
this(to,from,subject,body);
|
this(to,from,subject,body);
|
||||||
|
|
@ -133,34 +130,31 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a notification by supplying the digest, the receiver, and an existing
|
* Creates a notification by supplying the digest, the receiver, and an
|
||||||
* message to send.
|
* existing message to send.
|
||||||
*
|
*
|
||||||
* @param digest notification belongs to this digest
|
* @param digest notification belongs to this digest
|
||||||
* @param to the party recieving the message
|
* @param to the party recieving the message
|
||||||
* @param msg the message to send
|
* @param msg the message to send
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification(Digest digest, Party to, Message msg) {
|
public Notification(Digest digest, Party to, Message msg) {
|
||||||
this(to,msg);
|
this(to,msg);
|
||||||
setDigest(digest);
|
setDigest(digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a notification by supplying the sender, receiver,
|
* Creates a notification by supplying the sender, receiver, subject, and
|
||||||
* subject, and body of the message. Creates an internal {@link Message}
|
* body of the message. Creates an internal {@link Message} object to store
|
||||||
* object to store this information and sets the MessageDelete
|
* this information and sets the MessageDelete flag to <code>true</code> so
|
||||||
* flag to <code>true</code> so the internal object is deleted when
|
* the internal object is deleted when the notification is deleted.
|
||||||
* the notification is deleted. Also sets the isPermanent flag to
|
* Also sets the isPermanent flag to <code>false</code> so the
|
||||||
* <code>false</code> so the notification will be deleted after
|
* notification will be deleted after processing.
|
||||||
* processing.
|
|
||||||
*
|
*
|
||||||
* @param to the party receiving the message
|
* @param to the party receiving the message
|
||||||
* @param from the party sending the message
|
* @param from the party sending the message
|
||||||
* @param subject the subject of the message
|
* @param subject the subject of the message
|
||||||
* @param body the body of the message
|
* @param body the body of the message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification(Party to, Party from, String subject, String body) {
|
public Notification(Party to, Party from, String subject, String body) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
|
|
@ -174,13 +168,12 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a notification by supplying the receiver and an existing
|
* Creates a notification by supplying the receiver and an existing
|
||||||
* message to send. All other information (subject, body, and
|
* message to send. All other information (subject, body, and sender)
|
||||||
* sender) is encapsulated by the message.
|
* is encapsulated by the message.
|
||||||
*
|
*
|
||||||
* @param to the party recieving the message
|
* @param to the party recieving the message
|
||||||
* @param msg the message to send
|
* @param msg the message to send
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification(Party to, Message msg) {
|
public Notification(Party to, Message msg) {
|
||||||
this();
|
this();
|
||||||
|
|
||||||
|
|
@ -190,12 +183,10 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an existing notification from the database using its
|
* Retrieves an existing notification from the database using its OID.
|
||||||
* OID.
|
|
||||||
*
|
*
|
||||||
* @param oid the OID of the notification
|
* @param oid the OID of the notification
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification(OID oid) throws DataObjectNotFoundException {
|
public Notification(OID oid) throws DataObjectNotFoundException {
|
||||||
super(oid);
|
super(oid);
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +197,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param id the BigDecimal ID of the notification
|
* @param id the BigDecimal ID of the notification
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Notification(BigDecimal id) throws DataObjectNotFoundException {
|
public Notification(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
this(new OID(BASE_DATA_OBJECT_TYPE,id));
|
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.
|
* Sets the sender of the notification.
|
||||||
* @param to the sender of the notification
|
* @param to the sender of the notification
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setTo(Party to) {
|
public void setTo(Party to) {
|
||||||
set(PARTY_TO, to.getID());
|
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
|
* Gets the message object contained by this notification, which
|
||||||
* may be null.
|
* may be null.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Message getMessage() {
|
private Message getMessage() {
|
||||||
BigDecimal id = (BigDecimal) get(MESSAGE_ID);
|
BigDecimal id = (BigDecimal) get(MESSAGE_ID);
|
||||||
Message msg = null;
|
Message msg = null;
|
||||||
|
|
@ -247,7 +235,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* Note: should we disable this for anything not isNew()?
|
* Note: should we disable this for anything not isNew()?
|
||||||
* @param msg the message of this notification
|
* @param msg the message of this notification
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setMessage(Message msg) {
|
public void setMessage(Message msg) {
|
||||||
|
|
||||||
if (msg.isNew()) {
|
if (msg.isNew()) {
|
||||||
|
|
@ -260,7 +247,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
/**
|
/**
|
||||||
* Get the status of this notification.
|
* Get the status of this notification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return (String) get(STATUS);
|
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
|
* Gets the flag for whether this notification remains in the database
|
||||||
* database after processing.
|
* after processing.
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if this notification remains in the
|
* @return <code>true</code> if this notification remains in the database
|
||||||
* database after processing; <code>false</code> otherwise.
|
* after processing; <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Boolean getIsPermanent() {
|
public Boolean getIsPermanent() {
|
||||||
return new Boolean(!((Boolean) get(EXPUNGE_P)).booleanValue());
|
return new Boolean(!((Boolean) get(EXPUNGE_P)).booleanValue());
|
||||||
}
|
}
|
||||||
|
|
@ -292,7 +277,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* @param permanent <code>true</code> if this notification should
|
* @param permanent <code>true</code> if this notification should
|
||||||
* remain in the database after processing
|
* remain in the database after processing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setIsPermanent(Boolean permanent) {
|
public void setIsPermanent(Boolean permanent) {
|
||||||
set(EXPUNGE_P, new Boolean(!permanent.booleanValue()));
|
set(EXPUNGE_P, new Boolean(!permanent.booleanValue()));
|
||||||
}
|
}
|
||||||
|
|
@ -302,7 +286,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* @return <code>true</code> if the MessageDelete flag is set;
|
* @return <code>true</code> if the MessageDelete flag is set;
|
||||||
* <code>false</code> otherwise.
|
* <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Boolean getMessageDelete() {
|
public Boolean getMessageDelete() {
|
||||||
return (Boolean) get(EXPUNGE_MSG_P);
|
return (Boolean) get(EXPUNGE_MSG_P);
|
||||||
}
|
}
|
||||||
|
|
@ -313,7 +296,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* @param value <code>true</code> if the underlying message should be
|
* @param value <code>true</code> if the underlying message should be
|
||||||
* deleted when this request is deleted
|
* deleted when this request is deleted
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setMessageDelete(Boolean value) {
|
public void setMessageDelete(Boolean value) {
|
||||||
set(EXPUNGE_MSG_P, 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
|
* @return the digest of this notification, or null if
|
||||||
* there is no digest.
|
* there is no digest.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Digest getDigest()
|
public Digest getDigest()
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -358,7 +339,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
*
|
*
|
||||||
* @param digest the digest this message belongs to
|
* @param digest the digest this message belongs to
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setDigest(Digest digest) {
|
public void setDigest(Digest digest) {
|
||||||
set(DIGEST_ID, digest.getID());
|
set(DIGEST_ID, digest.getID());
|
||||||
}
|
}
|
||||||
|
|
@ -398,7 +378,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* @param header the header of the alert
|
* @param header the header of the alert
|
||||||
* @since 4.8.1
|
* @since 4.8.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setHeader(String header) {
|
public void setHeader(String header) {
|
||||||
set(HEADER, header);
|
set(HEADER, header);
|
||||||
}
|
}
|
||||||
|
|
@ -411,19 +390,17 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* @param signature the signature of the alert
|
* @param signature the signature of the alert
|
||||||
* @since 4.8.1
|
* @since 4.8.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setSignature(String signature) {
|
public void setSignature(String signature) {
|
||||||
set(SIGNATURE, signature);
|
set(SIGNATURE, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <code>true</code> if the primary MIME type of the
|
* Returns <code>true</code> if the primary MIME type of the contained
|
||||||
* contained message matches the specified MIME type. Always
|
* message matches the specified MIME type. Always returns false if a
|
||||||
* returns false if a message has not been specified.
|
* message has not been specified.
|
||||||
*
|
*
|
||||||
* @return true if the contained Message is of the specified type.
|
* @return true if the contained Message is of the specified type.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private boolean isMimeType(String type) {
|
private boolean isMimeType(String type) {
|
||||||
Message msg = getMessage();
|
Message msg = getMessage();
|
||||||
if (msg == null) {
|
if (msg == null) {
|
||||||
|
|
@ -435,9 +412,8 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
|
|
||||||
protected void beforeSave() {
|
protected void beforeSave() {
|
||||||
|
|
||||||
// Check to see if we need to save the underlying
|
// Check to see if we need to save the underlying message. This
|
||||||
// message. This could be the case if we generated an internal
|
// could be the case if we generated an internal message.
|
||||||
// message.
|
|
||||||
|
|
||||||
Message msg = getMessage();
|
Message msg = getMessage();
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
|
|
@ -455,7 +431,6 @@ public class Notification extends ACSObject implements NotificationConstants {
|
||||||
* Deletes the notification. This also checks to see if the
|
* Deletes the notification. This also checks to see if the
|
||||||
* corresponding message should be deleted at the same time.
|
* corresponding message should be deleted at the same time.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
|
|
||||||
boolean msgDelete = getMessageDelete().booleanValue();
|
boolean msgDelete = getMessageDelete().booleanValue();
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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]
|
||||||
|
|
@ -61,16 +61,14 @@ class QueueItem extends ObservableDomainObject
|
||||||
new HtmlToText();
|
new HtmlToText();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message object contained by this notification. Retrieved
|
* The message object contained by this notification. Retrieved once
|
||||||
* once from the database and cached.
|
* from the database and cached.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private Message m_message;
|
private Message m_message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a QueueItem from an OID.
|
* Creates a QueueItem from an OID.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QueueItem(OID oid) throws DataObjectNotFoundException {
|
QueueItem(OID oid) throws DataObjectNotFoundException {
|
||||||
super(oid);
|
super(oid);
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +76,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Creates a QueueItem from a Notification and recipient.
|
* Creates a QueueItem from a Notification and recipient.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QueueItem(Notification n, Party to) {
|
QueueItem(Notification n, Party to) {
|
||||||
super(BASE_DATA_OBJECT_TYPE);
|
super(BASE_DATA_OBJECT_TYPE);
|
||||||
set(REQUEST_ID, n.getID());
|
set(REQUEST_ID, n.getID());
|
||||||
|
|
@ -88,7 +85,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Set the success flag for this notification.
|
* Set the success flag for this notification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void setSuccess(Boolean b) {
|
void setSuccess(Boolean b) {
|
||||||
set(SUCCESS, b);
|
set(SUCCESS, b);
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +92,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Gets the message object contained by this notification.
|
* Gets the message object contained by this notification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Message getMessage()
|
Message getMessage()
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -109,7 +104,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Returns the email address of the recipient as a String.
|
* Returns the email address of the recipient as a String.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String getTo() {
|
String getTo() {
|
||||||
return (String) get(PARTY_TO_ADDR);
|
return (String) get(PARTY_TO_ADDR);
|
||||||
}
|
}
|
||||||
|
|
@ -117,7 +111,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Returns the email address of the sender as a String.
|
* Returns the email address of the sender as a String.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String getFrom()
|
String getFrom()
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +120,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Returns the subject of the notification.
|
* Returns the subject of the notification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String getSubject()
|
String getSubject()
|
||||||
throws DataObjectNotFoundException
|
throws DataObjectNotFoundException
|
||||||
{
|
{
|
||||||
|
|
@ -137,7 +129,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Gets the header for this notification.
|
* Gets the header for this notification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String getHeader() {
|
private String getHeader() {
|
||||||
return StringUtils.nullToEmptyString((String) get(HEADER));
|
return StringUtils.nullToEmptyString((String) get(HEADER));
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +136,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
/**
|
/**
|
||||||
* Gets the signature for this notification.
|
* Gets the signature for this notification.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String getSignature() {
|
private String getSignature() {
|
||||||
return StringUtils.nullToEmptyString((String) get(SIGNATURE));
|
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
|
* @return a plain text message to send as email to a user
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String getBody() throws DataObjectNotFoundException {
|
String getBody() throws DataObjectNotFoundException {
|
||||||
|
|
||||||
Message msg = getMessage();
|
Message msg = getMessage();
|
||||||
|
|
@ -178,6 +167,10 @@ class QueueItem extends ObservableDomainObject
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param mail
|
||||||
|
*/
|
||||||
void setBody(Mail mail) {
|
void setBody(Mail mail) {
|
||||||
Message msg = getMessage();
|
Message msg = getMessage();
|
||||||
String altBody = getBody();
|
String altBody = getBody();
|
||||||
|
|
@ -206,7 +199,6 @@ class QueueItem extends ObservableDomainObject
|
||||||
*
|
*
|
||||||
* @param mail the Mail to add attachments to
|
* @param mail the Mail to add attachments to
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void addAttachments(Mail mail)
|
void addAttachments(Mail mail)
|
||||||
throws MessagingException
|
throws MessagingException
|
||||||
{
|
{
|
||||||
|
|
@ -229,18 +221,34 @@ class QueueItem extends ObservableDomainObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
BigDecimal getRetryCount() {
|
BigDecimal getRetryCount() {
|
||||||
return (BigDecimal) get(RETRY_COUNT);
|
return (BigDecimal) get(RETRY_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param i
|
||||||
|
*/
|
||||||
void setRetryCount(BigDecimal i) {
|
void setRetryCount(BigDecimal i) {
|
||||||
set(RETRY_COUNT, i);
|
set(RETRY_COUNT, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void incrRetryCount() {
|
void incrRetryCount() {
|
||||||
set(RETRY_COUNT, getRetryCount().add(new BigDecimal(1)));
|
set(RETRY_COUNT, getRetryCount().add(new BigDecimal(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private StringBuffer qualifyImageTags (StringBuffer body) {
|
private StringBuffer qualifyImageTags (StringBuffer body) {
|
||||||
s_log.debug("qualify image tags");
|
s_log.debug("qualify image tags");
|
||||||
boolean inTagTest = false;
|
boolean inTagTest = false;
|
||||||
|
|
@ -258,8 +266,10 @@ class QueueItem extends ObservableDomainObject
|
||||||
// start of an image attribute value (or end)
|
// start of an image attribute value (or end)
|
||||||
if (converted.toString().endsWith("src=" + nextChar)) {
|
if (converted.toString().endsWith("src=" + nextChar)) {
|
||||||
s_log.debug("In fact, the start of the src attribute");
|
s_log.debug("In fact, the start of the src attribute");
|
||||||
converted.append("http://" + Web.getConfig().getServer().toString());
|
converted.append("http://" +
|
||||||
s_log.debug("inserting server name " + Web.getConfig().getServer().toString());
|
Web.getConfig().getServer().toString());
|
||||||
|
s_log.debug("inserting server name " +
|
||||||
|
Web.getConfig().getServer().toString());
|
||||||
inImageTag = false;
|
inImageTag = false;
|
||||||
inTagTest = false;
|
inTagTest = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,10 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The RequestManager is a child of TimerTask. It is scheduled for periodic
|
* The RequestManager is a child of TimerTask. It is scheduled for periodic
|
||||||
* execution in the Initializer. RequestManager sweeps through the list of notification
|
* execution in the Initializer. RequestManager sweeps through the list of
|
||||||
* requests and queues them for sending. Once a request is in the queue, its
|
* notification requests and queues them for sending. Once a request is in
|
||||||
* status is updated each time together and any necessary clean-up work is performed.
|
* the queue, its status is updated each time together and any necessary
|
||||||
|
* clean-up work is performed.
|
||||||
*
|
*
|
||||||
* @author David Dao
|
* @author David Dao
|
||||||
* @version $Id: RequestManager.java 287 2005-02-22 00:29:02Z sskracic $
|
* @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 {
|
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 =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(RequestManager.class.getName());
|
Logger.getLogger(RequestManager.class.getName());
|
||||||
|
|
||||||
|
|
@ -74,8 +72,8 @@ class RequestManager extends TimerTask {
|
||||||
"com.arsdigita.notification.GetCompleteNotifications";
|
"com.arsdigita.notification.GetCompleteNotifications";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the run method of TimerTask. This is the execution block each time
|
* Implements the run method of TimerTask. This is the execution block each
|
||||||
* the RequestManager runs. The following actions are performed:
|
* time the RequestManager runs. The following actions are performed:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Updates the status of requests, identifying which succeeded or failed
|
* <li>Updates the status of requests, identifying which succeeded or failed
|
||||||
* since the method was last run
|
* since the method was last run
|
||||||
|
|
@ -86,124 +84,122 @@ class RequestManager extends TimerTask {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
KernelExcursion rootExcursion = new KernelExcursion() {
|
KernelExcursion rootExcursion = new KernelExcursion() {
|
||||||
protected void excurse() {
|
protected void excurse() {
|
||||||
setEffectiveParty(Kernel.getSystemParty());
|
setEffectiveParty(Kernel.getSystemParty());
|
||||||
s_log.info("processing current requests.");
|
s_log.info("processing current requests.");
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check and update status of requests that have already been queued.
|
||||||
|
*/
|
||||||
|
boolean committedTxn = false;
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
session.getTransactionContext().beginTxn();
|
||||||
|
|
||||||
|
try {
|
||||||
|
session.retrieveDataOperation(UPDATE_NOTIFICATION_SUCCESSFUL).execute();
|
||||||
|
session.retrieveDataOperation(UPDATE_NOTIFICATION_FAILURE).execute();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check and update status of requests that have already been queued.
|
* NOTE: I need to rewrite this query. Currently this query is working
|
||||||
|
* correctly if it executes after UPDATE_NOTIFICATION_SUCCESSFUL and
|
||||||
|
* UPDATE_NOTIFICATION_FAILURE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
boolean committedTxn = false;
|
session.retrieveDataOperation(UPDATE_NOTIFICATION_PARTIAL_FAILURE).execute();
|
||||||
Session session = SessionManager.getSession();
|
|
||||||
session.getTransactionContext().beginTxn();
|
|
||||||
|
|
||||||
try {
|
// delete from nt_queue where status in ('sent', failed, partial-failure)
|
||||||
session.retrieveDataOperation(UPDATE_NOTIFICATION_SUCCESSFUL).execute();
|
|
||||||
session.retrieveDataOperation(UPDATE_NOTIFICATION_FAILURE).execute();
|
|
||||||
|
|
||||||
/**
|
session.retrieveDataOperation(DELETE_NOTIFICATION_QUEUED).execute();
|
||||||
* NOTE: I need to rewrite this query. Currently this query is working
|
|
||||||
* correctly if it executes after UPDATE_NOTIFICATION_SUCCESSFUL and
|
|
||||||
* UPDATE_NOTIFICATION_FAILURE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
session.retrieveDataOperation(UPDATE_NOTIFICATION_PARTIAL_FAILURE).execute();
|
// Iterate through a list of notifications and invoke delete on each
|
||||||
|
// object.
|
||||||
|
// Why I am not using one query to do the delete?
|
||||||
|
// Because there is no DELETE CASCADE in the datamodel for nt_requests
|
||||||
|
// table.
|
||||||
|
|
||||||
// delete from nt_queue where status in ('sent', failed, partial-failure)
|
DataQuery qry = session.retrieveQuery(GET_COMPLETE_NOTIFICATIONS);
|
||||||
|
while (qry.next()) {
|
||||||
session.retrieveDataOperation(DELETE_NOTIFICATION_QUEUED).execute();
|
try {
|
||||||
|
OID oid = new OID(Notification.BASE_DATA_OBJECT_TYPE, qry.get(REQUEST_ID));
|
||||||
// Iterate through a list of notifications and invoke delete on each
|
Notification n = new Notification(oid);
|
||||||
// object.
|
n.delete();
|
||||||
// Why I am not using one query to do the delete?
|
} catch (DataObjectNotFoundException e) {
|
||||||
// Because there is no DELETE CASCADE in the datamodel for nt_requests
|
s_log.error("Retrieve complete notification", e);
|
||||||
// table.
|
// skip this notification.
|
||||||
|
|
||||||
DataQuery qry = session.retrieveQuery(GET_COMPLETE_NOTIFICATIONS);
|
|
||||||
while (qry.next()) {
|
|
||||||
try {
|
|
||||||
OID oid = new OID(Notification.BASE_DATA_OBJECT_TYPE, qry.get(REQUEST_ID));
|
|
||||||
Notification n = new Notification(oid);
|
|
||||||
n.delete();
|
|
||||||
} catch (DataObjectNotFoundException e) {
|
|
||||||
s_log.error("Retrieve complete notification", e);
|
|
||||||
// skip this notification.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
session.getTransactionContext().commitTxn();
|
|
||||||
committedTxn = true;
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (!committedTxn) {
|
|
||||||
session.getTransactionContext().abortTxn();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
session.getTransactionContext().commitTxn();
|
||||||
|
committedTxn = true;
|
||||||
|
|
||||||
/**
|
} finally {
|
||||||
* Tranfer pending requests to the outbound queue.
|
if (!committedTxn) {
|
||||||
*/
|
session.getTransactionContext().abortTxn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
session.getTransactionContext().beginTxn();
|
/**
|
||||||
committedTxn = false;
|
* Tranfer pending requests to the outbound queue.
|
||||||
|
*/
|
||||||
|
|
||||||
try {
|
session.getTransactionContext().beginTxn();
|
||||||
DataQuery query = session.retrieveQuery(GET_PENDING_NOTIFCATIONS);
|
committedTxn = false;
|
||||||
|
|
||||||
while (query.next()) {
|
try {
|
||||||
|
DataQuery query = session.retrieveQuery(GET_PENDING_NOTIFCATIONS);
|
||||||
|
|
||||||
BigDecimal requestID = (BigDecimal) query.get(REQUEST_ID);
|
while (query.next()) {
|
||||||
BigDecimal partyTo = (BigDecimal) query.get(PARTY_TO);
|
|
||||||
|
|
||||||
try {
|
BigDecimal requestID = (BigDecimal) query.get(REQUEST_ID);
|
||||||
|
BigDecimal partyTo = (BigDecimal) query.get(PARTY_TO);
|
||||||
|
|
||||||
OID oid = new OID(Party.BASE_DATA_OBJECT_TYPE, partyTo);
|
try {
|
||||||
Party party = (Party) DomainObjectFactory.newInstance(oid);
|
|
||||||
|
|
||||||
Notification notification = new Notification(new OID(Notification.BASE_DATA_OBJECT_TYPE, requestID));
|
OID oid = new OID(Party.BASE_DATA_OBJECT_TYPE, partyTo);
|
||||||
notification.setStatus(NOTIFICATION_IN_QUEUE);
|
Party party = (Party) DomainObjectFactory.newInstance(oid);
|
||||||
notification.save();
|
|
||||||
|
|
||||||
// Add notification to queue
|
Notification notification = new Notification(new OID(Notification.BASE_DATA_OBJECT_TYPE, requestID));
|
||||||
|
notification.setStatus(NOTIFICATION_IN_QUEUE);
|
||||||
|
notification.save();
|
||||||
|
|
||||||
Boolean isGroupExpand = notification.getExpandGroup();
|
// Add notification to queue
|
||||||
boolean expand = true; // Default value for group expand
|
Boolean isGroupExpand = notification.getExpandGroup();
|
||||||
|
boolean expand = true; // Default value for group expand
|
||||||
|
|
||||||
if (isGroupExpand != null)
|
if (isGroupExpand != null)
|
||||||
expand = isGroupExpand.booleanValue();
|
expand = isGroupExpand.booleanValue();
|
||||||
|
|
||||||
if ((party instanceof User) || (!expand)) {
|
if ((party instanceof User) || (!expand)) {
|
||||||
QueueItem queued = new QueueItem(notification, party);
|
QueueItem queued = new QueueItem(notification, party);
|
||||||
|
queued.save();
|
||||||
|
} else if (party instanceof Group) {
|
||||||
|
// Expand group.
|
||||||
|
Group group = (Group) party;
|
||||||
|
UserCollection userCollection = group.getAllMemberUsers();
|
||||||
|
while (userCollection.next()) {
|
||||||
|
User user = userCollection.getUser();
|
||||||
|
QueueItem queued = new QueueItem(notification, user);
|
||||||
queued.save();
|
queued.save();
|
||||||
} else if (party instanceof Group) {
|
|
||||||
// Expand group.
|
|
||||||
Group group = (Group) party;
|
|
||||||
UserCollection userCollection = group.getAllMemberUsers();
|
|
||||||
while (userCollection.next()) {
|
|
||||||
User user = userCollection.getUser();
|
|
||||||
QueueItem queued = new QueueItem(notification, user);
|
|
||||||
queued.save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
s_log.warn("RequestManager", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
s_log.warn("RequestManager", e);
|
||||||
session.getTransactionContext().commitTxn();
|
e.printStackTrace();
|
||||||
committedTxn = true;
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (!committedTxn) {
|
|
||||||
session.getTransactionContext().abortTxn();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
time = System.currentTimeMillis() - time;
|
session.getTransactionContext().commitTxn();
|
||||||
s_log.info("RequestManager executed in " + time + " ms.");
|
committedTxn = true;
|
||||||
}};
|
|
||||||
|
} finally {
|
||||||
|
if (!committedTxn) {
|
||||||
|
session.getTransactionContext().abortTxn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
time = System.currentTimeMillis() - time;
|
||||||
|
s_log.info("RequestManager executed in " + time + " ms.");
|
||||||
|
}};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rootExcursion.run();
|
rootExcursion.run();
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.Session;
|
import com.arsdigita.persistence.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.util.StringUtils;
|
// import com.arsdigita.util.StringUtils;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
@ -45,15 +45,12 @@ class SimpleQueueManager extends TimerTask
|
||||||
implements NotificationConstants
|
implements NotificationConstants
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String versionId = "$Id: SimpleQueueManager.java 1513 2007-03-22 09:09:03Z chrisgilbert23 $ by $Author: chrisgilbert23 $, $Date: 2004/08/16 $";
|
|
||||||
|
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(SimpleQueueManager.class.getName());
|
Logger.getLogger(SimpleQueueManager.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs one sweep of the SimpleQueueManager.
|
* Performs one sweep of the SimpleQueueManager.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
s_log.info("processing current requests");
|
s_log.info("processing current requests");
|
||||||
|
|
|
||||||
|
|
@ -172,4 +172,4 @@ public class MasterTool {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -20,12 +20,12 @@ package com.arsdigita.persistence;
|
||||||
|
|
||||||
import com.arsdigita.persistence.metadata.MetadataRoot;
|
import com.arsdigita.persistence.metadata.MetadataRoot;
|
||||||
import com.arsdigita.persistence.pdl.PDLCompiler;
|
import com.arsdigita.persistence.pdl.PDLCompiler;
|
||||||
import com.arsdigita.runtime.DataInitEvent;
|
|
||||||
import com.arsdigita.runtime.DomainInitEvent;
|
import com.arsdigita.runtime.DomainInitEvent;
|
||||||
import com.arsdigita.runtime.LegacyInitEvent;
|
|
||||||
import com.arsdigita.runtime.RuntimeConfig;
|
import com.arsdigita.runtime.RuntimeConfig;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import org.apache.log4j.Level;
|
import org.apache.log4j.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -35,21 +35,19 @@ import org.apache.log4j.Level;
|
||||||
* @version $Revision: #23 $ $Date: 2004/08/16 $
|
* @version $Revision: #23 $ $Date: 2004/08/16 $
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public class Initializer implements com.arsdigita.runtime.Initializer {
|
public class Initializer extends com.arsdigita.runtime.GenericInitializer {
|
||||||
|
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
Logger.getLogger(Initializer.class.getName());
|
Logger.getLogger(Initializer.class.getName());
|
||||||
|
|
||||||
public void init(DataInitEvent evt) { }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the session and loads the persistence metadata from a
|
* Sets up the session and loads the persistence metadata from a file
|
||||||
* file somewhere in your classpath. The name of the file to which
|
* somewhere in your classpath. The name of the file to which to search for
|
||||||
* to search for is defined by the metadataXmlFileName
|
* is defined by the metadataXmlFileName initialization parameter.
|
||||||
* initialization parameter.
|
|
||||||
**/
|
**/
|
||||||
public void init(DomainInitEvent evt) {
|
public void init(DomainInitEvent evt) {
|
||||||
com.redhat.persistence.oql.Query.setQueryCacheSize( RuntimeConfig.getConfig().getQueryCacheSize() );
|
com.redhat.persistence.oql.Query.setQueryCacheSize(
|
||||||
|
RuntimeConfig.getConfig().getQueryCacheSize() );
|
||||||
|
|
||||||
// Finally the files out of the database
|
// Finally the files out of the database
|
||||||
TransactionContext txn = null;
|
TransactionContext txn = null;
|
||||||
|
|
@ -125,5 +123,4 @@ public class Initializer implements com.arsdigita.runtime.Initializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(LegacyInitEvent evt) { }
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
* @author Rafael H. Schloming <rhs@mit.edu>
|
||||||
* @version $Id: CompoundInitializer.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: CompoundInitializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public class CompoundInitializer implements Initializer {
|
public class CompoundInitializer implements Initializer {
|
||||||
|
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
|
|
@ -48,8 +47,7 @@ public class CompoundInitializer implements Initializer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new and empty compound initializer.
|
* Creates a new and empty compound initializer.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public CompoundInitializer() {
|
public CompoundInitializer() {
|
||||||
this(s_log);
|
this(s_log);
|
||||||
}
|
}
|
||||||
|
|
@ -60,33 +58,30 @@ public class CompoundInitializer implements Initializer {
|
||||||
*
|
*
|
||||||
* @param log A logger to be used for logging progress through
|
* @param log A logger to be used for logging progress through
|
||||||
* initialization.
|
* initialization.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public CompoundInitializer(Logger log) {
|
public CompoundInitializer(Logger log) {
|
||||||
m_log = log;
|
m_log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds <code>init</code> to the set of initializers to be
|
* Adds <code>init</code> to the set of initializers to be initialized by
|
||||||
* initialized by this CompoundInitializer. The most recently
|
* this CompoundInitializer.
|
||||||
* added initializers will be invoked last.
|
*
|
||||||
|
* The most recently added initializers will be invoked last.
|
||||||
*
|
*
|
||||||
* @param init The initializer to add to this CompoundInitializer
|
* @param init The initializer to add to this CompoundInitializer
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public void add(Initializer init) {
|
public void add(Initializer init) {
|
||||||
m_inits.add(init);
|
m_inits.add(init);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the {@link Initializer#init(DataInitEvent)}
|
* Implementation of the {@link Initializer#init(DataInitEvent)} method.
|
||||||
* method. This implementation proceeds through the list of sub
|
* This implementation proceeds through the list of sub initializers in order
|
||||||
* initializers in order and invokes the init(DataInitEvent)
|
* and invokes the init(DataInitEvent) method of each sub initializer in turn.
|
||||||
* method of each sub initializer in turn.
|
|
||||||
*
|
*
|
||||||
* @param evt The data init event.
|
* @param evt The data init event.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public void init(DataInitEvent evt) {
|
public void init(DataInitEvent evt) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
|
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)}
|
* Implementation of the {@link Initializer#init(DomainInitEvent)} method.
|
||||||
* method. This implementation proceeds through the list of sub
|
* This implementation proceeds through the list of sub initializers in
|
||||||
* initializers in order and invokes the init(DomainInitEvent)
|
* order and invokes the init(DomainInitEvent) method of each sub initializer
|
||||||
* method of each sub initializer in turn.
|
* in turn.
|
||||||
*
|
*
|
||||||
* @param evt The domain init event.
|
* @param evt The domain init event.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public void init(DomainInitEvent evt) {
|
public void init(DomainInitEvent evt) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
|
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)}
|
* Implementation of the {@link Initializer#init(LegacyInitEvent)} method.
|
||||||
* method. This implementation proceeds through the list of sub
|
* This implementation proceeds through the list of sub initializers in
|
||||||
* initializers in order and invokes the init(LegacyInitEvent)
|
* order and invokes the init(LegacyInitEvent) method of each sub initializer
|
||||||
* method of each sub initializer in turn.
|
* in turn.
|
||||||
*
|
*
|
||||||
* @param evt The legacy init event.
|
* @param evt The legacy init event.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
public void init(LegacyInitEvent evt) {
|
public void init(LegacyInitEvent evt) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,12 @@ import org.apache.log4j.Logger;
|
||||||
*
|
*
|
||||||
* An error to indicate invalid configurations.
|
* An error to indicate invalid configurations.
|
||||||
*
|
*
|
||||||
|
* Usage: throw new ConfigError( "message" );
|
||||||
|
*
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: ConfigError.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: ConfigError.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
*/
|
*/
|
||||||
public class ConfigError extends Error {
|
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
|
private static final Logger s_log = Logger.getLogger
|
||||||
(ConfigError.class);
|
(ConfigError.class);
|
||||||
|
|
|
||||||
|
|
@ -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());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -21,20 +21,15 @@ package com.arsdigita.runtime;
|
||||||
import com.arsdigita.persistence.pdl.PDLCompiler;
|
import com.arsdigita.persistence.pdl.PDLCompiler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DataInitEvent is passed to the {@link
|
* A DataInitEvent is passed to the {@link Initializer#init(DataInitEvent)}
|
||||||
* Initializer#init(DataInitEvent)} method in order to provide the
|
* method in order to provide the target Initializer access to the objects
|
||||||
* target Initializer access to the objects necessary to properly
|
* necessary to properly initialize the data layer.
|
||||||
* initialize the data layer.
|
|
||||||
*
|
*
|
||||||
* @author Rafael Schloming <rhs@mit.edu>
|
* @author Rafael Schloming <rhs@mit.edu>
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: DataInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: DataInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
*/
|
*/
|
||||||
public final class DataInitEvent {
|
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;
|
private final PDLCompiler m_compiler;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,6 @@ import com.arsdigita.domain.DomainObjectFactory;
|
||||||
* @version $Id: DomainInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: DomainInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
*/
|
*/
|
||||||
public final class DomainInitEvent {
|
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;
|
private final DomainObjectFactory m_factory;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -22,14 +22,26 @@ package com.arsdigita.runtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Initializer interface is used to prepare the CCM runtime for
|
* The Initializer interface is used to prepare the CCM runtime for
|
||||||
* interaction with the CCM database. This is done in two phases.
|
* interaction with the CCM database as well as cleanly shutdown a running CCM.
|
||||||
* First the data layer is initialized by loading any
|
*
|
||||||
* object-relational mapping metadata. Secondly the domain layer is
|
* Every CCM module usually provides an implementation of the initializer
|
||||||
* initialized by registering any domain metadata. This usually
|
* interface (specified in <module>.load and processed during installation in
|
||||||
* consists of domain object instantiators and observers. It is not
|
* the load step) which is invoked by the startup mechanism at boot time (and
|
||||||
* safe for CCM code to interact with a CCM database until these
|
* in case of shutdown) of the application ( @see com.arsdigita.runtime.Startup ).
|
||||||
|
*
|
||||||
|
* Preparation 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. Any
|
||||||
|
* other initialization requirements may be handled here as well.
|
||||||
|
*
|
||||||
|
* It is not safe for CCM code to interact with a CCM database until these
|
||||||
* phases have been completed.
|
* phases have been completed.
|
||||||
*
|
*
|
||||||
|
* Shutdown is done in one step where a domain object may provide housekeeping
|
||||||
|
* functionality, e.g. stop watch dogs or other background processes.
|
||||||
|
*
|
||||||
* @author Rafael Schloming <rhs@mit.edu>
|
* @author Rafael Schloming <rhs@mit.edu>
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: Initializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
|
|
@ -68,4 +80,16 @@ public interface Initializer {
|
||||||
*/
|
*/
|
||||||
void init(LegacyInitEvent e);
|
void init(LegacyInitEvent e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
void init(ContextInitEvent e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys the domain object, especially used to stop any background
|
||||||
|
* process.
|
||||||
|
*/
|
||||||
|
public void close(ContextCloseEvent evt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,6 @@ import com.arsdigita.persistence.Session;
|
||||||
* @version $Id: LegacyInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
|
* @version $Id: LegacyInitEvent.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
*/
|
*/
|
||||||
public final class LegacyInitEvent {
|
public final class LegacyInitEvent {
|
||||||
public final static String versionId =
|
|
||||||
"$Id: LegacyInitEvent.java 287 2005-02-22 00:29:02Z sskracic $" +
|
|
||||||
"$Author: sskracic $" +
|
|
||||||
"$DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
private final Session m_session;
|
private final Session m_session;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,11 @@ import java.io.InputStream;
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*
|
*
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
* @author Rafael H. Schloming <rhs@mit.edu>
|
||||||
* @version $Revision: #7 $ $Date: 2004/08/16 $
|
* @version $Id: LegacyInitializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public class LegacyInitializer implements Initializer {
|
public class LegacyInitializer extends GenericInitializer {
|
||||||
|
|
||||||
public final static String versionId = "$Id: LegacyInitializer.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
protected String m_init;
|
protected String m_init;
|
||||||
protected ConfigRegistry m_reg;
|
protected ConfigRegistry m_reg;
|
||||||
|
|
||||||
|
|
@ -102,24 +100,6 @@ public class LegacyInitializer implements Initializer {
|
||||||
this(init, Thread.currentThread().getContextClassLoader());
|
this(init, Thread.currentThread().getContextClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implentation of {@link Initializer#init(DataInitEvent evt)}
|
|
||||||
* that does nothing.
|
|
||||||
**/
|
|
||||||
|
|
||||||
public void init(DataInitEvent evt) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implentation of {@link Initializer#init(DomainInitEvent evt)}
|
|
||||||
* that does nothing.
|
|
||||||
**/
|
|
||||||
|
|
||||||
public void init(DomainInitEvent evt) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of {@link Initializer#init(LegacyInitEvent evt)}
|
* Implementation of {@link Initializer#init(LegacyInitEvent evt)}
|
||||||
* that locates the enterprise.init resource referenced in the
|
* that locates the enterprise.init resource referenced in the
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,11 @@ import com.arsdigita.persistence.pdl.PDLSource;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PDLInitializer class provides an implementation of the {@link
|
* Provides an implementation of the {@link Initializer} interface that works
|
||||||
* Initializer} interface that works in conjunction with the {@link
|
* in conjunction with the {@link PDLSource} interface and implementations
|
||||||
* PDLSource} interface and implementations thereof in order to
|
* thereof in order to provide a convenient way to initialize object-relational
|
||||||
* provide a convenient way to initialize object-relational metadata.
|
* metadata.
|
||||||
|
*
|
||||||
* This class is most convenient when used in conjunction with the
|
* This class is most convenient when used in conjunction with the
|
||||||
* {@link CompoundInitializer} class. For example:
|
* {@link CompoundInitializer} class. For example:
|
||||||
*
|
*
|
||||||
|
|
@ -49,24 +50,21 @@ import com.arsdigita.persistence.pdl.PDLSource;
|
||||||
* }
|
* }
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
*
|
*
|
||||||
* The class defined above will load all the object-relational
|
* The class defined above will load all the object-relational metadata for the
|
||||||
* metadata for the current database referenced from the
|
* current database referenced from the example-app.pdl.mf manifest file.
|
||||||
* example-app.pdl.mf manifest file.
|
|
||||||
*
|
*
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
* @author Rafael H. Schloming <rhs@mit.edu>
|
||||||
* @version $Revision: #6 $ $Date: 2004/08/16 $
|
* @version $Id: PDLInitializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public class PDLInitializer implements Initializer {
|
public class PDLInitializer implements Initializer {
|
||||||
|
|
||||||
public final static String versionId = "$Id: PDLInitializer.java 287 2005-02-22 00:29:02Z sskracic $ by $Author: sskracic $, $DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
private final PDLSource m_source;
|
private final PDLSource m_source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new implementation of the {@link Initializer}
|
* Constructs a new implementation of the {@link Initializer} interface
|
||||||
* interface that will upon invokation load any object-relational
|
* that will upon invokation load any object-relational metadata
|
||||||
* metadata referenced by the given PDLSource.
|
* referenced by the given PDLSource.
|
||||||
*
|
*
|
||||||
* @param source The object-relational metadata to load.
|
* @param source The object-relational metadata to load.
|
||||||
**/
|
**/
|
||||||
|
|
@ -76,10 +74,9 @@ public class PDLInitializer implements Initializer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of the {@link
|
* An implementation of the {@link Initializer#init(DataInitEvent)} that
|
||||||
* Initializer#init(DataInitEvent)} that loads the
|
* loads the object-relational metadata from the PDLSource specified
|
||||||
* object-relational metadata from the PDLSource specified during
|
* during construction of this PDLInitializer.
|
||||||
* construction of this PDLInitializer.
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public void init(DataInitEvent evt) {
|
public void init(DataInitEvent evt) {
|
||||||
|
|
@ -103,4 +100,20 @@ public class PDLInitializer implements Initializer {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty implementation of {@link Initializer#init(ContextInitEvent)}.
|
||||||
|
**/
|
||||||
|
|
||||||
|
public void init(ContextInitEvent evt) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty implementation of {@link Initializer#close()}.
|
||||||
|
**/
|
||||||
|
|
||||||
|
public void close(ContextCloseEvent evt) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,10 @@ import java.net.URL;
|
||||||
* waf.config.parents :
|
* waf.config.parents :
|
||||||
*
|
*
|
||||||
* @author Rafael H. Schloming <rhs@mit.edu>
|
* @author Rafael H. Schloming <rhs@mit.edu>
|
||||||
* @version $Revision: #6 $ $Date: 2004/08/16 $
|
* @version $Id: RegistryConfig.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
**/
|
**/
|
||||||
public class RegistryConfig extends AbstractConfig {
|
public class RegistryConfig extends AbstractConfig {
|
||||||
|
|
||||||
public final static String versionId =
|
|
||||||
"$Id: RegistryConfig.java 287 2005-02-22 00:29:02Z sskracic $" +
|
|
||||||
" by $Author: sskracic $, " +
|
|
||||||
"$DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
private static String[] array(String str) {
|
private static String[] array(String str) {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,534 @@
|
||||||
|
/*
|
||||||
|
* 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 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The central 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 and to shutdown the system by the servlet container or a manager
|
||||||
|
* application.
|
||||||
|
*
|
||||||
|
* It does this by accessing a persistent list of all the initializers required
|
||||||
|
* by the currently loaded modules. During startup this guarantees that any of
|
||||||
|
* these modules has the opportunity to load any object-relational metadata and
|
||||||
|
* register any domain-data coupling metadata before any database I/O is performed.
|
||||||
|
* During shutdown it enables all loaded modules to cleanup their runtime
|
||||||
|
* resources.
|
||||||
|
*
|
||||||
|
* USAGE:
|
||||||
|
* To startup construct an instance of this class and invoke its startup() method.
|
||||||
|
* <pre>
|
||||||
|
* Runtime runtime = new Runtime();
|
||||||
|
* if ( !runtime.hasRun() ) {
|
||||||
|
* runtime.startup();
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* 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 <code>log</code> 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 <code>Initializers</code> 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 <code>Initializers</code> 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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,41 +18,19 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.runtime;
|
package com.arsdigita.runtime;
|
||||||
|
|
||||||
import com.arsdigita.db.DbHelper;
|
|
||||||
import com.arsdigita.domain.DomainObjectFactory;
|
|
||||||
import com.arsdigita.persistence.ConnectionSource;
|
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.Session;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.persistence.metadata.MetadataRoot;
|
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.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;
|
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
|
* 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.
|
* 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
|
* 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 Rafael Schloming <rhs@mit.edu>
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @version $Id: Startup.java 738 2005-09-01 12:36:52Z sskracic $
|
* @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 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
|
// Constructor section
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default startup method. Determines the database connection information
|
* Default startup method, which determines the database connection information
|
||||||
* and delegates to a startup worker methods.
|
* and delegates to a detailed constructor.
|
||||||
|
* @deprecated use Runtime() instead
|
||||||
*/
|
*/
|
||||||
public Startup() {
|
public Startup() {
|
||||||
this(new PooledConnectionSource
|
super();
|
||||||
(RuntimeConfig.getConfig().getJDBCURL(),
|
|
||||||
RuntimeConfig.getConfig().getJDBCPoolSize(),
|
|
||||||
RuntimeConfig.getConfig().getJDBCPingInterval()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -117,14 +85,11 @@ public class Startup extends CompoundInitializer {
|
||||||
*
|
*
|
||||||
* @param source The connection source used to recover the list of
|
* @param source The connection source used to recover the list of
|
||||||
* initializers from the database; it cannot be null.
|
* initializers from the database; it cannot be null.
|
||||||
|
*
|
||||||
|
* @deprecated use Runtime.startup(ConnectionSource source) instead
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public Startup(ConnectionSource source) {
|
public Startup(ConnectionSource source) {
|
||||||
super(s_log);
|
super(source);
|
||||||
|
|
||||||
Assert.exists(source, ConnectionSource.class);
|
|
||||||
|
|
||||||
m_source = source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -137,193 +102,47 @@ public class Startup extends CompoundInitializer {
|
||||||
*
|
*
|
||||||
* @see MetadataRoot#getMetadataRoot()
|
* @see MetadataRoot#getMetadataRoot()
|
||||||
* @see SessionManager#getSession()
|
* @see SessionManager#getSession()
|
||||||
|
* @deprecated use Runtime.startup() instead
|
||||||
**/
|
**/
|
||||||
|
|
||||||
public final void run() {
|
public final void run() {
|
||||||
s_log.info("Initializing WAF runtime");
|
super.startup();
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the initialization process.
|
* Executes the initialization process.
|
||||||
*
|
*
|
||||||
* This method is going to move.
|
* This method is going to move.
|
||||||
|
* @deprecated use Runtimestartup(session.init) instead
|
||||||
*/
|
*/
|
||||||
public static final void run(final Session session,
|
// public static final void run(final Session session,
|
||||||
final Initializer init) {
|
public static void run(final Session session,
|
||||||
|
final Initializer init) {
|
||||||
|
|
||||||
Assert.exists(session, Session.class);
|
Runtime.startup(session, init);
|
||||||
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));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
|
* Returns whether the run method had already been invoked.
|
||||||
* Made protected so that test code can override the initializers
|
*
|
||||||
* loaded at test startup.
|
* @return true if run() has been invoked
|
||||||
*
|
* @deprecated use Runtime.hasRun() instead
|
||||||
* @return Collection of initializer names.
|
|
||||||
*/
|
*/
|
||||||
protected Collection getRuntimeInitializerNames() {
|
public static boolean hasRun() {
|
||||||
final Session session = session("startup", root());
|
return Runtime.hasRun();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
Runtime.main(args);
|
||||||
().getResourceAsStream(s_model);
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -18,45 +18,48 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.search;
|
package com.arsdigita.search;
|
||||||
|
|
||||||
import com.arsdigita.initializer.Configuration;
|
|
||||||
import com.arsdigita.initializer.InitializationException;
|
|
||||||
|
|
||||||
import com.arsdigita.domain.GlobalObserverManager;
|
import com.arsdigita.domain.GlobalObserverManager;
|
||||||
|
import com.arsdigita.runtime.DomainInitEvent;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This initializer (which will soon go away) activates
|
* Activates the appropriate search engine.
|
||||||
* the appropriate search engine.
|
*
|
||||||
* There are no APIs intended for public use in this class
|
* 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 extends com.arsdigita.runtime.GenericInitializer {
|
||||||
public class Initializer
|
|
||||||
implements com.arsdigita.initializer.Initializer {
|
|
||||||
|
|
||||||
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) {
|
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();
|
GlobalObserverManager gom = GlobalObserverManager.getManager();
|
||||||
gom.addObserver(new SearchObserver());
|
gom.addObserver(new SearchObserver());
|
||||||
} else {
|
} else {
|
||||||
s_log.info("Not registering a search observer");
|
s_log.info("Not registering a search observer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s_log.debug("domain init procedure finished ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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() {}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -91,19 +91,19 @@ public class Search {
|
||||||
CACHE_SIZE,
|
CACHE_SIZE,
|
||||||
CACHE_LIFETIME);
|
CACHE_LIFETIME);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Constant for intermedia search indexer
|
// * Constant for intermedia search indexer
|
||||||
* @deprecated use IndexerType.INTERMEDIA.getKey()
|
// * @deprecated use IndexerType.INTERMEDIA.getKey()
|
||||||
*/
|
// */
|
||||||
public static final String INDEXER_INTERMEDIA =
|
// public static final String INDEXER_INTERMEDIA =
|
||||||
IndexerType.INTERMEDIA.getKey();
|
// IndexerType.INTERMEDIA.getKey();
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Constant for lucene search indexer
|
// * Constant for lucene search indexer
|
||||||
* @deprecated use IndexerType.LUCENE.getKey()
|
// * @deprecated use IndexerType.LUCENE.getKey()
|
||||||
*/
|
// */
|
||||||
public static final String INDEXER_LUCENE =
|
// public static final String INDEXER_LUCENE =
|
||||||
IndexerType.LUCENE.getKey();
|
// IndexerType.LUCENE.getKey();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant for serach XML namespace prefix
|
* Constant for serach XML namespace prefix
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,6 @@ public final class SearchConfig extends AbstractConfig {
|
||||||
private Parameter m_lazyUpdates;
|
private Parameter m_lazyUpdates;
|
||||||
private Parameter m_xmlContentWeight;
|
private Parameter m_xmlContentWeight;
|
||||||
private Parameter m_rawContentWeight;
|
private Parameter m_rawContentWeight;
|
||||||
private Parameter m_stemming;
|
|
||||||
|
|
||||||
public SearchConfig() {
|
public SearchConfig() {
|
||||||
|
|
||||||
|
|
@ -66,16 +65,11 @@ public final class SearchConfig extends AbstractConfig {
|
||||||
("waf.search.intermedia.raw_content_weight",
|
("waf.search.intermedia.raw_content_weight",
|
||||||
Parameter.REQUIRED,
|
Parameter.REQUIRED,
|
||||||
new Integer(1));
|
new Integer(1));
|
||||||
m_stemming = new BooleanParameter
|
|
||||||
("waf.search.intermedia.stemming",
|
|
||||||
Parameter.REQUIRED,
|
|
||||||
Boolean.FALSE);
|
|
||||||
|
|
||||||
register(m_indexer);
|
register(m_indexer);
|
||||||
register(m_lazyUpdates);
|
register(m_lazyUpdates);
|
||||||
register(m_xmlContentWeight);
|
register(m_xmlContentWeight);
|
||||||
register(m_rawContentWeight);
|
register(m_rawContentWeight);
|
||||||
register(m_stemming);
|
|
||||||
|
|
||||||
loadInfo();
|
loadInfo();
|
||||||
}
|
}
|
||||||
|
|
@ -137,23 +131,6 @@ public final class SearchConfig extends AbstractConfig {
|
||||||
public ContentType[] getContent() {
|
public ContentType[] getContent() {
|
||||||
return getIndexerType().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
|
* Determines if raw binary content is supported
|
||||||
|
|
|
||||||
|
|
@ -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.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.example=1
|
||||||
waf.search.intermedia.raw_content_weight.format=[integer]
|
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]
|
|
||||||
|
|
|
||||||
|
|
@ -30,18 +30,15 @@ import java.util.Timer;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The BuildIndex class provides methods to keep track of when
|
* The BuildIndex class provides methods to keep track of when the index should
|
||||||
* the index should be rebuilt and to automatically rebuild
|
* be rebuilt and to automatically rebuild the index.
|
||||||
* the index.
|
|
||||||
*
|
*
|
||||||
* All the methods in the class are called either directly or
|
* All the methods in the class are called either directly or indirectly from
|
||||||
* indirectly from method checkState, which is called periodically by
|
* method checkState, which is called periodically by a timer.
|
||||||
* a timer. The object and timer are initialized at server startup by
|
* The object and timer are initialized at server startup by the Initializer
|
||||||
* a call to the Initializer (see Initializer.java) from
|
* (see Initializer.java)
|
||||||
* enterprise.init.
|
|
||||||
*
|
*
|
||||||
* A summary of how this class controls the index rebuilding is
|
* A summary of how this class controls the index rebuilding is given below:
|
||||||
* given below:
|
|
||||||
*
|
*
|
||||||
* When content that is searchable is changed or added, the
|
* When content that is searchable is changed or added, the
|
||||||
* SearchableObserver object for the content creates and saves
|
* SearchableObserver object for the content creates and saves
|
||||||
|
|
@ -64,9 +61,9 @@ import java.util.Timer;
|
||||||
* @author Jeff Teeters
|
* @author Jeff Teeters
|
||||||
* @author Joseph Bank
|
* @author Joseph Bank
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
**/
|
* @version $Id: BuildIndex.java 560 2005-06-10 17:01:14Z apevec $
|
||||||
|
*/
|
||||||
class BuildIndex {
|
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
|
// Creates a s_logging category with name = to the full name of class
|
||||||
private static final Logger s_log =
|
private static final Logger s_log =
|
||||||
|
|
@ -106,10 +103,9 @@ class BuildIndex {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setParametersValues - initialize delay and time values.
|
* setParametersValues - initialize delay and time values.
|
||||||
* Values must be specified in milliseconds. This called by
|
* Values must be specified in milliseconds. This called by the Initializer
|
||||||
* the Initializer and also by tests (which
|
* and also by tests (which use values much shorter than the defaults).
|
||||||
* use values much shorter than the defaults).
|
*/
|
||||||
**/
|
|
||||||
static void setParameterValues(int timerDelay,
|
static void setParameterValues(int timerDelay,
|
||||||
int syncDelay,
|
int syncDelay,
|
||||||
int maxSyncDelay,
|
int maxSyncDelay,
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,13 @@
|
||||||
package com.arsdigita.search.intermedia;
|
package com.arsdigita.search.intermedia;
|
||||||
|
|
||||||
import com.arsdigita.db.DbHelper;
|
import com.arsdigita.db.DbHelper;
|
||||||
import com.arsdigita.initializer.Configuration;
|
// import com.arsdigita.initializer.Configuration;
|
||||||
import com.arsdigita.initializer.InitializationException;
|
// 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.FilterType;
|
||||||
import com.arsdigita.search.IndexerType;
|
import com.arsdigita.search.IndexerType;
|
||||||
import com.arsdigita.search.QueryEngineRegistry;
|
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.ObjectTypeFilterType;
|
||||||
import com.arsdigita.search.filters.PermissionFilterType;
|
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;
|
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() {
|
public Initializer() {
|
||||||
return m_conf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on startup.
|
* Implementation of the {@link Initializer#init(ContextInitEvent)}
|
||||||
|
* method.
|
||||||
|
*
|
||||||
|
* @param evt The context init event.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// void startup() throws InitializationException;
|
public void init(ContextInitEvent evt) {
|
||||||
public void startup() {
|
|
||||||
if (Search.getConfig().isIntermediaEnabled()) {
|
if (Search.getConfig().isIntermediaEnabled()) {
|
||||||
|
|
||||||
if (DbHelper.getDatabase() != DbHelper.DB_ORACLE) {
|
if (DbHelper.getDatabase() != DbHelper.DB_ORACLE) {
|
||||||
throw new InitializationException(
|
throw new ConfigError(
|
||||||
"Intermedia searching only works on Oracle, not " +
|
"Intermedia searching only works on Oracle, not " +
|
||||||
DbHelper.getDatabaseName(DbHelper.getDatabase()));
|
DbHelper.getDatabaseName(DbHelper.getDatabase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply by 1000 to convert from seconds to milliseconds
|
IntermediaConfig conf = IntermediaConfig.getConfig();
|
||||||
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,
|
// Multiply by 1000 to convert from seconds to milliseconds
|
||||||
syncDelay,
|
BuildIndex.setParameterValues( conf.getTimerDelay() * 1000,
|
||||||
maxSyncDelay,
|
conf.getSyncDelay() * 1000,
|
||||||
maxIndexingTime,
|
conf.getMaxSyncDelay() * 1000,
|
||||||
indexingRetryDelay);
|
conf.getMaxIndexingTime() * 1000,
|
||||||
|
conf.getIndexingRetryDelay() * 1000 );
|
||||||
|
|
||||||
BuildIndex.startTimer();
|
BuildIndex.startTimer();
|
||||||
|
|
||||||
s_log.debug("Registering query engines");
|
s_log.debug("Registering query engines");
|
||||||
QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA,
|
QueryEngineRegistry.registerEngine(IndexerType.INTERMEDIA,
|
||||||
new FilterType[] {
|
new FilterType[] {
|
||||||
|
|
@ -159,15 +94,19 @@ public class Initializer
|
||||||
new CategoryFilterType()
|
new CategoryFilterType()
|
||||||
},
|
},
|
||||||
new BaseQueryEngine());
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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]
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue