Access Document content in Java action : 'virtual' NodeRef ?

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2011 06:27 PM
Hi all,
I'd like, in a Java action called inside a workflow, to retrieve the document content I just submitted.
I encountered some strange behaviour (to my point of view) : when executing action targetting document(s) : these document(s) seems inside sort of "virtual" NodeRef.
I'd like to know if my assumption (about "virtual" noderef) is true, or, if not, I'd like to understand the underlying behaviour about this
My processdefinition sample :
Then I have following implementation :
In [1] I retrieve current bpm_package's NodeRef.
In my particular case, as I said earlier, this NodeRef seems to not be an "existing" Node Reference (some sort of "virtual directory).
I made this assumption because :
When I execute fileFolderService.getFileInfo(virtualDirectory), it returns null (directory seems not to *really* exist) When iterating over virtualDirectory children ([2]), I only see modified document (other documents residing at the same level of the current modified document don't appear in the listing)
Are my assumptions right ?
(that is : is the algorithm in [2] a "good" algorithm allowing to retrieve modified document(s) content(s) ?)
Thanks in advance !
I'd like, in a Java action called inside a workflow, to retrieve the document content I just submitted.
I encountered some strange behaviour (to my point of view) : when executing action targetting document(s) : these document(s) seems inside sort of "virtual" NodeRef.
I'd like to know if my assumption (about "virtual" noderef) is true, or, if not, I'd like to understand the underlying behaviour about this

My processdefinition sample :
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:adhocCustom"> … <task-node name="adhoc"> <task name="wf:adhocTask" swimlane="assignee"> <event type="task-create"> <script> if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate; if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority; </script> </event> </task> <transition name="" to="completed"> <action class="foo.bar.MyAction"> </action> </transition> </task-node> … </process-definition>
Then I have following implementation :
public class MyAction extends JBPMSpringActionHandler { private NodeService nodeService; private ContentService contentService; private FileFolderService fileFolderService; @Override protected void initialiseHandler(BeanFactory factory) { ServiceRegistry services = (ServiceRegistry) factory.getBean(ServiceRegistry.SERVICE_REGISTRY); nodeService = services.getNodeService(); contentService = services.getContentService(); fileFolderService = services.getFileFolderService(); } public void execute(final ExecutionContext context) throws Exception { // Retrieving current "virtual" node hosting modified documents [1] NodeRef virtualDirectory = ((JBPMNode) context.getContextInstance().getVariable("bpm_package")).getNodeRef(); // Browsing every modified files, and calling target sites deployments [2] for(FileInfo fileInfo : fileFolderService.listFiles(virtualDirectory)){ // Retrieving document file path & content Path filePath = nodeService.getPath(fileInfo.getNodeRef()); String fileContent = contentService.getReader(fileInfo.getNodeRef(), ContentModel.PROP_CONTENT).getContentString(); // … } }}
In [1] I retrieve current bpm_package's NodeRef.
In my particular case, as I said earlier, this NodeRef seems to not be an "existing" Node Reference (some sort of "virtual directory).
I made this assumption because :
Are my assumptions right ?
(that is : is the algorithm in [2] a "good" algorithm allowing to retrieve modified document(s) content(s) ?)
Thanks in advance !
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 04:38 AM
No ALAIK there is no concept of virtual nodeRef in alfresco.
There might be something else you are missing here.
try to call the same class on some event like "node-leave" event.
There might be something else you are missing here.
try to call the same class on some event like "node-leave" event.
