Alfresco创建私人工作副本

时间:2013-07-17 10:39:17

标签: alfresco checkout working-copy opencmis

我使用Alfresco Community4.0.e,chemistry-opencmis-client 0.7.0,primefaces 3.4.1 我想在我的Web应用程序中添加“编辑离线”功能到我的附件文件 要做到这一点我尝试使用Web脚本“签出”但我找不到调用此Web脚本的正确方法 我通过“CMIS WorkBench”运行这个Web脚本,我试着读取日志 我发现alfresco像这样调用这个Web脚本

DEBUG ent.bindings.spi.http.DefaultHttpInvoker: POST http://fateh:8080/alfresco/service/cmis/checkedout

TRACE ent.bindings.spi.http.DefaultHttpInvoker: POST http://fateh: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://fateh:8080/alfresco/service/cmis/pwc/s/workspace:SpacesStore/..., Content-Type=[application/atom+xml;type=entry;charset=UTF-8], Server=[Apache-Coyote/1.1],Pragma=[no-cache], Cache-Control=[no-cache]}

我尝试编写代码以匹配我从日志中理解但不起作用的代码-_-

 public String cancelCheckOut(String objID) throws JSONException{
     try{
         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://50.17.228.246:80/alfresco/service/cmis/pwc/s/workspace:SpacesStore/i/5b4772c9-8d8d-4fab-a7b9-5fe5d25b45f1");
         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";    
} 

任何帮助?

3 个答案:

答案 0 :(得分:2)

您必须在POST中添加有效负载,以指定您要签出的文档,例如:

<?xml version="1.0" encoding="utf-8"?>
  <entry xmlns="http://www.w3.org/2005/Atom"
    xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/"
    xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908/">
    <cmisra:object>
    <cmis:properties>
    <cmis:propertyId propertyDefinitionId="cmis:objectId">
    <cmis:value>workspace:/SpacesStore/5b4772c9-8d8d-4fab-a7b9-5fe5d25b45f1</cmis:value>
    </cmis:propertyId>
    </cmis:properties>
    </cmisra:object>
 </entry>

curl query to check out a document using the CMIS protocol

答案 1 :(得分:1)

我找到了更简单的方法来创建私人工作副本因为我没有在卷曲查询之前使用

Session session = CMISUtils.getSession();
Document doc = (Document) session.getObject(session.createObjectId(attachment.getIdAttachment()));
Document pwc = (Document) session.getObject(doc.checkOut());

答案 2 :(得分:0)

就alfrescian的答案而言,这是你必须在client.execute之前编写的内容:

String data = "what alfrescian wrote";
httpPost.setEntity(new StringEntity(data));