diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 31b6af202a..49a9f63801 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -320,7 +320,6 @@ - diff --git a/config/alfresco/dbscripts/create/org.hibernate.dialect.Dialect/AlfrescoPostCreate-JBPM-Extra.sql b/config/alfresco/dbscripts/create/org.hibernate.dialect.Dialect/AlfrescoPostCreate-JBPM-Extra.sql index 75f6861e02..83e9f5a2f6 100644 --- a/config/alfresco/dbscripts/create/org.hibernate.dialect.Dialect/AlfrescoPostCreate-JBPM-Extra.sql +++ b/config/alfresco/dbscripts/create/org.hibernate.dialect.Dialect/AlfrescoPostCreate-JBPM-Extra.sql @@ -6,17 +6,5 @@ -- -- Please contact support@alfresco.com if you need assistance with the upgrade. -- --- This patch is only required to fix JBPM columns on DB2. +-- This script is only required to fix JBPM columns on DB2. -- - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.3-JBPM-Extra'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.3-JBPM-Extra', 'Manually executed script upgrade V3.3 fix problems in JBPM tables', - 0, 4105, -1, 4106, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/db-schema-context.xml b/config/alfresco/dbscripts/db-schema-context.xml index 88fb1f54f1..68f770b93c 100644 --- a/config/alfresco/dbscripts/db-schema-context.xml +++ b/config/alfresco/dbscripts/db-schema-context.xml @@ -46,10 +46,6 @@ - - - - @@ -98,7 +94,6 @@ - diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/authority-unique-idx.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/authority-unique-idx.sql deleted file mode 100644 index 9f4022b5b3..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/authority-unique-idx.sql +++ /dev/null @@ -1,20 +0,0 @@ --- --- Title: Upgrade to V3.4 - Ensure existence of unique index on alf_authority (DB2) --- Database: Generic --- Since: V3.4 schema 4100 --- Author: Derek Hulley --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-authority-unique-idx'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-authority-unique-idx', 'Manually executed script upgrade V3.4', - 0, 4099, -1, 4100, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/child-assoc-indexes.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/child-assoc-indexes.sql deleted file mode 100644 index a6c4b9deca..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/child-assoc-indexes.sql +++ /dev/null @@ -1,22 +0,0 @@ --- --- Title: Upgrade to V3.4 - Add alf_child_assoc.idx_alf_cass_pri index --- Database: Generic --- Since: V3.4 schema 4105 --- Author: unknown --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - -CREATE INDEX idx_alf_cass_pri ON alf_child_assoc (parent_node_id, is_primary, child_node_id); --(optional) - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-child-assoc-indexes'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-child-assoc-indexes', 'Manually executed script upgrade V3.4', - 0, 4104, -1, 4105, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/property-unique-ctx-idx.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/property-unique-ctx-idx.sql deleted file mode 100644 index dcc1d69578..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/property-unique-ctx-idx.sql +++ /dev/null @@ -1,24 +0,0 @@ --- --- Title: Upgrade to V3.4 - Add alf_prop_unique_ctx.prop1_id index --- Database: MySQL --- Since: V3.4 schema 4105 --- Author: Derek Hulley --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- Optional if upgrading from before 3.2.x - -CREATE INDEX fk_alf_propuctx_p1 ON alf_prop_unique_ctx(prop1_id); --(optional) - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-property-unique-ctx-idx'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-property-unique-ctx-idx', 'Manually executed script upgrade V3.4', - 0, 4104, -1, 4105, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/property-unique-ctx-value.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/property-unique-ctx-value.sql deleted file mode 100755 index 2537dbd0a3..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.MySQLInnoDBDialect/property-unique-ctx-value.sql +++ /dev/null @@ -1,27 +0,0 @@ --- --- Title: Upgrade to V3.4 - Add alf_prop_unique_ctx.prop1_id column --- Database: MySQL --- Since: V3.4 schema 4105 --- Author: Derek Hulley --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- Optional if upgrading from before 3.2.x - -ALTER TABLE alf_prop_unique_ctx - ADD COLUMN prop1_id BIGINT NULL AFTER value3_prop_id, - ADD CONSTRAINT fk_alf_propuctx_p1 FOREIGN KEY (prop1_id) REFERENCES alf_prop_root (id) -; --(optional) - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-property-unique-ctx-value'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-property-unique-ctx-value', 'Manually executed script upgrade V3.4', - 0, 4104, -1, 4105, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/property-unique-ctx-value.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/property-unique-ctx-value.sql deleted file mode 100755 index 60c9562c36..0000000000 --- a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/property-unique-ctx-value.sql +++ /dev/null @@ -1,28 +0,0 @@ --- --- Title: Upgrade to V3.4 - Add alf_prop_unique_ctx.prop1_id column --- Database: PostgreSQL --- Since: V3.4 schema 4105 --- Author: Derek Hulley --- --- Please contact support@alfresco.com if you need assistance with the upgrade. --- - --- Optional if upgrading from before 3.2.x - -ALTER TABLE alf_prop_unique_ctx - ADD COLUMN prop1_id INT8, - ADD CONSTRAINT fk_alf_propuctx_p1 FOREIGN KEY (prop1_id) REFERENCES alf_prop_root (id) -; --(optional) - - --- --- Record script finish --- -DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-property-unique-ctx-value'; -INSERT INTO alf_applied_patch - (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) - VALUES - ( - 'patch.db-V3.4-property-unique-ctx-value', 'Manually executed script upgrade V3.4', - 0, 4104, -1, 4105, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' - ); diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties index 74228c6763..cb27296ee5 100644 --- a/config/alfresco/messages/patch-service.properties +++ b/config/alfresco/messages/patch-service.properties @@ -196,9 +196,6 @@ patch.thumbnailsAssocQName.description=Update the 'cm:thumbnails' association QN patch.convertContentUrls.description=Converts pre-3.2 content URLs to use the alf_content_data table. The conversion work can also be done on a schedule; please contact Alfresco Support for further details. patch.fixAuthoritiesCrcValues.description=Fixes authority CRC32 values to match UTF-8 encoding. -patch.fixAuthoritiesCrcValues.result=Fixed CRC32 values for UTF-8 encoding for {0} authorities. See file {1} for details. -patch.fixAuthoritiesCrcValues.fixed=Updated CRC32 values for authority ''{0}''. -patch.fixAuthoritiesCrcValues.unableToChange=Failed to update the CRC32 value for authority: \n Authority: {0} \n Error: {1} patch.updateMimetypes1.description=Fix mimetypes for Excel and Powerpoint. patch.updateMimetypes2.description=Fix mimetypes for Excel and Powerpoint. @@ -209,19 +206,16 @@ patch.updateMimetypesSVG.description=Fix mimetype for SVG Image patch.updateMimetypesVISIO.description=Fix mimetype for Microsoft Visio patch.updateMimetypesSVG.description=Fix mimetype for Scalable Vector Graphics Image -patch.redeployJbpmAdhocWorkflow.description=Redeploy JBPM adhoc workflow -patch.redeployJbpmAdhocWorkflow.result=JBPM adhoc workflow redeployed - patch.db-V3.2-AddFKIndexes.description=Fixes ALF-3189: Added missing FK indexes. Note: The script is empty for MySQL. patch.migrateAttrTenants.description=Migrate old Tenant attributes -patch.migrateAttrTenants.result=Processed {0} attributes patch.migrateAttrPropBackedBeans.description=Migrate old Property-Backed Bean component attributes -patch.migrateAttrPropBackedBeans.result=Processed {0} attributes ({1} properties) patch.migrateAttrChainingURS.description=Migrate old Chaining User Registry Synchronizer attributes -patch.migrateAttrChainingURS.result=Processed {0} attributes + +patch.redeployJbpmAdhocWorkflow.description=Redeploy JBPM adhoc workflow +patch.redeployJbpmAdhocWorkflow.result=JBPM adhoc workflow redeployed patch.migrateAttrDropOldTables.description=Drops old alf_*attribute* tables and sequence patch.migrateAttrDropOldTables.result=Drop tables alf_attributes, alf_global_attributes, alf_list_attribute_entries, alf_map_attribute_entries and sequence alf_attributes_seq @@ -233,8 +227,6 @@ patch.transfer.targetrule.description=Creates the transfer target rule for the d patch.actions.scheduledfolder.description=Creates the scheduled actions folder in the Data Dictionary. patch.publishing.root.description=Creates the publishing root folder in the Data Dictionary -patch.removingLinkValidationMetadata.description=Fixes ALF-5185: Removes all Link Validation reports from schema - patch.varcharFieldSizesQuadrupleIncreasing.description=ALF-4300: Increasing 'VARCHAR' field sizes quadruply for DB2 dialect patch.mtFixAdminExistingTenants.description=Fix bootstrapped creator/modifier diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index e1a96e783f..70d1351c1b 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -1127,74 +1127,36 @@ 4.2.x - - + patch.db-V3.4-authority-unique-idx patch.schemaUpgradeScript.description 0 4099 4100 - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/authority-unique-idx.sql + + 4.2.x - - + patch.fixAuthoritiesCrcValues patch.fixAuthoritiesCrcValues.description 0 4100 4101 - false - - - - - - - - + + 4.2.x - - + patch.updateMimetypes1 patch.updateMimetypes1.description 0 4101 4102 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - true + + 4.2.x - patch.db-V3.3-modify-index-permission_id patch.schemaUpgradeScript.description @@ -1225,55 +1187,46 @@ 4.2.x - - + patch.db-V3.4-property-unique-ctx-value patch.schemaUpgradeScript.description 0 4104 4105 - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/property-unique-ctx-value.sql + + 4.2.x - + patch.db-V3.4-property-unique-ctx-idx patch.schemaUpgradeScript.description 0 4104 4105 - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/property-unique-ctx-idx.sql - - - - - + + 4.2.x - - + patch.db-V3.4-child-assoc-indexes patch.schemaUpgradeScript.description 0 4104 4105 - - classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/child-assoc-indexes.sql + + 4.2.x - - + patch.db-V3.3-JBPM-Extra patch.schemaUpgradeScript.description 0 4105 4106 - - classpath:alfresco/dbscripts/create/${db.script.dialect}/AlfrescoPostCreate-JBPM-Extra.sql + + 4.2.x - patch.db-V3.3-Node-Prop-Serializable patch.schemaUpgradeScript.description @@ -1284,222 +1237,96 @@ 4.2.x - - - + patch.migrateAttrTenants patch.migrateAttrTenants.description 0 - 0 - 1 - false - - - - - - - - - - + 4105 + 4106 + + 4.2.x - + patch.migrateAttrPropBackedBeans patch.migrateAttrPropBackedBeans.description 0 4106 4107 - false - - - - - - - - - - + + 4.2.x - + patch.migrateAttrChainingURS patch.migrateAttrChainingURS.description 0 4106 4107 - false - - - - - - - - - - + + 4.2.x - + patch.migrateAttrDelete patch.noOpPatch.description 0 4106 4107 + + 4.2.x + - + patch.replication.replication_actions patch.replication.replication_actions.description 0 4107 4108 - - - - - - - - - - /${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.replication.replication_actions.childname} - - - - /${spaces.company_home.childname}/${spaces.dictionary.childname} - alfresco/bootstrap/replicationActionSpace.xml - alfresco/messages/bootstrap-spaces - + + 4.2.x - - + patch.transfer.targetrulefolder patch.transfer.targetrulefolder.description 0 4108 4109 - - - - - - - - - - - /app:company_home/app:dictionary/app:transfers/app:transfer_groups/cm:default/rule:ruleFolder - - - - /app:company_home/app:dictionary/app:transfers/app:transfer_groups/cm:default - alfresco/bootstrap/transferTargetRuleFolder.xml - + + 4.2.x - - + patch.transfer.targetrule patch.transfer.targetrule.description 0 4108 4109 - - - - - - - - - - - /app:company_home/app:dictionary/app:transfers/app:transfer_groups/cm:default/rule:ruleFolder/rule:rules3245de8b-2cfe-42ed-8f8b-44089f99b265 - - - - /app:company_home/app:dictionary/app:transfers/app:transfer_groups/cm:default/rule:ruleFolder - alfresco/bootstrap/transferTargetRule.xml - + + 4.2.x - - + patch.actions.scheduledfolder patch.actions.scheduledfolder.description 0 4109 4110 - - - - - - - - - - /app:company_home/app:dictionary/cm:Scheduled_x0020_Actions - - - - /app:company_home/app:dictionary - alfresco/bootstrap/scheduledActionsFolder.xml - alfresco/messages/bootstrap-spaces - + + 4.2.x - - + patch.updateMimetypes2 patch.updateMimetypes2.description 0 4110 4111 - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - true + + 4.2.x - patch.db-V3.2-AddFKIndexes-2 patch.schemaUpgradeScript.description diff --git a/source/java/org/alfresco/repo/admin/patch/impl/FixAuthoritiesCrcValuesPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/FixAuthoritiesCrcValuesPatch.java deleted file mode 100644 index 8ddf134ecb..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/FixAuthoritiesCrcValuesPatch.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.io.File; -import java.io.IOException; -import java.io.RandomAccessFile; -import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.sql.Savepoint; -import java.util.Date; -import java.util.List; - -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.batch.BatchProcessor; -import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorker; -import org.alfresco.repo.domain.control.ControlDAO; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.repo.domain.permissions.AclCrudDAO; -import org.alfresco.repo.security.authentication.AuthenticationUtil; -import org.alfresco.util.TempFileProvider; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Fixes ALF-478. - * Checks all CRC values for alf_authorities. - * - * @author Andrew Hind - * @since V3.3 - */ -public class FixAuthoritiesCrcValuesPatch extends AbstractPatch -{ - private static final String MSG_SUCCESS = "patch.fixAuthoritiesCrcValues.result"; - private static final String MSG_REWRITTEN = "patch.fixAuthoritiesCrcValues.fixed"; - private static final String MSG_UNABLE_TO_CHANGE = "patch.fixAuthoritiesCrcValues.unableToChange"; - - private final Log logger = LogFactory.getLog(getClass()); - - private PatchDAO patchDAO; - private AclCrudDAO aclCrudDAO; - private ControlDAO controlDAO; - - public FixAuthoritiesCrcValuesPatch() - { - } - - /** - * @param patchDAO finds incorrect authorities - */ - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - /** - * @param aclCrudDAO does the actual fixing - */ - public void setAclCrudDAO(AclCrudDAO aclCrudDAO) - { - this.aclCrudDAO = aclCrudDAO; - } - - /** - * @param controlDAO used to create Savepoints - */ - public void setControlDAO(ControlDAO controlDAO) - { - this.controlDAO = controlDAO; - } - - @Override - protected void checkProperties() - { - super.checkProperties(); - checkPropertyNotNull(patchDAO, "patchDAO"); - checkPropertyNotNull(aclCrudDAO, "aclCrudDAO"); - checkPropertyNotNull(controlDAO, "controlDAO"); - } - - @Override - protected String applyInternal() throws Exception - { - // initialise the helper - FixAuthoritiesCrcValuesPatchHelper helper = new FixAuthoritiesCrcValuesPatchHelper(); - - try - { - String msg = helper.fixCrcValues(); - // done - return msg; - } - finally - { - helper.closeWriter(); - } - } - - private class FixAuthoritiesCrcValuesPatchHelper - { - private File logFile; - private FileChannel channel; - - private FixAuthoritiesCrcValuesPatchHelper() throws IOException - { - // put the log file into a long life temp directory - File tempDir = TempFileProvider.getLongLifeTempDir("patches"); - logFile = new File(tempDir, "FixAuthorityCrcValuesPatch.log"); - - // open the file for appending - RandomAccessFile outputFile = new RandomAccessFile(logFile, "rw"); - channel = outputFile.getChannel(); - // move to the end of the file - channel.position(channel.size()); - // add a newline and it's ready - writeLine("").writeLine(""); - writeLine("FixAuthorityCrcValuesPatch executing on " + new Date()); - } - - private FixAuthoritiesCrcValuesPatchHelper write(Object obj) throws IOException - { - channel.write(ByteBuffer.wrap(obj.toString().getBytes("UTF-8"))); - return this; - } - private FixAuthoritiesCrcValuesPatchHelper writeLine(Object obj) throws IOException - { - write(obj); - write("\n"); - return this; - } - private void closeWriter() - { - try { channel.close(); } catch (Throwable e) {} - } - - public String fixCrcValues() throws Exception - { - List mismatchedAuthorities = patchDAO.getAuthoritiesWithNonUtf8Crcs(); - // get the association types to check - BatchProcessor batchProcessor = new BatchProcessor( - "FixAuthorityCrcValuesPatch", - transactionHelper, - mismatchedAuthorities, - 2, 20, - applicationEventPublisher, - logger, 1000); - - int updated = batchProcessor.process(new BatchProcessWorker() - { - public String getIdentifier(String entry) - { - return entry; - } - - public void beforeProcess() throws Throwable - { - // Authenticate as system - String systemUsername = AuthenticationUtil.getSystemUserName(); - AuthenticationUtil.setFullyAuthenticatedUser(systemUsername); - } - - public void process(String authority) throws Throwable - { - // Persist - Savepoint savepoint = controlDAO.createSavepoint("FixAuthorityCrcValuesPatch"); - try - { - aclCrudDAO.renameAuthority(authority, authority); - controlDAO.releaseSavepoint(savepoint); - } - catch (Throwable e) - { - controlDAO.rollbackToSavepoint(savepoint); - - String msg = I18NUtil.getMessage(MSG_UNABLE_TO_CHANGE, authority, e.getMessage()); - // We just log this and add details to the message file - if (logger.isDebugEnabled()) - { - logger.debug(msg, e); - } - else - { - logger.warn(msg); - } - writeLine(msg); - } - // Record - writeLine(I18NUtil.getMessage(MSG_REWRITTEN, authority)); - } - - public void afterProcess() throws Throwable - { - } - }, true); - - - String msg = I18NUtil.getMessage(MSG_SUCCESS, updated, logFile); - return msg; - } -// Keeping this for reference. Actually, the query need only pull back the authority and crc -// private List findMismatchedCrcs() throws Exception -// { -// final List authorityIds = new ArrayList(1000); -// HibernateCallback callback = new HibernateCallback() -// { -// public Object doInHibernate(Session session) -// { -// SQLQuery query = session -// .createSQLQuery( -// " SELECT " + -// " au.id AS authority_id," + -// " au.authority AS authority," + -// " au.crc as crc" + -// " FROM" + -// " alf_authority au"); -// query.addScalar("authority_id", new LongType()); -// query.addScalar("authority", new StringType()); -// query.addScalar("crc", new LongType()); -// return query.scroll(ScrollMode.FORWARD_ONLY); -// } -// }; - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java deleted file mode 100644 index fb7f7cb8f0..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrChainingURSPatch.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.util.Map; - -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.repo.security.sync.ChainingUserRegistrySynchronizer; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.session.ResultContext; -import org.apache.ibatis.session.ResultHandler; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Migrate Chaining User Registry Synchronizer attributes (from 'alf_*attribute*' to 'alf_prop_*') - * - * @author janv - * @since 3.4 - */ -public class MigrateAttrChainingURSPatch extends AbstractPatch -{ - private Log logger = LogFactory.getLog(this.getClass()); - - private static final String MSG_SUCCESS = "patch.migrateAttrChainingURS.result"; - - private AttributeService attributeService; - private PatchDAO patchDAO; - - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - @Override - protected String applyInternal() throws Exception - { - long startTime = System.currentTimeMillis(); - - ChainingURSResultHandler handler = new ChainingURSResultHandler(); - patchDAO.migrateOldAttrChainingURS(handler); - - if (handler.total > 0) - { - logger.info("Processed "+handler.total+" Chaining URS attrs in "+(System.currentTimeMillis()-startTime)/1000+" secs"); - } - - // build the result message - String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total); - // done - return msg; - } - - private class ChainingURSResultHandler implements ResultHandler - { - private int total = 0; - - private ChainingURSResultHandler() - { - } - @SuppressWarnings("unchecked") - public void handleResult(ResultContext context) - { - Map result = (Map)context.getResultObject(); - - String label = (String)result.get("label"); - String zoneId = (String)result.get("zoneId"); - Long lastModified = (Long)result.get("lastModified"); - - attributeService.setAttribute( - lastModified, - ChainingUserRegistrySynchronizer.ROOT_ATTRIBUTE_PATH, label, zoneId); - - if (logger.isTraceEnabled()) - { - logger.trace("Set Chaining URS attr [label="+label+", zoneId="+zoneId+", lastModified="+lastModified+"]"); - } - - total++; - - if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) - { - logger.debug(" Handled " + total + " Chaining URS attributes"); - } - } - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java deleted file mode 100644 index b35518f5b8..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrPropBackedBeanPatch.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.io.Serializable; -import java.net.URLDecoder; -import java.util.HashMap; -import java.util.Map; - -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.MBeanServerConnection; -import javax.management.ObjectName; - -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.session.ResultContext; -import org.apache.ibatis.session.ResultHandler; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Migrate Property-Backed Bean attributes (from 'alf_*attribute*' to 'alf_prop_*') - * - * @author janv - * @since 3.4 - */ -public class MigrateAttrPropBackedBeanPatch extends AbstractPatch implements ApplicationContextAware -{ - private Log logger = LogFactory.getLog(this.getClass()); - - private static final String ROOT_KEY_PBB = ".PropertyBackedBeans"; // see also PropertyBackBeanAdapter.ROOT_ATTRIBUTE_PATH - - private static final String MSG_SUCCESS = "patch.migrateAttrPropBackedBeans.result"; - - private AttributeService attributeService; - private PatchDAO patchDAO; - private MBeanServerConnection mbeanServer; - - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - /* (non-Javadoc) - * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext) - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException - { - // Optional dependency - may not exist in community builds - this.mbeanServer = (MBeanServerConnection) applicationContext.getBean("alfrescoMBeanServer"); - } - - @Override - protected String applyInternal() throws Exception - { - long startTime = System.currentTimeMillis(); - - PBBesultHandler handler = new PBBesultHandler(); - patchDAO.migrateOldAttrPropertyBackedBeans(handler); - handler.setComponent(handler.currentComponentName, handler.attributeMap); // set last component attribute (if any) - - if (handler.total > 0) - { - logger.info("Processed "+handler.total+" Property-Backed Component attrs ("+handler.totalProps+" props) in "+(System.currentTimeMillis()-startTime)/1000+" secs"); - } - - // build the result message - String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total, handler.totalProps); - // done - return msg; - } - - private class PBBesultHandler implements ResultHandler - { - private int total = 0; - private int totalProps = 0; - - private Map attributeMap = new HashMap(10); - private String currentComponentName = ""; - - private PBBesultHandler() - { - } - @SuppressWarnings("unchecked") - public void handleResult(ResultContext context) - { - Map result = (Map)context.getResultObject(); - - String componentName = (String)result.get("componentName"); - String propName = (String)result.get("propName"); - String propValue = (String)result.get("propValue"); - - if (! currentComponentName.equals(componentName)) - { - // write out previous component - note: does nothing on 1st call - setComponent(currentComponentName, attributeMap); - - currentComponentName = componentName; - attributeMap.clear(); - } - - attributeMap.put(propName, propValue); - - totalProps++; - - if (logger.isTraceEnabled()) - { - logger.trace("Read PBB [componentName="+componentName+", propName="+propName+", propValue="+propValue+"]"); - } - } - - // note: args should not be null - public void setComponent(String componentName, Map attributeMap) - { - if (componentName.equals("") || attributeMap.size() == 0) - { - return; - } - - boolean done = false; - try - { - // Go through the subsystem MBean interface in case the subsystem is already live and the cluster needs - // to be resynced - - // Decode the bean ID to a hierarchical object name - String[] components = componentName.split("\\$"); - StringBuilder nameBuff = new StringBuilder(200).append("Alfresco:Type=Configuration,Category=").append( - URLDecoder.decode(components[0], "UTF-8")); - for (int i = 1; i < components.length; i++) - { - nameBuff.append(",id").append(i).append('=').append(URLDecoder.decode(components[i], "UTF-8")); - } - - ObjectName name = new ObjectName(nameBuff.toString()); - if (mbeanServer != null && mbeanServer.isRegistered(name)) - { - AttributeList attributeList = new AttributeList(); - for (Map.Entry entry : attributeMap.entrySet()) - { - attributeList.add(new Attribute(entry.getKey(), entry.getValue())); - } - mbeanServer.setAttributes(name, attributeList); - // We've successfully persisted the attributes. Job done - done = true; - } - } - catch (Exception e) - { - if (logger.isWarnEnabled()) - { - logger - .warn( - "Exception migrating attributes of subsystem " - + componentName - + ". Falling back to repository-only operation. Subsystem may remain out of sync until reboot.", - e); - } - } - - // Fallback: perhaps the subsystem isn't up yet and hasn't exported its bean. Or perhaps an error occurred - // above. Let's persist the new property anyway. - if (!done) - { - attributeService.setAttribute((Serializable) attributeMap, ROOT_KEY_PBB, componentName); - } - - if (logger.isTraceEnabled()) - { - logger.trace("Set PBB component attr [name="+componentName+", attributeMap="+attributeMap+"]"); - } - - total++; - - if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) - { - logger.debug(" Handled " + total + " Chaining URS attrs"); - } - } - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java deleted file mode 100644 index 6a2adc04a9..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/MigrateAttrTenantsPatch.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco 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 3 of the License, or - * (at your option) any later version. - * - * Alfresco 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 Alfresco. If not, see . - */ -package org.alfresco.repo.admin.patch.impl; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.Map; - -import org.alfresco.repo.admin.patch.AbstractPatch; -import org.alfresco.repo.domain.patch.PatchDAO; -import org.alfresco.repo.tenant.MultiTAdminServiceImpl; -import org.alfresco.service.cmr.attributes.AttributeService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.ibatis.session.ResultContext; -import org.apache.ibatis.session.ResultHandler; -import org.springframework.extensions.surf.util.I18NUtil; - -/** - * Migrate Tenant attributes (from 'alf_*attribute*' to 'alf_prop_*') - * - * @author janv - * @since 3.4 - */ -public class MigrateAttrTenantsPatch extends AbstractPatch -{ - private Log logger = LogFactory.getLog(this.getClass()); - - private static final String MSG_SUCCESS = "patch.migrateAttrTenants.result"; - - private AttributeService attributeService; - private PatchDAO patchDAO; - - public void setAttributeService(AttributeService attributeService) - { - this.attributeService = attributeService; - } - - public void setPatchDAO(PatchDAO patchDAO) - { - this.patchDAO = patchDAO; - } - - @Override - protected String applyInternal() throws Exception - { - long startTime = System.currentTimeMillis(); - - TenantResultHandler handler = new TenantResultHandler(); - patchDAO.migrateOldAttrTenants(handler); - - if (handler.total > 0) - { - logger.info("Processed "+handler.total+" Tenant attrs in "+(System.currentTimeMillis()-startTime)/1000+" secs"); - } - - // build the result message - String msg = I18NUtil.getMessage(MSG_SUCCESS, handler.total); - // done - return msg; - } - - /** - * Row handler for migrating tenants - */ - private class TenantResultHandler implements ResultHandler - { - private int total = 0; - - private TenantResultHandler() - { - } - @SuppressWarnings("unchecked") - public void handleResult(ResultContext context) - { - Map result = (Map)context.getResultObject(); - - String tenantDomain = (String)result.get("tenantDomain"); - Boolean isEnabled = (Boolean)result.get("isEnabled"); - String rootDir = (String)result.get("rootDir"); - - Map tenantAttributes = new HashMap(7); - tenantAttributes.put(MultiTAdminServiceImpl.TENANT_ATTRIBUTE_ENABLED, isEnabled.booleanValue()); - tenantAttributes.put(MultiTAdminServiceImpl.TENANT_ATTRIBUTE_ROOT_CONTENT_STORE_DIR, rootDir); - - attributeService.setAttribute( - (Serializable) tenantAttributes, - MultiTAdminServiceImpl.TENANTS_ATTRIBUTE_PATH, tenantDomain); - - if (logger.isTraceEnabled()) - { - logger.trace("Set Tenant attr [tenantDomain="+tenantDomain+", isEnabled="+isEnabled+", rootDir="+rootDir+"]"); - } - - total++; - - if (logger.isDebugEnabled() && (total == 0 || (total % 1000 == 0) )) - { - logger.debug(" Handled " + total + " tenant attributes"); - } - } - } -} diff --git a/source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java b/source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java index 2904c235e0..288aa2ad66 100644 --- a/source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java +++ b/source/java/org/alfresco/repo/tenant/MultiTenantBootstrap.java @@ -18,12 +18,7 @@ */ package org.alfresco.repo.tenant; -import java.util.List; - -import org.alfresco.repo.admin.patch.AppliedPatch; import org.alfresco.repo.admin.patch.PatchService; -import org.alfresco.repo.admin.patch.impl.MigrateAttrTenantsPatch; -import org.alfresco.service.descriptor.Descriptor; import org.alfresco.service.descriptor.DescriptorService; import org.alfresco.util.PropertyCheck; import org.springframework.context.ApplicationEvent; @@ -32,13 +27,12 @@ import org.springframework.extensions.surf.util.AbstractLifecycleBean; /** * This component is responsible for starting the enabled tenants (if MT is enabled). * - * @author Derek Hulley, janv + * @author janv */ public class MultiTenantBootstrap extends AbstractLifecycleBean { private TenantAdminService tenantAdminService; private PatchService patchService; - private MigrateAttrTenantsPatch migrateAttrTenantsPatch; private DescriptorService descriptorService; /** @@ -59,43 +53,16 @@ public class MultiTenantBootstrap extends AbstractLifecycleBean this.descriptorService = descriptorService; } - public void setMigrateAttrTenantsPatch(MigrateAttrTenantsPatch migrateAttrTenantsPatch) - { - this.migrateAttrTenantsPatch = migrateAttrTenantsPatch; - } - @Override protected void onBootstrap(ApplicationEvent event) { PropertyCheck.mandatory(this, "tenantAdminService", tenantAdminService); PropertyCheck.mandatory(this, "patchService", patchService); PropertyCheck.mandatory(this, "descriptorService", descriptorService); - + + // TODO: Is it really necessary to count the tenants? if (tenantAdminService.getAllTenants().size() > 0) { - // note: alf*attributes* tables do not exist from Alfresco 4.0.0 schema 5007 - Descriptor desc = descriptorService.getInstalledRepositoryDescriptor(); - if ((desc != null) && (desc.getSchema() < 5007) && (tenantAdminService.getAllTenants().size() == 0)) - { - // could be an upgrade (from before 3.4) - boolean applied = false; - List appliedPatches = patchService.getPatches(null, null); - for (AppliedPatch appliedPatch : appliedPatches) - { - if (appliedPatch.getId().equals("patch.migrateAttrTenants")) - { - applied = true; - break; - } - } - - if (! applied) - { - // upgrade to 3.4 or higher (chicken & egg) - migrateAttrTenantsPatch.apply(); - } - } - tenantAdminService.startTenants(); } }