Weitere Korrekturen an Upgrades

git-svn-id: https://svn.libreccm.org/ccm/trunk@2414 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-11-05 15:23:18 +00:00
parent 6e49e34ae7
commit 8a8a61ca29
4 changed files with 181 additions and 138 deletions

View File

@ -30,18 +30,26 @@ public class ArticleSectionContentSectionFix extends Program {
final DomainCollection mparticles = new DomainCollection(session.retrieve(
MultiPartArticle.BASE_DATA_OBJECT_TYPE));
final long mparticlesSize = mparticles.size();
int i = 1;
while(mparticles.next()) {
System.out.printf("Processing MultiPartArticle %d/%d...\n", i, mparticlesSize);
processMPArticle((MultiPartArticle)mparticles.getDomainObject());
i++;
}
}
private void processMPArticle(final MultiPartArticle mpa) {
final ArticleSectionCollection sections = mpa.getSections();
final long sectionsSize = sections.size();
int i = 1;
while(sections.next()) {
System.out.printf("\tProcessing ArticleSection %d/%d...\n", i, sectionsSize);
final ArticleSection section = sections.getArticleSection();
section.setContentSection(mpa.getContentSection());
section.save();
i++;
}
}

View File

@ -16,19 +16,22 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.core.upgrade;
import com.arsdigita.core.Loader;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.util.cmd.Program;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.util.StringUtils;
import com.arsdigita.web.Application;
import com.arsdigita.web.ApplicationType;
import com.arsdigita.ui.admin.Admin;
import com.arsdigita.ui.login.Login;
import com.arsdigita.ui.permissions.Permissions;
import com.arsdigita.webdevsupport.WebDevSupport;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.cli.CommandLine;
import org.apache.log4j.Logger;
@ -49,27 +52,25 @@ import org.apache.log4j.Logger;
* @author pb
*/
public class Upgrade664 extends Program {
private static Logger s_log = Logger.getLogger(Upgrade664.class);
/**
/* Constructor constructs a program object which initializes the CCM
/* Constructor constructs a program object which initializes the CCM
* runtime system and enables concatenation, so a following SQL script
* may be executed.
*/
public Upgrade664() {
super("Upgrade664", "1.0.0", "",true,true);
super("Upgrade664", "1.0.0", "", true, true);
}
/**
* The mandatory main method
* @param args
*/
public static void main(final String[] args) {
new Upgrade664().run(args);
}
new Upgrade664().run(args);
}
/**
* Worker method. Adds new style application entries.
@ -86,32 +87,39 @@ public class Upgrade664 extends Program {
tc.beginTxn();
// Update core Login application
// Previously login had been managed by a (virtual) root
// sitenode with login dispatcher associated.
// Login application is newly created, old sitenote deactivated.
Loader.loadLoginApp();
if (!appAlreadyInstalled(Login.BASE_DATA_OBJECT_TYPE, session)) {
// Update core Login application (if not already installed)
// Previously login had been managed by a (virtual) root
// sitenode with login dispatcher associated.
// Login application is newly created, old sitenote deactivated.
Loader.loadLoginApp();
}
if (!appAlreadyInstalled(Admin.BASE_DATA_OBJECT_TYPE, session)) {
// Update core Admin application (if not already installed)
// Old style package type already removed by sql script.
// Create a (new type, legacy free) web.ApplicationType type
// application
Loader.loadAdminApp();
}
// Update core Admin application
// Old style package type already removed by sql script.
// Create a (new type, legacy free) web.ApplicationType type
// application
Loader.loadAdminApp();
if (!appAlreadyInstalled(Permissions.BASE_DATA_OBJECT_TYPE, session)) {
// Update core permission support (if not already installed)
// Old style package type already removed by sql script.
// Create a (new type, legacy free) web.ApplicationType type
// application
Loader.loadPermissionsApp();
}
// Update core permission support
// Old style package type already removed by sql script.
// Create a (new type, legacy free) web.ApplicationType type
// application
Loader.loadPermissionsApp();
// Update core WebDeveloperSupport
// Old style package type already removed by sql script.
// Create a (new type, legacy free) web.ApplicationType type
// application
Loader.loadWebDev();
if (!appAlreadyInstalled(WebDevSupport.BASE_DATA_OBJECT_TYPE, session)) {
// Update core WebDeveloperSupport
// Old style package type already removed by sql script.
// Create a (new type, legacy free) web.ApplicationType type
// application
Loader.loadWebDev();
}
// Note: Old PackageType sitenode removed. It's useless now
@ -128,8 +136,17 @@ public class Upgrade664 extends Program {
tc.commitTxn();
}
}.run();
}
final boolean appAlreadyInstalled(final String type, final Session session) {
final DataCollection appTypes = session.retrieve(type);
final boolean result = !appTypes.isEmpty();
appTypes.close();
return result;
}
}

View File

@ -15,87 +15,104 @@
--
-- $Id: add_ispublic.sql pboy $
CREATE TABLE forum_temp as select * from forum_forums ;
DROP TABLE forum_forums CASCADE ;
ALTER TABLE forum_forums ADD COLUMN is_public BOOLEAN NOT NULL DEFAULT true;
CREATE TABLE forum_forums
(
forum_id integer NOT NULL,
is_moderated boolean NOT NULL,
is_noticeboard boolean NOT NULL,
is_public boolean NOT NULL,
admin_group_id integer,
mod_group_id integer,
create_group_id integer,
respond_group_id integer,
read_group_id integer,
category_id integer NOT NULL,
lifecycle_definition_id integer,
expire_after numeric,
file_attachments_allowed boolean NOT NULL,
image_uploads_allowed boolean NOT NULL,
subscribe_thread_starter boolean NOT NULL,
no_category_posts_allowed boolean NOT NULL,
anonymous_posts_allowed boolean NOT NULL,
introduction character varying(4000),
CONSTRAINT forum_forums_forum_id_p_9opkb PRIMARY KEY (forum_id),
CONSTRAINT foru_for_life_defin_id_f_ugal3 FOREIGN KEY (lifecycle_definition_id)
REFERENCES lifecycle_definitions (definition_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT foru_foru_admi_grou_id_f_k0nw6 FOREIGN KEY (admin_group_id)
REFERENCES groups (group_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT foru_foru_crea_grou_id_f_f7x57 FOREIGN KEY (create_group_id)
REFERENCES groups (group_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT foru_foru_respo_gro_id_f_rnofz FOREIGN KEY (respond_group_id)
REFERENCES groups (group_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT foru_forum_category_id_f_1u2dw FOREIGN KEY (category_id)
REFERENCES cat_categories (category_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT foru_forum_mod_grou_id_f__smmb FOREIGN KEY (mod_group_id)
REFERENCES groups (group_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT foru_forum_rea_grou_id_f_itati FOREIGN KEY (read_group_id)
REFERENCES groups (group_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT forum_forums_forum_id_f_znjmf FOREIGN KEY (forum_id)
REFERENCES applications (application_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
-- CREATE TABLE forum_temp AS SELECT * FROM forum_forums ;
-- DROP TABLE forum_forums CASCADE ;
-- CREATE TABLE forum_forums
-- (
-- forum_id INTEGER NOT NULL,
-- is_moderated BOOLEAN NOT NULL,
-- is_noticeboard BOOLEAN NOT NULL,
-- is_public BOOLEAN NOT NULL,
-- admin_group_id INTEGER,
-- mod_group_id INTEGER,
-- create_group_id INTEGER,
-- respond_group_id INTEGER,
-- read_group_id INTEGER,
-- category_id INTEGER NOT NULL,
-- lifecycle_definition_id INTEGER,
-- expire_after NUMERIC,
-- file_attachments_allowed BOOLEAN NOT NULL,
-- image_uploads_allowed BOOLEAN NOT NULL,
-- subscribe_thread_starter BOOLEAN NOT NULL,
-- no_category_posts_allowed BOOLEAN NOT NULL,
-- anonymous_posts_allowed BOOLEAN NOT NULL,
-- introduction CHARACTER VARYING(4000),
-- CONSTRAINT forum_forums_forum_id_p_9opkb PRIMARY KEY (forum_id),
-- CONSTRAINT foru_for_life_defin_id_f_ugal3 FOREIGN KEY (lifecycle_definition_id)
-- REFERENCES lifecycle_definitions (definition_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT foru_foru_admi_grou_id_f_k0nw6 FOREIGN KEY (admin_group_id)
-- REFERENCES groups (group_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT foru_foru_crea_grou_id_f_f7x57 FOREIGN KEY (create_group_id)
-- REFERENCES groups (group_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT foru_foru_respo_gro_id_f_rnofz FOREIGN KEY (respond_group_id)
-- REFERENCES groups (group_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT foru_forum_category_id_f_1u2dw FOREIGN KEY (category_id)
-- REFERENCES cat_categories (category_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT foru_forum_mod_grou_id_f__smmb FOREIGN KEY (mod_group_id)
-- REFERENCES groups (group_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT foru_forum_rea_grou_id_f_itati FOREIGN KEY (read_group_id)
-- REFERENCES groups (group_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION,
-- CONSTRAINT forum_forums_forum_id_f_znjmf FOREIGN KEY (forum_id)
-- REFERENCES applications (application_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION
-- )
-- WITH (
-- OIDS=FALSE
-- );
INSERT INTO forum_forums (forum_id,is_moderated,is_noticeboard,is_public,
admin_group_id,mod_group_id,create_group_id,
respond_group_id,read_group_id,category_id,
lifecycle_definition_id,expire_after,
file_attachments_allowed,image_uploads_allowed,
subscribe_thread_starter,no_category_posts_allowed,
anonymous_posts_allowed, introduction
)
SELECT forum_id,is_moderated,is_noticeboard,is_noticeboard,
admin_group_id,mod_group_id,create_group_id,
respond_group_id,read_group_id,category_id,
lifecycle_definition_id,expire_after,
file_attachments_allowed,image_uploads_allowed,
subscribe_thread_starter,no_category_posts_allowed,
anonymous_posts_allowed, introduction
FROM forum_temp;
-- INSERT INTO forum_forums (forum_id,
-- is_moderated,
-- is_noticeboard,
-- is_public,
-- admin_group_id,
-- mod_group_id,
-- create_group_id,
-- respond_group_id,
-- read_group_id,category_id,
-- lifecycle_definition_id,
-- expire_after,
-- file_attachments_allowed,
-- image_uploads_allowed,
-- subscribe_thread_starter,
-- no_category_posts_allowed,
-- anonymous_posts_allowed,
-- introduction)
-- SELECT forum_id,
-- is_moderated,
-- is_noticeboard,is_noticeboard,
-- admin_group_id,
-- mod_group_id,create_group_id,
-- respond_group_id,
-- read_group_id,category_id,
-- lifecycle_definition_id,
-- expire_after,
-- file_attachments_allowed,
-- image_uploads_allowed,
-- subscribe_thread_starter,
-- no_category_posts_allowed,
-- anonymous_posts_allowed,
-- introduction
-- FROM forum_temp;
UPDATE forum_forums
SET is_public=TRUE ;
-- UPDATE forum_forums SET is_public = TRUE;
-- restore constraint
ALTER TABLE forum_subscriptions
ADD CONSTRAINT foru_subscripti_for_id_f_xqfd9 FOREIGN KEY (forum_id)
REFERENCES forum_forums (forum_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;
-- ALTER TABLE forum_subscriptions
-- ADD CONSTRAINT foru_subscripti_for_id_f_xqfd9 FOREIGN KEY (forum_id)
-- REFERENCES forum_forums (forum_id) MATCH SIMPLE
-- ON UPDATE NO ACTION ON DELETE NO ACTION;
DROP TABLE forum_temp ;
-- DROP TABLE forum_temp;

View File

@ -20,44 +20,45 @@
-- adjust various system tables to the new name of application
update application_types
set title='Portal Workspace',
package_type_id=null
where object_type='com.arsdigita.portalworkspace.Workspace' ;
UPDATE application_types
SET title = 'Portal Workspace',
package_type_id = null
WHERE object_type = 'com.arsdigita.portalworkspace.Workspace';
update applications
set package_id=null
where primary_url = '/portal/' ;
UPDATE applications
SET package_id=null
WHERE application_type_id = (SELECT application_type_id
FROM application_types
WHERE object_type = 'com.arsdigita.portalworkspace.Workspace');
--WHERE primary_url = '/portal/';
-- table site_nodes
delete from site_nodes
where name like '%portal%' ;
DELETE FROM site_nodes
WHERE name LIKE '%portal%';
-- table apm_packages
delete from apm_packages
where pretty_name like '%Portal%' ;
DELETE FROM apm_packages
WHERE pretty_name LIKE '%Portal%';
-- table apm_package_types
delete from apm_package_types
where pretty_name like '%Workspace%' ;
DELETE FROM apm_package_types
where pretty_name LIKE '%Workspace%';
delete from object_context
where object_id = (select acs_objects.object_id from acs_objects
where acs_objects.object_type
like '%com.arsdigita.kernel%'
AND acs_objects.display_name like '/portal/') ;
DELETE FROM object_context
WHERE object_id = (SELECT acs_objects.object_id FROM acs_objects
WHERE acs_objects.object_type LIKE '%com.arsdigita.kernel%'
AND acs_objects.display_name LIKE '/portal/');
delete from object_context
where object_id = (select acs_objects.object_id from acs_objects
where acs_objects.object_type
like '%com.arsdigita.kernel%'
AND acs_objects.display_name like 'Portal Workspace') ;
DELETE FROM object_context
WHERE object_id IN (SELECT acs_objects.object_id FROM acs_objects
WHERE acs_objects.object_type LIKE '%com.arsdigita.kernel%'
AND acs_objects.display_name LIKE 'Portal Workspace');
delete from acs_objects
where object_type like '%com.arsdigita.kernel%'
AND display_name like '/portal/' ;
DELETE FROM acs_objects
WHERE object_type LIKE '%com.arsdigita.kernel%'
AND display_name LIKE '/portal/';
delete from acs_objects
where object_type like '%com.arsdigita.kernel%'
AND display_name like 'Portal Workspace' ;
DELETE FROM acs_objects
WHERE object_type LIKE '%com.arsdigita.kernel.PackageInstance'
AND display_name LIKE 'Portal Workspace';