diff --git a/config/alfresco/action-services-context.xml b/config/alfresco/action-services-context.xml
index 4f97d7da4a..9be5d613ce 100644
--- a/config/alfresco/action-services-context.xml
+++ b/config/alfresco/action-services-context.xml
@@ -488,6 +488,9 @@
+
+
+
false
diff --git a/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java b/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java
index 6c259a018f..5af82684d6 100644
--- a/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java
+++ b/source/java/org/alfresco/repo/avm/actions/AVMUndoSandboxListAction.java
@@ -4,16 +4,20 @@
package org.alfresco.repo.avm.actions;
import java.util.List;
+import java.util.Map;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
+import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
+import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.apache.log4j.Logger;
@@ -36,11 +40,21 @@ public class AVMUndoSandboxListAction extends ActionExecuterAbstractBase
* The AVM Service reference.
*/
private AVMService fAVMService;
+
+ /**
+ * The AVM Locking Service reference.
+ */
+ private AVMLockingService fAVMLockingService;
public void setAvmService(AVMService service)
{
fAVMService = service;
}
+
+ public void setAvmLockingService(AVMLockingService service)
+ {
+ fAVMLockingService = service;
+ }
/* (non-Javadoc)
* @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef)
@@ -65,8 +79,26 @@ public class AVMUndoSandboxListAction extends ActionExecuterAbstractBase
AVMNodeDescriptor parent = fAVMService.lookup(-1, parentChild[0], true);
if (parent.isLayeredDirectory())
{
+ if (fgLogger.isDebugEnabled())
+ fgLogger.debug("reverting " + parentChild[1] + " in " + parentChild[0]);
fAVMService.makeTransparent(parentChild[0], parentChild[1]);
}
+
+ final Map dnsProperties = fAVMService.queryStorePropertyKey(item.getSecond().split(":")[0], QName.createQName(null, ".dns%"));
+ String webProject = dnsProperties.keySet().iterator().next().getLocalName();
+ webProject = webProject.substring(webProject.lastIndexOf('.') + 1, webProject.length());
+ String path = item.getSecond().substring(item.getSecond().indexOf(":") + 1);
+ if (fgLogger.isDebugEnabled())
+ fgLogger.debug("unlocking file " + path + " in web project " + webProject);
+
+ if (fAVMLockingService.getLock(webProject, path) != null)
+ {
+ fAVMLockingService.removeLock(webProject, path);
+ }
+ else
+ {
+ fgLogger.warn("expected file " + path + " in " + webProject + " to be locked");
+ }
}
}
diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java
index cf2b14e666..b857a2a68a 100644
--- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java
+++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java
@@ -24,17 +24,22 @@ package org.alfresco.repo.avm.wf;
import java.io.Serializable;
import java.util.List;
+import java.util.Map;
import org.alfresco.repo.avm.AVMDAOs;
import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.workflow.jbpm.JBPMNode;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
+import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMService;
+import org.alfresco.service.cmr.avm.locking.AVMLockingService;
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;
@@ -59,6 +64,11 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
*/
private AVMSubmittedAspect fAVMSubmittedAspect;
+ /**
+ * The AVMLockingService instance.
+ */
+ private AVMLockingService fAVMLockingService;
+
/**
* The AVMSubmitTransactionListener instance
* (for JMX notification of virtualization server after commit/rollback).
@@ -73,8 +83,9 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
@Override
protected void initialiseHandler(BeanFactory factory)
{
- fAVMService = (AVMService)factory.getBean("AVMService");
- fAVMSyncService = (AVMSyncService)factory.getBean("AVMSyncService");
+ fAVMService = (AVMService)factory.getBean(ServiceRegistry.AVM_SERVICE.getLocalName());
+ fAVMSyncService = (AVMSyncService)factory.getBean(ServiceRegistry.AVM_SYNC_SERVICE.getLocalName());
+ fAVMLockingService = (AVMLockingService)factory.getBean(ServiceRegistry.AVM_LOCKING_SERVICE.getLocalName());
fAVMSubmittedAspect = (AVMSubmittedAspect)factory.getBean("AVMSubmittedAspect");
fAVMSubmitTransactionListener = (AVMSubmitTransactionListener) factory.getBean("AVMSubmitTransactionListener");
@@ -85,23 +96,28 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
* Do the actual work.
* @param executionContext The context to get stuff from.
*/
- public void execute(ExecutionContext executionContext) throws Exception
+ public void execute(final ExecutionContext executionContext)
+ throws Exception
{
// TODO: Allow submit parameters to be passed into this action handler
// rather than pulling directly from execution context
- NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
- Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
+ final NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
+ final Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
// submit the package changes
- String description = (String)executionContext.getContextInstance().getVariable("bpm_workflowDescription");
- String tag = (String)executionContext.getContextInstance().getVariable("wcmwf_label");
- AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
- String targetPath = pkgDesc.getIndirection();
- List stagingDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null);
- for (AVMDifference diff : stagingDiffs)
+ final String description = (String)executionContext.getContextInstance().getVariable("bpm_workflowDescription");
+ final String tag = (String)executionContext.getContextInstance().getVariable("wcmwf_label");
+ final AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
+ final String targetPath = pkgDesc.getIndirection();
+ final Map dnsProperties = this.fAVMService.queryStorePropertyKey(targetPath.split(":")[0], QName.createQName(null, ".dns%"));
+ String webProject = dnsProperties.keySet().iterator().next().getLocalName();
+ webProject = webProject.substring(webProject.lastIndexOf('.') + 1, webProject.length());
+ final List stagingDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null);
+ for (final AVMDifference diff : stagingDiffs)
{
fAVMSubmittedAspect.clearSubmitted(diff.getSourceVersion(), diff.getSourcePath());
+ this.fAVMLockingService.removeLock(webProject, diff.getSourcePath().substring(diff.getSourcePath().indexOf(":") + 1));
}
// Allow AVMSubmitTransactionListener to inspect the staging diffs
@@ -113,7 +129,6 @@ public class AVMSubmitPackageHandler extends JBPMSpringActionHandler implements
AlfrescoTransactionSupport.bindResource("staging_diffs", stagingDiffs);
-
fAVMSyncService.update(stagingDiffs, null, false, false, true, true, tag, description);
// flatten source folder where changes were submitted from
diff --git a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java
index c317446cba..8eec136cbe 100644
--- a/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java
+++ b/source/java/org/alfresco/repo/service/ServiceDescriptorRegistry.java
@@ -323,6 +323,15 @@ public class ServiceDescriptorRegistry
{
return (AVMService)getService(AVM_SERVICE);
}
+
+ /**
+ * Get the AVMService.
+ * @return The AVMService or null if there is none.
+ */
+ public AVMService getAVMLockingAwareService()
+ {
+ return (AVMService)getService(AVM_LOCKING_AWARE_SERVICE);
+ }
/**
* Get the AVM Sync Service.
diff --git a/source/java/org/alfresco/service/ServiceRegistry.java b/source/java/org/alfresco/service/ServiceRegistry.java
index 7370373cdf..9b647366f7 100644
--- a/source/java/org/alfresco/service/ServiceRegistry.java
+++ b/source/java/org/alfresco/service/ServiceRegistry.java
@@ -107,6 +107,7 @@ public interface ServiceRegistry
static final QName OWNABLE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "OwnableService");
static final QName PERSON_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "PersonService");
static final QName AVM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMService");
+ static final QName AVM_LOCKING_AWARE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMLockingAwareService");
static final QName AVM_SYNC_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMSyncService");
static final QName CROSS_REPO_COPY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CrossRepositoryCopyService");
static final QName ATTRIBUTE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AttributeService");
@@ -301,6 +302,13 @@ public interface ServiceRegistry
*/
@NotAuditable
AVMService getAVMService();
+
+ /**
+ * Get the AVMLockingAwareService.
+ * @return The AVM locking aware service (or null if one is not provided);
+ */
+ @NotAuditable
+ AVMService getAVMLockingAwareService();
/**
* Get the AVM Sync Service.