diff --git a/config/alfresco/dbscripts/upgrade/2.0/org.hibernate.dialect.PostgreSQLDialect/AlfrescoSchemaUpdate-2.0-AVMFKIndexes.sql b/config/alfresco/dbscripts/upgrade/2.0/org.hibernate.dialect.PostgreSQLDialect/AlfrescoSchemaUpdate-2.0-AVMFKIndexes.sql
new file mode 100644
index 0000000000..3985a05789
--- /dev/null
+++ b/config/alfresco/dbscripts/upgrade/2.0/org.hibernate.dialect.PostgreSQLDialect/AlfrescoSchemaUpdate-2.0-AVMFKIndexes.sql
@@ -0,0 +1,35 @@
+--
+-- Title: AVM Foreign Key indexes
+-- Database: PostgreSQL
+-- Since: V2.0 Schema 38
+-- Author: Derek Hulley
+--
+-- Please contact support@alfresco.com if you need assistance with the upgrade.
+--
+
+CREATE INDEX fk_avm_asp_node ON avm_aspects (node_id);
+CREATE INDEX fk_avm_ce_child ON avm_child_entries (child_id);
+CREATE INDEX fk_avm_ce_parent ON avm_child_entries (parent_id);
+CREATE INDEX fk_avm_hl_desc ON avm_history_links (descendent);
+CREATE INDEX fk_avm_hl_ancestor ON avm_history_links (ancestor);
+CREATE INDEX fk_avm_ml_from ON avm_merge_links (mfrom);
+CREATE INDEX fk_avm_ml_to ON avm_merge_links (mto);
+CREATE INDEX fk_avm_np_node ON avm_node_properties (node_id);
+CREATE INDEX fk_avm_n_acl ON avm_nodes (acl_id);
+CREATE INDEX fk_avm_n_store ON avm_nodes (store_new_id);
+CREATE INDEX fk_avm_sp_store ON avm_store_properties (avm_store_id);
+CREATE INDEX fk_avm_s_root ON avm_stores (current_root_id);
+CREATE INDEX fk_avm_vr_store ON avm_version_roots (avm_store_id);
+CREATE INDEX fk_avm_vr_root ON avm_version_roots (root_id);
+
+--
+-- Record script finish
+--
+DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.0-AVMFKIndexes';
+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-V2.0-AVMFKIndexes', 'Manually executed script upgrade V2.0: AVM Foreign Key Indexes',
+ 0, 37, -1, 38, null, 'UNKOWN', TRUE, TRUE, 'Script completed'
+ );
\ No newline at end of file
diff --git a/config/alfresco/dbscripts/upgrade/2.0/org.hibernate.dialect.PostgreSQLDialect/AlfrescoSchemaUpdate-2.0-ExplicitIndexes.sql b/config/alfresco/dbscripts/upgrade/2.0/org.hibernate.dialect.PostgreSQLDialect/AlfrescoSchemaUpdate-2.0-ExplicitIndexes.sql
new file mode 100644
index 0000000000..c610b0f361
--- /dev/null
+++ b/config/alfresco/dbscripts/upgrade/2.0/org.hibernate.dialect.PostgreSQLDialect/AlfrescoSchemaUpdate-2.0-ExplicitIndexes.sql
@@ -0,0 +1,66 @@
+--
+-- Title: Explicit indexes
+-- Database: PostgreSQL
+-- Since: V2.0 Schema 38
+-- Author: Derek Hulley
+--
+-- Please contact support@alfresco.com if you need assistance with the upgrade.
+--
+-- PostgreSQL cannot handle optional statements (statements that may fail) in the
+-- transaction.
+--
+
+-- JBPM tables
+DROP INDEX IF EXISTS IDX_PLDACTR_ACTID;
+CREATE INDEX IDX_PLDACTR_ACTID ON JBPM_POOLEDACTOR (ACTORID_);
+DROP INDEX IF EXISTS IDX_TASK_ACTORID;
+CREATE INDEX IDX_TASK_ACTORID ON JBPM_TASKINSTANCE (ACTORID_);
+
+-- Audit tables
+DROP INDEX IF EXISTS adt_q_idx;
+CREATE INDEX adt_q_idx ON alf_audit_date (quarter);
+DROP INDEX IF EXISTS adt_dow_idx;
+CREATE INDEX adt_dow_idx ON alf_audit_date (day_of_week);
+DROP INDEX IF EXISTS adt_date_idx;
+CREATE INDEX adt_date_idx ON alf_audit_date (date_only);
+DROP INDEX IF EXISTS adt_y_idx;
+CREATE INDEX adt_y_idx ON alf_audit_date (year);
+DROP INDEX IF EXISTS adt_hy_idx;
+CREATE INDEX adt_hy_idx ON alf_audit_date (halfYear);
+DROP INDEX IF EXISTS adt_wom_idx;
+CREATE INDEX adt_wom_idx ON alf_audit_date (week_of_month);
+DROP INDEX IF EXISTS adt_dom_idx;
+CREATE INDEX adt_dom_idx ON alf_audit_date (day_of_month);
+DROP INDEX IF EXISTS adt_m_idx;
+CREATE INDEX adt_m_idx ON alf_audit_date (month);
+DROP INDEX IF EXISTS adt_doy_idx;
+CREATE INDEX adt_doy_idx ON alf_audit_date (day_of_year);
+DROP INDEX IF EXISTS adt_woy_idx;
+CREATE INDEX adt_woy_idx ON alf_audit_date (week_of_year);
+DROP INDEX IF EXISTS adt_user_idx;
+CREATE INDEX adt_user_idx ON alf_audit_fact (user_id);
+DROP INDEX IF EXISTS adt_store_idx;
+CREATE INDEX adt_store_idx ON alf_audit_fact (store_protocol, store_id, node_uuid);
+DROP INDEX IF EXISTS app_source_met_idx;
+CREATE INDEX app_source_met_idx ON alf_audit_source (method);
+DROP INDEX IF EXISTS app_source_app_idx;
+CREATE INDEX app_source_app_idx ON alf_audit_source (application);
+DROP INDEX IF EXISTS app_source_ser_idx;
+CREATE INDEX app_source_ser_idx ON alf_audit_source (service);
+
+-- AVM tables: These are new so are not optional
+CREATE INDEX idx_avm_np_name ON avm_node_properties (qname);
+CREATE INDEX idx_avm_sp_name ON avm_store_properties (qname);
+CREATE INDEX idx_avm_vr_version ON avm_version_roots (version_id);
+
+--
+-- Record script finish
+--
+DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.0-ExplicitIndexes';
+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-V2.0-ExplicitIndexes', 'Manually executed script upgrade V2.0: Explicit Indexes',
+ 0, 37, -1, 38, null, 'UNKOWN', TRUE, TRUE, 'Script completed'
+ );
\ No newline at end of file
diff --git a/config/alfresco/extension/custom-repository.properties.sample b/config/alfresco/extension/custom-repository.properties.sample
index 56ee035323..1e89ff9dc8 100644
--- a/config/alfresco/extension/custom-repository.properties.sample
+++ b/config/alfresco/extension/custom-repository.properties.sample
@@ -58,3 +58,9 @@
#
#db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
#db.url=jdbc:sqlserver://localhost;DatabaseName=alfresco
+
+#
+# PostgreSQL connection (requires postgresql-8.2-504.jdbc3.jar or equivalent)
+#
+#db.driver=org.postgresql.Driver
+#db.url=jdbc:postgresql://localhost:5432/alfresco
diff --git a/config/alfresco/workflow/submit_processdefinition.xml b/config/alfresco/workflow/submit_processdefinition.xml
index b5f8057c5b..f32aaf9a9a 100644
--- a/config/alfresco/workflow/submit_processdefinition.xml
+++ b/config/alfresco/workflow/submit_processdefinition.xml
@@ -139,6 +139,7 @@
+
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java
index efbed57221..f2b5248c50 100644
--- a/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java
+++ b/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java
@@ -25,10 +25,8 @@
package org.alfresco.repo.avm.wf;
import java.util.List;
-import java.util.Map;
import org.alfresco.repo.avm.AVMNodeConverter;
-import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
@@ -36,7 +34,6 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.avmsync.AVMSyncService;
import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
@@ -106,17 +103,6 @@ public class AVMClearSubmittedHandler extends JBPMSpringActionHandler
String submittedPath = from + diff.getSourcePath().substring(pkgPath.getSecond().length());
fAVMSubmittedAspect.clearSubmitted(-1, submittedPath);
}
- // Now delete the stores in the workflow sandbox.
- String [] storePath = pkgPath.getSecond().split(":");
- // Get the sandbox id for the package.
- Map matches = fAVMService.queryStorePropertyKey(storePath[0], QName.createQName(null, ".sandbox-id%"));
- QName sandboxID = matches.keySet().iterator().next();
- // Get all the stores in the sandbox.
- Map> stores = fAVMService.queryStoresPropertyKeys(sandboxID);
- for (String storeName : stores.keySet())
- {
- fAVMService.purgeStore(storeName);
- }
}
}
diff --git a/source/java/org/alfresco/repo/avm/wf/AVMRemoveWFStoreHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMRemoveWFStoreHandler.java
new file mode 100644
index 0000000000..f31f034326
--- /dev/null
+++ b/source/java/org/alfresco/repo/avm/wf/AVMRemoveWFStoreHandler.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing
+ */
+package org.alfresco.repo.avm.wf;
+
+import java.util.Map;
+
+import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.repo.workflow.jbpm.JBPMNode;
+import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
+import org.alfresco.service.cmr.avm.AVMService;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.util.Pair;
+import org.jbpm.graph.exe.ExecutionContext;
+import org.springframework.beans.factory.BeanFactory;
+
+
+/**
+ * Remove WF sandbox
+ *
+ * @author brittp
+ */
+public class AVMRemoveWFStoreHandler extends JBPMSpringActionHandler
+{
+ private static final long serialVersionUID = 4113360751217684995L;
+
+ /**
+ * The AVMService instance.
+ */
+ private AVMService fAVMService;
+
+
+ /**
+ * Initialize service references.
+ * @param factory The BeanFactory to get references from.
+ */
+ @Override
+ protected void initialiseHandler(BeanFactory factory)
+ {
+ fAVMService = (AVMService)factory.getBean("AVMService");
+ }
+
+ /**
+ * Do the actual work.
+ * @param executionContext The context to get stuff from.
+ */
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ // TODO: Allow submit parameters to be passed into this action handler
+ // rather than pulling directly from execution context
+
+ // retrieve submitted package
+ NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
+ Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
+
+ // Now delete the stores in the workflow sandbox.
+ String [] storePath = pkgPath.getSecond().split(":");
+ // Get the sandbox id for the package.
+ Map matches = fAVMService.queryStorePropertyKey(storePath[0], QName.createQName(null, ".sandbox-id%"));
+ QName sandboxID = matches.keySet().iterator().next();
+ // Get all the stores in the sandbox.
+ Map> stores = fAVMService.queryStoresPropertyKeys(sandboxID);
+ for (String storeName : stores.keySet())
+ {
+ fAVMService.purgeStore(storeName);
+ }
+ }
+
+}