Erster Teil Umstellung cms-workspace und cms-service auf new application type. Functional noch unverändert. Release um 1 erhöht.

git-svn-id: https://svn.libreccm.org/ccm/trunk@906 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2011-05-12 23:49:19 +00:00
parent f2387d424f
commit dc0c1ceb6a
12 changed files with 364 additions and 82 deletions

View File

@ -2,7 +2,7 @@
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project" <ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name="ccm-cms" name="ccm-cms"
prettyName="Red Hat CCM Content Management System" prettyName="Red Hat CCM Content Management System"
version="6.6.1" version="6.6.2"
release="1" release="1"
webapp="ROOT"> webapp="ROOT">
<ccm:dependencies> <ccm:dependencies>

View File

@ -0,0 +1,27 @@
//
// Copyright (C) 2011 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
// 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
//
// $Id: Service.pdl pboy $
model com.arsdigita.cms;
import com.arsdigita.kernel.*;
import com.arsdigita.web.Application;
object type Service extends Application {
// nothing to persist yet
// reference key (cms_service.service_id);
}

View File

@ -0,0 +1,27 @@
//
// Copyright (C) 2011 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
// 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
//
// $Id: Workspace.pdl pboy $
model com.arsdigita.cms;
import com.arsdigita.kernel.*;
import com.arsdigita.web.Application;
object type Workspace extends Application {
// nothing to persist yet
// reference key (cms_workspace.workspace_id);
}

View File

@ -38,10 +38,14 @@
</version> </version>
<version from="6.6.0" to="6.6.1"> <version from="6.6.0" to="6.6.1">
<!--
-->
<script sql="ccm-cms/upgrade/::database::-6.6.0-6.6.1.sql"/> <script sql="ccm-cms/upgrade/::database::-6.6.0-6.6.1.sql"/>
<script class="com.arsdigita.cms.upgrade.CreateGenericContentTypes"/> <script class="com.arsdigita.cms.upgrade.CreateGenericContentTypes"/>
</version> </version>
<version from="6.6.1" to="6.6.2">
<script class="com.arsdigita.cms.upgrade.AddNewStyleApplicationEntries"/>
<!--
<script sql="ccm-cms/upgrade/::database::-6.6.0-6.6.1.sql"/>
-->
</version>
</upgrade> </upgrade>

View File

@ -127,12 +127,13 @@ public class Loader extends PackageLoader {
"com.arsdigita.cms.dispatcher.ContentCenterDispatcher"; "com.arsdigita.cms.dispatcher.ContentCenterDispatcher";
// To be updated soon... // To be updated soon...
// "com.arsdigita.dispatcher.DefaultPackageDispatcher"; // "com.arsdigita.dispatcher.DefaultPackageDispatcher";
/**
* Stylesheet which has to be assigned as part of a legacy application // /**
* creation. // * Stylesheet which has to be assigned as part of a legacy application
*/ // * creation.
private final static String WORKSPACE_STYLESHEET = // */
"/packages/content-section/xsl/content-center.xsl"; // private final static String WORKSPACE_STYLESHEET =
// "/packages/content-section/xsl/content-center.xsl";
/** /**
* Name of the CMS service package instance, i.e. its URL. * Name of the CMS service package instance, i.e. its URL.
*/ */
@ -170,11 +171,11 @@ public class Loader extends PackageLoader {
// 2 - step 1b) Setup the Workspace package. // 2 - step 1b) Setup the Workspace package.
loadWorkspacePackage(); // using old stype loadWorkspacePackage(); // using old stype
// loadWorkspacePackageNewStyle(); // loadWorkspacePackageNewStyle(); // using new style
// 3 - step 1c) Setup the CMS global services package. // 3 - step 1c) Setup the CMS global services package.
loadServicePackage(); // using olde style loadServicePackage(); // using olde style
// loadServicePackageNewStyle(); // loadServicePackageNewStyle(); // using new style
// 4 - step 1d) Load the content-center page mappings // 4 - step 1d) Load the content-center page mappings
// Wrong! Is Initializer task, must be done each startup, in // Wrong! Is Initializer task, must be done each startup, in
@ -283,19 +284,6 @@ public class Loader extends PackageLoader {
"Content Centers", "Content Centers",
"http://cms-workspace.arsdigita.com/"); "http://cms-workspace.arsdigita.com/");
type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS); type.setDispatcherClass(WORKSPACE_DISPATCHER_CLASS);
// Register a stylesheet to the Content Center package.
// Registering a Stylesheet referrs to the old LegacyStylesheetResolver
// which uses a database entry to determine an appropriate stylesheet.
// New way is a pattern based search algorithm. Preserved here for easy
// reference during transition (removal of corresponding classes)
// see com.arsdigita.templating
// content center works without registering a style sheet here.
// Stylesheet ss =
// Stylesheet.createStylesheet(WORKSPACE_STYLESHEET);
// ss.save();
// type.addStylesheet(ss);
type.save(); type.save();
// from PackageInstance instance = workspaceInstaller.createPackageInstance(); // from PackageInstance instance = workspaceInstaller.createPackageInstance();
@ -329,8 +317,8 @@ public class Loader extends PackageLoader {
* Loads and instantiates the Workspace package (content-center) in the * Loads and instantiates the Workspace package (content-center) in the
* database. * database.
*/ */
private void loadWorkspacePackageNewStyle() { public static ApplicationType loadWorkspaceApplicationType() {
s_log.debug("Creating CMS Workspace..."); s_log.warn("Creating CMS Workspace...");
// Creating of Workspace package using new style c.ad.web.Application // Creating of Workspace package using new style c.ad.web.Application
// in legacy compatible mode. Needs refactoring of the Workspace package. // in legacy compatible mode. Needs refactoring of the Workspace package.
@ -358,15 +346,27 @@ public class Loader extends PackageLoader {
ApplicationType workspaceType = appsetup.run(); ApplicationType workspaceType = appsetup.run();
workspaceType.save(); workspaceType.save();
s_log.warn("CMS Workspace type created.");
return workspaceType;
}
/**
*
* @param workspaceType
*/
public static void setupDefaultWorkspaceApplicationInstance(
ApplicationType workspaceType) {
// create legacy compatible application instance, // create legacy compatible application instance,
// old-style package key used as url fragment where to install the instance // old-style package key used as url fragment where to install the instance
s_log.warn("Creating CMS Workspace instance ...");
Workspace app = (Workspace) Application.createApplication( Workspace app = (Workspace) Application.createApplication(
workspaceType, // type workspaceType, // type
Workspace.PACKAGE_KEY, // url fragment Workspace.PACKAGE_KEY, // url fragment
Workspace.INSTANCE_NAME,// title Workspace.INSTANCE_NAME,// title
null); // parent null); // parent
app.save(); app.save();
s_log.warn("CMS Workspace instance created.");
s_log.debug("Done loading CMS Workspace."); s_log.debug("Done loading CMS Workspace.");
} }
@ -411,7 +411,7 @@ public class Loader extends PackageLoader {
* store for global resources and assets. * store for global resources and assets.
* *
*/ */
private void loadServicePackageNewStyle() { public static ApplicationType loadServiceApplicationType() {
s_log.debug("Loading CMS Servce Package..."); s_log.debug("Loading CMS Servce Package...");
@ -429,8 +429,6 @@ public class Loader extends PackageLoader {
// old style / legacy compatible properties // old style / legacy compatible properties
appsetup.setKey(Service.PACKAGE_KEY); appsetup.setKey(Service.PACKAGE_KEY);
appsetup.setDispatcherClass(Service.DISPATCHER_CLASS); appsetup.setDispatcherClass(Service.DISPATCHER_CLASS);
// Service has no UI, therefore no stylesheet available
// appsetup.setStylesheet( Workspace.STYLESHEET );
appsetup.setSingleton(true); appsetup.setSingleton(true);
appsetup.setPortalApplication(false); appsetup.setPortalApplication(false);
appsetup.setInstantiator(new ACSObjectInstantiator() { appsetup.setInstantiator(new ACSObjectInstantiator() {
@ -443,6 +441,16 @@ public class Loader extends PackageLoader {
ApplicationType serviceType = appsetup.run(); ApplicationType serviceType = appsetup.run();
serviceType.save(); serviceType.save();
return serviceType;
}
/**
*
* @param serviceType
*/
public static void setupDefaultServiceApplicationInstance(
ApplicationType serviceType) {
// create legacy compatible application instance, // create legacy compatible application instance,
// old-style package key used as url fragment where to install the instance // old-style package key used as url fragment where to install the instance
Service app = (Service) Application.createApplication( Service app = (Service) Application.createApplication(

View File

@ -43,8 +43,11 @@ public class Service extends Application {
private static final Logger s_log = Logger.getLogger(ContentSection.class); private static final Logger s_log = Logger.getLogger(ContentSection.class);
// pdl stuff (constants)
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.Service"; "com.arsdigita.cms.Service";
// general constants
public static final String PACKAGE_KEY = "cms-service"; public static final String PACKAGE_KEY = "cms-service";
public static final String INSTANCE_NAME = "CMS Service"; public static final String INSTANCE_NAME = "CMS Service";
public static final String DISPATCHER_CLASS = public static final String DISPATCHER_CLASS =
@ -54,20 +57,57 @@ public class Service extends Application {
// "/packages/content-section/xsl/content-center.xsl"; // "/packages/content-section/xsl/content-center.xsl";
/** /**
* Constructor * Constructor retrieving service from the database usings its OID.
* @param oid *
* @param oid the OID of the service (cms-service)
* @throws DataObjectNotFoundException * @throws DataObjectNotFoundException
*/ */
public Service(OID oid) throws DataObjectNotFoundException { public Service(OID oid) throws DataObjectNotFoundException {
super(oid); super(oid);
} }
/**
* Constructor retrieving the contained <code>DataObject</code> from the
* persistent storage mechanism with an <code>OID</code> specified by id.
*
* @param id The <code>id</code> for the retrieved
* <code>DataObject</code>.
*/
public Service(BigDecimal key) throws DataObjectNotFoundException { public Service(BigDecimal key) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, key)); this(new OID(BASE_DATA_OBJECT_TYPE, key));
} }
/**
* Constructs a service domain object from the underlying data object.
*/
public Service(DataObject dataObject) { public Service(DataObject dataObject) {
super(dataObject); super(dataObject);
} }
/**
* Getter to retrieve the base database object type name
*
* @return base data aoject type as String
*/
@Override
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
/**
* This is called when the application is created.
*/
public static Service create(String urlName,
String title,
Application parent) {
Service app = (Service) Application.createApplication
(BASE_DATA_OBJECT_TYPE, urlName, title, parent);
app.save();
return app;
}
} }

View File

@ -21,14 +21,15 @@ package com.arsdigita.cms;
import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.DataAssociation; // import com.arsdigita.persistence.DataAssociation;
import com.arsdigita.persistence.PersistenceException; // import com.arsdigita.persistence.PersistenceException;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
// WORK IN PROGRESS !!
/** /**
* Application domain class for the CMS module user entry page (content-center) * Application domain class for the CMS module user entry page (content-center)
@ -40,8 +41,11 @@ public class Workspace extends Application {
private static final Logger s_log = Logger.getLogger(ContentSection.class); private static final Logger s_log = Logger.getLogger(ContentSection.class);
// pdl stuff (constants)
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.Workspace"; "com.arsdigita.cms.Workspace";
// general constants
public static final String PACKAGE_KEY = "content-center"; public static final String PACKAGE_KEY = "content-center";
public static final String INSTANCE_NAME = "Content Center"; public static final String INSTANCE_NAME = "Content Center";
public static final String DISPATCHER_CLASS = public static final String DISPATCHER_CLASS =
@ -50,20 +54,57 @@ public class Workspace extends Application {
"/packages/content-section/xsl/content-center.xsl"; "/packages/content-section/xsl/content-center.xsl";
/** /**
* Constructor * Constructor retrieving a workspace from the database usings its OID.
* @param oid *
* @param oid the OID of the workspace (content-center)
* @throws DataObjectNotFoundException * @throws DataObjectNotFoundException
*/ */
public Workspace(OID oid) throws DataObjectNotFoundException { public Workspace(OID oid) throws DataObjectNotFoundException {
super(oid); super(oid);
} }
/**
* Constructor retrieving the contained <code>DataObject</code> from the
* persistent storage mechanism with an <code>OID</code> specified by id.
*
* @param id The <code>id</code> for the retrieved
* <code>DataObject</code>.
*/
public Workspace(BigDecimal key) throws DataObjectNotFoundException { public Workspace(BigDecimal key) throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, key)); this(new OID(BASE_DATA_OBJECT_TYPE, key));
} }
/**
* Constructs a repository from the underlying data object.
*/
public Workspace(DataObject dataObject) { public Workspace(DataObject dataObject) {
super(dataObject); super(dataObject);
} }
/**
* Getter to retrieve the base database object type name
*
* @return base data aoject type as String
*/
@Override
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
/**
* This is called when the application is created.
*/
public static Workspace create(String urlName,
String title,
Application parent) {
Workspace app =
(Workspace) Application.createApplication
(BASE_DATA_OBJECT_TYPE, urlName, title, parent);
app.save();
return app;
}
} }

View File

@ -0,0 +1,117 @@
/*
* Copyright (C) 2011 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
* 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.upgrade;
import com.arsdigita.cms.Loader;
import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.kernel.PackageInstance;
import com.arsdigita.kernel.PackageInstanceCollection;
import com.arsdigita.kernel.PackageType;
import com.arsdigita.kernel.Resource;
import com.arsdigita.kernel.ResourceType;
import com.arsdigita.packaging.Program;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.web.ApplicationType;
import org.apache.commons.cli.CommandLine;
import org.apache.log4j.Logger;
/**
* Update from CCM version 6.6.1 to 6.6.2 where loader has been refactored to
* use (new style) applications in package com.arsdigita.weg instead of old
* style applications using com.arsdigita.kermel.[Package* & SiteNode].
*
* Affected are the packages CMS Workspace and Service. They are now loaded
* using new style application classes Workspace and Service.
*
* The task at hand is to add the necessary table entries for CMS Workspace and
* Service to the tables application_types and applications using the
* information already existing (by old style initialization) in
* apm_package_types, site_nodes, and apm_packages.
*
* @author pb
*/
public class AddNewStyleApplicationEntries extends Program {
private static Logger s_log = Logger.getLogger(CreateGenericContentTypes.class);
/**
/* Constructor
*/
public AddNewStyleApplicationEntries() {
super("AddNewStyleApplicationEntries", "1.0.0", "");
}
/**
* The mandatory main method
* @param args
*/
public static void main(final String[] args) {
new AddNewStyleApplicationEntries().run(args);
}
/**
* Worker method. Adds new style application entries.
*
* @param cmdLine
*/
public void doRun(CommandLine cmdLine) {
new KernelExcursion() {
public void excurse() {
setEffectiveParty(Kernel.getSystemParty());
final Session session = SessionManager.getSession();
final TransactionContext tc = session.getTransactionContext();
tc.beginTxn();
// experimental
ApplicationType appType = null;
appType = Loader.loadWorkspaceApplicationType();
// get corresponding package type
PackageType packageType = appType.getPackageType();
// get all installed instances
PackageInstanceCollection allPackages = packageType
.getInstances();
PackageInstance aPackage = null ;
Resource res = null;
while ( allPackages.next() ) {
aPackage = allPackages.getPackageInstance();
res = Resource.createResource((ResourceType)appType,
aPackage.getDisplayName(),
null);
}
appType = null;
appType = Loader.loadServiceApplicationType();
tc.commitTxn();
}
}.run();
}
}

View File

@ -181,14 +181,15 @@ public class Application extends Resource {
final String title, final String title,
final Application parent, final Application parent,
final boolean createContainerGroup) { final boolean createContainerGroup) {
final ApplicationType type = final ApplicationType type = ApplicationType
ApplicationType.retrieveApplicationTypeForApplication(typeName); .retrieveApplicationTypeForApplication(
typeName);
if (type == null) { if (type == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"No ApplicationType found for type name " + typeName); "No ApplicationType found for type name " + typeName);
} }
return Application.createApplication(type,fragment, return Application.createApplication(type,fragment,
title,parent,createContainerGroup); title,parent,createContainerGroup);
} }
/** /**
@ -206,10 +207,11 @@ public class Application extends Resource {
*/ */
public static Application createApplication( public static Application createApplication(
final ApplicationType type, final ApplicationType type,
final String fragment, final String fragment,
final String title, final String title,
final Application parent, final Application parent,
final boolean createContainerGroup) { final boolean createContainerGroup) {
if (Assert.isEnabled()) { if (Assert.isEnabled()) {
Assert.exists(type, ApplicationType.class); Assert.exists(type, ApplicationType.class);
Assert.exists(fragment, String.class); Assert.exists(fragment, String.class);
@ -219,10 +221,12 @@ public class Application extends Resource {
} }
s_log.debug("Application type legacy free: " + type.m_legacyFree ); s_log.debug("Application type legacy free: " + type.m_legacyFree );
if (type.m_legacyFree) { if (type.m_legacyFree) {
return Application.make(type,fragment,title,parent,createContainerGroup); return Application.make(type,fragment,title,parent,
createContainerGroup);
} else { } else {
s_log.debug("Creating legacy compatible app"); s_log.debug("Creating legacy compatible app");
return Application.legacyMake(type,fragment,title,parent,createContainerGroup); return Application.legacyMake(type,fragment,title,parent,
createContainerGroup);
} }
} }
@ -295,6 +299,7 @@ public class Application extends Resource {
final String title, final String title,
final Application parent, final Application parent,
final boolean createContainerGroup) { final boolean createContainerGroup) {
final Application application = (Application) Resource.createResource( final Application application = (Application) Resource.createResource(
type, title, parent); type, title, parent);
if (createContainerGroup) { if (createContainerGroup) {
@ -636,8 +641,8 @@ public class Application extends Resource {
return apps; return apps;
} }
public static boolean isInstalled public static boolean isInstalled (String applicationObjectType,
(String applicationObjectType, String path) { String path) {
DataCollection dataCollection = DataCollection dataCollection =
SessionManager.getSession().retrieve(applicationObjectType); SessionManager.getSession().retrieve(applicationObjectType);

View File

@ -44,16 +44,15 @@ import org.apache.log4j.Category;
* setup.run(); * setup.run();
* </blockquote></pre> * </blockquote></pre>
* *
* <strong>Important note.</strong> When <code>Application</code>s are * <strong>Important note.</strong> When <code>Application</code>s are used
* used in the context of old-style apps that use * in the context of old-style apps that use <code>SiteNode</code>s and
* <code>SiteNode</code>s and <code>PackageType</code>s, it is * <code>PackageType</code>s, it is important to use the
* important to use the <code>setKey("some-string-key")</code> so that * <code>setKey("some-string-key")</code> so that your new applications can
* your new applications can interoperate fluidly with the legacy * interoperate fluidly with the legacy applications.
* applications. Use of the <code>setKey</code> method ensures that * Use of the <code>setKey</code> method ensures that your application will,
* your application will, behind the scenes, use site nodes and * behind the scenes, use site nodes and package instances, in addition to the
* package instances, in addition to the <code>Application</code> * <code>Application</code> object, to represent each new mountable application.
* object, to represent each new mountable application. As a result, * As a result, legacy code for managing and dispatching applications will work
* legacy code for managing and dispatching applications will work
* with both your old and your new applications. * with both your old and your new applications.
* *
* @see com.arsdigita.web.ApplicationType * @see com.arsdigita.web.ApplicationType
@ -62,6 +61,7 @@ import org.apache.log4j.Category;
*/ */
public class ApplicationSetup { public class ApplicationSetup {
/** Appender to enable writing to the löog file. */
protected Category m_category; protected Category m_category;
protected String m_title = null; protected String m_title = null;
protected String m_description = null; protected String m_description = null;
@ -76,6 +76,11 @@ public class ApplicationSetup {
protected boolean m_isSingleton = false; protected boolean m_isSingleton = false;
protected String m_dispatcherClass = null; protected String m_dispatcherClass = null;
/**
* Constructor.
*
* @param category as appender to the log file.
*/
public ApplicationSetup(Category category) { public ApplicationSetup(Category category) {
m_category = category; m_category = category;
} }
@ -143,10 +148,9 @@ public class ApplicationSetup {
} }
/** /**
* Marks this applications of this type as ones that do or do not * Marks this applications of this type as ones that do or do not belong to
* belong to a "portal", a special application type that collects * a "portal", a special application type that collects child applications
* child applications together for presentation and navigation * together for presentation and navigation purposes.
* purposes.
* *
* By default, this value is true. * By default, this value is true.
*/ */

View File

@ -60,7 +60,7 @@ public class ApplicationType extends ResourceType {
* this case is the same as the Java type (full qualified class name). * this case is the same as the Java type (full qualified class name).
*/ */
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.web.ApplicationType"; "com.arsdigita.web.ApplicationType";
private PackageType m_packageType; private PackageType m_packageType;
boolean m_legacyFree = false; boolean m_legacyFree = false;
@ -69,12 +69,15 @@ public class ApplicationType extends ResourceType {
* Constructor creates a new ApplicationType instance to encapsulate a given * Constructor creates a new ApplicationType instance to encapsulate a given
* data object (@see com.arsdigita.persistence.Session#retrieve(String) ). * data object (@see com.arsdigita.persistence.Session#retrieve(String) ).
* The super implementation uses overwritable methods initialize() and * The super implementation uses overwritable methods initialize() and
* postInitialization() to further process the dataObject (see below). * postInitialization() to further process the dataObject.
* *
* @param dataObject * @param dataObject
*/ */
public ApplicationType(DataObject dataObject) { public ApplicationType(DataObject dataObject) {
super(dataObject); super(dataObject);
if (this.getPackageType() == null) { // indicates a legacy free app
m_legacyFree = true;
} // otherwise leave it on its default value of false
} }
protected ApplicationType(String dataObjectType) { protected ApplicationType(String dataObjectType) {
@ -85,6 +88,12 @@ public class ApplicationType extends ResourceType {
final String title, final String title,
final String applicationObjectType) { final String applicationObjectType) {
this(objectType, title, applicationObjectType, false); this(objectType, title, applicationObjectType, false);
// under some circumstances m_legacyFree is set correctly to true
if (m_legacyFree == false) { //check if default value is correct!
if (this.getPackageType() == null) { // indicates a legacy free app
m_legacyFree = true;
} // otherwise leave it on its default value of false
}
} }
@ -228,7 +237,7 @@ public class ApplicationType extends ResourceType {
/** /**
* Helper method to create a packageType for a new legacy compatible * Helper method to create a packageType for a new legacy compatible
* application type without a already existing (i.e. installed in db) legacy * application type without an already existing (i.e. installed in db) legacy
* application. * application.
* *
* @param key of the package to be created * @param key of the package to be created
@ -315,7 +324,8 @@ public class ApplicationType extends ResourceType {
// Can return null. // Can return null.
public static ApplicationType retrieveApplicationTypeForApplication public static ApplicationType retrieveApplicationTypeForApplication
(String applicationObjectType) { (String applicationObjectType) {
Assert.exists(applicationObjectType, "applicationObjectType"); Assert.exists(applicationObjectType, "applicationObjectType");
DataCollection collection = DataCollection collection =
@ -609,19 +619,28 @@ public class ApplicationType extends ResourceType {
* So wwe have to provide this functionality by ApplicationType as well * So wwe have to provide this functionality by ApplicationType as well
* which has no kind of "key" by design. * which has no kind of "key" by design.
*/ */
// XXX we need a better way to determine a name, probably using
// the class name without leading package name.
public String getName() { public String getName() {
// m_legacyFree seems sometimes not set correctly! if (m_legacyFree == true ) {
// if (m_legacyFree == true ) {
if (getPackageType() == null) { // indicates a legacy free ApplicationType
// XXX we need a better way to determine a name, probably using
// the class name without leading package name.
s_log.debug("Expect XSL templates at " + StringUtils.urlize(getTitle())); s_log.debug("Expect XSL templates at " + StringUtils.urlize(getTitle()));
return StringUtils.urlize(getTitle()); return StringUtils.urlize(getTitle());
} else { } else {
return this.getPackageType().getKey(); // m_legacyFree seems sometimes not set correctly! It's odd but the
} // goal is to get rid of legacy code so it should do it for the
// time beeing. We check getPackageType to see if m_legacyFree is
// really set correctly.
if (getPackageType() == null) { // indicates legacy free App
s_log.debug("Expect XSL templates at "
+ StringUtils.urlize(getTitle()));
m_legacyFree = true; // correct m_legacyFree for future use
return StringUtils.urlize(getTitle());
} else {
return this.getPackageType().getKey();
}
}
} }
/** /**

View File

@ -175,22 +175,12 @@ public class Loader extends PackageLoader {
* to lower case. * to lower case.
* "Portal Workspace" will become "portal-workspace". * "Portal Workspace" will become "portal-workspace".
* *
* Creates an entry in table application_types and a corresponding entry in
* apm_package_types
*
* @return * @return
*/ */
private ApplicationType setupWorkspaceType() { private ApplicationType setupWorkspaceType() {
s_log.debug("Creating an application type for portal workspace. " + s_log.debug("Creating an application type for portal workspace. " +
"Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE); "Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE);
// The first string is a key parameter used to create a
// legacy package type to back the new application type.
// ApplicationType type = ApplicationType.createApplicationType(
// "portalworkspace",
// "Portal Workspace",
// Workspace.BASE_DATA_OBJECT_TYPE);
ApplicationType type = new ApplicationType( "Portal Workspace", ApplicationType type = new ApplicationType( "Portal Workspace",
Workspace.BASE_DATA_OBJECT_TYPE ); Workspace.BASE_DATA_OBJECT_TYPE );