ccm-cms Loader kann jetzt mehrer Content Sections anlegen, Loader gefixt, LoaderConfig berfeinigt, Altlasten beseitigt, diverse Formatierungen.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1315 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
4e04b6335d
commit
819753491b
|
|
@ -50,6 +50,10 @@ import java.util.StringTokenizer;
|
|||
* Creates category domains in the terms application according to
|
||||
* configuration files and adds jsp templates to navigation.
|
||||
*
|
||||
* NOTE: Configuration parameters used at load time MUST be part of Loader
|
||||
* class and can not delegated to a Config object (derived from AbstractConfig).
|
||||
* They will (and can) not be persisted into an registry object (file).
|
||||
*
|
||||
* @author Justin Ross <jross@redhat.com>
|
||||
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
|
||||
* @version $Id: Loader.java 755 2005-09-02 13:42:47Z sskracic $
|
||||
|
|
@ -70,9 +74,11 @@ public class Loader extends PackageLoader {
|
|||
* FULL_QUALIFIED_CLASS_NAME : URL : TITLE ,
|
||||
* .... ,
|
||||
* FULL_QUALIFIED_CLASS_NAME : URL : TITLE "
|
||||
* E.G.
|
||||
* "com.arsdigita.navigation.Navigation:local:Local Navigation"
|
||||
*/
|
||||
private Parameter m_customApplicationInstances = new StringArrayParameter(
|
||||
"com.arsdigita.bundle.local_app_instances",
|
||||
"com.arsdigita.bundle.loader.custom_app_instances",
|
||||
Parameter.OPTIONAL, null
|
||||
);
|
||||
|
||||
|
|
@ -84,7 +90,7 @@ public class Loader extends PackageLoader {
|
|||
* Files are stored as part of the jar, so classloader can find them.
|
||||
*/
|
||||
private Parameter m_categoryFiles = new StringArrayParameter(
|
||||
"com.arsdigita.bundle.category_files",
|
||||
"com.arsdigita.bundle.loader.category_files",
|
||||
Parameter.REQUIRED,new String[]{
|
||||
"bundle/categories/gen-nav-domain-1.00.xml",
|
||||
"bundle/categories/gen-nav-hierarchy-1.00.xml" }
|
||||
|
|
@ -107,7 +113,7 @@ public class Loader extends PackageLoader {
|
|||
*
|
||||
*/
|
||||
private Parameter m_domainMappings = new StringArrayParameter(
|
||||
"com.arsdigita.bundle.domain_mappings",
|
||||
"com.arsdigita.bundle.loader.domain_mappings",
|
||||
Parameter.REQUIRED,new String[]{ "STD-NAV:/navigation/",
|
||||
"STD-NAV:/content/",
|
||||
"STD-NAV:/portal/" }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
com.arsdigita.bundle.loader.custom_app_instances.title= Applications to create
|
||||
com.arsdigita.bundle.loader.custom_app_instances.purpose=List of comma separated sets of application instance specifications,optionally used to create arbitrary custom application instances
|
||||
com.arsdigita.bundle.loader.custom_app_instances.example=com.arsdigita.navigation.Navigation:scimenu:ScientificCMS Navigation Menu,com.arsdigita.navigation.Navigation:libmenu:LibreCMS Navigation Menu
|
||||
com.arsdigita.bundle.loader.custom_app_instances.format=CLASS_NAME:URL:TITLE[,CLASS_NAME:URL:TITLE[,...]]
|
||||
|
||||
com.arsdigita.bundle.loader.category_files.title= Domain Categories Definitions Files
|
||||
com.arsdigita.bundle.loader.category_files.purpose=Comma separated list of fully qualified filenames.
|
||||
com.arsdigita.bundle.loader.category_files.example=bundle/categories/gen-nav-domain-1.00.xml,bundle/categories/gen-nav-hierarchy-1.00.xml
|
||||
com.arsdigita.bundle.loader.category_files.format=[StringArray]
|
||||
|
||||
com.arsdigita.bundle.loader.domain_mappings.title= Domain Mappings
|
||||
com.arsdigita.bundle.loader.domain_mappings.purpose=List of comma separated sets of domain mappings.
|
||||
com.arsdigita.bundle.loader.domain_mappings.example=STD-NAV:/navigation/,STD-NAV:/content/,STD-NAV:/portal/
|
||||
com.arsdigita.bundle.loader.domain_mappings.format=[StringArray]
|
||||
|
|
@ -1,7 +1,16 @@
|
|||
<?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-type label="Job" description="An job type" objectType="com.arsdigita.cms.contenttypes.Job" classname="com.arsdigita.cms.contenttypes.Job">
|
||||
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
||||
<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="Job"
|
||||
description="An job type"
|
||||
objectType="com.arsdigita.cms.contenttypes.Job"
|
||||
classname="com.arsdigita.cms.contenttypes.Job">
|
||||
|
||||
<ctd:authoring-kit
|
||||
createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
||||
<ctd:authoring-step
|
||||
labelKey="cms.contenttypes.shared.basic_properties.title"
|
||||
labelBundle="com.arsdigita.cms.CMSResources"
|
||||
|
|
@ -11,5 +20,6 @@
|
|||
|
||||
<ctd:include href="/WEB-INF/content-types/shared.xml"/>
|
||||
</ctd:authoring-kit>
|
||||
|
||||
</ctd:content-type>
|
||||
</ctd:content-types>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.kernel.KernelExcursion;
|
||||
import com.arsdigita.persistence.Session;
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
storage="ccm-cms/contentsection.properties"/>
|
||||
<config class="com.arsdigita.cms.lifecycle.LifecycleConfig"
|
||||
storage="ccm-cms/lifecycle.properties"/>
|
||||
<config class="com.arsdigita.cms.LoaderConfig"
|
||||
storage="ccm-cms/loader.properties"/>
|
||||
<config class="com.arsdigita.cms.publishToFile.PublishToFileConfig"
|
||||
storage="ccm-cms/publishToFile.properties"/>
|
||||
<config class="com.arsdigita.cms.contenttypes.GenericAddressConfig"
|
||||
|
|
|
|||
|
|
@ -1112,6 +1112,8 @@ public class ContentSection extends Application {
|
|||
String prc,
|
||||
String irc,
|
||||
String xgc) {
|
||||
/** Set default as template resolver class name */
|
||||
String trc = "com.arsdigita.cms.dispatcher.DefaultTemplateResolver";
|
||||
return ContentSection.create(
|
||||
name,
|
||||
folder,
|
||||
|
|
@ -1120,7 +1122,7 @@ public class ContentSection extends Application {
|
|||
prc,
|
||||
irc,
|
||||
xgc,
|
||||
"com.arsdigita.cms.dispatcher.DefaultTemplateResolver");
|
||||
trc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1310,8 +1312,4 @@ public class ContentSection extends Application {
|
|||
return URL.SERVLET_DIR + "/content-section";
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public String getStylesheetPath() {
|
||||
// return STYLESHEET;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,13 +29,12 @@ import java.math.BigDecimal;
|
|||
/**
|
||||
* Represents a set of {@link com.arsdigita.cms.ContentItem content
|
||||
* items}.
|
||||
* @see com.arsdigita.domain.DomainCollection
|
||||
* @see com.arsdigita.persistence.DataCollection
|
||||
*
|
||||
* @author <a href="mailto:pihman@arsdigita.com">Michael Pih</a>
|
||||
* @author <a href="mailto:lutter@arsdigita.com">David Lutterkort</a>
|
||||
* @version $Revision: #14 $ $Date: 2004/08/17 $
|
||||
*
|
||||
* @see com.arsdigita.domain.DomainCollection
|
||||
* @see com.arsdigita.persistence.DataCollection
|
||||
*/
|
||||
public class ItemCollection extends DomainCollection {
|
||||
|
||||
|
|
|
|||
|
|
@ -20,28 +20,25 @@ package com.arsdigita.cms;
|
|||
|
||||
import com.arsdigita.cms.contentsection.ContentSectionSetup;
|
||||
import com.arsdigita.cms.util.Util;
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.contenttypes.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.portlet.ContentDirectoryPortlet;
|
||||
import com.arsdigita.cms.portlet.ContentItemPortlet;
|
||||
import com.arsdigita.cms.portlet.ContentSectionsPortlet;
|
||||
import com.arsdigita.cms.portlet.TaskPortlet;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
// import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.formbuilder.util.FormbuilderSetup;
|
||||
import com.arsdigita.kernel.ACSObjectInstantiator;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.kernel.KernelExcursion;
|
||||
// import com.arsdigita.kernel.PackageInstance;
|
||||
// import com.arsdigita.kernel.PackageType;
|
||||
// import com.arsdigita.kernel.SiteNode;
|
||||
// import com.arsdigita.kernel.Stylesheet;
|
||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||
import com.arsdigita.loader.PackageLoader;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
// import com.arsdigita.runtime.ConfigError;
|
||||
import com.arsdigita.runtime.ScriptContext;
|
||||
import com.arsdigita.util.parameter.Parameter;
|
||||
import com.arsdigita.util.parameter.StringArrayParameter;
|
||||
// import com.arsdigita.util.parameter.StringParameter;
|
||||
import com.arsdigita.web.Application;
|
||||
import com.arsdigita.web.ApplicationSetup;
|
||||
import com.arsdigita.web.ApplicationType;
|
||||
|
|
@ -53,6 +50,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
// Migration status
|
||||
//
|
||||
// The module in its complete version (i.e. all method invocations in run()
|
||||
|
|
@ -61,6 +59,8 @@ import org.apache.log4j.Logger;
|
|||
//
|
||||
// Next Try
|
||||
// Refactor using legacy compatible web/Application and ApplicationSetup
|
||||
|
||||
|
||||
/**
|
||||
* <p>Executes nonrecurring at install time and loads (installs and initializes)
|
||||
* the Content Management System module,including the Content Center, CMS Service
|
||||
|
|
@ -92,57 +92,73 @@ public class Loader extends PackageLoader {
|
|||
/** Creates a s_logging category with name = full name of class */
|
||||
private static final Logger s_log = Logger.getLogger(Loader.class);
|
||||
|
||||
/** Loader configuration object, singleton design pattern */
|
||||
/** Loader configuration object, singleton design pattern
|
||||
* NOTE: LoaderConfig only supplies unmutable hatrd coded defaults! It is
|
||||
* not possible to alter any to the contained values by specifiying an
|
||||
* configuration parameter during load step. If a configuration value
|
||||
* has to be configurable at load time, the parameter must be relcated
|
||||
* into this Loader class! */
|
||||
private static final LoaderConfig s_conf = LoaderConfig.getInstance();
|
||||
|
||||
/**
|
||||
* Constant string used as key for creating CMS (content-section) as a
|
||||
* legacy application.
|
||||
*/
|
||||
private final static String CMS_PACKAGE_KEY = "content-section";
|
||||
/**
|
||||
* Dispatcher class for CMS (needed to be assigned to a legacy application).
|
||||
*/
|
||||
private final static String CMS_DISPATCHER_CLASS =
|
||||
"com.arsdigita.cms.dispatcher.ContentSectionDispatcher";
|
||||
// ///////////////////////////////////////////////////////////////////
|
||||
// Configurable parameters during load step.
|
||||
// ///////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The name(s) of the content section(s). In case of more than one name the
|
||||
* first is treated as default section. Otherwise the section created is the
|
||||
* default section. More sections can always be created during a subsequent
|
||||
* system startup using initialization parameters.
|
||||
*/
|
||||
private final Parameter m_contentSectionNames = new StringArrayParameter(
|
||||
"com.arsdigita.cms.loader.section_names",
|
||||
Parameter.REQUIRED,
|
||||
new String[] {"content"}
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Nolonger used
|
||||
// /**
|
||||
// * Stylesheet which has to be assigned as part of a legacy application
|
||||
// * creation.
|
||||
// * Constant string used as key for creating CMS (content-section) as a
|
||||
// * legacy application.
|
||||
// */
|
||||
// Assigned stylesheets no longer used and base class removed.
|
||||
// private final static String CMS_STYLESHEET =
|
||||
// "/packages/content-section/xsl/cms.xsl";
|
||||
// private final static String CMS_PACKAGE_KEY = "content-section";
|
||||
// /**
|
||||
// * Dispatcher class for CMS (needed to be assigned to a legacy application).
|
||||
// */
|
||||
// private final static String CMS_DISPATCHER_CLASS =
|
||||
// "com.arsdigita.cms.dispatcher.ContentSectionDispatcher";
|
||||
|
||||
// /**
|
||||
// * Constant string used as key for creating Workspace (content-center) as a
|
||||
// * legacy application.
|
||||
// */
|
||||
// public static final String WORKSPACE_PACKAGE_KEY = "content-center";
|
||||
private static final String WORKSPACE_INSTANCE_NAME = "Content Center";
|
||||
/**
|
||||
* Dispatcher class for Workspace (content-center) (needed to be assigned
|
||||
* to a legacy application).
|
||||
*/
|
||||
private static final String WORKSPACE_DISPATCHER_CLASS =
|
||||
"com.arsdigita.cms.dispatcher.ContentCenterDispatcher";
|
||||
// To be updated soon...
|
||||
// "com.arsdigita.dispatcher.DefaultPackageDispatcher";
|
||||
|
||||
// private static final String WORKSPACE_INSTANCE_NAME = "Content Center";
|
||||
// /**
|
||||
// * Stylesheet which has to be assigned as part of a legacy application
|
||||
// * creation.
|
||||
// * Dispatcher class for Workspace (content-center) (needed to be assigned
|
||||
// * to a legacy application).
|
||||
// */
|
||||
// private final static String WORKSPACE_STYLESHEET =
|
||||
// "/packages/content-section/xsl/content-center.xsl";
|
||||
/**
|
||||
* Name of the CMS service package instance, i.e. its URL.
|
||||
*/
|
||||
private final static String SERVICE_URL = "cms-service";
|
||||
// private static final String WORKSPACE_DISPATCHER_CLASS =
|
||||
// "com.arsdigita.cms.dispatcher.ContentCenterDispatcher";
|
||||
// // To be updated soon...
|
||||
// // "com.arsdigita.dispatcher.DefaultPackageDispatcher";
|
||||
|
||||
// No longer used, moved to class Service
|
||||
// /**
|
||||
// * Name of the CMS service package instance, i.e. its URL.
|
||||
// */
|
||||
// private final static String SERVICE_URL = "cms-service";
|
||||
// /**
|
||||
// * Constant string used as key for creating service package as a
|
||||
// * legacy application.
|
||||
// */
|
||||
// public final static String SERVICE_PACKAGE_KEY = "cms-service";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private ArrayList m_content_type_list = new ArrayList();
|
||||
|
||||
/**
|
||||
|
|
@ -151,6 +167,8 @@ public class Loader extends PackageLoader {
|
|||
public Loader() {
|
||||
s_log.debug("CMS.loader (Constructor) invoked");
|
||||
|
||||
register(m_contentSectionNames);
|
||||
|
||||
s_log.debug("CMS.loader (Constructor) completed");
|
||||
}
|
||||
|
||||
|
|
@ -162,13 +180,6 @@ public class Loader extends PackageLoader {
|
|||
public void excurse() {
|
||||
setEffectiveParty(Kernel.getSystemParty());
|
||||
|
||||
// 1 - step 1a) Setup the CMS (content section) package type.
|
||||
// Uses old style application setup kernel.Package and Sitenode.
|
||||
// It is not needed, this step is included in new style setup
|
||||
// of content section (see below). It is here for reference
|
||||
// purpose during migration of the whole CMS to new style.
|
||||
// loadCMSPackageType();
|
||||
|
||||
// 2 - step 1b) Setup the Workspace package.
|
||||
// loadWorkspacePackage(); // using old stype
|
||||
// new style:
|
||||
|
|
@ -187,7 +198,7 @@ public class Loader extends PackageLoader {
|
|||
// purpose during migration of the whole CMS to new style.
|
||||
// loadContentCenterMapping(s_conf.getContentCenterMap() );
|
||||
|
||||
// 5) load content type definition(s)
|
||||
// 5) load (cms internal) content type definition(s)
|
||||
// Used to be step 2 in former enterprise.init file
|
||||
loadContentTypeDefinitions(s_conf.getCTDefFiles());
|
||||
|
||||
|
|
@ -197,7 +208,7 @@ public class Loader extends PackageLoader {
|
|||
// Implemented by
|
||||
// com.arsdigita.cms.installer.SectionInitializer
|
||||
// Loads content section application type and instance in one step
|
||||
loadContentSection(s_conf.getContentSectionName());
|
||||
loadContentSection( (String[]) get(m_contentSectionNames) );
|
||||
|
||||
// Loading CMS portlets
|
||||
// Used to be step 7 (last step) in former enterprise.init
|
||||
|
|
@ -218,106 +229,6 @@ public class Loader extends PackageLoader {
|
|||
}.run();
|
||||
}
|
||||
|
||||
// Migration Status:
|
||||
// Method completely replaced by loadContentSection()
|
||||
// Code kept for reference purpose untill the complete migration will be done.
|
||||
//
|
||||
// /**
|
||||
// * Loads the CMS package type in the database, i.e. content-section,
|
||||
// * the main CMS domain (application) class.
|
||||
// *
|
||||
// * (pb) WRONG:
|
||||
// * Creates content-section PackageType. Is replaced by newer ApplicationType
|
||||
// * mechanisam (see loadContentSection). Must nolonger be used.
|
||||
// * createPrivileges might be included in load, but has te be executed at
|
||||
// * each startup to take modifications into accout. So it has to be an
|
||||
// * initializer task anyway.
|
||||
// */
|
||||
// private void loadCMSPackageType() {
|
||||
// s_log.debug("Loading the CMS package type...");
|
||||
//
|
||||
// // creating appl. type using the deprecated legacy application style.
|
||||
// // Should be refactored to c.ad.web.Application.
|
||||
// // CMS_PACKAGE_KEY = "content-section"
|
||||
// PackageType type = PackageType.create
|
||||
// (CMS_PACKAGE_KEY,
|
||||
// "Content Management System",
|
||||
// "Content Management Systems",
|
||||
// "http://cms-java.arsdigita.com/");
|
||||
//
|
||||
// type.setDispatcherClass(CMS_DISPATCHER_CLASS);
|
||||
// //type.addListener(LISTENER_CLASS); (commented out)
|
||||
//
|
||||
// // Register a stylesheets to the CMS package.
|
||||
// Stylesheet ss = Stylesheet.createStylesheet(CMS_STYLESHEET);
|
||||
// ss.save();
|
||||
// type.addStylesheet(ss);
|
||||
// type.save();
|
||||
//
|
||||
//
|
||||
// Creating of CMS package using new style c.ad.web.Application could
|
||||
// be done like the following.
|
||||
// ApplicationType type = ApplicationType
|
||||
// .createApplicationType(ContentSection.PACKAGE_TYPE,
|
||||
// "Conten Management Application (i.e. content-section)",
|
||||
// ContentSection.BASE_DATA_OBJECT_TYPE);
|
||||
// type.setDescription("The content management application.");
|
||||
// // Question: Do we need to use deprectated (with no replacement) method
|
||||
// // setDispatcherClass in web.Application or does it work magically without?
|
||||
// type.setDispatcherClass(CMS_DISPATCHER_CLASS);
|
||||
// type.addStylesheet(ss);
|
||||
//
|
||||
//
|
||||
// createPrivileges();
|
||||
//
|
||||
// s_log.debug("Done creating the CMS package type.");
|
||||
// }
|
||||
// /**
|
||||
// * Loads and instantiates the Workspace package (content-center) in the
|
||||
// * database using old style application.
|
||||
// * Will be replaced by new style application in the migration process,
|
||||
// */
|
||||
/*
|
||||
private void loadWorkspacePackage() {
|
||||
s_log.debug("Creating CMS Workspace...");
|
||||
|
||||
// from WorkspaceInstaller workspaceInstaller = new WorkspaceInstaller();
|
||||
try {
|
||||
// workspaceInstaller.createPackageType();
|
||||
PackageType type = PackageType.create(CMS.WORKSPACE_PACKAGE_KEY,
|
||||
"Content Center",
|
||||
"Content Centers",
|
||||
"http://cms-workspace.arsdigita.com/");
|
||||
type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS);
|
||||
type.save();
|
||||
|
||||
// from PackageInstance instance = workspaceInstaller.createPackageInstance();
|
||||
// Does the following:
|
||||
type = PackageType.findByKey(CMS.WORKSPACE_PACKAGE_KEY);
|
||||
PackageInstance instance = type.createInstance(WORKSPACE_INSTANCE_NAME);
|
||||
instance.save();
|
||||
|
||||
// from: workspaceInstaller.mountPackageInstance(instance, m_workspaceURL);
|
||||
// Does the following:
|
||||
// We really don't want it configurable.
|
||||
// SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY,
|
||||
// SiteNode.getRootSiteNode());
|
||||
SiteNode node = SiteNode.createSiteNode(CMS.WORKSPACE_PACKAGE_KEY,
|
||||
SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
node.save();
|
||||
|
||||
// m_workspaceURL == WORKSPACE_PACKAGE_KEY
|
||||
// workspaceInstaller.mountPackageInstance(instance, m_workspaceURL);
|
||||
// workspaceInstaller.mountPackageInstance(instance, CMS.WORKSPACE_PACKAGE_KEY);
|
||||
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new ConfigError(
|
||||
"Failed to initialize the Workspace package: ");
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Loads and instantiates the Workspace package (content-center) in the
|
||||
* database.
|
||||
|
|
@ -374,46 +285,12 @@ public class Loader extends PackageLoader {
|
|||
null); // parent
|
||||
app.setDescription("The default CMS workspace instance.");
|
||||
app.save();
|
||||
s_log.warn("CMS Workspace instance created.");
|
||||
s_log.warn("CMS Workspace instance " + Workspace.PACKAGE_KEY + " created.");
|
||||
|
||||
s_log.debug("Done loading CMS Workspace.");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * CMS Service application is used by the Content Management System as a
|
||||
// * store for global resources and assets.
|
||||
// * Using old style application, will be replaced by new style in the
|
||||
// * migration process.
|
||||
// */
|
||||
/* private void loadServicePackage() {
|
||||
s_log.debug("Loading CMS Servce Package...");
|
||||
|
||||
try {
|
||||
// from ServiceInstaller.createPackageType();
|
||||
PackageType type = PackageType.create(CMS.SERVICE_PACKAGE_KEY,
|
||||
"Content Management System Services",
|
||||
"Content Management System Services",
|
||||
"http://cms-service.arsdigita.com/");
|
||||
type.setDispatcherClass(
|
||||
"com.arsdigita.cms.dispatcher.ServiceDispatcher");
|
||||
type.save();
|
||||
|
||||
// from PackageInstance instance = ServiceInstaller.createPackageInstance();
|
||||
type = PackageType.findByKey(CMS.SERVICE_PACKAGE_KEY);
|
||||
PackageInstance instance = type.createInstance(CMS.SERVICE_PACKAGE_KEY);
|
||||
instance.save();
|
||||
|
||||
// from ServiceInstaller.mountPackageInstance(instance, url);
|
||||
SiteNode node = SiteNode.createSiteNode(SERVICE_URL,
|
||||
SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
node.save();
|
||||
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new ConfigError("Failed to initialize CMS global services package.");
|
||||
}
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* CMS Service application is used by the Content Management System as a
|
||||
* store for global resources and assets.
|
||||
|
|
@ -473,23 +350,26 @@ public class Loader extends PackageLoader {
|
|||
s_log.debug("Done creating CMS Service Package.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load an content section application type and an initial default
|
||||
* content-section instance as specified in LoaderConfig.
|
||||
* Load a content section application type and an initial default
|
||||
* content-section instance(s).
|
||||
* Some configuration values which are to be considered as unmutable are
|
||||
* specified in LoaderConfig.
|
||||
* Uses new style application in legacy compatible mode.
|
||||
*
|
||||
* NOTE: At ccm-cms load time no content type packages are available because
|
||||
* any content type depends on ccm-cms. Therefore, the loading step can not
|
||||
* process content type package assignment! Instead each content type itself
|
||||
* must assign itself to an apropriate content section at it's load time.
|
||||
* Cf. {@link com.arsdigita.cms.contenttype.AbstractContentTypeLoader}.
|
||||
*
|
||||
* But the load step has to process the cms internal content types!
|
||||
*/
|
||||
private void loadContentSection(String name) {
|
||||
private void loadContentSection(String[] sectionNames) {
|
||||
|
||||
s_log.info("Creating content section on /" + name);
|
||||
|
||||
// Step 1: Validate name for section
|
||||
Util.validateURLParameter("name", name);
|
||||
|
||||
// Step 2: Creating content section application type first so that
|
||||
// concrete content-section instance can be created.
|
||||
// from: ContentSectionSetup.setupContentSectionAppType();
|
||||
// Install application type using new application classes
|
||||
// Step 1: Create content section application type
|
||||
// prerequisite for concrete content-section instance creation.
|
||||
ApplicationSetup appType = new ApplicationSetup(s_log);
|
||||
appType.setApplicationObjectType(ContentSection.BASE_DATA_OBJECT_TYPE);
|
||||
appType.setKey(ContentSection.PACKAGE_TYPE); // by default: content-section
|
||||
|
|
@ -511,23 +391,32 @@ public class Loader extends PackageLoader {
|
|||
|
||||
appType.run();
|
||||
|
||||
// Step 3:
|
||||
// Step 2: Load CMS specific privileges into central (core) privilege
|
||||
// system.
|
||||
createPrivileges();
|
||||
|
||||
// Step 4: Create the installation default content section "name"
|
||||
// Step 3: Create the installation default content section(s).
|
||||
// ContentSection.create creates a section with several default values
|
||||
// which have to be adopted for a concrete installation.
|
||||
ContentSection section = ContentSection.create(name);
|
||||
// ContentSectionSetup is a convenient class to adopt a section created
|
||||
// by ContentSection.create()
|
||||
for (int i = 0 ; i < sectionNames.length ; i++) {
|
||||
|
||||
final String sectionName = sectionNames[i];
|
||||
s_log.warn("Creating content section on /" + sectionName);
|
||||
|
||||
// Step 1: Validate name for section
|
||||
Util.validateURLParameter("name", sectionName);
|
||||
|
||||
// Step 2: Create a section using default values
|
||||
ContentSection section = ContentSection.create(sectionName);
|
||||
|
||||
// Step 3: Adopt the created section to site specific requirements
|
||||
// ContentSectionSetup is a convenient class to adopt a
|
||||
// section created by ContentSection.create()
|
||||
ContentSectionSetup setup = new ContentSectionSetup(section);
|
||||
|
||||
// ContentSection.create uses the following properties:
|
||||
// Name, see above
|
||||
// Root & template folder, set autonomously by ContentSection.create()
|
||||
|
||||
// Roles (staff group) used in content section. Register roles using
|
||||
// a complete set of default roles defined in ContentSectionSetup
|
||||
// Step 3a: Roles (staff group) used in this content section.
|
||||
// Register roles using a complete set of default roles
|
||||
// defined in ContentSectionSetup
|
||||
setup.registerRoles(s_conf.getStuffGroup());
|
||||
|
||||
// ViewerGroup populated in ContentSection, public access is determined
|
||||
|
|
@ -547,8 +436,15 @@ public class Loader extends PackageLoader {
|
|||
s_conf.getTemplateResolverClass());
|
||||
// XML generator class, set autonomously by ContentSection.create()
|
||||
|
||||
/* Register internal base content types. Paramter is a list of
|
||||
* class names created by internal content type load method.
|
||||
* @see loadContentTypeDefinitions(List) */
|
||||
setup.registerContentTypes(m_content_type_list);
|
||||
setup.registerContentTypes(s_conf.getContentSectionsContentTypes());
|
||||
|
||||
// See method doc above. No external content types available at
|
||||
// cms load time,
|
||||
// setup.registerContentTypes(s_conf.getContentSectionsContentTypes());
|
||||
|
||||
// Section specific categories, usually not used.
|
||||
// During initial load at install time nor used at all!
|
||||
// default value is false so no categories get loaded.
|
||||
|
|
@ -568,18 +464,21 @@ public class Loader extends PackageLoader {
|
|||
|
||||
section.save(); //persists any changes in the database (DomainObject)
|
||||
//i.e. creates an object (instance)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses XML file definition of content types and loads them to the
|
||||
* database. The XML config looks like the example below, the
|
||||
* "parentType" and "name" attributes are optional, and only required
|
||||
* for creating User Defined ContentTypes. Label corresponds to
|
||||
* ContentType's label and can be multiple words, and "name" to
|
||||
* DynamicObject's name property, and must be a single word. The
|
||||
* objectType attribute is ignored for UDCTs, as it gets dynamically
|
||||
* generated.
|
||||
* Parses XML file definition of (internal) base content types and loads
|
||||
* them into database. It fulfills a task similiar to the Loader of external
|
||||
* content type packages.
|
||||
*
|
||||
* The XML config looks like the example below, the "parentType" and "name"
|
||||
* attributes are optional, and only required for creating
|
||||
* User Defined ContentTypes. Label corresponds to ContentType's label and
|
||||
* can be multiple words, and "name" to DynamicObject's name property,
|
||||
* and must be a single word. The objectType attribute is ignored for
|
||||
* UDCTs, as it gets dynamically generated.
|
||||
*
|
||||
* <b>UDCT Copyright</b>
|
||||
* <pre>
|
||||
|
|
|
|||
|
|
@ -31,11 +31,20 @@ import java.util.ArrayList;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
// IMPLEMENTATION NOTE
|
||||
// Class is a result of migrating the old enterprise.init based
|
||||
// initialization process and not yet completed. Functionality is
|
||||
// basically OK so far, but code urgently needs cleaning up and a
|
||||
// check for useful bits.
|
||||
|
||||
|
||||
/**
|
||||
* Module enables administrators to configure some features of the CMS application
|
||||
* at install time. It is read in and processed only once and configuration is
|
||||
* persisted in database. Currently there is no way to alter these features
|
||||
* later after the installation step.
|
||||
* Container for various configuration parameters for ccm-cms package loader.
|
||||
*
|
||||
* The parameters are basically immutable for users and administrators and only
|
||||
* accessible to developers and require recompilation. Specifying any of these
|
||||
* parameters during installation takes no effect at all! Parameters which have
|
||||
* to be modifiable must be included in Loader class itself!
|
||||
*
|
||||
* @author pb
|
||||
* @version $Id: LoaderConfig.java $
|
||||
|
|
@ -56,16 +65,11 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
public static synchronized LoaderConfig getInstance() {
|
||||
if (s_conf == null) {
|
||||
s_conf = new LoaderConfig();
|
||||
/* Currently LoaderConfig does not process parameters stored in a
|
||||
* properties file. In order to do so the class must be added to
|
||||
* ccm-cms.config, a storage file specified and the load() commented
|
||||
* in.
|
||||
* Before it can be used meaningfully, ccm-xxx-aplaws must be enhanced
|
||||
* to be able tp process dynamically e.g. section name and other
|
||||
* parameter values. Currently, section name is hardcoded (content) as
|
||||
* well as creating terms domains etc.
|
||||
/* Parameters are not stored in registry nor modified by installation
|
||||
* specification. It is not possible to process a config object at
|
||||
* Load time!
|
||||
* s_conf.load();
|
||||
*/
|
||||
// s_conf.load();
|
||||
}
|
||||
|
||||
return s_conf;
|
||||
|
|
@ -125,23 +129,26 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
// s_log.debug("Set cache items to " + cacheItems);
|
||||
// ItemDispatcher.setCacheItems(cacheItems);
|
||||
|
||||
// /////////////////////////////////////////////////////
|
||||
// Following parameter is used by c.ad.cms.installer.xml
|
||||
// to load definition(s) of content types to database.
|
||||
// (Definitions describe sections to be included in
|
||||
// authoring steps).
|
||||
// /////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* List of Paths to XML files that contain content type definition(s).
|
||||
* Comma separated list of XML definition files for internal content types
|
||||
* (base types).
|
||||
*
|
||||
* Each internal content type (see package com/arsdigita/cms/contenttypes)
|
||||
* requires an entry in this list in order to get CMS Loader to load it
|
||||
* into permanent storage (equivalent to the Loader of each external
|
||||
* content type package).
|
||||
*
|
||||
* Each definition file name has to be fully qualified relative to
|
||||
* application (context) root.
|
||||
* Example:
|
||||
* contentTypeDefinitions = { "/WEB-INF/content-types/Template.xml" };
|
||||
* An entry in this list is required by internal content types (see package
|
||||
* ccm-cms/src/com/arsdigita/cms/contenttypes)
|
||||
*
|
||||
* This parameter should be altered only by developers!
|
||||
*/
|
||||
private final Parameter m_ctDefFiles =
|
||||
new StringArrayParameter(
|
||||
"com.arsdigita.cms.loader.contenttype_definition_files",
|
||||
"com.arsdigita.cms.loader.internal_cts",
|
||||
Parameter.REQUIRED,
|
||||
// Generic*.xml added by Quasi in enterprise.init for
|
||||
// new generic Basetypes in addition to article
|
||||
|
|
@ -163,15 +170,7 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
// ///////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* The name of the content section, the default value used for initial
|
||||
* setup.
|
||||
*/
|
||||
private final Parameter
|
||||
m_contentSectionName = new StringParameter(
|
||||
"com.arsdigita.cms.loader.section_name",
|
||||
Parameter.REQUIRED,
|
||||
"content");
|
||||
// Section Name, configured by Loader parameter
|
||||
|
||||
// Root Folder, set autonomously by ContentSection.create() method
|
||||
|
||||
|
|
@ -224,12 +223,16 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
* When the list is empty and the first default content section is created,
|
||||
* all installed content types will get registered. This behaviour should
|
||||
* not be altered without very good reasons.
|
||||
*
|
||||
* While loading ccm-cms no external content type packages are available
|
||||
* because all content types depend on ccm-cms. Therefore this parameter
|
||||
* can not beused in loader context.
|
||||
*/
|
||||
private final Parameter
|
||||
m_contentTypeList = new StringArrayParameter(
|
||||
"com.arsdigita.cms.loader.section_ctypes_list",
|
||||
Parameter.REQUIRED,
|
||||
new String[] {} );
|
||||
//private final Parameter
|
||||
// m_contentTypeList = new StringArrayParameter(
|
||||
// "com.arsdigita.cms.loader.section_ctypes_list",
|
||||
// Parameter.REQUIRED,
|
||||
// new String[] {} );
|
||||
|
||||
// Page Resolver Class, set autonomously by ContentSection.create() method.
|
||||
|
||||
|
|
@ -310,7 +313,6 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
// new String[] {"/WEB-INF/resources/article-categories.xml",
|
||||
// "/WEB-INF/resources/navigation-categories.xml"} );
|
||||
|
||||
|
||||
/** List of widgets used in applications forms. Each widget is described by
|
||||
application indicator, widget name (singular & plural), model class name
|
||||
and model ui class name. These are really not user or administrator
|
||||
|
|
@ -486,12 +488,11 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
register(m_ctDefFiles);
|
||||
|
||||
// Parameters for creating a content section
|
||||
register(m_contentSectionName);
|
||||
register(m_isPublic);
|
||||
register(m_itemResolverClass);
|
||||
register(m_templateResolverClass);
|
||||
|
||||
register(m_contentTypeList);
|
||||
// register(m_contentTypeList);
|
||||
register(m_useSectionCategories);
|
||||
register(m_categoryFileList);
|
||||
|
||||
|
|
@ -504,9 +505,7 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
// register(m_overdueAlertInterval);
|
||||
// register(m_maxAlerts);
|
||||
|
||||
|
||||
|
||||
|
||||
// Does not work at load time!
|
||||
// loadInfo();
|
||||
|
||||
}
|
||||
|
|
@ -542,12 +541,6 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the name of the content-section
|
||||
*/
|
||||
public String getContentSectionName() {
|
||||
return (String) get(m_contentSectionName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -694,9 +687,9 @@ public final class LoaderConfig extends AbstractConfig {
|
|||
/**
|
||||
* Retrieve the
|
||||
*/
|
||||
public List getContentSectionsContentTypes() {
|
||||
String[] contentTypes = (String[]) get(m_contentTypeList);
|
||||
return Arrays.asList(contentTypes);
|
||||
}
|
||||
// public List getContentSectionsContentTypes() {
|
||||
// String[] contentTypes = (String[]) get(m_contentTypeList);
|
||||
// return Arrays.asList(contentTypes);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@ com.arsdigita.cms.loader.contenttype_definition_files.purpose=
|
|||
com.arsdigita.cms.loader.contenttype_definition_files.example=
|
||||
com.arsdigita.cms.loader.contenttype_definition_files.format=[StringArray]
|
||||
|
||||
com.arsdigita.cms.loader.section_name.title=
|
||||
com.arsdigita.cms.loader.section_name.purpose=
|
||||
com.arsdigita.cms.loader.section_name.example=
|
||||
com.arsdigita.cms.loader.section_name.format=[StringArray]
|
||||
|
||||
com.arsdigita.cms.loader.section_staff_group.title=
|
||||
com.arsdigita.cms.loader.section_staff_group.purpose=
|
||||
com.arsdigita.cms.loader.section_staff_group.example=
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
com.arsdigita.cms.loader.section_name.title= Name(s) of content section(s)
|
||||
com.arsdigita.cms.loader.section_name.purpose=One ore more content section names to create
|
||||
com.arsdigita.cms.loader.section_name.example=content[,generic]
|
||||
com.arsdigita.cms.loader.section_name.format=[StringArray]
|
||||
|
||||
|
||||
|
|
@ -30,6 +30,9 @@ import java.math.BigDecimal;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
// WORK IN PROGRESS !!
|
||||
// Currentliy just a minimal implementation ready to switch cms-service from an
|
||||
// old style package-type application to a new style legacy compatible
|
||||
// application based an classes web.Application etc.
|
||||
|
||||
/**
|
||||
* Application domain class for the CMS Service application, a CMS module which
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contentitem;
|
||||
|
||||
import com.arsdigita.cms.ContentBundle;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contentitem;
|
||||
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contentitem;
|
||||
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.CategoryPurpose;
|
||||
|
|
@ -16,8 +16,9 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contentitem;
|
||||
|
||||
import com.arsdigita.cms.contentitem.ContentPageHelper;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.TextAsset;
|
||||
import com.arsdigita.cms.contenttypes.GenericArticle;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contentitem;
|
||||
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
|
|
@ -29,6 +29,7 @@ import com.arsdigita.persistence.DataAssociation;
|
|||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.StringUtils;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -36,11 +37,14 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.oro.text.perl.Perl5Util;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Parses and XML file definition of content items in a folder.
|
||||
* the XML configuration should look like this:
|
||||
|
|
@ -101,8 +105,6 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||
* </PRE>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class XMLContentItemHandler extends DefaultHandler {
|
||||
private static final Logger s_log
|
||||
= Logger.getLogger(XMLContentItemHandler.class);
|
||||
|
|
@ -140,6 +142,7 @@ public class XMLContentItemHandler extends DefaultHandler {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void startElement( String uri, String name,
|
||||
String qName, Attributes atts) {
|
||||
|
||||
|
|
@ -160,7 +163,7 @@ public class XMLContentItemHandler extends DefaultHandler {
|
|||
currFolderTree.addSubTree ( newFolderTree );
|
||||
currFolderTree = newFolderTree;
|
||||
|
||||
m_folder = (Folder) currFolderTree.getFolderHelper().createContentItem ( true );
|
||||
m_folder = (Folder) currFolderTree.getFolderHelper().createContentItem(true );
|
||||
|
||||
} else if ( qName.equals(CONTENT_ITEM)) {
|
||||
/*
|
||||
|
|
@ -224,6 +227,7 @@ public class XMLContentItemHandler extends DefaultHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch,
|
||||
int start,
|
||||
int length) {
|
||||
|
|
@ -231,6 +235,7 @@ public class XMLContentItemHandler extends DefaultHandler {
|
|||
m_body = new String(ch, start, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement( String uri, String name,
|
||||
String qName) {
|
||||
|
||||
|
|
@ -33,7 +33,6 @@ import com.arsdigita.cms.util.GlobalizationUtil;
|
|||
import com.arsdigita.cms.workflow.CMSTask;
|
||||
import com.arsdigita.cms.workflow.CMSTaskType;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
//import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.Party;
|
||||
import com.arsdigita.kernel.PartyCollection;
|
||||
import com.arsdigita.kernel.Role;
|
||||
|
|
@ -72,7 +71,6 @@ import org.xml.sax.helpers.DefaultHandler;
|
|||
public final class ContentSectionSetup {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(ContentSectionSetup.class);
|
||||
private final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl";
|
||||
private HashMap m_tasks = new HashMap();
|
||||
private LifecycleDefinition m_lcd;
|
||||
private WorkflowTemplate m_wf;
|
||||
|
|
@ -457,6 +455,11 @@ public final class ContentSectionSetup {
|
|||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @param filename
|
||||
*/
|
||||
void registerTemplate(ContentType type, String filename) {
|
||||
// Use the base of the file name (ie without path & extension)
|
||||
// as the template name
|
||||
|
|
@ -675,5 +678,7 @@ public final class ContentSectionSetup {
|
|||
m_cats.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // END private class CategoryHandler
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import com.arsdigita.cms.ContentTypeWorkflowTemplate;
|
|||
import com.arsdigita.cms.Template;
|
||||
import com.arsdigita.cms.TemplateManager;
|
||||
import com.arsdigita.cms.TemplateManagerFactory;
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinitionCollection;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
|
|
@ -60,19 +59,30 @@ import org.apache.log4j.Logger;
|
|||
**/
|
||||
public abstract class AbstractContentTypeLoader extends PackageLoader {
|
||||
|
||||
/** Logger instance for debugging */
|
||||
private static final Logger s_log = Logger.getLogger(
|
||||
AbstractContentTypeLoader.class);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
public void run(final ScriptContext ctx) {
|
||||
new KernelExcursion() {
|
||||
|
||||
protected void excurse() {
|
||||
setEffectiveParty(Kernel.getSystemParty());
|
||||
|
||||
createTypes(ctx);
|
||||
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ctx
|
||||
*/
|
||||
private void createTypes(ScriptContext ctx) {
|
||||
XMLContentTypeHandler handler = new XMLContentTypeHandler();
|
||||
String[] contentTypes = getTypes();
|
||||
|
|
@ -86,7 +96,9 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
|
|||
ContentSection.BASE_DATA_OBJECT_TYPE);
|
||||
|
||||
while (sections.next()) {
|
||||
ContentSection section = (ContentSection) DomainObjectFactory.newInstance(sections.getDataObject());
|
||||
ContentSection section = (ContentSection)
|
||||
DomainObjectFactory.newInstance(
|
||||
sections.getDataObject());
|
||||
if (!isLoadableInto(section)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -128,6 +140,9 @@ public abstract class AbstractContentTypeLoader extends PackageLoader {
|
|||
|
||||
protected abstract String[] getTypes();
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
private boolean isLoadableInto(ContentSection section) {
|
||||
if (section == null) {
|
||||
throw new NullPointerException("section");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.AuthoringKit;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.AuthoringKit;
|
||||
import com.arsdigita.cms.AuthoringStep;
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.AuthoringKit;
|
||||
import com.arsdigita.cms.AuthoringStep;
|
||||
|
|
@ -37,6 +37,10 @@ import org.apache.oro.text.perl.Perl5Util;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UDCTHelper extends ContentTypeHelperImpl implements ContentTypeHelper {
|
||||
private static final Logger s_log
|
||||
= Logger.getLogger(UDCTHelper.class);
|
||||
|
|
@ -54,6 +58,10 @@ public class UDCTHelper extends ContentTypeHelperImpl implements ContentTypeHelp
|
|||
private int m_stepCount = 1;
|
||||
// Flag to avoid the duplication of categorization step
|
||||
private boolean m_hasCategoryStep = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public UDCTHelper() {
|
||||
// this is predefined
|
||||
setCreateComponent(CREATION_COMPONENT);
|
||||
|
|
@ -88,6 +96,11 @@ public class UDCTHelper extends ContentTypeHelperImpl implements ContentTypeHelp
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AuthoringKit createAuthoringKit() {
|
||||
setCreateComponent(CREATION_COMPONENT);
|
||||
AuthoringKit kit = super.createAuthoringKit();
|
||||
|
|
@ -96,12 +109,21 @@ public class UDCTHelper extends ContentTypeHelperImpl implements ContentTypeHelp
|
|||
return kit;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private DynamicObjectType createDOT() {
|
||||
DynamicObjectType dot = new DynamicObjectType(m_name, m_parentType);
|
||||
dot.save();
|
||||
return dot;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ContentType createType() {
|
||||
|
||||
MetadataRoot root = SessionManager.getMetadataRoot();
|
||||
|
|
@ -161,6 +183,14 @@ public class UDCTHelper extends ContentTypeHelperImpl implements ContentTypeHelp
|
|||
m_type.save();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param label
|
||||
* @param description
|
||||
* @param component
|
||||
* @param ordering
|
||||
*/
|
||||
@Override
|
||||
public void addAuthoringStep(String label,
|
||||
String description,
|
||||
String component,
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
package com.arsdigita.cms.installer.xml;
|
||||
package com.arsdigita.cms.contenttypes;
|
||||
|
||||
import com.arsdigita.cms.AuthoringKit;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
|
|
@ -1,269 +0,0 @@
|
|||
/*
|
||||
* 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.installer;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.PackageInstance;
|
||||
import com.arsdigita.kernel.PackageType;
|
||||
// import com.arsdigita.kernel.Stylesheet;
|
||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
// Migration Status
|
||||
// All tasks this class used to perform are migrated to either cms.Loader or
|
||||
// cms.WorkspaceSetup.
|
||||
// File is kept in trunk for reference purpose until the whole migration process
|
||||
// will be completed. (2010-20-18)
|
||||
|
||||
/**
|
||||
* Sets up the CMS package.
|
||||
*
|
||||
* @author Jon Orris (jorris@redhat.com)
|
||||
* @version $Revision: #10 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
*/
|
||||
public final class ContentCenterSetup {
|
||||
|
||||
/** URL to access the CMS Workspace, by default content-center */
|
||||
final String m_workspaceURL;
|
||||
|
||||
/** Map of URL stubs and resource handler classes for ContentCenterDispatcher
|
||||
* to use */
|
||||
final String m_contentCenterMap;
|
||||
|
||||
/** Contains mapping of URL (key) to resource handler*/
|
||||
private static HashMap s_pageClasses = new HashMap();
|
||||
|
||||
/** Contains mapping of resource(key) to resource handler */
|
||||
private static HashMap s_pageURLs = new HashMap();
|
||||
|
||||
|
||||
private final static String SERVICE_URL = "cms-service";
|
||||
|
||||
private final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl";
|
||||
private final static String PACKAGE_KEY = "content-section";
|
||||
private final static String DISPATCHER_CLASS =
|
||||
"com.arsdigita.cms.dispatcher.ContentSectionDispatcher";
|
||||
|
||||
|
||||
private static Logger s_log = Logger.getLogger(ContentSectionSetup.class);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param workspaceURL
|
||||
* @param contentCenterMap
|
||||
*/
|
||||
public ContentCenterSetup( String workspaceURL,
|
||||
String contentCenterMap) {
|
||||
|
||||
m_workspaceURL = workspaceURL;
|
||||
m_contentCenterMap = contentCenterMap;
|
||||
|
||||
}
|
||||
|
||||
/** Gives you a mapping of URL (key) to resource handler
|
||||
* Use the returned map like so: map.get("search");
|
||||
*/
|
||||
public static HashMap getURLToClassMap() {
|
||||
return s_pageClasses;
|
||||
}
|
||||
|
||||
/** Gives you a mapping of resource(key) to resource handler
|
||||
* Use the returned map like so: map.get("com.arsdigita.cms.ui.WorkspacePage");
|
||||
*/
|
||||
public static HashMap getClassToURLMap() {
|
||||
return s_pageURLs;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
||||
// 1) Setup the content section package.
|
||||
// Currently just invokes createPrivileges, which should be executed
|
||||
// at each system startup to check for modifications. So it is an
|
||||
// Initializer task and will be moved to an Initializer.
|
||||
// setupCMSPackage();
|
||||
// createPrivileges();
|
||||
|
||||
// 2) Setup the Workspace package.
|
||||
// Moved to Loader
|
||||
// setupWorkspacePackage();
|
||||
|
||||
// 3) Setup the CMS global services package.
|
||||
// Moved to Loader
|
||||
// setupServicePackage();
|
||||
|
||||
// 8) Load the content-center page mappings
|
||||
// Has to be executed an each system startup and is an
|
||||
// Initializer task.
|
||||
setupContentCenter();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the CMS (i.e. content section) package type if it does not already exist.
|
||||
*
|
||||
* Actually: Creation ot content section is migrated to loader. Just used to
|
||||
* create privileges.
|
||||
*/
|
||||
private static void setupCMSPackage() {
|
||||
if ( !PackageType.typeExists(Installer.PACKAGE_KEY) ) { //key = content-section
|
||||
s_log.info("Creating the CMS package type...");
|
||||
|
||||
// PackageType type = PackageType.create
|
||||
// (PACKAGE_KEY, "Content Management System", "Content Management Systems",
|
||||
// "http://cms-java.arsdigita.com/");
|
||||
// type.setDispatcherClass(DISPATCHER_CLASS);
|
||||
// //type.addListener(LISTENER_CLASS);
|
||||
|
||||
// Register a stylesheets to the CMS package.
|
||||
// Stylesheet ss = Stylesheet.createStylesheet(STYLESHEET);
|
||||
// ss.save();
|
||||
// type.addStylesheet(ss);
|
||||
// type.save();
|
||||
|
||||
createPrivileges();
|
||||
|
||||
s_log.info("Done creating the CMS package type.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates and mounts the Workspace package.
|
||||
*/
|
||||
private void setupWorkspacePackage() throws InitializationException {
|
||||
if ( !PackageType.typeExists((new WorkspaceInstaller()).getPackageKey())) {
|
||||
s_log.info("Initializing CMS Workspace...");
|
||||
|
||||
Util.validateURLParameter("workspace", m_workspaceURL);
|
||||
|
||||
WorkspaceInstaller workspaceInstaller = new WorkspaceInstaller();
|
||||
try {
|
||||
workspaceInstaller.createPackageType();
|
||||
PackageInstance instance = workspaceInstaller.createPackageInstance();
|
||||
workspaceInstaller.mountPackageInstance(instance, m_workspaceURL);
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new InitializationException
|
||||
("Failed to initialize the Workspace package: ", e);
|
||||
}
|
||||
|
||||
s_log.info("Done initializing CMS Workspace.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and mounts the CMS Service package.
|
||||
*/
|
||||
private static void setupServicePackage() {
|
||||
if ( !PackageType.typeExists(ServiceInstaller.PACKAGE_KEY) ) {
|
||||
String url = SERVICE_URL;
|
||||
|
||||
try {
|
||||
ServiceInstaller.createPackageType();
|
||||
PackageInstance instance = ServiceInstaller.createPackageInstance();
|
||||
ServiceInstaller.mountPackageInstance(instance, url);
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new InitializationException
|
||||
("Failed to initialize CMS global services package: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Integrates the CMS privileges into the Core permision system.
|
||||
*
|
||||
* Skips through the CMS specific privileges and integrates those which are
|
||||
* missing in core's acs_privileges into it, so the systems security system
|
||||
* is aware of it.
|
||||
*/
|
||||
private static void createPrivileges() {
|
||||
|
||||
final String CMS_PRIVILEGES = "com.arsdigita.cms.getPrivileges";
|
||||
final String PRIVILEGE = "privilege";
|
||||
|
||||
DataQuery dq = SessionManager.getSession().retrieveQuery(CMS_PRIVILEGES);
|
||||
try {
|
||||
while ( dq.next() ) {
|
||||
String privilege = (String) dq.get(PRIVILEGE);
|
||||
s_log.warn(String.format("privilege = %s", privilege));
|
||||
if ( PrivilegeDescriptor.get(privilege) == null ) {
|
||||
PrivilegeDescriptor.createPrivilege(privilege);
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
dq.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load the content center page mappings.
|
||||
* Mapping stored in hashMaps, must be run during each system startup, so
|
||||
* it is an initializer task.
|
||||
* @throws InitializationException
|
||||
*/
|
||||
private void setupContentCenter() throws InitializationException {
|
||||
final PageClassConfigHandler handler
|
||||
= new PageClassConfigHandler(s_pageClasses, s_pageURLs);
|
||||
|
||||
final ClassLoader loader = Thread.currentThread
|
||||
().getContextClassLoader();
|
||||
final InputStream input = loader.getResourceAsStream
|
||||
(m_contentCenterMap.substring(1));
|
||||
|
||||
if (input == null) {
|
||||
throw new IllegalStateException(m_contentCenterMap + " not found");
|
||||
}
|
||||
|
||||
final InputSource source = new InputSource
|
||||
(input);
|
||||
|
||||
try {
|
||||
final SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
final SAXParser parser = spf.newSAXParser();
|
||||
parser.parse(source, handler);
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new UncheckedWrapperException("error parsing dispatcher config", e);
|
||||
} catch (SAXException e) {
|
||||
throw new UncheckedWrapperException("error parsing dispatcher config", e);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedWrapperException("error parsing dispatcher config", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,679 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2005 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.installer;
|
||||
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.categorization.RootCategoryCollection;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.ContentTypeWorkflowTemplate;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.Template;
|
||||
import com.arsdigita.cms.TemplateManagerFactory;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.cms.lifecycle.PhaseDefinition;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.cms.workflow.CMSTask;
|
||||
import com.arsdigita.cms.workflow.CMSTaskType;
|
||||
import com.arsdigita.cms.workflow.UnfinishedTaskNotifier;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.ACSObjectInstantiator;
|
||||
import com.arsdigita.kernel.Party;
|
||||
import com.arsdigita.kernel.PartyCollection;
|
||||
import com.arsdigita.kernel.Role;
|
||||
import com.arsdigita.kernel.permissions.PermissionService;
|
||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
// import com.arsdigita.runtime.AbstractConfig;
|
||||
import com.arsdigita.cms.LoaderConfig;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.util.UncheckedWrapperException;
|
||||
import com.arsdigita.web.ApplicationSetup;
|
||||
import com.arsdigita.workflow.simple.WorkflowTemplate;
|
||||
import com.arsdigita.xml.XML;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Date;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Timer;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* Sets up the content section.
|
||||
*
|
||||
* @author Jon Orris (jorris@redhat.com)
|
||||
* @version $Revision: #17 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
*/
|
||||
|
||||
public final class ContentSectionSetup {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(ContentSectionSetup.class);
|
||||
|
||||
private final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl";
|
||||
private HashMap m_tasks = new HashMap();
|
||||
private LifecycleDefinition m_lcd;
|
||||
private WorkflowTemplate m_wf;
|
||||
final ContentSection m_section;
|
||||
|
||||
// Load main CMS configuration file
|
||||
private static final LoaderConfig s_conf = new LoaderConfig();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param section
|
||||
*/
|
||||
public ContentSectionSetup(ContentSection section) {
|
||||
Assert.exists(section, ContentSection.class);
|
||||
m_section = section;
|
||||
}
|
||||
|
||||
// public void run() {
|
||||
//
|
||||
// // 4) Mount content sections.
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Setup content section app type
|
||||
*/
|
||||
// Nach bisherigen Erkenntnissen: Braucht nur einmal aufgerufen zu werden,
|
||||
// um den Typ in die Datenbank einzutragen, d.h. letztlich den Klassennamen
|
||||
// mit zugehörien Support Klassen zu registrieren. Damit kann die Klasse
|
||||
// noch nicht benutzt oder angesprochen werden. Dazu muss zumindest eine
|
||||
// Instanz des Typs erstellt werden, (d.h. eine content section, z.B. die
|
||||
// default section 'content'. Für einen Typ können im Prinzip mehrere
|
||||
// Instanzen geschaffen werden, die sich vor allem durch den Namen, d.h. die
|
||||
// URL, unter der sie angesprochen werden, unterscheiden.
|
||||
public static void setupContentSectionAppType() {
|
||||
|
||||
// Install application type using new application classes
|
||||
ApplicationSetup setup = new ApplicationSetup(s_log);
|
||||
setup.setApplicationObjectType(ContentSection.BASE_DATA_OBJECT_TYPE);
|
||||
setup.setKey(ContentSection.PACKAGE_TYPE); // by default: content-section
|
||||
setup.setTitle("CMS Content Section");
|
||||
setup.setDescription("A CMS Content Section");
|
||||
setup.setPortalApplication(false);
|
||||
//setup.setDispatcherClass(ContentItemDispatcher.class.getName());
|
||||
setup.setStylesheet(STYLESHEET); // by default: /pack./c-s/xml/cms.xml
|
||||
// contains the xsl to generate the page
|
||||
|
||||
setup.setInstantiator(new ACSObjectInstantiator() {
|
||||
@Override
|
||||
public DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new ContentSection(dataObject);
|
||||
}
|
||||
});
|
||||
|
||||
setup.run();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* setup content section app instance
|
||||
*/
|
||||
public static void setupContentSectionAppInstance(String name,
|
||||
List categoryFileList,
|
||||
List staffGroup,
|
||||
Boolean isPubliclyViewable) {
|
||||
|
||||
s_log.info("Creating content section on /" + name);
|
||||
|
||||
|
||||
ContentSection section = ContentSection.create(name);
|
||||
|
||||
ContentSectionSetup setup = new ContentSectionSetup(section);
|
||||
|
||||
// Setup the access controls
|
||||
|
||||
// section specific categories, usually not used.
|
||||
// During initial load at install time nor used at all!
|
||||
if (ContentSection.getConfig().getUseSectionCategories()) {
|
||||
// Iterator files = ((List) m_conf.getParameter(CATEGORIES)).iterator();
|
||||
// Iterator files = s_conf.getCategoryFileList().iterator();
|
||||
Iterator files = categoryFileList.iterator();
|
||||
while ( files.hasNext() ) {
|
||||
setup.registerCategories((String) files.next());
|
||||
}
|
||||
}
|
||||
|
||||
setup.registerRoles(staffGroup);
|
||||
// setup.registerViewers((Boolean)m_conf.getParameter(PUBLIC));
|
||||
setup.registerViewers(isPubliclyViewable);
|
||||
setup.registerAlerts();
|
||||
setup.registerPublicationCycles();
|
||||
setup.registerWorkflowTemplates();
|
||||
// setup.registerContentTypes((List)m_conf.getParameter(TYPES));
|
||||
setup.registerContentTypes(s_conf.getContentSectionsContentTypes());
|
||||
// setup.registerResolvers
|
||||
// ((String) m_conf.getParameter(ITEM_RESOLVER_CLASS),
|
||||
// (String) m_conf.getParameter(TEMPLATE_RESOLVER_CLASS));
|
||||
setup.registerResolvers
|
||||
(s_conf.getItemResolverClass(),
|
||||
s_conf.getTemplateResolverClass());
|
||||
section.save();
|
||||
|
||||
// return section;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param filename
|
||||
*/
|
||||
public void registerCategories(String filename) {
|
||||
|
||||
if (filename == null) {
|
||||
s_log.info("not loading any categories");
|
||||
return;
|
||||
}
|
||||
|
||||
s_log.info("loading categories from " + filename);
|
||||
|
||||
XML.parseResource(filename, new CategoryHandler(m_section));
|
||||
}
|
||||
|
||||
|
||||
public void registerRoles(List roles) {
|
||||
|
||||
Iterator i = roles.iterator();
|
||||
while (i.hasNext()) {
|
||||
List role = (List)i.next();
|
||||
|
||||
String name = (String)role.get(0);
|
||||
String desc = (String)role.get(1);
|
||||
List privileges = (List)role.get(2);
|
||||
String task = (role.size() > 3 ? (String)role.get(3) : null);
|
||||
|
||||
s_log.info("Creating role " + name);
|
||||
|
||||
|
||||
Role group = registerRole(
|
||||
name,
|
||||
desc,
|
||||
privileges);
|
||||
|
||||
if (task != null)
|
||||
m_tasks.put(task, group);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Role registerRole(String name,
|
||||
String desc,
|
||||
List privileges) {
|
||||
Role role = m_section.getStaffGroup().createRole(name);
|
||||
role.setDescription(desc);
|
||||
role.save();
|
||||
|
||||
Iterator i = privileges.iterator();
|
||||
while (i.hasNext()) {
|
||||
String priv = (String)i.next();
|
||||
s_log.info("Granting privilege cms_" + priv);
|
||||
|
||||
role.grantPermission(m_section,
|
||||
PrivilegeDescriptor.get("cms_" + priv));
|
||||
|
||||
if (priv.equals(SecurityManager.CATEGORY_ADMIN) ||
|
||||
priv.equals(SecurityManager.CATEGORIZE_ITEMS)) {
|
||||
RootCategoryCollection coll = Category.getRootCategories(m_section);
|
||||
while (coll.next()) {
|
||||
if (priv.equals(SecurityManager.CATEGORY_ADMIN)) {
|
||||
role.grantPermission(coll.getCategory(),
|
||||
PrivilegeDescriptor.ADMIN);
|
||||
} else {
|
||||
role.grantPermission(coll.getCategory(),
|
||||
Category.MAP_DESCRIPTOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return role;
|
||||
}
|
||||
|
||||
public void registerResolvers(String itemResolverClass, String templateResolverClass) {
|
||||
|
||||
if (itemResolverClass != null && itemResolverClass.length()>0) {
|
||||
m_section.setItemResolverClass(itemResolverClass);
|
||||
s_log.info("Registering " + itemResolverClass + " as the item resolver class");
|
||||
} else {
|
||||
m_section.setItemResolverClass
|
||||
(ContentSection.getConfig().getDefaultItemResolverClass().getName());
|
||||
s_log.info("Registering " + itemResolverClass + " as the item resolver class");
|
||||
}
|
||||
if (templateResolverClass != null && templateResolverClass.length()>0) {
|
||||
m_section.setTemplateResolverClass(templateResolverClass);
|
||||
s_log.info("Registering " + templateResolverClass +
|
||||
" as the template resolver class");
|
||||
} else {
|
||||
m_section.setTemplateResolverClass
|
||||
(ContentSection.getConfig().getDefaultTemplateResolverClass().getName());
|
||||
s_log.info("Registering " + templateResolverClass +
|
||||
" as the template resolver class");
|
||||
}
|
||||
|
||||
m_section.save();
|
||||
}
|
||||
|
||||
public void registerWorkflowTemplates()
|
||||
throws InitializationException {
|
||||
|
||||
// The 3-step production workflow.
|
||||
WorkflowTemplate wf = new WorkflowTemplate();
|
||||
wf.setLabel( (String) GlobalizationUtil.globalize(
|
||||
"cms.installer.production_workflow").localize());
|
||||
wf.setDescription("A process that involves creating and approving content.");
|
||||
wf.save();
|
||||
|
||||
CMSTask authoring = new CMSTask();
|
||||
authoring.setLabel((String) GlobalizationUtil.globalize(
|
||||
"cms.installer.authoring").localize());
|
||||
authoring.setDescription("Create content.");
|
||||
authoring.save();
|
||||
|
||||
|
||||
Role author = (Role)m_tasks.get("Authoring");
|
||||
if (author != null)
|
||||
authoring.assignGroup(author.getGroup());
|
||||
|
||||
authoring.setTaskType(CMSTaskType.retrieve(CMSTaskType.AUTHOR));
|
||||
authoring.save();
|
||||
|
||||
CMSTask approval = new CMSTask();
|
||||
approval.setLabel( (String) GlobalizationUtil.globalize(
|
||||
"cms.installer.approval").localize());
|
||||
approval.setDescription("Approve content.");
|
||||
approval.save();
|
||||
approval.addDependency(authoring);
|
||||
approval.save();
|
||||
|
||||
Role approver = (Role)m_tasks.get("Approval");
|
||||
if (approver != null)
|
||||
approval.assignGroup(approver.getGroup());
|
||||
|
||||
approval.setTaskType(CMSTaskType.retrieve(CMSTaskType.EDIT));
|
||||
approval.save();
|
||||
|
||||
|
||||
CMSTask deploy = new CMSTask();
|
||||
deploy.setLabel((String) GlobalizationUtil.globalize(
|
||||
"cms.installer.deploy").localize());
|
||||
deploy.setDescription("Deploy content.");
|
||||
deploy.save();
|
||||
deploy.addDependency(approval);
|
||||
deploy.save();
|
||||
|
||||
Role publisher = (Role)m_tasks.get("Publishing");
|
||||
if (publisher != null)
|
||||
deploy.assignGroup(publisher.getGroup());
|
||||
|
||||
deploy.setTaskType(CMSTaskType.retrieve(CMSTaskType.DEPLOY));
|
||||
deploy.save();
|
||||
|
||||
wf.addTask(authoring);
|
||||
wf.addTask(approval);
|
||||
wf.addTask(deploy);
|
||||
wf.save();
|
||||
|
||||
m_section.addWorkflowTemplate(wf);
|
||||
m_section.save();
|
||||
|
||||
m_wf = wf;
|
||||
}
|
||||
|
||||
public void registerViewers(Boolean pub) {
|
||||
Role viewers = m_section.getViewersGroup().createRole("Content Reader");
|
||||
viewers.setDescription("Can view published pages within this section");
|
||||
viewers.save();
|
||||
|
||||
viewers.grantPermission(m_section,
|
||||
PrivilegeDescriptor.get("cms_read_item"));
|
||||
|
||||
|
||||
String email = Boolean.TRUE.equals(pub) ? "public@nullhost"
|
||||
: "registered@nullhost";
|
||||
|
||||
Party viewer = retrieveParty(email);
|
||||
if (viewer == null)
|
||||
throw new InitializationException(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.installer.cannot_find_group_for_email").localize() + email);
|
||||
|
||||
s_log.info("Adding " + email + " to viewers role");
|
||||
viewers.getGroup().addMemberOrSubgroup(viewer);
|
||||
viewers.save();
|
||||
}
|
||||
|
||||
Party retrieveParty(String email) {
|
||||
PartyCollection parties = Party.retrieveAllParties();
|
||||
parties.filter(email);
|
||||
if (parties.next()) {
|
||||
Party party = parties.getParty();
|
||||
parties.close();
|
||||
return party;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For the content section to be created create a role whose member will
|
||||
* receive alerts.
|
||||
*/
|
||||
public void registerAlerts() {
|
||||
Role alert = m_section.getStaffGroup().createRole("Alert Recipient");
|
||||
alert.setDescription("Receive alerts regarding expiration of pubished content");
|
||||
alert.save();
|
||||
}
|
||||
|
||||
public void registerContentTypes(List types) {
|
||||
|
||||
Iterator i = types.iterator();
|
||||
|
||||
while (i.hasNext()) {
|
||||
Object obj = i.next();
|
||||
if (obj instanceof String) {
|
||||
registerContentType((String)obj);
|
||||
} else {
|
||||
List list = (List)obj;
|
||||
String name = (String)list.get(0);
|
||||
String file = (String)list.get(1);
|
||||
|
||||
ContentType type = registerContentType(name);
|
||||
registerTemplate(type, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ContentType registerContentType(String name) {
|
||||
ContentType type = null;
|
||||
try {
|
||||
type = ContentType.findByAssociatedObjectType(name);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.installer.cannot_find_content_type").localize() + name, ex);
|
||||
}
|
||||
|
||||
s_log.info("Adding type " + name + " to " + m_section.getDisplayName());
|
||||
m_section.addContentType(type);
|
||||
|
||||
s_log.info("Setting the default lifecycle for " +
|
||||
name + " to " + m_lcd.getLabel());
|
||||
ContentTypeLifecycleDefinition.
|
||||
updateLifecycleDefinition(m_section, type, m_lcd);
|
||||
m_lcd.save();
|
||||
|
||||
s_log.info("Setting the default workflow template for " + name +
|
||||
" to " + m_wf.getLabel());
|
||||
ContentTypeWorkflowTemplate.updateWorkflowTemplate(m_section, type, m_wf);
|
||||
m_wf.save();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
void registerTemplate(ContentType type, String filename) {
|
||||
// Use the base of the file name (ie without path & extension)
|
||||
// as the template name
|
||||
int pos1 = filename.lastIndexOf("/");
|
||||
int pos2 = filename.lastIndexOf(".");
|
||||
|
||||
if (pos2 == -1)
|
||||
pos2 = filename.length();
|
||||
|
||||
String label = filename.substring(pos1+1,pos2);
|
||||
|
||||
String typename = type.getClassName();
|
||||
int pos3 = typename.lastIndexOf(".");
|
||||
String name = typename.substring(pos3+1, typename.length()) + "-" + label;
|
||||
|
||||
Template temp = new Template();
|
||||
temp.setContentSection(m_section);
|
||||
temp.setName(name);
|
||||
temp.setLabel(label);
|
||||
temp.setParent(m_section.getTemplatesFolder());
|
||||
|
||||
final ClassLoader loader = Thread.currentThread
|
||||
().getContextClassLoader();
|
||||
final InputStream stream = loader.getResourceAsStream
|
||||
(filename.substring(1));
|
||||
|
||||
if (stream == null) {
|
||||
throw new IllegalStateException
|
||||
((String) GlobalizationUtil.globalize
|
||||
("cms.installer.cannot_find_file").localize() + filename);
|
||||
}
|
||||
|
||||
final BufferedReader input = new BufferedReader
|
||||
(new InputStreamReader(stream));
|
||||
|
||||
StringBuffer body = new StringBuffer();
|
||||
String line;
|
||||
for (;;) {
|
||||
try {
|
||||
line = input.readLine();
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.installer.cannot_read_line_of_data").localize(), ex);
|
||||
}
|
||||
if (line == null)
|
||||
break;
|
||||
|
||||
body.append(line);
|
||||
body.append("\n");
|
||||
}
|
||||
|
||||
temp.setText(body.toString());
|
||||
|
||||
temp.save();
|
||||
|
||||
TemplateManagerFactory.getInstance()
|
||||
.addTemplate(m_section, type, temp, "public");
|
||||
|
||||
temp.publish(m_lcd, new Date());
|
||||
// Dan said to comment this out
|
||||
// temp.getLifecycle().start();
|
||||
}
|
||||
|
||||
public void registerPublicationCycles()
|
||||
throws InitializationException {
|
||||
|
||||
// The feature lifecycle.
|
||||
LifecycleDefinition lcd = new LifecycleDefinition();
|
||||
lcd.setLabel( (String) GlobalizationUtil.globalize(
|
||||
"cms.installer.simple_publication").localize());
|
||||
lcd.setDescription("A one-phase lifecycle for items.");
|
||||
lcd.save();
|
||||
|
||||
PhaseDefinition pd = lcd.addPhaseDefinition(
|
||||
"Live", "The first phase. It lasts forever.",
|
||||
new Integer(0), null, null);
|
||||
pd.save();
|
||||
|
||||
lcd.save();
|
||||
|
||||
m_lcd = lcd;
|
||||
|
||||
m_section.addLifecycleDefinition(lcd);
|
||||
m_section.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* SAX Handler for category lists. Creates the categories as they are
|
||||
* defined, with structure, in the xml document.
|
||||
*/
|
||||
private class CategoryHandler extends DefaultHandler {
|
||||
private Stack m_cats = new Stack();
|
||||
private ContentSection m_section;
|
||||
|
||||
public CategoryHandler(ContentSection section) {
|
||||
m_section = section;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement ( String uri, String local,
|
||||
String qName, Attributes attrs ) {
|
||||
if ("categories".equals(qName)) {
|
||||
String name = attrs.getValue("name");
|
||||
if (name == null) {
|
||||
name = "Root";
|
||||
}
|
||||
String description = attrs.getValue("description");
|
||||
String context = attrs.getValue("context");
|
||||
|
||||
Category root = Category.getRootForObject(m_section,
|
||||
context);
|
||||
if (root == null) {
|
||||
root = new Category();
|
||||
}
|
||||
root.setName(name);
|
||||
root.setDescription(description);
|
||||
|
||||
if (root.isNew()) {
|
||||
Category.setRootForObject(m_section,
|
||||
root,
|
||||
context);
|
||||
}
|
||||
m_cats.push(root);
|
||||
PermissionService.setContext(root, m_section);
|
||||
} else if ( "category".equals(qName) ) {
|
||||
String name = attrs.getValue("name");
|
||||
String description = attrs.getValue("description");
|
||||
String url = attrs.getValue("url");
|
||||
|
||||
// set the default description to the name of the category
|
||||
if ( description == null ) {
|
||||
description = name;
|
||||
}
|
||||
|
||||
s_log.debug("creating category '" + name + "'");
|
||||
Category cat = new Category(name, description, url);
|
||||
cat.save();
|
||||
|
||||
Category parent = null;
|
||||
try {
|
||||
parent = (Category)m_cats.peek();
|
||||
} catch ( EmptyStackException ex ) {
|
||||
throw new UncheckedWrapperException("no root category", ex);
|
||||
}
|
||||
|
||||
parent.addChild(cat);
|
||||
parent.save();
|
||||
cat.setDefaultParentCategory(parent);
|
||||
cat.save();
|
||||
|
||||
m_cats.push(cat);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement ( String uri, String local, String qName ) {
|
||||
if ( "category".equals(qName) ) {
|
||||
m_cats.pop();
|
||||
} else if ( "categories".equals(qName)) {
|
||||
m_cats.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tasks
|
||||
*/
|
||||
public void loadAlertPrefs(List tasks) {
|
||||
if (tasks == null) {
|
||||
// fallback to default com.arsdigita.cms.default_task_alerts registry parameter
|
||||
String[] defaultTaskAlerts = ContentSection.getConfig().getDefaultTaskAlerts();
|
||||
if (defaultTaskAlerts != null) {
|
||||
for (int i=0,n=defaultTaskAlerts.length; i<n; i++) {
|
||||
StringTokenizer tok = new StringTokenizer(defaultTaskAlerts[i],":");
|
||||
try {
|
||||
String taskName = tok.nextToken();
|
||||
while (tok.hasMoreTokens()) {
|
||||
String operation = tok.nextToken();
|
||||
CMSTask.addAlert(m_section, taskName, operation);
|
||||
}
|
||||
} catch (NoSuchElementException nsee) {
|
||||
s_log.warn("Invalid task alerts definition");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Iterator taskIter = tasks.iterator();
|
||||
while (taskIter.hasNext()) {
|
||||
List oneTask = (List) taskIter.next();
|
||||
String taskName = (String) oneTask.get(0);
|
||||
List operationList = (List) oneTask.get(1);
|
||||
Iterator operationIter = null;
|
||||
if (operationList != null) {
|
||||
operationIter = operationList.iterator();
|
||||
}
|
||||
if (operationIter != null) {
|
||||
while (operationIter.hasNext()) {
|
||||
String operation = (String) operationIter.next();
|
||||
CMSTask.addAlert(m_section, taskName, operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Timer startNotifierTask(Boolean sendOverdue, Integer duration,
|
||||
Integer alertInterval, Integer max) {
|
||||
Timer unfinished = null;
|
||||
if (sendOverdue.booleanValue()) {
|
||||
if (duration == null || alertInterval == null || max == null) {
|
||||
s_log.info("Not sending overdue task alerts, " +
|
||||
"required initialization parameters were not specified");
|
||||
return null;
|
||||
}
|
||||
// start the Timer as a daemon, so it doesn't keep the JVM from exiting
|
||||
unfinished = new Timer(true);
|
||||
UnfinishedTaskNotifier notifier = new UnfinishedTaskNotifier(
|
||||
m_section, duration.intValue(),
|
||||
alertInterval.intValue(), max.intValue());
|
||||
// schedule the Task to start in 5 minutes, at 1 hour intervals
|
||||
unfinished.schedule(notifier, 5L * 60 * 1000, 60L * 60 * 1000);
|
||||
s_log.info("Sending overdue alerts for tasks greater than " +
|
||||
duration + " hours old");
|
||||
} else {
|
||||
s_log.info("Not sending overdue task alerts");
|
||||
}
|
||||
|
||||
return unfinished;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
// Migration Status
|
||||
// All tasks this class used to perform are migrated to cms.Loader
|
||||
// File is kept in trunk for reference purpose until the whole migration process
|
||||
// will be completed. (2010-20-18)
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
package com.arsdigita.cms.installer;
|
||||
|
||||
import com.arsdigita.cms.LoaderConfig;
|
||||
import com.arsdigita.runtime.CompoundInitializer;
|
||||
// import com.arsdigita.runtime.DataInitEvent;
|
||||
import com.arsdigita.runtime.DomainInitEvent;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
// WORK IN PROGRESS
|
||||
// Migrating the CMS Code from old style initializer and old style application
|
||||
// to new style initializer and new style application.
|
||||
//
|
||||
//
|
||||
// Plannings
|
||||
// 1. Step
|
||||
// (Simple) Migration of the Old Initializer code of this package to the new
|
||||
// initializer system. Current goal is a pure replacement with as less code
|
||||
// changes as possible.
|
||||
// 2. Step
|
||||
// Restructuring codel eventually remove this Initializer
|
||||
|
||||
/**
|
||||
* XXX Reformulate according to the code development!
|
||||
*
|
||||
* Initializes the CMS package.
|
||||
*
|
||||
* <p>The main initializer for the Content Management System.</p>
|
||||
*
|
||||
* <p>Initializes the Content Management System, including the Content Center
|
||||
* and CMS Service applications and CMS Mime Types service. This class also
|
||||
* optionally initializes user-defined content types and user-defined content
|
||||
* sections.</p>
|
||||
*
|
||||
*
|
||||
* @author Peter Boy (pboy@barkhof.uni-bremen.de)
|
||||
* @version $Id: $
|
||||
*
|
||||
*/
|
||||
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 final LoaderConfig s_conf = new LoaderConfig();
|
||||
// Verursacht aktuell eine Exception "no such context"
|
||||
// Vermutliche Lösung: in config.xml eintragen.
|
||||
// static { // requirred to actually read the config file!
|
||||
// s_conf.load();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public Initializer() {
|
||||
//final String url = RuntimeConfig.getConfig().getJDBCURL();
|
||||
//final int database = DbHelper.getDatabaseFromURL(url);
|
||||
|
||||
s_log.debug("CMS.installer.Initializer.(Constructor) completed");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * An empty implementation of {@link Initializer#init(DataInitEvent)}.
|
||||
// *
|
||||
// * @param evt The data init event.
|
||||
// */
|
||||
// public void init(DataInitEvent evt) {
|
||||
// }
|
||||
|
||||
/**
|
||||
* Initializes domain-coupling machinery, usually consisting of
|
||||
* registering object instantiators and observers.
|
||||
*
|
||||
*/
|
||||
public void init(DomainInitEvent evt) {
|
||||
s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) invoked");
|
||||
|
||||
super.init(evt); // !
|
||||
|
||||
/*
|
||||
* Imported from LegacyInitializer:
|
||||
* TASK:
|
||||
* Check if CMS package type exists. If not, then:
|
||||
*
|
||||
* <ol>
|
||||
* <li>create CMS package type</li>
|
||||
* <li>create Workspace package type and instance</li>
|
||||
* <li>create CMS Service package type and instance</li>
|
||||
* </ol>
|
||||
*
|
||||
* All these tasks are migrated to Loader (2010-10-15).
|
||||
*/
|
||||
|
||||
|
||||
// Update master object if upgrading from old versioning
|
||||
// XXX: shouldn't we just gut this section (and
|
||||
// VersioningUpgrader)? It is an upgrade fix from 5.1 or
|
||||
// earlier, and relying on VersionedACSObject is
|
||||
// deprecated
|
||||
// pb: But see: ContentItem.java, l. 1650 ff. (setVersion Recursively)
|
||||
// VersionUptrader is used by lifecycle.
|
||||
// pb begin
|
||||
// final boolean updateMaster =
|
||||
// ((Boolean)m_conf.getParameter(UPDATE_MASTER)).booleanValue();
|
||||
// if (updateMaster) {
|
||||
// VersioningUpgrader.updateMasterObject();
|
||||
// }
|
||||
// pb end
|
||||
|
||||
// From comment in original enterprise.init file:
|
||||
// XXX: ItemDispatcher is no longer used. Is the following
|
||||
// still a valid enterprise.init parameter? Do we need to
|
||||
// set ContentSectionServlet.s_cacheItems instead of the
|
||||
// below (which is currently always true), or does this go
|
||||
// away entirely?
|
||||
// NB. true is default for ItemDispatcher!
|
||||
// This would be a typical domain init initialization task.
|
||||
// final boolean cacheItems =
|
||||
// s_conf.
|
||||
// s_log.debug("Set cache items to " + cacheItems);
|
||||
// ItemDispatcher.setCacheItems(cacheItems);
|
||||
|
||||
final String workspaceURL = s_conf.getWorkspaceURL();
|
||||
final String contentCenterMap = s_conf.getContentCenterMap();
|
||||
ContentCenterSetup centerSetup = new ContentCenterSetup( workspaceURL,
|
||||
contentCenterMap);
|
||||
centerSetup.run();
|
||||
|
||||
s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) completed");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,275 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
// Migration Status
|
||||
// All tasks this class used to perform are migrated to cms.Loader
|
||||
// File is kept in trunk for reference purpose until the whole migration process
|
||||
// will be completed. (2010-20-18)
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
package com.arsdigita.cms.installer;
|
||||
|
||||
|
||||
import com.arsdigita.categorization.Category;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.dispatcher.Resource;
|
||||
import com.arsdigita.cms.dispatcher.ResourceMapping;
|
||||
import com.arsdigita.cms.dispatcher.ResourceType;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.kernel.PackageEventListener;
|
||||
import com.arsdigita.kernel.PackageInstance;
|
||||
import com.arsdigita.kernel.PackageType;
|
||||
import com.arsdigita.kernel.SiteNode;
|
||||
import com.arsdigita.kernel.Stylesheet;
|
||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Provides methods to install the Content Management System.</p>
|
||||
*
|
||||
* <p>This class includes methods to:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><p>Create the CMS package type.</p></li>
|
||||
* <li><p>Create the CMS package instance.</p></li>
|
||||
* <li><p>Create a default content section.</p></li>
|
||||
* <li><p>Mount a CMS package instance (and content section).</p></li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @author Jack Chung (flattop@arsdigita.com)
|
||||
* @version $Id: Installer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class Installer implements PackageEventListener {
|
||||
//public class Installer {
|
||||
|
||||
public final static String PACKAGE_KEY = "content-section";
|
||||
|
||||
public final static String DISPATCHER_CLASS =
|
||||
"com.arsdigita.cms.dispatcher.ContentSectionDispatcher";
|
||||
|
||||
// To be updated soon...
|
||||
// "com.arsdigita.cms.dispatcher.ContentSectionDispatcher";
|
||||
|
||||
public final static String LISTENER_CLASS =
|
||||
"com.arsdigita.cms.installer.Installer";
|
||||
|
||||
public final static String STYLESHEET = "/packages/content-section/xsl/cms.xsl";
|
||||
|
||||
/**
|
||||
* <p>Creates the CMS package type.</p>
|
||||
*
|
||||
* <p>This includes creating and registering XSL stylesheets to the CMS .
|
||||
* package type and registering privileges for use by CMS.</p>
|
||||
*
|
||||
* @return The CMS package type
|
||||
*/
|
||||
protected static PackageType createPackageType()
|
||||
throws DataObjectNotFoundException {
|
||||
|
||||
PackageType type = PackageType.create
|
||||
(PACKAGE_KEY, "Content Management System", "Content Management Systems",
|
||||
"http://cms-java.arsdigita.com/");
|
||||
type.setDispatcherClass(DISPATCHER_CLASS);
|
||||
type.addListener(LISTENER_CLASS);
|
||||
|
||||
// Register a stylesheets to the CMS package.
|
||||
Stylesheet ss = Stylesheet.createStylesheet(STYLESHEET);
|
||||
ss.save();
|
||||
type.addStylesheet(ss);
|
||||
type.save();
|
||||
|
||||
createPrivileges();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates the CMS package type.</p>
|
||||
*
|
||||
* <p>This includes creating and registering XSL stylesheets to the CMS .
|
||||
* package type and registering privileges for use by CMS.</p>
|
||||
*
|
||||
* @param name The name of the package instance
|
||||
* @return A new CMS package instance
|
||||
*/
|
||||
protected static PackageInstance createPackageInstance(String name)
|
||||
throws DataObjectNotFoundException {
|
||||
|
||||
PackageType type = PackageType.findByKey(PACKAGE_KEY);
|
||||
PackageInstance instance = type.createInstance(name);
|
||||
instance.save();
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Mounts a CMS package instance.</p>
|
||||
*
|
||||
* <p>This includes creating and registering XSL stylesheets to the CMS .
|
||||
* package type and registering privileges for use by CMS.</p>
|
||||
*
|
||||
* @param instance The package instance
|
||||
* @param location The location of the package instance (and content section)
|
||||
* @return The SiteNode where the content section is mounted at
|
||||
*/
|
||||
protected static SiteNode mountPackageInstance(PackageInstance instance,
|
||||
String location) {
|
||||
SiteNode node =
|
||||
SiteNode.createSiteNode(location, SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
node.save();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates and maps default resources to the content section.
|
||||
*
|
||||
* @param section The content section
|
||||
*
|
||||
* MP: create resource types.
|
||||
* MP: use the resources API.
|
||||
* MP: only create resources once.
|
||||
*/
|
||||
protected static void createDefaultResources(ContentSection section) {
|
||||
// XML resources
|
||||
ResourceType rt = ResourceType.findResourceType("xml");
|
||||
Resource r =
|
||||
rt.createInstance("com.arsdigita.cms.ui.ContentSectionPage");
|
||||
r.save();
|
||||
ResourceMapping rm = r.createInstance(section, "admin");
|
||||
rm.save();
|
||||
rm = r.createInstance(section, "admin/index");
|
||||
rm.save();
|
||||
|
||||
//This won't be served by the new application-oriented CMS dispatcher.
|
||||
//The default folder template creates this instead now.
|
||||
// r = rt.createInstance("com.arsdigita.cms.user.ItemIndexPage");
|
||||
// r.save();
|
||||
// rm = r.createInstance(section, "index");
|
||||
// rm.save();
|
||||
|
||||
r = rt.createInstance("com.arsdigita.cms.ui.ContentItemPage");
|
||||
r.save();
|
||||
rm = r.createInstance(section, "admin/item");
|
||||
rm.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the CMS privileges.
|
||||
*/
|
||||
private static void createPrivileges() {
|
||||
|
||||
final String CMS_PRIVILEGES = "com.arsdigita.cms.getPrivileges";
|
||||
final String PRIVILEGE = "privilege";
|
||||
|
||||
DataQuery dq = SessionManager.getSession().retrieveQuery(CMS_PRIVILEGES);
|
||||
while ( dq.next() ) {
|
||||
String privilege = (String) dq.get(PRIVILEGE);
|
||||
if ( PrivilegeDescriptor.get(privilege) == null ) {
|
||||
PrivilegeDescriptor.createPrivilege(privilege);
|
||||
}
|
||||
}
|
||||
dq.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates the root folder for a content section.
|
||||
*
|
||||
* @param name The name of the content section
|
||||
* @return The root folder
|
||||
*/
|
||||
protected static Folder createRootFolder(String name) {
|
||||
Folder root = new Folder();
|
||||
root.setName("/");
|
||||
root.setLabel( (String) GlobalizationUtil.globalize("cms.installer.root_folder").localize());
|
||||
root.save();
|
||||
return root;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the root category for a content section.
|
||||
*
|
||||
* @param name The name of the content section
|
||||
* @return The root category
|
||||
*/
|
||||
protected static Category createRootCategory(String name) {
|
||||
Category root = new Category("/", "Root Category");
|
||||
root.save();
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
//
|
||||
// PackageEventListener methods
|
||||
//
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is mounted on a
|
||||
* siteNode. It does nothing.
|
||||
*
|
||||
* @param siteNode The SiteNode where the instance is mounted.
|
||||
* @param pkg The instance being mounted.
|
||||
*/
|
||||
public void onMount(SiteNode siteNode, PackageInstance pkg) {}
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is unmounted from a
|
||||
* siteNode. It does nothing.
|
||||
*
|
||||
* @param siteNode The SiteNode where the instance is mounted.
|
||||
* @param pkg The instance being unmounted.
|
||||
*/
|
||||
public void onUnmount(SiteNode siteNode, PackageInstance pkg) {}
|
||||
|
||||
|
||||
/**
|
||||
* This method is called when a new package instance is created.
|
||||
* This method creates a content section and a new instance of
|
||||
* the CMS package.
|
||||
*
|
||||
* @param pkg a <code>PackageInstance</code> value
|
||||
*/
|
||||
public void onCreate(PackageInstance pkg) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is deleted.
|
||||
* It does nothing.
|
||||
*
|
||||
* @param pkg a <code>PackageInstance</code> value
|
||||
*/
|
||||
public void onDelete(PackageInstance pkg) {}
|
||||
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/*
|
||||
* 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.installer;
|
||||
|
||||
// unused import com.arsdigita.auditing.BasicAuditTrail;
|
||||
import com.arsdigita.cms.LoaderConfig;
|
||||
import com.arsdigita.cms.dispatcher.ContentCenterDispatcher;
|
||||
import com.arsdigita.cms.dispatcher.ItemDispatcher;
|
||||
// unused import com.arsdigita.domain.DomainObject;
|
||||
// unused import com.arsdigita.domain.DomainObjectFactory;
|
||||
// unused import com.arsdigita.domain.DomainObjectInstantiator;
|
||||
import com.arsdigita.initializer.Configuration;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
// unused import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>The main initializer for the Content Management System.</p>
|
||||
*
|
||||
* <p>Initializes the Content Management System, including the Content Center
|
||||
* and CMS Service applications and CMS Mime Types service. This class also
|
||||
* optionally initializes user-defined content types and user-defined content
|
||||
* sections.</p>
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @version $Revision: #47 $ $Date: 2004/08/17 $
|
||||
* @since ACS 5.0
|
||||
*/
|
||||
public class LegacyInitializer extends com.arsdigita.kernel.BaseInitializer {
|
||||
|
||||
private static Logger s_log = Logger.getLogger(Initializer.class);
|
||||
|
||||
private final static String CACHE_ITEMS
|
||||
= "cacheItems";
|
||||
private static final String UPDATE_MASTER
|
||||
= "updateMasterObject";
|
||||
private final static String CONTENT_CENTER_MAP
|
||||
= "contentCenterMap";
|
||||
private final static String WORKSPACE
|
||||
= "workspace";
|
||||
// Init script parameters
|
||||
private Configuration m_conf = new Configuration();
|
||||
|
||||
// Temporär: Einbinden des neuen Parameter Systems
|
||||
private static final LoaderConfig s_conf = new LoaderConfig();
|
||||
// LoaderConfig conf = LoaderConfig.getConfig();
|
||||
|
||||
// As an example
|
||||
// private static final ContentSectionConfig s_config = new ContentSectionConfig();
|
||||
|
||||
// static {
|
||||
// s_config.load();
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public LegacyInitializer() throws InitializationException {
|
||||
m_conf.initParameter
|
||||
(WORKSPACE, "The name of the workspace package instance",
|
||||
String.class);
|
||||
m_conf.initParameter
|
||||
(CACHE_ITEMS,
|
||||
"Enable caching of content items",
|
||||
Boolean.class,
|
||||
Boolean.TRUE);
|
||||
m_conf.initParameter
|
||||
(UPDATE_MASTER,
|
||||
"If true, attempts to recursively set the correct master object for " +
|
||||
"all content items within the system.",
|
||||
Boolean.class,
|
||||
Boolean.FALSE);
|
||||
m_conf.initParameter
|
||||
(CONTENT_CENTER_MAP,
|
||||
"XML Mapping of the content center tabs to " +
|
||||
"URLs, see ContentCenterDispatcher",
|
||||
String.class,
|
||||
ContentCenterDispatcher.DEFAULT_MAP_FILE);
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return m_conf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if CMS package type exists. If not, then:
|
||||
*
|
||||
* <ol>
|
||||
* <li>create CMS package type</li>
|
||||
* <li>create Workspace package type and instance</li>
|
||||
* <li>create CMS Service package type and instance</li>
|
||||
* </ol>
|
||||
*/
|
||||
protected void doStartup() {
|
||||
|
||||
TransactionContext txn =
|
||||
SessionManager.getSession().getTransactionContext();
|
||||
txn.beginTxn();
|
||||
|
||||
try {
|
||||
|
||||
//final String workspaceURL = (String) m_conf
|
||||
// .getParameter(WORKSPACE);
|
||||
//final String contentCenterMap = (String)m_conf
|
||||
// .getParameter(CONTENT_CENTER_MAP);
|
||||
|
||||
// Update master object if upgrading from old versioning
|
||||
// XXX: shouldn't we just gut this section (and
|
||||
// VersioningUpgrader)? It is an upgrade fix from 5.1 or
|
||||
// earlier, and relying on VersionedACSObject is
|
||||
// deprecated
|
||||
// pb: But see: ContentItem.java, l. 1650 ff. (setVersion Recursively)
|
||||
// VersionUptrader is used by lifecycle.
|
||||
// pb begin
|
||||
// final boolean updateMaster =
|
||||
// ((Boolean)m_conf.getParameter(UPDATE_MASTER)).booleanValue();
|
||||
// if (updateMaster) {
|
||||
// VersioningUpgrader.updateMasterObject();
|
||||
// }
|
||||
// pb end
|
||||
|
||||
// XXX: ItemDispatcher is no longer used. Is the following
|
||||
// still a valid enterprise.init parameter? Do we need to
|
||||
// set ContentSectionServlet.s_cacheItems instead of the
|
||||
// below (which is currently always true), or does this go
|
||||
// away entirely?
|
||||
final boolean cacheItems =
|
||||
((Boolean)m_conf.getParameter(CACHE_ITEMS)).booleanValue();
|
||||
s_log.debug("Set cache items to " + cacheItems);
|
||||
ItemDispatcher.setCacheItems(cacheItems);
|
||||
|
||||
final String workspaceURL = s_conf.getWorkspaceURL();
|
||||
final String contentCenterMap = s_conf.getContentCenterMap();
|
||||
ContentCenterSetup centerSetup = new ContentCenterSetup(
|
||||
workspaceURL,
|
||||
contentCenterMap);
|
||||
|
||||
centerSetup.run();
|
||||
|
||||
} finally {
|
||||
txn.commitTxn();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void doShutdown() {}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,295 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2002-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.installer;
|
||||
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.LoaderConfig;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.initializer.Configuration;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.SiteNode;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.util.Assert;
|
||||
import com.arsdigita.web.Application;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
// import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
// import java.util.List;
|
||||
import java.util.Timer;
|
||||
|
||||
// import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <p>Initializes a content section, registering a default
|
||||
* workflow, lifecycle & roles and adding the content types
|
||||
*
|
||||
* <p>The initialization process takes several configuration
|
||||
* parameters. The <code>name</code> is the name of the content
|
||||
* section, the <code>types</code> is a list of content types
|
||||
* to register
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author Daniel Berrange (berrange@redhat.com)
|
||||
* @author Michael Pih
|
||||
* @version $Id: SectionLegacyInitializer.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class SectionLegacyInitializer extends com.arsdigita.kernel.BaseInitializer {
|
||||
|
||||
private static org.apache.log4j.Logger s_log =
|
||||
org.apache.log4j.Logger.getLogger(SectionLegacyInitializer.class);
|
||||
|
||||
// private static final String NAME = "name";
|
||||
// private static final String TYPES = "types";
|
||||
// private static final String ROLES = "roles";
|
||||
// private static final String PUBLIC = "public";
|
||||
// private static final String CATEGORIES = "categories";
|
||||
// private static final String TASK_ALERTS = "taskAlerts";
|
||||
// private static final String SEND_OVERDUE_ALERTS = "sendOverdueAlerts";
|
||||
// private static final String TASK_DURATION = "taskDuration";
|
||||
// private static final String OVERDUE_ALERT_INTERVAL = "alertInterval";
|
||||
// private static final String MAX_ALERTS = "maxAlerts";
|
||||
// private static final String ITEM_RESOLVER_CLASS = "itemResolverClass";
|
||||
// private static final String TEMPLATE_RESOLVER_CLASS = "templateResolverClass";
|
||||
|
||||
// private Configuration m_conf = new Configuration();
|
||||
|
||||
// Temporär: Einbinden des neuen Parameter Systems
|
||||
private static final LoaderConfig s_conf = new LoaderConfig();
|
||||
|
||||
// Required to actually load the parameter file.
|
||||
// Aktuell: wenn man das aktiviert, gibt's einen Fehler: Kontext existiert
|
||||
// nicht, offensichtlich keine aktuelle Datei zugeordnet.
|
||||
// static {
|
||||
// s_conf.load();
|
||||
// }
|
||||
|
||||
// the Timer used to send Unfinished notifications
|
||||
private static Timer s_unfinishedTimer;
|
||||
|
||||
public SectionLegacyInitializer() throws InitializationException {
|
||||
s_log.debug("CMS.installer.SectionLegacyInitializer.(Constructor) invoked");
|
||||
// m_conf.initParameter(NAME,
|
||||
// "The name of the content section",
|
||||
// String.class);
|
||||
// m_conf.initParameter(TYPES,
|
||||
// "The content types to register",
|
||||
// List.class);
|
||||
// m_conf.initParameter(ROLES,
|
||||
// "The roles to create",
|
||||
// List.class);
|
||||
// m_conf.initParameter(PUBLIC,
|
||||
// "Whether to make published content available to non-registered users",
|
||||
// Boolean.class);
|
||||
// m_conf.initParameter(CATEGORIES,
|
||||
// "XML file containing the category tree",
|
||||
// List.class,
|
||||
// Collections.EMPTY_LIST);
|
||||
// m_conf.initParameter(TASK_ALERTS,
|
||||
// "A list of workflow tasks, and the events for which alerts are sent",
|
||||
// List.class);
|
||||
// m_conf.initParameter(SEND_OVERDUE_ALERTS,
|
||||
// "Send alerts when a task is overdue (has remained in the \"enabled\" state for a long time)",
|
||||
// Boolean.class,
|
||||
// Boolean.FALSE);
|
||||
// XXX Once the Duration of a Task can actually be maintained (in the UI, or initialization parameters),
|
||||
// we should use the value in the DB, and get rid of this
|
||||
// m_conf.initParameter(TASK_DURATION,
|
||||
// "How long a task can remain \"enabled\" before it is considered overdue (in hours)",
|
||||
// Integer.class);
|
||||
// m_conf.initParameter(OVERDUE_ALERT_INTERVAL,
|
||||
// "Time to wait between sending overdue notifications on the same task (in hours)",
|
||||
// Integer.class);
|
||||
// m_conf.initParameter(MAX_ALERTS,
|
||||
// "The maximum number of alerts to send that a single task is overdue",
|
||||
// Integer.class);
|
||||
// m_conf.initParameter(ITEM_RESOLVER_CLASS,
|
||||
// "The ItemResolver class to use for the section (defaults to MultilingualItemResolver)",
|
||||
// String.class);
|
||||
// m_conf.initParameter(TEMPLATE_RESOLVER_CLASS,
|
||||
// "The TemplateResolver class to use for the section (defaults to DefaultTemplateResolver)",
|
||||
// String.class);
|
||||
s_log.debug("CMS.installer.SectionLegacyInitializer.(Constructor) completed");
|
||||
}
|
||||
|
||||
// required by parent class.
|
||||
public Configuration getConfiguration() {
|
||||
// return m_conf;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected void doStartup() {
|
||||
s_log.debug("CMS.installer.SectionLegacyInitializer.doStartup() invoked");
|
||||
|
||||
// Create and mount the demo content section if it does not exist.
|
||||
// String name = (String) m_conf.getParameter(NAME);
|
||||
String name = s_conf.getContentSectionName();
|
||||
|
||||
TransactionContext txn =
|
||||
SessionManager.getSession().getTransactionContext();
|
||||
txn.beginTxn();
|
||||
|
||||
// Setup application type content-section first so that concrete
|
||||
// content-section can be created.
|
||||
ContentSectionSetup.setupContentSectionAppType();
|
||||
|
||||
Util.validateURLParameter("name", name);
|
||||
String sitemapEntry = "/" + name + "/";
|
||||
if (Application.isInstalled(ContentSection.BASE_DATA_OBJECT_TYPE,
|
||||
sitemapEntry)) {
|
||||
s_log.info("skipping " + name +
|
||||
" because it is already installed");
|
||||
} else {
|
||||
s_log.info("Installing " + name + " at " +
|
||||
sitemapEntry);
|
||||
createSection(name); // Create a content section, initial
|
||||
// creation is a loader task, additional
|
||||
// sections may be created during (re)start
|
||||
}
|
||||
|
||||
ContentSection section = retrieveContentSection(name);
|
||||
Assert.exists(section, ContentSection.class);
|
||||
ContentSectionSetup setup = new ContentSectionSetup(section);
|
||||
|
||||
// setup.loadAlertPrefs((List) m_conf.getParameter(TASK_ALERTS));
|
||||
/*
|
||||
* loadAlertPrefs loads a list of workflow tasks and associated events
|
||||
* from configuration file and fills a hashmap. No database operation.
|
||||
* Not a loader task! Moved to contentsection/Initializer
|
||||
*/
|
||||
// Moved from LoaderConfig to contentsection/ContentSectionConfig
|
||||
// setup.loadAlertPrefs( s_conf.getTaskAlerts());
|
||||
|
||||
// s_unfinishedTimer = setup.startNotifierTask
|
||||
// ((Boolean) m_conf.getParameter(SEND_OVERDUE_ALERTS),
|
||||
// (Integer) m_conf.getParameter(TASK_DURATION),
|
||||
// (Integer) m_conf.getParameter(OVERDUE_ALERT_INTERVAL),
|
||||
// (Integer) m_conf.getParameter(MAX_ALERTS));
|
||||
|
||||
// Commented out in LoadereConfig because not a Loader task. So commented
|
||||
// out here. If SectionLegacyInitializer should ever be used again, a
|
||||
// defferent config file (section initializer config) should be used here
|
||||
// s_unfinishedTimer = setup.startNotifierTask
|
||||
// (s_conf.getSendOverdueAlerts(),
|
||||
// s_conf.getTaskDuration(),
|
||||
// s_conf.getOverdueAlertInterval(),
|
||||
// s_conf.getMaxAlerts());
|
||||
|
||||
txn.commitTxn();
|
||||
s_log.debug("CMS.installer.SectionLegacyInitializer.doStartup() completed");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
|
||||
// seems not to be requirred when using new web application functionality
|
||||
// instead of old fashioned PackageType / SiteNode
|
||||
// Not migrated to Loader nor to Initializer.
|
||||
|
||||
private ContentSection retrieveContentSection(String name) {
|
||||
BigDecimal rootNodeID = SiteNode.getRootSiteNode().getID();
|
||||
SiteNode node = null;
|
||||
try {
|
||||
node = SiteNode.getSiteNode("/" + name);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new InitializationException(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.installer.root_site_node_missing").localize(), ex);
|
||||
}
|
||||
ContentSection section = null;
|
||||
if ( rootNodeID.equals(node.getID()) ) {
|
||||
// This instance does not exist yet.
|
||||
section = createSection(name);
|
||||
} else {
|
||||
try {
|
||||
section = ContentSection.getSectionFromNode(node);
|
||||
} catch (DataObjectNotFoundException de) {
|
||||
throw new InitializationException(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.installer.could_not_load_section",
|
||||
new Object[] {name}).localize(), de);
|
||||
}
|
||||
}
|
||||
return section;
|
||||
}
|
||||
|
||||
protected void doShutdown() {
|
||||
if (s_unfinishedTimer != null) {
|
||||
s_unfinishedTimer.cancel();
|
||||
s_unfinishedTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the CMS Demo.
|
||||
*/
|
||||
|
||||
// Moved into Loader
|
||||
|
||||
private ContentSection createSection(String name) {
|
||||
|
||||
s_log.info("Creating content section on /" + name);
|
||||
|
||||
|
||||
ContentSection section = ContentSection.create(name);
|
||||
|
||||
ContentSectionSetup setup = new ContentSectionSetup(section);
|
||||
|
||||
// Setup the access controls
|
||||
|
||||
// section specific categories, usually not used.
|
||||
// During initial load at install time nor used at all!
|
||||
if (ContentSection.getConfig().getUseSectionCategories()) {
|
||||
// Iterator files = ((List) m_conf.getParameter(CATEGORIES)).iterator();
|
||||
Iterator files = s_conf.getCategoryFileList().iterator();
|
||||
while ( files.hasNext() ) {
|
||||
setup.registerCategories((String) files.next());
|
||||
}
|
||||
}
|
||||
|
||||
// setup.registerRoles((List)m_conf.getParameter(ROLES));
|
||||
setup.registerRoles(s_conf.getStuffGroup());
|
||||
// setup.registerViewers((Boolean)m_conf.getParameter(PUBLIC));
|
||||
setup.registerViewers(s_conf.isPubliclyViewable());
|
||||
setup.registerAlerts();
|
||||
setup.registerPublicationCycles();
|
||||
setup.registerWorkflowTemplates();
|
||||
// setup.registerContentTypes((List)m_conf.getParameter(TYPES));
|
||||
setup.registerContentTypes(s_conf.getContentSectionsContentTypes());
|
||||
// setup.registerResolvers
|
||||
// ((String) m_conf.getParameter(ITEM_RESOLVER_CLASS),
|
||||
// (String) m_conf.getParameter(TEMPLATE_RESOLVER_CLASS));
|
||||
setup.registerResolvers
|
||||
(s_conf.getItemResolverClass(),
|
||||
s_conf.getTemplateResolverClass());
|
||||
section.save();
|
||||
|
||||
return section;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
// Migration Status
|
||||
// All tasks this class used to perform are migrated to either cms.Loader or
|
||||
// cms.CMS.
|
||||
// File is kept in trunk for reference purpose until the whole migration process
|
||||
// will be completed. (2010-20-18)
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
package com.arsdigita.cms.installer;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.kernel.PackageEventListener;
|
||||
import com.arsdigita.kernel.PackageInstance;
|
||||
import com.arsdigita.kernel.PackageType;
|
||||
import com.arsdigita.kernel.SiteNode;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <p>Provides methods to install the CMS Service application, which
|
||||
* is used by the Content Management System as a store for global
|
||||
* resources and assets.</p>
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @version $Revision: #7 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
* @version $Id: ServiceInstaller.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class ServiceInstaller implements PackageEventListener {
|
||||
|
||||
public final static String PACKAGE_KEY = "cms-service";
|
||||
|
||||
|
||||
/**
|
||||
* Create the CMS services package type.
|
||||
* @return The package type
|
||||
*/
|
||||
protected static PackageType createPackageType()
|
||||
throws DataObjectNotFoundException {
|
||||
|
||||
PackageType type = PackageType.create
|
||||
(PACKAGE_KEY, "Content Management System Services",
|
||||
"Content Management System Services",
|
||||
"http://cms-service.arsdigita.com/");
|
||||
type.setDispatcherClass("com.arsdigita.cms.dispatcher.ServiceDispatcher");
|
||||
type.save();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance of the CMS service package type.
|
||||
* @return The package instance
|
||||
*/
|
||||
protected static PackageInstance createPackageInstance()
|
||||
throws DataObjectNotFoundException {
|
||||
|
||||
PackageType type = PackageType.findByKey(PACKAGE_KEY);
|
||||
PackageInstance instance = type.createInstance(PACKAGE_KEY);
|
||||
instance.save();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mount the CMS services package instance.
|
||||
*
|
||||
* @param instance The package instance
|
||||
* @param location The URL where the package instance will be mounted
|
||||
* @return The SiteNode where the instance was mounted
|
||||
*/
|
||||
protected static SiteNode mountPackageInstance(PackageInstance instance,
|
||||
String location) {
|
||||
SiteNode node =
|
||||
SiteNode.createSiteNode(location, SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
node.save();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////
|
||||
//
|
||||
// PackageEventListener methods
|
||||
//
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is mounted on a
|
||||
* siteNode. It does nothing.
|
||||
*
|
||||
* @param siteNode The SiteNode where the instance is mounted.
|
||||
* @param pkg The instance being mounted.
|
||||
*/
|
||||
public void onMount(SiteNode siteNode, PackageInstance pkg) {}
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is unmounted from a
|
||||
* siteNode. It does nothing.
|
||||
*
|
||||
* @param siteNode The SiteNode where the instance is mounted.
|
||||
* @param pkg The instance being unmounted.
|
||||
*/
|
||||
public void onUnmount(SiteNode siteNode, PackageInstance pkg) {}
|
||||
|
||||
/**
|
||||
* This method is called when a new package instance is created.
|
||||
* It does nothing
|
||||
* @param pkg a <code>PackageInstance</code> value
|
||||
*/
|
||||
public void onCreate(PackageInstance pkg) {}
|
||||
|
||||
/**
|
||||
* Describe <code>onDelete</code> method here.
|
||||
*
|
||||
* @param pkg a <code>PackageInstance</code> value
|
||||
*/
|
||||
public void onDelete(PackageInstance pkg) {}
|
||||
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* 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.installer;
|
||||
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.DataQueryDataCollectionAdapter;
|
||||
import com.arsdigita.cms.ItemCollection;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
|
||||
// From Initializer.java:
|
||||
// Update master object if upgrading from old versioning
|
||||
// XXX: shouldn't we just gut this section (and
|
||||
// VersioningUpgrader)? It is an upgrade fix from 5.1 or
|
||||
// earlier, and relying on VersionedACSObject is
|
||||
// deprecated
|
||||
// (probably written by Michael Pih (pihman@arsdigita.com) )
|
||||
|
||||
/**
|
||||
* VersioningUpgrader
|
||||
*
|
||||
* @author <a href="mailto:jorris@redhat.com">Jon Orris</a>
|
||||
* @version $Revision: #5 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
*/
|
||||
final class VersioningUpgrader {
|
||||
|
||||
private static final String QUERY_TOP_ITEMS =
|
||||
"com.arsdigita.cms.topLevelItems";
|
||||
private static final String QUERY_ITEM = "item";
|
||||
|
||||
/**
|
||||
* Update the master object for all the content items, by assuming
|
||||
* that all items whose parent is a folder are master objects.
|
||||
*/
|
||||
static void updateMasterObject() {
|
||||
DataQuery dq = SessionManager.getSession().retrieveQuery(QUERY_TOP_ITEMS);
|
||||
ItemCollection c = new ItemCollection
|
||||
(new DataQueryDataCollectionAdapter(dq, QUERY_ITEM));
|
||||
|
||||
try {
|
||||
while (c.next()) {
|
||||
ContentItem item = c.getContentItem();
|
||||
item.autoPropagateMaster(item);
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,182 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
// Migration Status
|
||||
// All tasks this class used to perform are migrated to either cms.Loader or
|
||||
// cms.CMS.
|
||||
// File is kept in trunk for reference purpose until the whole migration process
|
||||
// will be completed. (2010-20-18)
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
package com.arsdigita.cms.installer;
|
||||
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.kernel.PackageEventListener;
|
||||
import com.arsdigita.kernel.PackageInstance;
|
||||
import com.arsdigita.kernel.PackageType;
|
||||
import com.arsdigita.kernel.SiteNode;
|
||||
import com.arsdigita.kernel.Stylesheet;
|
||||
|
||||
|
||||
/**
|
||||
* <p>Provides methods to install the Content Center application, which
|
||||
* is used by the Content Management System.</p>
|
||||
*
|
||||
* @author Michael Pih (pihman@arsdigita.com)
|
||||
* @author Jack Chung (flattop@arsdigita.com)
|
||||
* @version $Revision: #10 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
* @version $Id: WorkspaceInstaller.java 287 2005-02-22 00:29:02Z sskracic $
|
||||
*/
|
||||
public class WorkspaceInstaller implements PackageEventListener {
|
||||
|
||||
public static final String PACKAGE_KEY = "content-center";
|
||||
private static final String INSTANCE_NAME = "Content Center";
|
||||
private static final String DISPATCHER_CLASS =
|
||||
"com.arsdigita.cms.dispatcher.ContentCenterDispatcher";
|
||||
|
||||
// To be updated soon...
|
||||
// "com.arsdigita.dispatcher.DefaultPackageDispatcher";
|
||||
|
||||
/**
|
||||
* Returns this workspace's instance name
|
||||
**/
|
||||
public String getPackageKey() {
|
||||
return PACKAGE_KEY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns this workspace's instance name
|
||||
**/
|
||||
public String getInstanceName() {
|
||||
return INSTANCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the dispatcher class to use
|
||||
**/
|
||||
protected String getDispatcherClass() {
|
||||
return DISPATCHER_CLASS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the CMS package type.
|
||||
*
|
||||
* @return The Content Center package type
|
||||
*/
|
||||
// protected PackageType createPackageType()
|
||||
public PackageType createPackageType()
|
||||
throws DataObjectNotFoundException {
|
||||
|
||||
PackageType type = PackageType.create
|
||||
(getPackageKey(), "Content Center",
|
||||
"Content Centers",
|
||||
"http://cms-workspace.arsdigita.com/");
|
||||
type.setDispatcherClass(getDispatcherClass());
|
||||
|
||||
// Register a stylesheet to the Content Center package.
|
||||
Stylesheet ss =
|
||||
Stylesheet.createStylesheet(
|
||||
"/packages/content-section/xsl/content-center.xsl");
|
||||
ss.save();
|
||||
type.addStylesheet(ss);
|
||||
|
||||
type.save();
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Content Center application instance.
|
||||
*
|
||||
* @return The Content Center package instance
|
||||
*/
|
||||
// protected PackageInstance createPackageInstance()
|
||||
public PackageInstance createPackageInstance()
|
||||
throws DataObjectNotFoundException {
|
||||
|
||||
PackageType type =
|
||||
PackageType.findByKey(getPackageKey());
|
||||
PackageInstance instance =
|
||||
type.createInstance(getInstanceName());
|
||||
instance.save();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mount the Content Center application instance.
|
||||
*
|
||||
* @param instance The package instance
|
||||
* @param location The location of the Content Center
|
||||
* @return The SiteNode where the Content Center is mounted at
|
||||
*/
|
||||
// protected SiteNode mountPackageInstance(PackageInstance instance,
|
||||
public SiteNode mountPackageInstance(PackageInstance instance,
|
||||
String location) {
|
||||
SiteNode node =
|
||||
SiteNode.createSiteNode(location, SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
node.save();
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
//
|
||||
// PackageEventListener methods
|
||||
//
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is mounted on a
|
||||
* siteNode. It does nothing.
|
||||
*
|
||||
* @param siteNode The SiteNode where the instance is mounted.
|
||||
* @param pkg The instance being mounted.
|
||||
*/
|
||||
public void onMount(SiteNode siteNode, PackageInstance pkg) {}
|
||||
|
||||
/**
|
||||
* This method is called when a package instance is unmounted from a
|
||||
* siteNode. It does nothing.
|
||||
*
|
||||
* @param siteNode The SiteNode where the instance is mounted.
|
||||
* @param pkg The instance being unmounted.
|
||||
*/
|
||||
public void onUnmount(SiteNode siteNode, PackageInstance pkg) {}
|
||||
|
||||
|
||||
/**
|
||||
* This method is called when a new package instance is created.
|
||||
* It does nothing
|
||||
* @param pkg a <code>PackageInstance</code> value
|
||||
*/
|
||||
public void onCreate(PackageInstance pkg) {}
|
||||
|
||||
/**
|
||||
* Describe <code>onDelete</code> method here.
|
||||
*
|
||||
* @param pkg a <code>PackageInstance</code> value
|
||||
*/
|
||||
public void onDelete(PackageInstance pkg) {}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
// CMS initialization file
|
||||
//
|
||||
// $Id: enterprise.init 2070 2010-01-28 08:47:41Z pboy $
|
||||
//
|
||||
|
||||
// Migration status: Config parameters in cms/LoaderConfig (these options are to
|
||||
// be used only once during installation).
|
||||
// Config options in Initializer replaced by the new Config.
|
||||
init com.arsdigita.cms.installer.LegacyInitializer {
|
||||
updateMasterObject = false;
|
||||
workspace = "content-center";
|
||||
contentCenterMap = "/WEB-INF/resources/content-center-map.xml";
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>Installation and Initialization</title>
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<p>Provides a set of classes to install and initialize the Content
|
||||
Management System.</p>
|
||||
|
||||
<p>There are two common types of files:</p>
|
||||
|
||||
<ol>
|
||||
|
||||
<li><p><b>Installers</b> - These classes contain the code to
|
||||
install the Content Management System and mount content
|
||||
sections.</p></li>
|
||||
|
||||
<li><p><b>Initializers</b> - These classes are run at server
|
||||
startup and are used to install the Content Management System if
|
||||
it has not already been installed. For the most part,
|
||||
initializers call the installers' methods.</p></li>
|
||||
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* 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.installer.portlet;
|
||||
|
||||
import com.arsdigita.bebop.RequestLocal;
|
||||
import com.arsdigita.cms.portlet.ContentDirectoryPortlet;
|
||||
import com.arsdigita.cms.portlet.ContentItemPortlet;
|
||||
import com.arsdigita.cms.portlet.ContentSectionsPortlet;
|
||||
import com.arsdigita.cms.portlet.TaskPortlet;
|
||||
import com.arsdigita.cms.ui.portlet.ContentItemPortletEditor;
|
||||
import com.arsdigita.cms.ui.portlet.TaskPortletEditor;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.initializer.Configuration;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.ACSObjectInstantiator;
|
||||
import com.arsdigita.kernel.BaseInitializer;
|
||||
import com.arsdigita.kernel.ResourceType;
|
||||
import com.arsdigita.kernel.ResourceTypeConfig;
|
||||
import com.arsdigita.kernel.ui.ResourceConfigFormSection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.portal.PortletSetup;
|
||||
import com.arsdigita.portal.PortletType;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Migrated to new initializer system.
|
||||
// code moved to c.ad.cms.loader and c.ad.cms.portlet.initializer
|
||||
//
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public class Initializer
|
||||
extends BaseInitializer {
|
||||
|
||||
public static final String TYPES = "types";
|
||||
|
||||
private static Logger s_log = Logger.getLogger
|
||||
(Initializer.class.getName());
|
||||
|
||||
|
||||
private Configuration m_conf = new Configuration();
|
||||
|
||||
/**
|
||||
* Empty Constructor!
|
||||
* @throws InitializationException
|
||||
*/
|
||||
public Initializer() throws InitializationException {
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return m_conf;
|
||||
}
|
||||
|
||||
protected void doStartup() {
|
||||
TransactionContext txn = SessionManager.getSession()
|
||||
.getTransactionContext();
|
||||
|
||||
txn.beginTxn();
|
||||
|
||||
//loadContentDirectoryPortlet();
|
||||
loadContentItemPortlet();
|
||||
//loadContentSectionsPortlet();
|
||||
loadTaskPortlet();
|
||||
|
||||
txn.commitTxn();
|
||||
}
|
||||
|
||||
|
||||
protected void doShutdown() {
|
||||
/* Empty */
|
||||
}
|
||||
|
||||
|
||||
private void loadContentDirectoryPortlet() {
|
||||
PortletSetup setup = new PortletSetup(s_log);
|
||||
setup.setPortletObjectType(ContentDirectoryPortlet.BASE_DATA_OBJECT_TYPE);
|
||||
setup.setTitle("Content Directory");
|
||||
setup.setDescription("Displays the content directory categories");
|
||||
setup.setProfile(PortletType.WIDE_PROFILE);
|
||||
setup.setInstantiator(new ACSObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new ContentDirectoryPortlet(dataObject);
|
||||
}
|
||||
});
|
||||
setup.run();
|
||||
}
|
||||
|
||||
private void loadContentItemPortlet() {
|
||||
PortletSetup setup = new PortletSetup(s_log);
|
||||
setup.setPortletObjectType(ContentItemPortlet.BASE_DATA_OBJECT_TYPE);
|
||||
setup.setTitle("Content Item");
|
||||
setup.setDescription("Displays the body of a content item");
|
||||
setup.setProfile(PortletType.WIDE_PROFILE);
|
||||
setup.setInstantiator(new ACSObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new ContentItemPortlet(dataObject);
|
||||
}
|
||||
});
|
||||
setup.run();
|
||||
|
||||
new ResourceTypeConfig(ContentItemPortlet.BASE_DATA_OBJECT_TYPE) {
|
||||
public ResourceConfigFormSection getCreateFormSection
|
||||
(final ResourceType resType, final RequestLocal parentAppRL) {
|
||||
final ResourceConfigFormSection config =
|
||||
new ContentItemPortletEditor(resType, parentAppRL);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public ResourceConfigFormSection getModifyFormSection
|
||||
(final RequestLocal application) {
|
||||
final ContentItemPortletEditor config =
|
||||
new ContentItemPortletEditor(application);
|
||||
|
||||
return config;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void loadContentSectionsPortlet() {
|
||||
PortletSetup setup = new PortletSetup(s_log);
|
||||
setup.setPortletObjectType(ContentSectionsPortlet.BASE_DATA_OBJECT_TYPE);
|
||||
setup.setTitle("Content Sections");
|
||||
setup.setDescription("Displays a list of content sections");
|
||||
setup.setProfile(PortletType.WIDE_PROFILE);
|
||||
setup.setInstantiator(new ACSObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new ContentSectionsPortlet(dataObject);
|
||||
}
|
||||
});
|
||||
setup.run();
|
||||
}
|
||||
|
||||
private void loadTaskPortlet() {
|
||||
PortletSetup setup = new PortletSetup(s_log);
|
||||
setup.setPortletObjectType(TaskPortlet.BASE_DATA_OBJECT_TYPE);
|
||||
setup.setTitle("Task Portlet");
|
||||
setup.setDescription("Displays a Task List");
|
||||
setup.setProfile(PortletType.WIDE_PROFILE);
|
||||
setup.setInstantiator(new ACSObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new TaskPortlet(dataObject);
|
||||
}
|
||||
});
|
||||
setup.run();
|
||||
|
||||
new ResourceTypeConfig(TaskPortlet.BASE_DATA_OBJECT_TYPE) {
|
||||
public ResourceConfigFormSection getCreateFormSection
|
||||
(final ResourceType resType, final RequestLocal parentAppRL) {
|
||||
final ResourceConfigFormSection config =
|
||||
new TaskPortletEditor(resType, parentAppRL);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
public ResourceConfigFormSection getModifyFormSection
|
||||
(final RequestLocal application) {
|
||||
final TaskPortletEditor config =
|
||||
new TaskPortletEditor(application);
|
||||
|
||||
return config;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,235 +0,0 @@
|
|||
/*
|
||||
* 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.installer.xml;
|
||||
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
import com.arsdigita.initializer.Configuration;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.BaseInitializer;
|
||||
import com.arsdigita.kernel.SiteNode;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.util.ResourceManager;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.oro.text.perl.Perl5Util;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NOT USED anywhere in the code base.
|
||||
// Kept here temporarily for easy reference until until refactoring of
|
||||
// unit tests is completed.
|
||||
//
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* An initializer to load content items for load testing Will take an
|
||||
* XML file with one content item definition, and create items whose
|
||||
* title is "title + number".
|
||||
*
|
||||
* There's an example configuration file in
|
||||
* /WEB-INF/content-items/ContentItemLoader.xml It looks like this:
|
||||
*
|
||||
* <ccm:content-items>
|
||||
* <ccm:folder
|
||||
* clone="3"
|
||||
* depth="2"
|
||||
* label="Folder" >
|
||||
*
|
||||
* <ccm:content-item clone="4">
|
||||
* <ccm:content-type
|
||||
* classname="com.arsdigita.cms.dublin.types.DublinArticle"
|
||||
* objectType="com.arsdigita.cms.dublin.types.DublinArticle"/>
|
||||
*
|
||||
* <ccm:item-properties title="item" >
|
||||
* <body-text>
|
||||
* body text
|
||||
* </body-text>
|
||||
* </ccm:item-properties>
|
||||
* </ccm:content-item>
|
||||
* <ccm:content-item clone="1">
|
||||
* <ccm:content-type
|
||||
* classname="com.arsdigita.cms.contenttypes.Address"
|
||||
* objectType="com.arsdigita.cms.contenttypes.Address"
|
||||
* helperClass="com.arsdigita.util.cms.ContentPageHelper"/>
|
||||
*
|
||||
* <ccm:item-properties title="address" >
|
||||
* <ccm:item-property method="setAddress"
|
||||
* argClass="java.lang.String" argValue="338 EustonRoad"/>
|
||||
*
|
||||
* <body-text>
|
||||
* there's no body text
|
||||
* </body-text>
|
||||
* </ccm:item-properties>
|
||||
* </ccm:content-item>
|
||||
*
|
||||
*
|
||||
* </ccm:folder>
|
||||
* </ccm:content-items>
|
||||
*
|
||||
* This will create a folder tree with 2 levels of folders, each folder
|
||||
* will have 3 subfolders and 4 content items.
|
||||
*
|
||||
* The XMLContentItemHandler will create any content type. However, it
|
||||
* will only process the values for the basic attributes (name, title,
|
||||
* body text if it exists).
|
||||
*
|
||||
* @author Nobuko Asakai (nasakai@redhat.com)
|
||||
* @see XMLContentItemHandler
|
||||
* @see ContentItemHelper
|
||||
*/
|
||||
public class ContentItemLoader extends BaseInitializer {
|
||||
|
||||
private Configuration m_conf = new Configuration();
|
||||
|
||||
private static Logger s_log =
|
||||
Logger.getLogger(ContentItemLoader.class);
|
||||
|
||||
|
||||
private static final String CONTENT_DEFINITION = "contentItemDef";
|
||||
private static final String SECTION = "section";
|
||||
|
||||
public ContentItemLoader() {
|
||||
// To be changed to List {{xmlfile} {numbertobeduplicated}}
|
||||
m_conf.initParameter(
|
||||
CONTENT_DEFINITION,
|
||||
"Path to XML definition file for the contents of the content item",
|
||||
String.class
|
||||
);
|
||||
|
||||
m_conf.initParameter(
|
||||
SECTION,
|
||||
"Content section where the content items should be created",
|
||||
String.class
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Accessors
|
||||
|
||||
public String getContentSectionParam() {
|
||||
return (String)m_conf.getParameter(SECTION);
|
||||
}
|
||||
|
||||
public String getContentDefinition() {
|
||||
return (String)m_conf.getParameter(CONTENT_DEFINITION);
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
return m_conf;
|
||||
}
|
||||
|
||||
private String getXMLFilePath(String xmlFile) {
|
||||
return ResourceManager.getInstance().getServletContext().
|
||||
getRealPath(xmlFile);
|
||||
}
|
||||
|
||||
|
||||
public void doStartup() {
|
||||
s_log.warn("Starting ContentItemLoader");
|
||||
TransactionContext txn = SessionManager.getSession()
|
||||
.getTransactionContext();
|
||||
txn.beginTxn();
|
||||
String xmlFile = getXMLFilePath(getContentDefinition());
|
||||
|
||||
ContentSection section = getContentSection();
|
||||
|
||||
s_log.debug("Loading XMLFile: " + xmlFile);
|
||||
loadContentItems(xmlFile, section);
|
||||
txn.commitTxn();
|
||||
}
|
||||
|
||||
public void doShutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public void validateNameParameter(String value)
|
||||
throws InitializationException {
|
||||
|
||||
final String pattern = "/[^A-Za-z_0-9\\-]+/";
|
||||
Perl5Util util = new Perl5Util();
|
||||
if ( util.match(pattern, value) ) {
|
||||
throw new InitializationException("The \"" + value + "\" name parameter must contain only alpha-numeric " +
|
||||
"characters, underscores, and/or hyphens.");
|
||||
}
|
||||
}
|
||||
|
||||
public ContentSection getContentSection() throws InitializationException {
|
||||
String name = getContentSectionParam();
|
||||
|
||||
validateNameParameter(name);
|
||||
|
||||
BigDecimal rootNodeID = SiteNode.getRootSiteNode().getID();
|
||||
SiteNode node = null;
|
||||
try {
|
||||
node = SiteNode.getSiteNode("/" + name);
|
||||
} catch (DataObjectNotFoundException ex) {
|
||||
throw new InitializationException(
|
||||
(String) GlobalizationUtil.globalize("cms.installer.root_site_node_missing")
|
||||
.localize(), ex);
|
||||
}
|
||||
|
||||
if ( rootNodeID.equals(node.getID()) ) {
|
||||
// This instance does not exist yet, abort
|
||||
throw new InitializationException("The section does not exist");
|
||||
}
|
||||
|
||||
ContentSection section = null;
|
||||
try {
|
||||
section = ContentSection.getSectionFromNode(node);
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new InitializationException(
|
||||
(String) GlobalizationUtil.globalize(
|
||||
"cms.installer.failed_to_update_the_default_content_section").localize());
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
public void loadContentItems(String path,
|
||||
ContentSection section) {
|
||||
// Make duplicates of the content item
|
||||
XMLContentItemHandler handler
|
||||
= new XMLContentItemHandler(section);
|
||||
|
||||
try {
|
||||
SAXParserFactory spf = SAXParserFactory.newInstance();
|
||||
SAXParser parser = spf.newSAXParser();
|
||||
parser.parse(path, handler);
|
||||
} catch (ParserConfigurationException e) {
|
||||
s_log.error("error parsing content item config", e);
|
||||
} catch (SAXException e) {
|
||||
s_log.error("error parsing content item config", e);
|
||||
} catch (IOException e) {
|
||||
s_log.error("error parsing content item config", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* 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.installer.xml;
|
||||
|
||||
|
||||
import com.arsdigita.cms.LoaderConfig;
|
||||
import com.arsdigita.initializer.Configuration;
|
||||
import com.arsdigita.initializer.InitializationException;
|
||||
import com.arsdigita.kernel.BaseInitializer;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
import com.arsdigita.persistence.TransactionContext;
|
||||
import com.arsdigita.xml.XML;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
// This initializer loads definitions into the database and is a
|
||||
// LOADER TASK! (pboy)
|
||||
|
||||
/**
|
||||
* Parses XML file definition of content types and loads them to the
|
||||
* database. The XML config looks like the example below, the
|
||||
* "parentType" and "name" attributes are optional, and only required
|
||||
* for creating User Defined ContentTypes. Label corresponds to
|
||||
* ContentType's label and can be multiple words, and "name" to
|
||||
* DynamicObject's name property, and must be a single word. The
|
||||
* objectType attribute is ignored for UDCTs, as it gets dynamically
|
||||
* generated.
|
||||
*
|
||||
* <b>UDCT Copyright</b>
|
||||
* <pre>
|
||||
* <ccm:content-types>
|
||||
* <ccm:content-type
|
||||
* name="Copyright"
|
||||
* label="UDCT Copyright"
|
||||
* parentType="com.arsdigita.cms.contenttypes.Address"
|
||||
* classname="com.arsdigita.cms.contenttypes.Address"
|
||||
* description="Copyright for storing copyright information"
|
||||
* objectType="com.arsdigita.cms.contentTypes.Address" >
|
||||
*
|
||||
* <ccm:authoring-kit>
|
||||
* </ccm:authoring-kit>
|
||||
* </ccm:content-type>
|
||||
* </ccm:content-types>
|
||||
*</pre>
|
||||
*
|
||||
* <b>Initializer</b>
|
||||
* <pre>
|
||||
* init com.arsdigita.cms.installer.ContentTypeInitializer {
|
||||
* contentTypes = {
|
||||
* "/WEB-INF/content-types/Article.xml"
|
||||
* };
|
||||
* }
|
||||
*</pre>
|
||||
* @author Nobuko Asakai <nasakai@redhat.com>
|
||||
* @see XMLContentTypeHandler
|
||||
*/
|
||||
public class ContentTypeLegacyInitializer extends BaseInitializer {
|
||||
|
||||
private static org.apache.log4j.Logger s_log =
|
||||
org.apache.log4j.Logger.getLogger(ContentTypeLegacyInitializer.class);
|
||||
|
||||
// Load main CMS configuration file
|
||||
private static final LoaderConfig s_conf = new LoaderConfig();
|
||||
|
||||
// public static final String CONTENT_TYPES = "contentTypes";
|
||||
// private Configuration m_conf = new Configuration();
|
||||
|
||||
public ContentTypeLegacyInitializer() {
|
||||
// Could make this a list later...
|
||||
// m_conf.initParameter
|
||||
// (CONTENT_TYPES,
|
||||
// "Path to XML files that contains content type definition",
|
||||
// List.class);
|
||||
}
|
||||
|
||||
public Configuration getConfiguration() {
|
||||
// return m_conf;
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void doShutdown() {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
protected void doStartup() throws InitializationException {
|
||||
// List contentTypes = (List)m_conf.getParameter(CONTENT_TYPES);
|
||||
List contentTypes = s_conf.getCTDefFiles();
|
||||
|
||||
if ( contentTypes != null) {
|
||||
Iterator i = contentTypes.iterator();
|
||||
while (i.hasNext()) {
|
||||
TransactionContext txn = SessionManager.getSession()
|
||||
.getTransactionContext();
|
||||
txn.beginTxn();
|
||||
String xmlFile = (String)i.next();
|
||||
s_log.debug("Processing contentTypes in: " + xmlFile);
|
||||
XML.parseResource(xmlFile, new XMLContentTypeHandler());
|
||||
txn.commitTxn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
// CMS initialization file
|
||||
//
|
||||
// $Id: enterprise.init 2070 2010-01-28 08:47:41Z pboy $
|
||||
//
|
||||
// init com.arsdigita.cms.installer.xml.ContentTypeLegacyInitializer {
|
||||
// contentTypes = {
|
||||
// "/WEB-INF/content-types/Template.xml"
|
||||
// };
|
||||
// }
|
||||
|
||||
// ContentTypeLegacyInitializer uses new config to get parameters
|
||||
init com.arsdigita.cms.installer.xml.ContentTypeLegacyInitializer {}
|
||||
|
|
@ -23,7 +23,7 @@ import com.arsdigita.cms.ContentType;
|
|||
import com.arsdigita.cms.ContentTypeCollection;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.ContentTypeWorkflowTemplate;
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.contenttypes.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
import com.arsdigita.kernel.Kernel;
|
||||
import com.arsdigita.kernel.KernelExcursion;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import com.arsdigita.cms.ContentPage;
|
|||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ContentTypeLifecycleDefinition;
|
||||
import com.arsdigita.cms.Folder;
|
||||
import com.arsdigita.cms.installer.xml.ContentBundleHelper;
|
||||
import com.arsdigita.cms.contentitem.ContentBundleHelper;
|
||||
import com.arsdigita.cms.lifecycle.LifecycleDefinition;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.arsdigita.london.util.cmd;
|
||||
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.contenttypes.XMLContentTypeHandler;
|
||||
import com.arsdigita.london.util.Transaction;
|
||||
import com.arsdigita.packaging.Program;
|
||||
import com.arsdigita.xml.XML;
|
||||
|
|
|
|||
Loading…
Reference in New Issue