From f99a06df88c988f4dc85ce4c19c8786acf375d9f Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Thu, 7 Jun 2012 11:26:35 +0000 Subject: [PATCH] Merged V4.0-BUG-FIX to HEAD 37410: ALF-14386 HttpClient returns a null byte array if there is no response body (eg 204), swap that for an empty array to avoid NPEs and better fit the interface contract 37439: ALF-13979: Schema comparison NPE when encountering a keyless table 37443: Hand merge of second round of PATH query improvements for ALF-13404 to doclib2 API scripts 37480: Merged V4.0 to V4.0-BUG-FIX 37470: ALF-14434: Specify a START WITH value for the rebuilt alf_acl_change_set primary key on DB2 37475: ALF-13839: Transaction purging didn't work on SQL Server! 37484: Merged PATCHES/V3.4.6 to V4.0-BUG-FIX (RECORD ONLY) 36821: ALF-13827: Make replicated caches recover from temporary comms failures by flushing when a change in peers is detected - We do not flush caches who replicate via copy (e.g. tickets cache) as these may not be recoverable 37487: Merged V3.4-BUG-FIX to V4.0-BUG-FIX 37225: ALF-13617 Revert To Version functionality incorrectly reverts to the wrong version/file 37280: Merged DEV to V3.4-BUG-FIX 37279: ALF-14360 : Missing caches from ehcache-custom.xml.sample.cluster org.alfresco.cache.avm.avmVersionRootEntityCache and org.alfresco.cache.tagscopeSummaryCache were added to the ehcache configuration. 37473: ALF-12081: Ensure that cancel checkout can both unlock and cancel offline edit 37478: Merged BRANCHES/DEV/BELARUS/V3.4-BUG-FIX-2012_05_22 to BRANCHES/DEV/V3.4-BUG-FIX: 37471: ALF-9475 : Remove JBPM indexes present from upgrades 37485: ALF-9475: Fix up schema versions 37488: Merged V3.4-BUG-FIX to V4.0-BUG-FIX (RECORD ONLY) 37330: Merged V4.0-BUG-FIX to V3.4-BUG-FIX 37323: ALF-13247: Two nodes with the same primary path. -Fixed by initializing zone before parallel batch processing begins. 37356: ALF-14392: Merged V4.0-BUG-FIX to V3.4-BUG-FIX 36346: Fix for ALF-9466 - We can search contents sorted by categories in Advanced search in Share, but saved search will not be shown in UI. 37373: Merged PATCHES/V3.4.6 to V3.4-BUG-FIX 36821: ALF-13827 / ALF-14402: Make replicated caches recover from temporary comms failures by flushing when a change in peers is detected - We do not flush caches who replicate via copy (e.g. tickets cache) as these may not be recoverable 37122: ALF-13919 / ALF-14403: Merged DEV to PATCHES/V3.4.6 - Rework of Dmitry's implementation - Uses dynamic HQL query to retrieve JBPM workflow instances by specified query criteria - WorkflowInstancesGet web script no longer has to iterate over every workflow instance in the database! - DB index added to enable efficient querying by string variable - Hibernate tastic! 37188: ALF-13919 / ALF-14403: Worked around HQL polymorphism issues by using explicit variable subclass names in from clause 37204: ALF-13919 / ALF-14403: Fix to date range handling by Dmitry 37481: Merged HEAD to V3.4-BUG-FIX 37388: ALF-13545: First attempt at digitally signing the Windows installers 37391: ALF-13545: Fix quoting and output directory specification 37393: ALF-13545: Correct deployment installer signcode command git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@37491 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/bootstrap-context.xml | 1 + .../remove-redundant-jbpm-indexes.sql | 66 +++++++++++++++++++ .../remove-redundant-jbpm-indexes.sql | 66 +++++++++++++++++++ config/alfresco/ehcache-default.xml | 10 +++ .../ehcache-custom.xml.sample.cluster | 20 +++++- .../node-common-SqlMap.xml | 4 +- .../alfresco/patch/patch-services-context.xml | 11 ++++ config/alfresco/version.properties | 2 +- .../org/alfresco/repo/jscript/ScriptNode.java | 29 +++++--- .../RemoteConnectorResponseImpl.java | 14 +++- .../schemacomp/DbObjectXMLTransformer.java | 5 +- .../DbObjectXMLTransformerTest.java | 23 ++++++- .../alfresco/util/schemacomp/model/Table.java | 7 ++ 13 files changed, 241 insertions(+), 17 deletions(-) create mode 100644 config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/remove-redundant-jbpm-indexes.sql create mode 100644 config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/remove-redundant-jbpm-indexes.sql diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 7eea049604..624183c079 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -166,6 +166,7 @@ + diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/remove-redundant-jbpm-indexes.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/remove-redundant-jbpm-indexes.sql new file mode 100644 index 0000000000..7e8f29c76e --- /dev/null +++ b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.Dialect/remove-redundant-jbpm-indexes.sql @@ -0,0 +1,66 @@ +-- +-- Title: Upgrade to V3.4 - Remove redundant indexes in jbpm tables +-- Database: Generic +-- Since: V3.4 schema 4210 +-- Author: Pavel Yurkevich +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- + +DROP INDEX IDX_ACTION_ACTNDL ON JBPM_ACTION; -- (optional) +DROP INDEX IDX_ACTION_EVENT ON JBPM_ACTION; -- (optional) +DROP INDEX IDX_ACTION_PROCDF ON JBPM_ACTION; -- (optional) +DROP INDEX IDX_COMMENT_TOKEN ON JBPM_COMMENT; -- (optional) +DROP INDEX IDX_COMMENT_TSK ON JBPM_COMMENT; -- (optional) +DROP INDEX IDX_DELEG_PRCD ON JBPM_DELEGATION; -- (optional) +DROP INDEX IDX_JOB_PRINST ON JBPM_JOB; -- (optional) +DROP INDEX IDX_JOB_TOKEN ON JBPM_JOB; -- (optional) +DROP INDEX IDX_JOB_TSKINST ON JBPM_JOB; -- (optional) +DROP INDEX IDX_MODDEF_PROCDF ON JBPM_MODULEDEFINITION; -- (optional) +DROP INDEX IDX_MODINST_PRINST ON JBPM_MODULEINSTANCE; -- (optional) +DROP INDEX IDX_NODE_ACTION ON JBPM_NODE; -- (optional) +DROP INDEX IDX_NODE_PROCDEF ON JBPM_NODE; -- (optional) +DROP INDEX IDX_NODE_SUPRSTATE ON JBPM_NODE; -- (optional) +DROP INDEX IDX_PSTATE_SBPRCDEF ON JBPM_NODE; -- (optional) +DROP INDEX IDX_PLDACTR_ACTID ON JBPM_POOLEDACTOR; -- (optional) +DROP INDEX IDX_TSKINST_SWLANE ON JBPM_POOLEDACTOR; -- (optional) +DROP INDEX IDX_PROCDEF_STRTST ON JBPM_PROCESSDEFINITION; -- (optional) +DROP INDEX IDX_PROCIN_KEY ON JBPM_PROCESSINSTANCE; -- (optional) +DROP INDEX IDX_PROCIN_PROCDEF ON JBPM_PROCESSINSTANCE; -- (optional) +DROP INDEX IDX_PROCIN_ROOTTK ON JBPM_PROCESSINSTANCE; -- (optional) +DROP INDEX IDX_PROCIN_SPROCTK ON JBPM_PROCESSINSTANCE; -- (optional) +DROP INDEX IDX_RTACTN_ACTION ON JBPM_RUNTIMEACTION; -- (optional) +DROP INDEX IDX_RTACTN_PRCINST ON JBPM_RUNTIMEACTION; -- (optional) +DROP INDEX IDX_SWIMLINST_SL ON JBPM_SWIMLANEINSTANCE; -- (optional) +DROP INDEX IDX_TASK_PROCDEF ON JBPM_TASK; -- (optional) +DROP INDEX IDX_TASK_TASKMGTDF ON JBPM_TASK; -- (optional) +DROP INDEX IDX_TASK_TSKNODE ON JBPM_TASK; -- (optional) +DROP INDEX IDX_TASKINST_TOKN ON JBPM_TASKINSTANCE; -- (optional) +DROP INDEX IDX_TASKINST_TSK ON JBPM_TASKINSTANCE; -- (optional) +DROP INDEX IDX_TASK_ACTORID ON JBPM_TASKINSTANCE; -- (optional) +DROP INDEX IDX_TSKINST_SLINST ON JBPM_TASKINSTANCE; -- (optional) +DROP INDEX IDX_TSKINST_TMINST ON JBPM_TASKINSTANCE; -- (optional) +DROP INDEX IDX_TOKEN_NODE ON JBPM_TOKEN; -- (optional) +DROP INDEX IDX_TOKEN_PARENT ON JBPM_TOKEN; -- (optional) +DROP INDEX IDX_TOKEN_PROCIN ON JBPM_TOKEN; -- (optional) +DROP INDEX IDX_TOKEN_SUBPI ON JBPM_TOKEN; -- (optional) +DROP INDEX IDX_TKVARMAP_CTXT ON JBPM_TOKENVARIABLEMAP; -- (optional) +DROP INDEX IDX_TKVVARMP_TOKEN ON JBPM_TOKENVARIABLEMAP; -- (optional) +DROP INDEX IDX_TRANSIT_FROM ON JBPM_TRANSITION; -- (optional) +DROP INDEX IDX_TRANSIT_TO ON JBPM_TRANSITION; -- (optional) +DROP INDEX IDX_TRANS_PROCDEF ON JBPM_TRANSITION; -- (optional) +DROP INDEX IDX_VARINST_PRCINS ON JBPM_VARIABLEINSTANCE; -- (optional) +DROP INDEX IDX_VARINST_TK ON JBPM_VARIABLEINSTANCE; -- (optional) +DROP INDEX IDX_VARINST_TKVARMP ON JBPM_VARIABLEINSTANCE; -- (optional) + +-- +-- Record script finish +-- +DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-remove-redundant-jbpm-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-remove-redundant-jbpm-indexes', 'Manually executed script upgrade V3.4', + 0, 6010, -1, 6011, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' + ); diff --git a/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/remove-redundant-jbpm-indexes.sql b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/remove-redundant-jbpm-indexes.sql new file mode 100644 index 0000000000..c5959873ea --- /dev/null +++ b/config/alfresco/dbscripts/upgrade/3.4/org.hibernate.dialect.PostgreSQLDialect/remove-redundant-jbpm-indexes.sql @@ -0,0 +1,66 @@ +-- +-- Title: Upgrade to V3.4 - Remove redundant indexes in jbpm tables +-- Database: PostgreSQL +-- Since: V3.4 schema 4210 +-- Author: Pavel Yurkevich +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- + +DROP INDEX IDX_ACTION_ACTNDL; -- (optional) +DROP INDEX IDX_ACTION_EVENT; -- (optional) +DROP INDEX IDX_ACTION_PROCDF; -- (optional) +DROP INDEX IDX_COMMENT_TOKEN; -- (optional) +DROP INDEX IDX_COMMENT_TSK; -- (optional) +DROP INDEX IDX_DELEG_PRCD; -- (optional) +DROP INDEX IDX_JOB_PRINST; -- (optional) +DROP INDEX IDX_JOB_TOKEN; -- (optional) +DROP INDEX IDX_JOB_TSKINST; -- (optional) +DROP INDEX IDX_MODDEF_PROCDF; -- (optional) +DROP INDEX IDX_MODINST_PRINST; -- (optional) +DROP INDEX IDX_NODE_ACTION; -- (optional) +DROP INDEX IDX_NODE_PROCDEF; -- (optional) +DROP INDEX IDX_NODE_SUPRSTATE; -- (optional) +DROP INDEX IDX_PSTATE_SBPRCDEF; -- (optional) +DROP INDEX IDX_PLDACTR_ACTID; -- (optional) +DROP INDEX IDX_TSKINST_SWLANE; -- (optional) +DROP INDEX IDX_PROCDEF_STRTST; -- (optional) +DROP INDEX IDX_PROCIN_KEY; -- (optional) +DROP INDEX IDX_PROCIN_PROCDEF; -- (optional) +DROP INDEX IDX_PROCIN_ROOTTK; -- (optional) +DROP INDEX IDX_PROCIN_SPROCTK; -- (optional) +DROP INDEX IDX_RTACTN_ACTION; -- (optional) +DROP INDEX IDX_RTACTN_PRCINST; -- (optional) +DROP INDEX IDX_SWIMLINST_SL; -- (optional) +DROP INDEX IDX_TASK_PROCDEF; -- (optional) +DROP INDEX IDX_TASK_TASKMGTDF; -- (optional) +DROP INDEX IDX_TASK_TSKNODE; -- (optional) +DROP INDEX IDX_TASKINST_TOKN; -- (optional) +DROP INDEX IDX_TASKINST_TSK; -- (optional) +DROP INDEX IDX_TASK_ACTORID; -- (optional) +DROP INDEX IDX_TSKINST_SLINST; -- (optional) +DROP INDEX IDX_TSKINST_TMINST; -- (optional) +DROP INDEX IDX_TOKEN_NODE; -- (optional) +DROP INDEX IDX_TOKEN_PARENT; -- (optional) +DROP INDEX IDX_TOKEN_PROCIN; -- (optional) +DROP INDEX IDX_TOKEN_SUBPI; -- (optional) +DROP INDEX IDX_TKVARMAP_CTXT; -- (optional) +DROP INDEX IDX_TKVVARMP_TOKEN; -- (optional) +DROP INDEX IDX_TRANSIT_FROM; -- (optional) +DROP INDEX IDX_TRANSIT_TO; -- (optional) +DROP INDEX IDX_TRANS_PROCDEF; -- (optional) +DROP INDEX IDX_VARINST_PRCINS; -- (optional) +DROP INDEX IDX_VARINST_TK; -- (optional) +DROP INDEX IDX_VARINST_TKVARMP; -- (optional) + +-- +-- Record script finish +-- +DELETE FROM alf_applied_patch WHERE id = 'patch.db-V3.4-remove-redundant-jbpm-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-remove-redundant-jbpm-indexes', 'Manually executed script upgrade V3.4', + 0, 6010, -1, 6011, null, 'UNKOWN', ${TRUE}, ${TRUE}, 'Script completed' + ); diff --git a/config/alfresco/ehcache-default.xml b/config/alfresco/ehcache-default.xml index 8376ab6b42..971cf63ae7 100644 --- a/config/alfresco/ehcache-default.xml +++ b/config/alfresco/ehcache-default.xml @@ -377,6 +377,16 @@ statistics="false" /> + + + + + + + + + + delete from - alf_transaction txn + alf_transaction where not exists ( select 1 from alf_node node where - node.transaction_id = txn.id + node.transaction_id = alf_transaction.id ) = #{minCommitTime}]]> diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index b79259f006..616ce2b65a 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -3222,4 +3222,15 @@ + + patch.db-V3.4-remove-redundant-jbpm-indexes + patch.schemaUpgradeScript.description + 0 + 5035 + 5036 + + classpath:alfresco/dbscripts/upgrade/3.4/${db.script.dialect}/remove-redundant-jbpm-indexes.sql + + + diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index 8ba94036b4..4169d3b41d 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -19,4 +19,4 @@ version.build=@build-number@ # Schema number -version.schema=6010 +version.schema=6011 diff --git a/source/java/org/alfresco/repo/jscript/ScriptNode.java b/source/java/org/alfresco/repo/jscript/ScriptNode.java index 547499354a..80d4935b7e 100644 --- a/source/java/org/alfresco/repo/jscript/ScriptNode.java +++ b/source/java/org/alfresco/repo/jscript/ScriptNode.java @@ -2022,20 +2022,22 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider return null; } - // Checkout the node if required - ScriptNode workingCopy = this; - if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) + ScriptNode originalNode = this; + //cancel editing if we want to revert + if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)) { - workingCopy = checkout(); + originalNode = cancelCheckout(); } - // Checkin the node - to get the new version - workingCopy = workingCopy.checkin(history, majorVersion); - // Revert the new (current) version of the node - services.getVersionService().revert(workingCopy.nodeRef, version, deep); + services.getVersionService().revert(originalNode.getNodeRef(), version, deep); - return workingCopy; + // Checkout/Checkin the node - to store the new version in version history + ScriptNode workingCopy = originalNode.checkout(); + originalNode = workingCopy.checkin(history, majorVersion); + + + return originalNode; } /** @@ -2414,6 +2416,15 @@ public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider return newInstance(original, this.services, this.scope); } + /** + * Removes the lock on a node. + * + */ + public void unlock() + { + this.services.getLockService().unlock(this.nodeRef); + } + /** * Cancel the check-out of a working copy document. The working copy will be deleted and any changes made to it * are lost. Note that this method can only be called on a working copy Node. The reference to this working copy diff --git a/source/java/org/alfresco/repo/remoteconnector/RemoteConnectorResponseImpl.java b/source/java/org/alfresco/repo/remoteconnector/RemoteConnectorResponseImpl.java index 6b0726fcd3..dff666c3a1 100644 --- a/source/java/org/alfresco/repo/remoteconnector/RemoteConnectorResponseImpl.java +++ b/source/java/org/alfresco/repo/remoteconnector/RemoteConnectorResponseImpl.java @@ -67,9 +67,19 @@ public class RemoteConnectorResponseImpl implements RemoteConnectorResponse public RemoteConnectorResponseImpl(RemoteConnectorRequest request, String contentType, String charset, int status, Header[] headers, byte[] response) { - this(request, contentType, charset, status, headers, new ByteArrayInputStream(response)); - this.bodyBytes = response; + this(request, contentType, charset, status, headers, new ByteArrayInputStream(ensureBytes(response))); + this.bodyBytes = ensureBytes(response); } + /** + * HttpClient will return a null response body for things like 204 (No Content). + * We want to treat that as an empty byte array, to meet our contracts + */ + private static byte[] ensureBytes(byte[] bytes) + { + if (bytes == null) return EMPTY_BYTE_ARRAY; + return bytes; + } + private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; @Override public int getStatus() diff --git a/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformer.java b/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformer.java index 9a2b986940..d347966808 100644 --- a/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformer.java +++ b/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformer.java @@ -206,7 +206,10 @@ public class DbObjectXMLTransformer simpleEndTag(XML.EL_COLUMNS); // Output primary key - output(table.getPrimaryKey()); + if (table.hasPrimaryKey()) + { + output(table.getPrimaryKey()); + } // Output foreign keys simpleStartTag(XML.EL_FOREIGN_KEYS); diff --git a/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java b/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java index 6f67e7ea15..7b85635f6b 100644 --- a/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java +++ b/source/java/org/alfresco/util/schemacomp/DbObjectXMLTransformerTest.java @@ -24,6 +24,7 @@ import static org.alfresco.util.schemacomp.SchemaCompTestingUtils.fk; import static org.alfresco.util.schemacomp.SchemaCompTestingUtils.fkeys; import static org.alfresco.util.schemacomp.SchemaCompTestingUtils.indexes; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.BufferedReader; @@ -264,6 +265,26 @@ public class DbObjectXMLTransformerTest assertEquals("", reader.readLine()); } + /** + * ALF-13979: empty table causes NPE during schema export. + * @throws IOException + */ + @Test + public void transformTableWithoutPrimaryKey() throws IOException + { + Table table = new Table("my_table"); + assertFalse(table.hasPrimaryKey()); + + transformer.output(table); + + BufferedReader reader = new BufferedReader(new StringReader(writer.toString())); + dumpOutput(); + assertHasPreamble(reader); + skipUntilEnd(" {columns}", reader, true); + skipUntilEnd(" {foreignkeys}", reader, true); + skipUntilEnd(" {indexes}", reader, true); + assertEquals("", reader.readLine()); + } @Test public void transformObjectWithValidators() throws IOException @@ -332,7 +353,7 @@ public class DbObjectXMLTransformerTest { textToFind = textToFind.trim(). replace("{", "<"). - replace("}", "\\s+.*/>"); + replace("}", ".*/>"); } else { diff --git a/source/java/org/alfresco/util/schemacomp/model/Table.java b/source/java/org/alfresco/util/schemacomp/model/Table.java index 9e242960d6..340dd06d62 100644 --- a/source/java/org/alfresco/util/schemacomp/model/Table.java +++ b/source/java/org/alfresco/util/schemacomp/model/Table.java @@ -102,6 +102,13 @@ public class Table extends AbstractDbObject return this.primaryKey; } + /** + * @return Whether there is a primary key on this table. + */ + public boolean hasPrimaryKey() + { + return (primaryKey != null); + } /** * @param primaryKey the primaryKey to set