diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml
index 665fe54040..5cdc9ddc91 100644
--- a/config/alfresco/avm-services-context.xml
+++ b/config/alfresco/avm-services-context.xml
@@ -1,347 +1,342 @@
-
-
-
-
-
-
-
-
-
- node
-
-
-
-
-
-
-
-
- layer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 50
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1000
-
-
- 50
-
-
- 1000
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ node
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- .*/#[^/]*
-
-
-
-
-
-
-
- .o
- .bak
- .tmp
- ~
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- admin
-
-
- jbpm$wcmwf:changerequest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ layer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 50
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1000
+
+
+ 50
+
+
+ 1000
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ .*/#[^/]*
+
+
+
+
+
+
+
+ .o
+ .bak
+ .tmp
+ ~
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ admin
+
+
+ jbpm$wcmwf:changerequest
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- workspace://SpacesStore
-
-
-
-
\ No newline at end of file
+
+
+ workspace://SpacesStore
+
+
+
+
diff --git a/config/alfresco/workflow/submit_processdefinition.xml b/config/alfresco/workflow/submit_processdefinition.xml
index 817896067d..0d39a21685 100644
--- a/config/alfresco/workflow/submit_processdefinition.xml
+++ b/config/alfresco/workflow/submit_processdefinition.xml
@@ -210,9 +210,6 @@
-
-
-
@@ -225,7 +222,6 @@
-
@@ -233,7 +229,6 @@
-
diff --git a/source/java/org/alfresco/linkvalidation/LinkValidationAction.java b/source/java/org/alfresco/linkvalidation/LinkValidationAction.java
index 367e5bf728..08016198bb 100644
--- a/source/java/org/alfresco/linkvalidation/LinkValidationAction.java
+++ b/source/java/org/alfresco/linkvalidation/LinkValidationAction.java
@@ -158,47 +158,21 @@ public class LinkValidationAction extends ActionExecuterAbstractBase
// get the broken files created due to deletions and new/modified files
HrefManifest manifest = this.linkValidationService.getBrokenHrefManifest(hdiff);
- // TODO: use the counts retrieved from the manifest object and pass them
- // into the constructor, the report object can then store these for
- // later retrieval.
-
-// int baseVersion = manifest.getBaseSnapshotVersion();
-// int latestVersion = manifest.getLatestSnapshotVersion();
-// int fileCount = manifest.getBaseFileCount();
-// int linkCount = manifest.getBaseLinkCount();
-
- HrefManifest bogus = new HrefManifest();
-
- // TODO: change the constructor to just take one manifest object
-
// create the report object using the 2 sets of results
- report = new LinkValidationReport(storeName, webappName, monitor, manifest, bogus);
+ report = new LinkValidationReport(storeName, webappName, manifest,
+ monitor.getFileUpdateCount(), monitor.getUrlUpdateCount());
}
else
{
// retrieve the manifest of all the broken links and files for the webapp
HrefManifest manifest = this.linkValidationService.getBrokenHrefManifest(webappPath);
- List manifests =
- manifest.getManifestEntries();
-
- // TODO: use the counts retrieved from the manifest object and pass them
- // into the constructor, the report object can then store these for
- // later retrieval to show how far 'bejind' the report is.
- // NOTE: that latestVersion >= baseVersion
- // Whenever latestVersion > baseVersion,
- // link validation is "behind".
-
-// int baseVersion = manifest.getBaseSnapshotVersion();
-// int latestVersion = manifest.getLatestSnapshotVersion();
-// int fileCount = manifest.getBaseFileCount();
-// int linkCount = manifest.getBaseLinkCount();
-
// Create the report object using the link check results
- report = new LinkValidationReport(storeName, webappName, monitor, manifests);
+ report = new LinkValidationReport(storeName, webappName, manifest,
+ manifest.getBaseFileCount(), manifest.getBaseLinkCount());
- // the monitor object is not used anymore so manually set
- // the done status so the client ca retrieve the report.
+ // the monitor object is not used here so manually set
+ // the done status so the client can retrieve the report.
monitor.setDone( true );
}
}
diff --git a/source/java/org/alfresco/linkvalidation/LinkValidationReport.java b/source/java/org/alfresco/linkvalidation/LinkValidationReport.java
index f871b1e5f7..4695c8f93e 100755
--- a/source/java/org/alfresco/linkvalidation/LinkValidationReport.java
+++ b/source/java/org/alfresco/linkvalidation/LinkValidationReport.java
@@ -52,6 +52,8 @@ public class LinkValidationReport implements Serializable
private int numberFilesChecked = -1;
private int numberLinksChecked = -1;
private int numberBrokenLinks = -1;
+ private int baseSnapshotVersion = -1;
+ private int latestSnapshotVersion = -1;
private boolean successful = true;
private Date completedAt;
@@ -67,21 +69,24 @@ public class LinkValidationReport implements Serializable
*
* @param store The store the link check was run against
* @param webapp The webapp within the store the check was run against
- * @param status The object containing status i.e. file, link counts and the list
- * of files containing broken links
- * @param manifests The manifest of broken links and files
+ * @param manifest The manifest of broken links and snapshot info
+ * @param noFilesChecked The number of files checked
+ * @param noLinksChecked The number of links checked
*/
- public LinkValidationReport(String store, String webapp, HrefValidationProgress status,
- List manifests)
+ public LinkValidationReport(String store, String webapp, HrefManifest manifest,
+ int noFilesChecked, int noLinksChecked)
{
this.store = store;
this.webapp = webapp;
this.completedAt = new Date();
- this.numberFilesChecked = status.getFileUpdateCount();
- this.numberLinksChecked = status.getUrlUpdateCount();
this.numberBrokenLinks = 0;
+ this.numberFilesChecked = noFilesChecked;
+ this.numberLinksChecked = noLinksChecked;
+ this.baseSnapshotVersion = manifest.getBaseSnapshotVersion();
+ this.latestSnapshotVersion = manifest.getLatestSnapshotVersion();
// create list and map
+ List manifests = manifest.getManifestEntries();
this.brokenFiles = new ArrayList(manifests.size());
this.brokenLinksByFile = new HashMap(manifests.size());
@@ -89,43 +94,6 @@ public class LinkValidationReport implements Serializable
storeBrokenFiles(manifests);
}
- /**
- * Constructs a link validation report from the results of a comparison check
- * between the staging area and another sandbox i.e. an authors sandbox or a
- * workflow sandbox.
- *
- * @param store The store the link check was run against
- * @param webapp The webapp within the store the check was run against
- * @param status The object containing status i.e. file, link counts and the list
- * of files containing broken links
- * @param brokenByDelete Object representing the broken links caused by deleted assets
- * @param brokenByNewOrMod Object representing the broken links caused by new or
- * modified assets
- */
- public LinkValidationReport(String store, String webapp, HrefValidationProgress status,
- HrefManifest brokenByDelete, HrefManifest brokenByNewOrMod)
- {
- this.store = store;
- this.webapp = webapp;
- this.completedAt = new Date();
- this.numberFilesChecked = status.getFileUpdateCount();
- this.numberLinksChecked = status.getUrlUpdateCount();
- this.numberBrokenLinks = 0;
-
- // get the lists of broken files
- List byDelete = brokenByDelete.getManifestEntries();
- List byNewOrMod = brokenByNewOrMod.getManifestEntries();
-
- // create list and map
- this.brokenFiles = new ArrayList(byDelete.size() + byNewOrMod.size());
- this.brokenLinksByFile = new HashMap(
- byDelete.size() + byNewOrMod.size());
-
- // build the required list and map
- storeBrokenFiles(byDelete);
- storeBrokenFiles(byNewOrMod);
- }
-
/**
* Constructs a link validation report from an error that occurred
*
@@ -197,6 +165,16 @@ public class LinkValidationReport implements Serializable
return links;
}
+ public int getBaseSnapshotVersion()
+ {
+ return this.baseSnapshotVersion;
+ }
+
+ public int getLatestSnapshotVersion()
+ {
+ return this.latestSnapshotVersion;
+ }
+
public boolean wasSuccessful()
{
return this.successful;
@@ -219,6 +197,8 @@ public class LinkValidationReport implements Serializable
StringBuilder buffer = new StringBuilder(super.toString());
buffer.append(" (store=").append(this.store);
buffer.append(" webapp=").append(this.webapp);
+ buffer.append(" baseSnapshot=").append(this.baseSnapshotVersion);
+ buffer.append(" latestSnapshot=").append(this.latestSnapshotVersion);
buffer.append(" error=").append(this.error).append(")");
return buffer.toString();
}
@@ -236,13 +216,9 @@ public class LinkValidationReport implements Serializable
{
String fileName = manifest.getFileName();
- // make sure the same file only gets added once
- if (this.brokenFiles.contains(fileName) == false)
- {
- this.brokenFiles.add(fileName);
- this.brokenLinksByFile.put(fileName, manifest);
- this.numberBrokenLinks = this.numberBrokenLinks + manifest.getHrefs().size();
- }
+ this.brokenFiles.add(fileName);
+ this.brokenLinksByFile.put(fileName, manifest);
+ this.numberBrokenLinks = this.numberBrokenLinks + manifest.getHrefs().size();
}
}
}
diff --git a/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java
index 2cccc16df8..6a1e6f2b3a 100644
--- a/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java
+++ b/source/java/org/alfresco/repo/avm/wf/AVMClearSubmittedHandler.java
@@ -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 pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg);
- AVMNodeDescriptor pkgDesc = this.avmService.lookup(pkgPath.getFirst(), pkgPath.getSecond());
- String targetPath = pkgDesc.getIndirection();
- final List 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
+ {
+ }
}
diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java
index 71e6a3bfcd..184c0f5ab1 100644
--- a/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java
+++ b/source/java/org/alfresco/repo/avm/wf/AVMSubmitPackageHandler.java
@@ -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 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 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)
{
- 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 sandboxDiffs = fAVMSyncService.compare(pkgPath.getFirst(), pkgPath.getSecond(), -1, from, null);
+ final List 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());
}
}
}
diff --git a/source/java/org/alfresco/repo/avm/wf/AVMSubmittedAspect.java b/source/java/org/alfresco/repo/avm/wf/AVMSubmittedAspect.java
deleted file mode 100644
index 95e5dbbd15..0000000000
--- a/source/java/org/alfresco/repo/avm/wf/AVMSubmittedAspect.java
+++ /dev/null
@@ -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;
- }
-
-}