Weiterer Schritte, old initializer auszubauen: Alle einmaligen Initialisierunge jetzt in Loader aktiv. Kein Update erforderlich.
git-svn-id: https://svn.libreccm.org/ccm/trunk@575 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
454f5d12ed
commit
9c5a5c56ac
|
|
@ -142,7 +142,7 @@ public class Initializer extends CompoundInitializer {
|
|||
// add(new LegacyInitializer("com/arsdigita/cms/contentsection/enterprise.init"));
|
||||
|
||||
// Step 4a new
|
||||
// Initializer for content section, needed when LegacyInitializer in step 3
|
||||
// Initializer for content section, needed when LegacyInitializer in step 4
|
||||
// has been moved to c.ad.Loader in order to register the application and
|
||||
// optionally to install additional content sections.
|
||||
// add(new com.arsdigita.cms.contentsection.Initializer());
|
||||
|
|
@ -256,8 +256,6 @@ public class Initializer extends CompoundInitializer {
|
|||
FileAsset.BASE_DATA_OBJECT_TYPE,
|
||||
new AssetMetadataProvider());
|
||||
|
||||
// Mount the content-center sidenode
|
||||
|
||||
|
||||
s_log.debug("CMS.Initializer.init(DomainInitEvent) completed");
|
||||
} // END init(DomainInitEvent e)
|
||||
|
|
@ -307,8 +305,6 @@ public class Initializer extends CompoundInitializer {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
f.registerInstantiator
|
||||
(Workflow.BASE_DATA_OBJECT_TYPE,
|
||||
new ACSObjectInstantiator() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved.
|
||||
* Copyright (C) 2009 Peter Boy <pb@zes.uni-bremen.de> 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
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
package com.arsdigita.cms;
|
||||
|
||||
import com.arsdigita.cms.installer.ContentSectionSetup;
|
||||
import com.arsdigita.cms.installer.PageClassConfigHandler;
|
||||
// import com.arsdigita.cms.installer.PageClassConfigHandler;
|
||||
import com.arsdigita.cms.installer.Util;
|
||||
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
|
||||
import com.arsdigita.cms.installer.WorkspaceInstaller;
|
||||
|
|
@ -28,40 +28,45 @@ 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.DomainObjectFactory;
|
||||
// import com.arsdigita.domain.DomainObjectInstantiator;
|
||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||
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.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.UncheckedWrapperException;
|
||||
// import com.arsdigita.util.UncheckedWrapperException;
|
||||
//import com.arsdigita.util.parameter.Parameter;
|
||||
// import com.arsdigita.util.parameter.BooleanParameter;
|
||||
//import com.arsdigita.util.parameter.StringParameter;
|
||||
//import com.arsdigita.util.parameter.URLParameter;
|
||||
// import com.arsdigita.web.Application;
|
||||
// import com.arsdigita.web.ApplicationType;
|
||||
import com.arsdigita.web.Application;
|
||||
import com.arsdigita.web.ApplicationSetup;
|
||||
import com.arsdigita.web.ApplicationType;
|
||||
import com.arsdigita.xml.XML;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
// import java.io.IOException;
|
||||
// import java.io.InputStream;
|
||||
// import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
// import javax.xml.parsers.ParserConfigurationException;
|
||||
// import javax.xml.parsers.SAXParser;
|
||||
// import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
// import org.xml.sax.InputSource;
|
||||
// import org.xml.sax.SAXException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -72,6 +77,10 @@ import org.apache.log4j.Logger;
|
|||
// method commented IN(!) does load all packages into database and
|
||||
// ccm/admin/sitemap lists them appropriately.
|
||||
// Not yet found a way to mount them in the URL tree while initializing.
|
||||
// This is true using the old style application using package / sitenode
|
||||
//
|
||||
// Next Try
|
||||
// Refactor using legacy compatible web/Application and ApplicationSetup
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -102,7 +111,7 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
public class Loader extends PackageLoader {
|
||||
|
||||
/** Private logger instance */
|
||||
/** Creates a s_logging category with name = full name of class */
|
||||
private static final Logger s_log = Logger.getLogger(Loader.class);
|
||||
|
||||
// Load main CMS configuration file
|
||||
|
|
@ -161,8 +170,6 @@ public class Loader extends PackageLoader {
|
|||
public final static String SERVICE_PACKAGE_KEY = "cms-service";
|
||||
|
||||
|
||||
private static HashMap s_pageClasses = new HashMap();
|
||||
private static HashMap s_pageURLs = new HashMap();
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -176,60 +183,47 @@ public class Loader extends PackageLoader {
|
|||
|
||||
|
||||
public void run(final ScriptContext ctx) {
|
||||
// XXX: Should move on demand initialization stuff here.
|
||||
s_log.debug("CMS.loader.run() invoked");
|
||||
|
||||
new KernelExcursion() {
|
||||
public void excurse() {
|
||||
setEffectiveParty(Kernel.getSystemParty());
|
||||
|
||||
|
||||
// ////////////////////////
|
||||
// Loading CMS package (esp. content center, cms service
|
||||
// Used to be step 1 in former enterprise.init file
|
||||
// Implemented by
|
||||
// com.arsdigita.cms.installer.xml.ContentTypeInitializer
|
||||
// ////////////////////////////////
|
||||
// 1 - step 1a) Setup the CMS package.
|
||||
// loadCMSPackageType();
|
||||
// loadContentSectionPackageType using (new) c.ad.web package.
|
||||
// ContentSectionSetup.setupContentSectionAppType();
|
||||
|
||||
// createPrivileges();
|
||||
// 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();
|
||||
loadWorkspacePackage(); // using old stype
|
||||
// loadWorkspacePackageNewStyle();
|
||||
|
||||
// 3 - step 1c) Setup the CMS global services package.
|
||||
// loadServicePackage();
|
||||
loadServicePackage(); // using olde style
|
||||
// loadServicePackageNewStyle();
|
||||
|
||||
// 4 - stgep 1d) Load the content-center page mappings
|
||||
// loadContentCenterMapping(s_conf.getContentCenterMap() );
|
||||
// 4 - step 1d) Load the content-center page mappings
|
||||
// Wrong! Is Initializer task, must be done each startup, in
|
||||
// any way not a Loader task. It is here for reference
|
||||
// purpose during migration of the whole CMS to new style.
|
||||
// loadContentCenterMapping(s_conf.getContentCenterMap() );
|
||||
|
||||
// ////////////////////////
|
||||
// 5) load content type definition(s)
|
||||
// Loading content type definitions
|
||||
// Used to be step 2 in former enterprise.init file
|
||||
// Implemented by
|
||||
// com.arsdigita.cms.installer.xml.ContentTypeInitializer
|
||||
// ////////////////////////////////
|
||||
loadContentTypeDefinitions(s_conf.getCTDefFiles() );
|
||||
|
||||
// ////////////////////////
|
||||
// 6) Load CMS (content section) package application instance
|
||||
// Loading content section application type and instance
|
||||
// Used to be step 4 in former enterprise.init file
|
||||
// (step 3 being initialize publishToFile, not to handle in Loader)
|
||||
// Implemented by
|
||||
// com.arsdigita.cms.installer.SectionInitializer
|
||||
// ////////////////////////////////
|
||||
// Loads content section application type and instance in one step
|
||||
loadContentSection(s_conf.getContentSectionName());
|
||||
|
||||
|
||||
// ///////////////////////////////////////////////////////
|
||||
// Loading CMS portlets
|
||||
// Used to be step 7 (last step) in former enterprise.init
|
||||
// ///////////////////////////////////////////////////////
|
||||
s_log.debug("CMS.loader going to load portlets");
|
||||
//ContentDirectoryPortlet.loadPortletType();
|
||||
ContentItemPortlet.loadPortletType();
|
||||
|
|
@ -248,8 +242,10 @@ public class Loader extends PackageLoader {
|
|||
*
|
||||
* (pb) WRONG:
|
||||
* Creates content-section PackageType. Is replaced by newer ApplicationType
|
||||
* mechanisam (see loadContentSection). Must nolonger be used except of
|
||||
* createPrivileges!
|
||||
* 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...");
|
||||
|
|
@ -294,24 +290,25 @@ public class Loader extends PackageLoader {
|
|||
|
||||
/**
|
||||
* Loads and instantiates the Workspace package (content-center) in the
|
||||
* database.
|
||||
* 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...");
|
||||
|
||||
WorkspaceInstaller workspaceInstaller = new WorkspaceInstaller();
|
||||
WorkspaceInstaller workspaceInstaller = new WorkspaceInstaller();
|
||||
try {
|
||||
workspaceInstaller.createPackageType();
|
||||
// type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS);
|
||||
|
||||
// PackageInstance instance = workspaceInstaller.createPackageInstance();
|
||||
// PackageInstance instance = workspaceInstaller.createPackageInstance();
|
||||
// Does the following:
|
||||
// type = PackageType.findByKey(WORKSPACE_PACKAGE_KEY);
|
||||
// PackageInstance instance = type.createInstance(WORKSPACE_INSTANCE_NAME);
|
||||
// instance.save();
|
||||
PackageInstance instance = workspaceInstaller.createPackageInstance();
|
||||
|
||||
// workspaceInstaller.mountPackageInstance(instance, m_workspaceURL);
|
||||
// workspaceInstaller.mountPackageInstance(instance, m_workspaceURL);
|
||||
// Does the following:
|
||||
// SiteNode node = SiteNode.createSiteNode(
|
||||
// s_conf.getWorkspaceURL(),
|
||||
|
|
@ -325,26 +322,54 @@ public class Loader extends PackageLoader {
|
|||
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new ConfigError(
|
||||
"Failed to initialize the Workspace package: ");
|
||||
"Failed to initialize the Workspace package: ");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Creating of Workspace package using new style c.ad.web.Application could
|
||||
// be done like the following (legacy compatible style!).
|
||||
// Needs refactoring of the Workspace package.
|
||||
// // Step 1: Create application type
|
||||
// ApplicationType type = ApplicationType
|
||||
// .createApplicationType("content-center",
|
||||
// "The Content Center Workspace",
|
||||
// ContentCenter.BASE_DATA_OBJECT_TYPE); NEEDED!
|
||||
// type.setDescription("The content center workspace for content creators.");
|
||||
//
|
||||
// // Step 2: Create application
|
||||
// Application app = Application.createRootApplication(
|
||||
// type,
|
||||
// "Content Center Workspace");
|
||||
// app.setPath((String) get(m_workspaceURL));
|
||||
/**
|
||||
* Loads and instantiates the Workspace package (content-center) in the
|
||||
* database.
|
||||
*/
|
||||
private void loadWorkspacePackageNewStyle() {
|
||||
s_log.debug("Creating CMS Workspace...");
|
||||
|
||||
// Creating of Workspace package using new style c.ad.web.Application
|
||||
// in legacy compatible mode. Needs refactoring of the Workspace package.
|
||||
// In a first step these instructions replace c.ad.installer.WorkspaceInstaller
|
||||
|
||||
// create application type
|
||||
ApplicationSetup appsetup = new ApplicationSetup(s_log);
|
||||
// new style properties
|
||||
appsetup.setApplicationObjectType( Workspace.BASE_DATA_OBJECT_TYPE );
|
||||
appsetup.setTitle( Workspace.INSTANCE_NAME ); // same as for instance
|
||||
// there is only one
|
||||
appsetup.setDescription("The content center workspace for content creators.");
|
||||
// old style / legacy compatible properties
|
||||
appsetup.setKey( Workspace.PACKAGE_KEY );
|
||||
appsetup.setDispatcherClass( Workspace.DISPATCHER_CLASS );
|
||||
// should not be needed anymore, stypesheets handled by StylesheetResolver
|
||||
appsetup.setStylesheet( Workspace.STYLESHEET );
|
||||
appsetup.setSingleton(true);
|
||||
appsetup.setPortalApplication(false);
|
||||
appsetup.setInstantiator(new ACSObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new Workspace(dataObject);
|
||||
}
|
||||
});
|
||||
|
||||
ApplicationType workspaceType = appsetup.run();
|
||||
workspaceType.save();
|
||||
|
||||
// create legacy compatible application instance,
|
||||
// old-style package key used as url fragment where to install the instance
|
||||
Workspace app = (Workspace) Application.createApplication(
|
||||
workspaceType, // type
|
||||
Workspace.PACKAGE_KEY, // url fragment
|
||||
Workspace.INSTANCE_NAME,// title
|
||||
null); // parent
|
||||
app.save();
|
||||
|
||||
s_log.debug("Done loading CMS Workspace.");
|
||||
}
|
||||
|
|
@ -353,13 +378,14 @@ public class Loader extends PackageLoader {
|
|||
/**
|
||||
* 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 {
|
||||
// ServiceInstaller.createPackageType();
|
||||
// from ServiceInstaller.createPackageType();
|
||||
PackageType type = PackageType.create
|
||||
(SERVICE_PACKAGE_KEY,
|
||||
"Content Management System Services",
|
||||
|
|
@ -369,152 +395,77 @@ public class Loader extends PackageLoader {
|
|||
"com.arsdigita.cms.dispatcher.ServiceDispatcher");
|
||||
type.save();
|
||||
|
||||
// PackageInstance instance = ServiceInstaller.createPackageInstance();
|
||||
type = PackageType.findByKey(SERVICE_PACKAGE_KEY);
|
||||
// from PackageInstance instance = ServiceInstaller.createPackageInstance();
|
||||
type = PackageType.findByKey(SERVICE_PACKAGE_KEY);
|
||||
PackageInstance instance = type.createInstance(SERVICE_PACKAGE_KEY);
|
||||
instance.save();
|
||||
|
||||
// ServiceInstaller.mountPackageInstance(instance, url);
|
||||
// from ServiceInstaller.mountPackageInstance(instance, url);
|
||||
SiteNode node = SiteNode.createSiteNode(SERVICE_URL,
|
||||
SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
SiteNode.getRootSiteNode());
|
||||
node.mountPackage(instance);
|
||||
node.save();
|
||||
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new ConfigError
|
||||
("Failed to initialize CMS global services package.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Creating of Service package using new style c.ad.web.Application could
|
||||
// be done like the following (legacy compatible style!).
|
||||
// Needs refactoring of the Servcie package.
|
||||
// // Step 1: Create application type
|
||||
// ApplicationType type = ApplicationType
|
||||
// .createApplicationType("cms-service", // Type = PACKAGE_KEY,
|
||||
// "Content Management System Services",
|
||||
// SERVICE_BASE_DATA_OBJECT_TYPE);
|
||||
// // Step 2: Create application
|
||||
// Application workspace = Application.createRootApplication(
|
||||
// type,
|
||||
// "Content Center Workspace");
|
||||
// app.setPath((String) get(m_workspaceURL));
|
||||
|
||||
s_log.debug("Done creating CMS Servce Package.");
|
||||
}
|
||||
|
||||
|
||||
private void loadContentCenterMapping(String mapFileName) throws ConfigError {
|
||||
|
||||
final PageClassConfigHandler handler
|
||||
= new PageClassConfigHandler(s_pageClasses, s_pageURLs);
|
||||
|
||||
final ClassLoader loader = Thread.currentThread
|
||||
().getContextClassLoader();
|
||||
final InputStream input = loader.getResourceAsStream
|
||||
(mapFileName.substring(1));
|
||||
|
||||
if (input == null) {
|
||||
throw new IllegalStateException(mapFileName + " 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);
|
||||
}
|
||||
} catch (DataObjectNotFoundException e) {
|
||||
throw new ConfigError
|
||||
("Failed to initialize CMS global services package.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* CMS Service application is used by the Content Management System as a
|
||||
* store for global resources and assets.
|
||||
*
|
||||
* <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>
|
||||
*
|
||||
* @see XMLContentTypeHandler
|
||||
*/
|
||||
private void loadContentTypeDefinitions(List ctDefFiles) {
|
||||
s_log.debug("Loading content type definitions ...");
|
||||
|
||||
if ( ctDefFiles != null) {
|
||||
Iterator i = ctDefFiles.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();
|
||||
}
|
||||
}
|
||||
|
||||
s_log.debug("Done loading content type definitions.");
|
||||
}
|
||||
private void loadServicePackageNewStyle() {
|
||||
s_log.debug("Loading CMS Servce Package...");
|
||||
|
||||
|
||||
/**
|
||||
* Creates the CMS privileges.
|
||||
*/
|
||||
private static void createPrivileges() {
|
||||
s_log.debug("Creating Privileges...");
|
||||
// Creating Service package using new style c.ad.web.Application
|
||||
// in legacy compatible mode. Needs refactoring of the Service package.
|
||||
// In a first step these instructions replace c.ad.installer.ServiceInstaller
|
||||
|
||||
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);
|
||||
if ( PrivilegeDescriptor.get(privilege) == null ) {
|
||||
PrivilegeDescriptor.createPrivilege(privilege);
|
||||
// create application type
|
||||
ApplicationSetup appsetup = new ApplicationSetup(s_log);
|
||||
// new style properties
|
||||
appsetup.setApplicationObjectType( Service.BASE_DATA_OBJECT_TYPE );
|
||||
appsetup.setTitle( Service.INSTANCE_NAME ); // same as for instance
|
||||
// there is only one
|
||||
appsetup.setDescription("Services to store global resources and assets.");
|
||||
// old style / legacy compatible properties
|
||||
appsetup.setKey( Service.PACKAGE_KEY );
|
||||
appsetup.setDispatcherClass( Service.DISPATCHER_CLASS );
|
||||
// Service has no UI, therefore no stylesheet available
|
||||
// appsetup.setStylesheet( Workspace.STYLESHEET );
|
||||
appsetup.setSingleton(true);
|
||||
appsetup.setPortalApplication(false);
|
||||
appsetup.setInstantiator(new ACSObjectInstantiator() {
|
||||
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||
return new Service(dataObject);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} finally {
|
||||
dq.close();
|
||||
}
|
||||
s_log.debug("Done creating Privileges.");
|
||||
ApplicationType serviceType = appsetup.run();
|
||||
serviceType.save();
|
||||
|
||||
// create legacy compatible application instance,
|
||||
// old-style package key used as url fragment where to install the instance
|
||||
Service app = (Service) Application.createApplication(
|
||||
serviceType, // type
|
||||
Service.PACKAGE_KEY, // url fragment
|
||||
Service.INSTANCE_NAME,// title
|
||||
null); // parent
|
||||
app.save();
|
||||
|
||||
s_log.debug("Done creating CMS Service Package.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load an initial default content-section, specified in LoaderConfig.
|
||||
*
|
||||
* Load an content section application type and an initial default
|
||||
* content-section instance as specified in LoaderConfig.
|
||||
* Uses new style application in legacy compatible mode.
|
||||
*
|
||||
*/
|
||||
private void loadContentSection(String name) {
|
||||
|
|
@ -525,11 +476,11 @@ public class Loader extends PackageLoader {
|
|||
// concrete content-section instance can be created.
|
||||
ContentSectionSetup.setupContentSectionAppType();
|
||||
|
||||
|
||||
createPrivileges();
|
||||
|
||||
// Step 2: Validatge name for section
|
||||
Util.validateURLParameter("name", name);
|
||||
|
||||
|
||||
// Step 3: Create the installation default content section "name"
|
||||
ContentSection section = ContentSection.create(name);
|
||||
|
||||
|
|
@ -577,6 +528,79 @@ public class Loader extends PackageLoader {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*
|
||||
* @see XMLContentTypeHandler
|
||||
*/
|
||||
private void loadContentTypeDefinitions(List ctDefFiles) {
|
||||
s_log.debug("Loading content type definitions ...");
|
||||
|
||||
if ( ctDefFiles != null) {
|
||||
Iterator i = ctDefFiles.iterator();
|
||||
while (i.hasNext()) {
|
||||
String xmlFile = (String)i.next();
|
||||
s_log.debug("Processing contentTypes in: " + xmlFile);
|
||||
XML.parseResource(xmlFile, new XMLContentTypeHandler());
|
||||
}
|
||||
}
|
||||
|
||||
s_log.debug("Done loading content type definitions.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
s_log.debug("Creating Privileges...");
|
||||
|
||||
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.debug(String.format("privilege = %s", privilege));
|
||||
if ( PrivilegeDescriptor.get(privilege) == null ) {
|
||||
PrivilegeDescriptor.createPrivilege(privilege);
|
||||
}
|
||||
}
|
||||
|
||||
} finally {
|
||||
dq.close();
|
||||
}
|
||||
s_log.debug("Done creating Privileges.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ public class ContentCenterDispatcher extends LockableImpl
|
|||
/**
|
||||
* The path of the file that maps resources.
|
||||
*/
|
||||
|
||||
public final static String DEFAULT_MAP_FILE = "/WEB-INF/resources/content-center-map.xml";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ 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.Stylesheet;
|
||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||
import com.arsdigita.persistence.DataQuery;
|
||||
import com.arsdigita.persistence.SessionManager;
|
||||
|
|
@ -39,7 +39,7 @@ import org.xml.sax.SAXException;
|
|||
|
||||
|
||||
/**
|
||||
* Sets up the content section.
|
||||
* Sets up the CMS package.
|
||||
*
|
||||
* @author Jon Orris (jorris@redhat.com)
|
||||
* @version $Revision: #10 $ $DateTime: 2004/08/17 23:15:09 $
|
||||
|
|
@ -101,26 +101,34 @@ public final class ContentCenterSetup {
|
|||
|
||||
public void run() {
|
||||
|
||||
// 1) Setup the CMS package.
|
||||
setupCMSPackage();
|
||||
// 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.
|
||||
|
||||
setupWorkspacePackage();
|
||||
// Moved to Loader
|
||||
// setupWorkspacePackage();
|
||||
|
||||
// 3) Setup the CMS global services package.
|
||||
setupServicePackage();
|
||||
// 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 package type if it does not already exist.
|
||||
* Creates the CMS (i.e. content section) package type if it does not already exist.
|
||||
*
|
||||
* Actually: Creates the PackageType contentsection!
|
||||
* 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
|
||||
|
|
@ -217,6 +225,12 @@ public final class ContentCenterSetup {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
|
|
|||
|
|
@ -26,11 +26,18 @@ import com.arsdigita.runtime.DomainInitEvent;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
// CURRENT STATUS:
|
||||
// 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.
|
||||
// In a second step a restructure of the code will be done.
|
||||
// 2. Step
|
||||
// Restructuring codel eventually remove this Initializer
|
||||
|
||||
/**
|
||||
* XXX Reformulate according to the code development!
|
||||
|
|
@ -51,12 +58,12 @@ import org.apache.log4j.Logger;
|
|||
*/
|
||||
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 contgext"
|
||||
// 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();
|
||||
// }
|
||||
|
|
@ -87,13 +94,7 @@ public class Initializer extends CompoundInitializer {
|
|||
public void init(DomainInitEvent evt) {
|
||||
s_log.debug("CMS.installer.Initializer.init(DomainInitEvent) invoked");
|
||||
|
||||
// Recursive invokation of init, is it really necessary??
|
||||
// On the other hand:
|
||||
// An empty implementations prevents this initializer from being executed.
|
||||
// A missing implementations causes the super class method to be executed,
|
||||
// which invokes the above added LegacyInitializer.
|
||||
// If super is not invoked, various other cms sub-initializer may not run.
|
||||
super.init(evt);
|
||||
super.init(evt); // !
|
||||
|
||||
/*
|
||||
* Imported from LegacyInitializer:
|
||||
|
|
@ -136,14 +137,11 @@ public class Initializer extends CompoundInitializer {
|
|||
// 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();
|
||||
|
||||
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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ 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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue