Hi I'm a new developer to the AEM platform and i'm currently trying to create a custom process step which processes a text file (contains some file names) which will be uploaded to the workflow and then it finds those file names in a different folder of the DAM and does a different process with it.
Now my question is how would I read that txt file?
My guess is to use the resource factory?
private ResourceResolverFactory resourceResolverFactory;
ResourceResolver resolver=null;
resolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
Resource res=null;
res= resolver.getResource("PATH");
Also can you guys let me know if this post is on the right track, it shows multiple methods but i strictly want a file being uploaded.
http://www.wemblog.com/2011/10/how-to-read-external-file-in-cq.html
Thanks,
Ram
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Ram,
If you are using the Granite Workflow Process API as described here [0] you can get a ResourceResolver directly by adapting the WorkflowSession passed into your process step to a ResourceResolver. like this:
ResourceResolver resolver = workflowSession.adaptTo(ResourceResolver.class);
You do not need to close this resolver, the workflow engine will take care of that for you. Note you can also adapt a workflow session to a javax.jcr.Session.
I looked at the example you provided, and I didn't know you could adapt a resource to a java.io.File. If you have trouble with that try the approach taken here [1] to read the binary value of the jcr:data property, it's probably the approach I would have taken. Careful however, this example reads the entire file into a byte array in memory, which may not be the best approach for large files.
Hope this helps - good luck!
Will
[0] http://docs.adobe.com/docs/en/cq/current/workflows/wf-extending.html#Developing Process Step Implementations
[1] http://blogs.adobe.com/saket/readwrite-content-nodes-or-files-frominto-the-crx-repository-2/
Views
Replies
Total Likes
I referenced an article on your other thread about how to upload a file and use AssetManager to place into the DAM. I have asked our Workflow expert to address your question on using Dialog boxes and getting values.
Views
Replies
Total Likes
Hi Ram,
If you are using the Granite Workflow Process API as described here [0] you can get a ResourceResolver directly by adapting the WorkflowSession passed into your process step to a ResourceResolver. like this:
ResourceResolver resolver = workflowSession.adaptTo(ResourceResolver.class);
You do not need to close this resolver, the workflow engine will take care of that for you. Note you can also adapt a workflow session to a javax.jcr.Session.
I looked at the example you provided, and I didn't know you could adapt a resource to a java.io.File. If you have trouble with that try the approach taken here [1] to read the binary value of the jcr:data property, it's probably the approach I would have taken. Careful however, this example reads the entire file into a byte array in memory, which may not be the best approach for large files.
Hope this helps - good luck!
Will
[0] http://docs.adobe.com/docs/en/cq/current/workflows/wf-extending.html#Developing Process Step Implementations
[1] http://blogs.adobe.com/saket/readwrite-content-nodes-or-files-frominto-the-crx-repository-2/
Views
Replies
Total Likes
Views
Likes
Replies