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( final DomainCollection mparticles = new DomainCollection(session.retrieve(
MultiPartArticle.BASE_DATA_OBJECT_TYPE)); MultiPartArticle.BASE_DATA_OBJECT_TYPE));
final long mparticlesSize = mparticles.size();
int i = 1;
while(mparticles.next()) { while(mparticles.next()) {
System.out.printf("Processing MultiPartArticle %d/%d...\n", i, mparticlesSize);
processMPArticle((MultiPartArticle)mparticles.getDomainObject()); processMPArticle((MultiPartArticle)mparticles.getDomainObject());
i++;
} }
} }
private void processMPArticle(final MultiPartArticle mpa) { private void processMPArticle(final MultiPartArticle mpa) {
final ArticleSectionCollection sections = mpa.getSections(); final ArticleSectionCollection sections = mpa.getSections();
final long sectionsSize = sections.size();
int i = 1;
while(sections.next()) { while(sections.next()) {
System.out.printf("\tProcessing ArticleSection %d/%d...\n", i, sectionsSize);
final ArticleSection section = sections.getArticleSection(); final ArticleSection section = sections.getArticleSection();
section.setContentSection(mpa.getContentSection()); section.setContentSection(mpa.getContentSection());
section.save(); section.save();
i++;
} }
} }

View File

@ -16,19 +16,22 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.core.upgrade; package com.arsdigita.core.upgrade;
import com.arsdigita.core.Loader; import com.arsdigita.core.Loader;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion; import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.util.cmd.Program; import com.arsdigita.util.cmd.Program;
import com.arsdigita.persistence.Session; import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext; import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.util.StringUtils; import com.arsdigita.ui.admin.Admin;
import com.arsdigita.web.Application; import com.arsdigita.ui.login.Login;
import com.arsdigita.web.ApplicationType; 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.commons.cli.CommandLine;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -53,23 +56,21 @@ public class Upgrade664 extends Program {
private static Logger s_log = Logger.getLogger(Upgrade664.class); 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 * runtime system and enables concatenation, so a following SQL script
* may be executed. * may be executed.
*/ */
public Upgrade664() { public Upgrade664() {
super("Upgrade664", "1.0.0", "",true,true); super("Upgrade664", "1.0.0", "", true, true);
} }
/** /**
* The mandatory main method * The mandatory main method
* @param args * @param args
*/ */
public static void main(final String[] args) { public static void main(final String[] args) {
new Upgrade664().run(args); new Upgrade664().run(args);
} }
/** /**
* Worker method. Adds new style application entries. * Worker method. Adds new style application entries.
@ -86,32 +87,39 @@ public class Upgrade664 extends Program {
tc.beginTxn(); tc.beginTxn();
// Update core Login application if (!appAlreadyInstalled(Login.BASE_DATA_OBJECT_TYPE, session)) {
// Previously login had been managed by a (virtual) root // Update core Login application (if not already installed)
// sitenode with login dispatcher associated. // Previously login had been managed by a (virtual) root
// Login application is newly created, old sitenote deactivated. // sitenode with login dispatcher associated.
Loader.loadLoginApp(); // 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 if (!appAlreadyInstalled(Permissions.BASE_DATA_OBJECT_TYPE, session)) {
// Old style package type already removed by sql script. // Update core permission support (if not already installed)
// Create a (new type, legacy free) web.ApplicationType type // Old style package type already removed by sql script.
// application // Create a (new type, legacy free) web.ApplicationType type
Loader.loadAdminApp(); // application
Loader.loadPermissionsApp();
}
// Update core permission support if (!appAlreadyInstalled(WebDevSupport.BASE_DATA_OBJECT_TYPE, session)) {
// Old style package type already removed by sql script. // Update core WebDeveloperSupport
// Create a (new type, legacy free) web.ApplicationType type // Old style package type already removed by sql script.
// application // Create a (new type, legacy free) web.ApplicationType type
Loader.loadPermissionsApp(); // application
Loader.loadWebDev();
}
// 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 // Note: Old PackageType sitenode removed. It's useless now
@ -128,8 +136,17 @@ public class Upgrade664 extends Program {
tc.commitTxn(); tc.commitTxn();
} }
}.run(); }.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 $ -- $Id: add_ispublic.sql pboy $
CREATE TABLE forum_temp as select * from forum_forums ; ALTER TABLE forum_forums ADD COLUMN is_public BOOLEAN NOT NULL DEFAULT true;
DROP TABLE forum_forums CASCADE ;
CREATE TABLE forum_forums -- CREATE TABLE forum_temp AS SELECT * FROM forum_forums ;
( -- DROP TABLE forum_forums CASCADE ;
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_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, -- INSERT INTO forum_forums (forum_id,
admin_group_id,mod_group_id,create_group_id, -- is_moderated,
respond_group_id,read_group_id,category_id, -- is_noticeboard,
lifecycle_definition_id,expire_after, -- is_public,
file_attachments_allowed,image_uploads_allowed, -- admin_group_id,
subscribe_thread_starter,no_category_posts_allowed, -- mod_group_id,
anonymous_posts_allowed, introduction -- create_group_id,
) -- respond_group_id,
SELECT forum_id,is_moderated,is_noticeboard,is_noticeboard, -- read_group_id,category_id,
admin_group_id,mod_group_id,create_group_id, -- lifecycle_definition_id,
respond_group_id,read_group_id,category_id, -- expire_after,
lifecycle_definition_id,expire_after, -- file_attachments_allowed,
file_attachments_allowed,image_uploads_allowed, -- image_uploads_allowed,
subscribe_thread_starter,no_category_posts_allowed, -- subscribe_thread_starter,
anonymous_posts_allowed, introduction -- no_category_posts_allowed,
FROM forum_temp; -- 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 -- UPDATE forum_forums SET is_public = TRUE;
SET is_public=TRUE ;
-- restore constraint -- restore constraint
ALTER TABLE forum_subscriptions -- ALTER TABLE forum_subscriptions
ADD CONSTRAINT foru_subscripti_for_id_f_xqfd9 FOREIGN KEY (forum_id) -- ADD CONSTRAINT foru_subscripti_for_id_f_xqfd9 FOREIGN KEY (forum_id)
REFERENCES forum_forums (forum_id) MATCH SIMPLE -- REFERENCES forum_forums (forum_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION; -- 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 -- adjust various system tables to the new name of application
update application_types UPDATE application_types
set title='Portal Workspace', SET title = 'Portal Workspace',
package_type_id=null package_type_id = null
where object_type='com.arsdigita.portalworkspace.Workspace' ; WHERE object_type = 'com.arsdigita.portalworkspace.Workspace';
update applications UPDATE applications
set package_id=null SET package_id=null
where primary_url = '/portal/' ; 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 -- table site_nodes
delete from site_nodes DELETE FROM site_nodes
where name like '%portal%' ; WHERE name LIKE '%portal%';
-- table apm_packages -- table apm_packages
delete from apm_packages DELETE FROM apm_packages
where pretty_name like '%Portal%' ; WHERE pretty_name LIKE '%Portal%';
-- table apm_package_types -- table apm_package_types
delete from apm_package_types DELETE FROM apm_package_types
where pretty_name like '%Workspace%' ; where pretty_name LIKE '%Workspace%';
delete from object_context DELETE FROM object_context
where object_id = (select acs_objects.object_id from acs_objects WHERE object_id = (SELECT acs_objects.object_id FROM acs_objects
where acs_objects.object_type WHERE acs_objects.object_type LIKE '%com.arsdigita.kernel%'
like '%com.arsdigita.kernel%' AND acs_objects.display_name LIKE '/portal/');
AND acs_objects.display_name like '/portal/') ;
delete from object_context DELETE FROM object_context
where object_id = (select acs_objects.object_id from acs_objects WHERE object_id IN (SELECT acs_objects.object_id FROM acs_objects
where acs_objects.object_type WHERE acs_objects.object_type LIKE '%com.arsdigita.kernel%'
like '%com.arsdigita.kernel%' AND acs_objects.display_name LIKE 'Portal Workspace');
AND acs_objects.display_name like 'Portal Workspace') ;
delete from acs_objects DELETE FROM acs_objects
where object_type like '%com.arsdigita.kernel%' WHERE object_type LIKE '%com.arsdigita.kernel%'
AND display_name like '/portal/' ; AND display_name LIKE '/portal/';
delete from acs_objects DELETE FROM acs_objects
where object_type like '%com.arsdigita.kernel%' WHERE object_type LIKE '%com.arsdigita.kernel.PackageInstance'
AND display_name like 'Portal Workspace' ; AND display_name LIKE 'Portal Workspace';