cancel
Showing results for 
Search instead for 
Did you mean: 

Create privet working copy

wolfateh
Champ in-the-making
Champ in-the-making
Hi all
I use Alfresco Community4.0.e, chemistry-opencmis-client 0.7.0,primefaces 3.4.1
i want to add "Edit offline" feature to my attachment Files in my web application
to do this i try to use the Web Scripts "checkedout" but I couldn't find the proper way to invoke this Web Scripts
I run this Web Scripts through "CMIS WorkBench" and i tried to read the log
i found that alfresco invoke this Web Scripts like this

> 13:41:49 DEBUG ent.bindings.spi.http.DefaultHttpInvoker: POST http://127.0.0.1:8080/alfresco/service/cmis/checkedout
> 13:41:50 TRACE ent.bindings.spi.http.DefaultHttpInvoker: POST http://127.0.0.1:8080/alfresco/service/cmis/checkedout > Headers: {null=[HTTP/1.1 201 Created], Date=[Tue, 16 Jul 2013 10:38:53 GMT], Transfer-Encoding=[chunked], Location=[http://127.0.0.1:8080/alfresco/service/cmis/pwc/s/workspaceSmiley FrustratedpacesStore/i/5b4772c9-8d8d-4fab-a7b9-5fe5...], Content-Type=[application/atom+xml;type=entry;charset=UTF-8], Server=[Apache-Coyote/1.1], Pragma=[no-cache], Cache-Control=[no-cache]}

i try to write code to match what i understand from the log but it not working -_-

public String checkOutDoc(String objID) throws JSONException{
        //String json = "{"                
        //         + "\"id\" : \"" + objID+ "\""
        //         + "}";
         try{
             System.out.println("Jason "+json.toString());
             HttpPost httpPost = new HttpPost("http://'+Constant.getAlfrescoIpConcatPort()+"/alfresco/service/cmis/checkedout");
             //StringEntity requestEntity  =new StringEntity(json);
             //httpPost.setEntity(requestEntity);
             httpPost.setHeader("Transfer-Encoding", "chunked");
             httpPost.setHeader("Content-type", "application/atom+xml");
             httpPost.setHeader("Location", "http://127.0.0.1:8080/alfresco/service/cmis/pwc/s/workspaceSmiley FrustratedpacesStore/i/5b4772c9-8d8d-4fab-a7b9-5fe5...");
             httpPost.setHeader("Content-Type", "application/atom+xml;type=entry;charset=UTF-8");
             httpPost.setHeader("Pragma", "no-cache");
             httpPost.setHeader("Cache-Control", "no-cache");
            
             System.out.println("Http post "+ httpPost.toString());
            
             HttpResponse response = client.execute(httpPost);
             System.out.println("response "+ response.toString());
            
             HttpEntity entity = response.getEntity();
             if (entity != null) {
                     return "done";
             }
        }catch (Exception ex) {        
            System.out.println(ex.getLocalizedMessage());
        } finally {
            client.getConnectionManager().shutdown();
        }
        return "failed";   
    }  


also any help please ?

thanks in advanced
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
Please don't use 4.0.e. If you have to stick with 4.0.x use 4.0.d. 4.0.e was never meant to be used for anything other than previewing the Activiti integration. We tried to mark it as such on the download page but sometimes people miss it.

You appear to be using the Web Services CMIS implementation URL. I recommend you switch to the OpenCMIS URL, which is /alfresco/cmisatom. You should consider the Web Services CMIS implementation to be deprecated.

It looks like you are using Java code. Why not use the OpenCMIS client so you don't have to worry about making HTTP posts directly to the CMIS binding? It's a LOT easier. For example, here's how to do a checkout when you are using a CMIS client library like OpenCMIS:

Document pwc = (Document) session.getObject(doc.checkOut());

More OpenCMIS code and examples <a href="http://chemistry.apache.org/java/developing/guide.html">here</a>.

Jeff

wolfateh
Champ in-the-making
Champ in-the-making
Thanks a lot it is worked-out