Reputation: 85
I want to move documents attached with workflow to some specific. I have done this in java script.
var destNode = search.findNode("workspace://SpacesStore/55bbdd0e-c185-4ab4-a7e8-5e8d9701a5ed");
for (var i = 0; i < bpm_package.children.length; i++)
{
bpm_package.children[i].move(destNode);
}
But I want java version of doing same ? Please help me! Thanks in advance.
Upvotes: 2
Views: 1425
Reputation: 383
Here is the Java equivalent:
ActivitiScriptNode bpmPackageScriptNode = (ActivitiScriptNode) delegateTask.getVariable("bpm_package");
if(bpmPackageScriptNode != null) {
NodeRef bpmPackage = bpmPackageScriptNode.getNodeRef();
List<ChildAssociationRef> children = nodeService.getChildAssocs(
bpmPackage, WorkflowModel.ASSOC_PACKAGE_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef child : children) {
NodeRef childRef = child.getChildRef();
fileService.move(childRef, destinationXpath, null);
}
}
It is better to use move(...)
from FileFolderService
instead of NodeSerivce
because of some additional checks.
Upvotes: 0
Reputation: 3175
you can use fileFolderService to move any document.There is method in fileFolderService called move.You can fine more on this on below link.
http://dev.alfresco.com/resource/docs/java/org/alfresco/service/cmr/model/FileFolderService.html
For using filefolderService you need to inject that service.Ig you are using javabackend webscript you can do it like below in any context file.
<bean id="webscript.{Path}.get" class="com.yaskawa.api.WebScript"
parent="webscript">
<property name="fileFolderService" ref="fileFolderService" />
</bean>
Below is example
FileFolderService().move(node,destNode, "NameOnDestination")
Hope this helps:)
Upvotes: 2