Hi Punit
I didn't get any method that returns working copy reference if file is already checkedout.
According to my application, I am craeting a folder(folder name based on request id for eg., A123) in alfresco server. If I upload a photo (for eg., car.jpeg) using photo browser, then I renamed this jpeg file like photo.jpeg and
I put this photo in the request id folder. I am uploading 5 different files for a request id.
Let me explain what I did. When I upload a document in alfresco tht time —
Case 1: If file is already checkin
1) I am adding versioning aspect to the checkin file.
2) Checkedout the checkin file and get the CheckOutResult object
3) get the Working Copy Reference from CheckOutResult object
4) write the data in working copy
5) checkin the file
Case 2: If file is already checkedout
1) If i add versioning aspect to the checkedout file, it is throwing following exception–
RepositoryFault:<ns1:errorCode>0</ns1:errorCode><ns1:message>org.alfresco.service.cmr.lock.NodeLockedException: Can not perform operation since the node (id:91fec287-e3b9-11dd-bbcd-d302f1baf9e5) is locked.</ns1:message>
That means Node is already checkedout.
2) that time I am getting the file name and extn which we have to upload. In my case, no need to get file name from alfresco because I always rename the file before uploading operation (file name depends on browse button).
Note : As per my understanding, you can't do checkout/checkin for different extn. means if you have already a file policy.doc in alfresco then you can't checkin this file by some other extn (for eg, policy.pdf)
3)Now I am creating a new file object like filename + " (Working Copy)." + extn
Note: As you noticed that when you checkedout a file (policy.pdf) that time alfresco creates a working copy (policy Working Copy.pdf)
4)Now I am searching this file name in that request id then I am getting workingCopyReference of checkedout file
5) write the data in working copy
6) checkin the file
Hope it will help.
Regards
Nishant Chauhan