I want to use Activiti to edit the text content and it's metadata which is present in alfresco repository/alfresco share. What is the best way to do it?
My approach is kind of goes this way. But I feel I am making it complicated.
1. Create the form in activiti to choose the alfresco share document
2. get the node reference from the chosen path
3. call the alfresco webscript endpoint task which can get the JSON response using this GET method
e.g. GET /alfresco/service/api/metadata?nodeRef=workspace://SpacesStore/1b10bd64-e22f-458c-8632-468b53174266
4. DO the response mapping and get all the properties that the file is having in variables
5. load that in the form in which user can edit.
6. complete the editing process by publishing the same document.
Do you have any other approach ? This is kind of a lot of work for a simple editing the document.
Activiti version 1.6.0
Could you please provide a little bit more information, eg: use case. If you are trying to edit a file, why are your doing it using Activiti? Can you not do it using the repo UI? Or is this edit just a part of a bigger workflow? Also, if you are looking for updating office docs, there is office integration in Alfresco Process Services which allow you to edit a document through the browser.
Yes. I can do that using Repo UI. But it is part of a bigger workflow. Business users are having difficulties understanding the repo UI. I know it is a simple from our perspective but this is the task I have to do it.
and my content will be some txt files. Not the office documents. I already integrated office documents editing capabilities.
Let me know if there is better solution available to edit the content.
Ok, understood. Depending on the requirement it can be done a few different ways.
If you want to do it in two steps (selection of file by a user and update by another user in another task) , you can combine the "Retrieve Alfresco Properties", then edit the variables via a user task form, then "Update Alfresco Properties"
Hope this helps.
Ok. I am working with alfresco 5.0.2. So the node REST API will not work.
I did exactly the same thing you mentioned to update the Alfresco properties. I am able to update the properties using perfectly fine.
But, I am not able to get the path of the file while choosing the file. Can you tell me which form properties should I use and how? you told me about APS. what is that ? Please give me details.
Right now I am stuck at getting the path of the file from the upload file.
I need that in a string variable like "Sites/mySite/documentlibrary/myfolder/file.txt"
So that I can get the nodeRef and open the content using this API and make an update. and publish it to alfresco.
All the following task is completed. I am not able to get the file path from the file chooser.
APS is Alfresco Process Services formerly known as Alfresco Activiti (and sorry for the confusion)! You should be able to get the node id (sourceId) from the related content table using a script/service task using the java apis (using beans such as relatedContentService, relatedContentRepository etc).
Check activiti-examples/CopyAttachmentTaskListener.java at master · cijujoseph/activiti-examples · GitHub which is an example of iterating through related contents.
I am getting confused. I need nodeRef. For example.
I want the path in string or the nodeRef from the file selector. Either of them is fine. You are telling me regarding node id(source id). Is nodeRef you meant?
I am creating my business process in Activiti (Alfresco process service) which can edit the content in alfresco.
Can you clarify my doubt?
1. I have Created the following app. And This is what I see when I start the process. I can choose the file present in alfresco content service. (Alfresco repository). So that I can edit the alfresco properties by calling "Retrieve alfresco properties" task. I am successfully able to do that.
2. After Choosing file and entering the same filepath. It will look like this. (This is the thing that I want to get rid off. I do not want to enter the filepath here.) I am entering it only to get the content of the file.
3. I am starting the process now. and it retrives the properties(Using retrive alfresco properties) and Content(Using Alfresco webscript api called as REST task).Title, Description Approved by etc. ["Content" does not come as a property. So I use Alfresco Webscript api to call this. ] (more details below)
3. Now the Alfresco webscript goes like this. It needs the nodeRef of the content (File). This is how I wrote that. It returns the content in Json format and I store it in a variable using Response mapping in the "REST call task". And then you can see the content in the above screen shot.
args.filename is the value that I enter in the form showed first screenshot (filepath variable). see the var basepath commented for the example.
4. So, I am able to retrive the content and metadata(properties). I show it to the form. I pass it through our business process of approval and it publishes to alfresco repository.
I hope you get the point. The only thing I am missing is that Alfresco does not provide out of the box content editing. There should be some task that can edit the alfresco content.
So, I found the way of webscripts way to do it. But it requires alfresco nodeRef, and nodeRef requires path. So, I have to enter the path manually which I want to get rid off coz user will not know the path. I want to get the path of the file from the file selector itself. Or the nodeRef. Anything will be fine.
I hope this clears what I exactly want to do. I will wait for your response.