mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.1 to HEAD
6408: removing the avmsubmittedaspect 6409: reintroducing the avmclearsubmittedhandler as a stub in order to keep inflight workflows operating properly. 6412: Fix to a subtle navigation issue when browsing WCM projects. 6415: WCM-678 - Page size WCM browse screens 6417: Fixes WCM-556, WCM-557, WCM-618 & WCM-620 Line endings change -- manual merge Manual 'root\projects\web-client\config\alfresco\messages\webclient.properties' git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6731 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -20,109 +20,36 @@
|
||||
* 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"
|
||||
* http://www.alfresco.com/legal/licensing
|
||||
*/
|
||||
package org.alfresco.repo.avm.wf;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
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.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.jbpm.graph.exe.ExecutionContext;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Clear "submitted" mark from (source of) items within the WCM Workflow Package
|
||||
*
|
||||
* @author davidc
|
||||
* No-op stub for the no longer used AVMSubmittedApsect.
|
||||
*/
|
||||
public class AVMClearSubmittedHandler extends JBPMSpringActionHandler
|
||||
{
|
||||
private static final long serialVersionUID = 4113360751217684995L;
|
||||
private static final long serialVersionUID = 4113360751217684995L;
|
||||
|
||||
/**
|
||||
* The AVMService instance.
|
||||
*/
|
||||
private AVMService avmService;
|
||||
|
||||
/**
|
||||
* The AVMSyncService instance.
|
||||
*/
|
||||
private AVMSyncService avmSyncService;
|
||||
|
||||
/**
|
||||
* The AVMSubmittedAspect instance.
|
||||
*/
|
||||
private AVMSubmittedAspect avmSubmittedAspect;
|
||||
|
||||
/**
|
||||
* Initialize service references.
|
||||
* @param factory The BeanFactory to get references from.
|
||||
*/
|
||||
@Override
|
||||
protected void initialiseHandler(BeanFactory factory)
|
||||
{
|
||||
this.avmService = (AVMService)factory.getBean(ServiceRegistry.AVM_SERVICE.getLocalName());
|
||||
this.avmSyncService = (AVMSyncService)factory.getBean(ServiceRegistry.AVM_SYNC_SERVICE.getLocalName());
|
||||
this.avmSubmittedAspect = (AVMSubmittedAspect)factory.getBean("AVMSubmittedAspect");
|
||||
}
|
||||
/**
|
||||
* Initialize service references.
|
||||
* @param factory The BeanFactory to get references from.
|
||||
*/
|
||||
@Override
|
||||
protected void initialiseHandler(BeanFactory factory)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the actual work.
|
||||
* @param executionContext The context to get stuff from.
|
||||
*/
|
||||
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
|
||||
|
||||
// NOTE: Submitted items can only be marked as "submitted" if we know where they came from
|
||||
String from = (String)executionContext.getContextInstance().getVariable("wcmwf_fromPath");
|
||||
if (from == null || from.length() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// retrieve list of changes in submitted package
|
||||
NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
|
||||
Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
|
||||
AVMNodeDescriptor pkgDesc = this.avmService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
|
||||
String targetPath = pkgDesc.getIndirection();
|
||||
final List<AVMDifference> diffs = this.avmSyncService.compare(pkgPath.getFirst(),
|
||||
pkgPath.getSecond(),
|
||||
-1,
|
||||
targetPath,
|
||||
null);
|
||||
|
||||
// for each change, mark original as submitted
|
||||
for (final AVMDifference diff : diffs)
|
||||
{
|
||||
final String submittedPath = from + diff.getSourcePath().substring(pkgPath.getSecond().length());
|
||||
this.clearSubmitted(this.avmService.lookup(-1, submittedPath, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively clear the submitted aspect.
|
||||
*/
|
||||
private void clearSubmitted(final AVMNodeDescriptor d)
|
||||
{
|
||||
this.avmSubmittedAspect.clearSubmitted(d.getVersionID(), d.getPath());
|
||||
if (d.isDirectory())
|
||||
{
|
||||
for (final AVMNodeDescriptor c : this.avmService.getDirectoryListingArray(d, true))
|
||||
{
|
||||
this.clearSubmitted(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Do the actual work.
|
||||
* @param executionContext The context to get stuff from.
|
||||
*/
|
||||
public void execute(ExecutionContext executionContext) throws Exception
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -42,6 +42,8 @@ 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.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.jbpm.graph.exe.ExecutionContext;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
|
||||
@@ -51,24 +53,15 @@ public class AVMSubmitPackageHandler
|
||||
{
|
||||
private static final long serialVersionUID = 4113360751217684995L;
|
||||
|
||||
/**
|
||||
* The AVMService instance.
|
||||
*/
|
||||
private static final Log LOGGER = LogFactory.getLog(AVMSubmitPackageHandler.class);
|
||||
|
||||
/** The AVMService instance. */
|
||||
private AVMService fAVMService;
|
||||
|
||||
/**
|
||||
* The AVMSyncService instance.
|
||||
*/
|
||||
/** The AVMSyncService instance. */
|
||||
private AVMSyncService fAVMSyncService;
|
||||
|
||||
/**
|
||||
* The AVMSubmittedAspect instance.
|
||||
*/
|
||||
private AVMSubmittedAspect fAVMSubmittedAspect;
|
||||
|
||||
/**
|
||||
* The AVMLockingService instance.
|
||||
*/
|
||||
/** The AVMLockingService instance. */
|
||||
private AVMLockingService fAVMLockingService;
|
||||
|
||||
/**
|
||||
@@ -76,19 +69,17 @@ public class AVMSubmitPackageHandler
|
||||
* (for JMX notification of virtualization server after commit/rollback).
|
||||
*/
|
||||
private AVMSubmitTransactionListener fAVMSubmitTransactionListener;
|
||||
|
||||
|
||||
/**
|
||||
* Initialize service references.
|
||||
* @param factory The BeanFactory to get references from.
|
||||
*/
|
||||
@Override
|
||||
protected void initialiseHandler(BeanFactory factory)
|
||||
protected void initialiseHandler(final BeanFactory factory)
|
||||
{
|
||||
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");
|
||||
|
||||
AlfrescoTransactionSupport.bindListener(fAVMSubmitTransactionListener);
|
||||
@@ -103,24 +94,30 @@ public class AVMSubmitPackageHandler
|
||||
{
|
||||
// TODO: Allow submit parameters to be passed into this action handler
|
||||
// rather than pulling directly from execution context
|
||||
|
||||
final NodeRef pkg = ((JBPMNode)executionContext.getContextInstance().getVariable("bpm_package")).getNodeRef();
|
||||
final Pair<Integer, String> pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
|
||||
final AVMNodeDescriptor pkgDesc = fAVMService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
|
||||
final String from = (String)executionContext.getContextInstance().getVariable("wcmwf_fromPath");
|
||||
final String targetPath = pkgDesc.getIndirection();
|
||||
LOGGER.debug("handling submit of " + pkgPath.getSecond() + " from " + from + " to " + targetPath);
|
||||
|
||||
// submit the package changes
|
||||
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<QName, PropertyValue> 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<AVMDifference> stagingDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, targetPath, null);
|
||||
for (final AVMDifference diff : stagingDiffs)
|
||||
{
|
||||
this.recursivelyRemoveLocksAndSubmittedAspect(webProject,
|
||||
diff.getSourceVersion(),
|
||||
diff.getSourcePath());
|
||||
String p = diff.getSourcePath();
|
||||
if (from != null && from.length() != 0)
|
||||
{
|
||||
p = from + p.substring(pkgPath.getSecond().length());
|
||||
}
|
||||
this.recursivelyRemoveLocks(webProject, -1, p);
|
||||
}
|
||||
|
||||
// Allow AVMSubmitTransactionListener to inspect the staging diffs
|
||||
@@ -133,16 +130,17 @@ public class AVMSubmitPackageHandler
|
||||
AlfrescoTransactionSupport.bindResource("staging_diffs", stagingDiffs);
|
||||
|
||||
fAVMSyncService.update(stagingDiffs, null, false, false, true, true, tag, description);
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
fAVMSyncService.flatten(pkgPath.getSecond(), targetPath);
|
||||
|
||||
// flatten source folder where changes were submitted from
|
||||
String from = (String)executionContext.getContextInstance().getVariable("wcmwf_fromPath");
|
||||
if (from != null && from.length() > 0)
|
||||
{
|
||||
// first, submit changes back to sandbox forcing addition of edits in workflow (and submission
|
||||
// flag removal). second, flatten sandbox, removing modified items that have been submitted
|
||||
// TODO: Without locking on the sandbox, it's possible that a change to a "submitted" item
|
||||
// may get lost when the item is finally approved
|
||||
List<AVMDifference> sandboxDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, from, null);
|
||||
final List<AVMDifference> sandboxDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, from, null);
|
||||
fAVMSyncService.update(sandboxDiffs, null, true, true, false, false, tag, description);
|
||||
AVMDAOs.Instance().fAVMNodeDAO.flush();
|
||||
fAVMSyncService.flatten(from, targetPath);
|
||||
@@ -153,10 +151,10 @@ public class AVMSubmitPackageHandler
|
||||
* Recursively remove locks from a path. Walking child folders looking for files
|
||||
* to remove locks from.
|
||||
*/
|
||||
private void recursivelyRemoveLocksAndSubmittedAspect(final String webProject, final int version, final String path)
|
||||
private void recursivelyRemoveLocks(final String webProject, final int version, final String path)
|
||||
{
|
||||
fAVMSubmittedAspect.clearSubmitted(version, path);
|
||||
AVMNodeDescriptor desc = fAVMService.lookup(version, path, true);
|
||||
LOGGER.debug("removing lock on " + path);
|
||||
final AVMNodeDescriptor desc = fAVMService.lookup(version, path, true);
|
||||
if (desc.isFile() || desc.isDeletedFile())
|
||||
{
|
||||
fAVMLockingService.removeLock(webProject, path.substring(path.indexOf(":") + 1));
|
||||
@@ -165,7 +163,7 @@ public class AVMSubmitPackageHandler
|
||||
{
|
||||
for (final AVMNodeDescriptor child : fAVMService.getDirectoryListingArray(version, path, true))
|
||||
{
|
||||
this.recursivelyRemoveLocksAndSubmittedAspect(webProject, version, child.getPath());
|
||||
this.recursivelyRemoveLocks(webProject, version, child.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* 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 org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowException;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
|
||||
/**
|
||||
* Aspect to represent a node is currently taking part in a workflow.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class AVMSubmittedAspect
|
||||
{
|
||||
|
||||
private final static String NAMESPACE_URI = "http://www.alfresco.org/model/wcmworkflow/1.0";
|
||||
|
||||
public final static QName ASPECT = QName.createQName(NAMESPACE_URI, "submitted");
|
||||
public final static QName PROP_WORKFLOW_INSTANCE_ID = QName.createQName(NAMESPACE_URI, "workflowInstanceId");
|
||||
|
||||
|
||||
// Dependencies
|
||||
private AVMService avmService;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the AVM Service
|
||||
*
|
||||
* @param avmService
|
||||
*/
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mark an item as submitted via a workflow
|
||||
*
|
||||
* @param version
|
||||
* @param path
|
||||
* @param workflowInstanceId
|
||||
*/
|
||||
public void markSubmitted(int version, String path, String workflowInstanceId)
|
||||
{
|
||||
String existingWorkflowInstanceId = getWorkflowInstance(version, path);
|
||||
if (existingWorkflowInstanceId != null)
|
||||
{
|
||||
throw new WorkflowException("Node " + path + "[" + version + "] already submitted in workflow " + existingWorkflowInstanceId);
|
||||
}
|
||||
|
||||
ParameterCheck.mandatoryString("workflowInstanceId", workflowInstanceId);
|
||||
avmService.addAspect(path, ASPECT);
|
||||
avmService.setNodeProperty(path, PROP_WORKFLOW_INSTANCE_ID, new PropertyValue(DataTypeDefinition.TEXT, workflowInstanceId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unmark an submitted item
|
||||
*
|
||||
* @param version
|
||||
* @param path
|
||||
*/
|
||||
public void clearSubmitted(int version, String path)
|
||||
{
|
||||
if (avmService.hasAspect(version, path, ASPECT))
|
||||
{
|
||||
avmService.removeAspect(path, ASPECT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the submitted workflow instances for the specified item
|
||||
*
|
||||
* @param version
|
||||
* @param path
|
||||
* @return workflow instance (or null, if not submitted)
|
||||
*/
|
||||
public String getWorkflowInstance(int version, String path)
|
||||
{
|
||||
String workflowInstanceId = null;
|
||||
PropertyValue value = avmService.getNodeProperty(version, path, PROP_WORKFLOW_INSTANCE_ID);
|
||||
if (value != null)
|
||||
{
|
||||
workflowInstanceId = value.getStringValue();
|
||||
}
|
||||
return workflowInstanceId;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user