在Alfresco中创建的文件替代了文件夹

在Alfresco中创建的文件替代了文件夹,alfresco,cmis,Alfresco,Cmis,我正在尝试使用XMSI在Alfresco中创建一个文件夹,下面是我正在使用的代码 公共静态void main(字符串[]args)引发异常{ 长启动=System.currentTimeMillis() String host=“127.0.0.1”; int端口=9080; 字符串username=“admin”; 字符串password=“admin”; 字符串parentFolder=“公司%20Home”; 字符串folderName=“sales3”; String descripti

我正在尝试使用XMSI在Alfresco中创建一个文件夹,下面是我正在使用的代码

公共静态void main(字符串[]args)引发异常{ 长启动=System.currentTimeMillis()

String host=“127.0.0.1”;
int端口=9080;
字符串username=“admin”;
字符串password=“admin”;
字符串parentFolder=“公司%20Home”;
字符串folderName=“sales3”;
String description=“sales space3”;
RulesRequest请求=新的RulesRequest();
//request.SetRecomptionProfileObj(修正配置文件);
Gson gs=新的Gson();
字符串json=gs.toJson(请求);
DefaultHttpClient=新的DefaultHttpClient();
RestClient rstClnt=new RestClient();
String ticket=rstClnt.restClientPost(json)http://127.0.0.10:9080/alfresco/service/api/login?u=admin&pw=admin“,客户);
//String url=“http://“+host+”:“+port+”/alfresco/service/api/path/workspace/SpacesStore/“+parentFolder+”/children”;
字符串url=”http://localhost:9080/alfresco/service/cmis/s/workspace:SpacesStore/i/078b05c6-14bd-439c-a1ae-db032c5d98fc/儿童?alf_票证=“+票证;
String contentType=“应用程序/atom+xml;type=entry”;
字符串xml=
“\n”+
“\n”+
“+folderName+”\n”+
“”+说明+“\n”+
“\n”+
“\n”+
“\n”+
“cmis:文件夹\n”+
“\n”+
“\n”+
“\n”+
“\n”;
DefaultHttpClient httpclient=新的DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(
新的AuthScope(主机、端口),
新用户名密码凭据(用户名、密码));
HttpPost HttpPost=新的HttpPost(url);
setHeader(“内容类型”,contentType);
StringEntity requestEntity=新的StringEntity(xml,“UTF-8”);
httppost.setEntity(requestEntity);
System.out.println(“正在执行请求”+httppost.getRequestLine());
HttpResponse response=httpclient.execute(httppost);
HttpEntity=response.getEntity();
System.out.println(“--------------------------------------------------------”;
System.out.println(response.getStatusLine());
如果(实体!=null){
System.out.println(“响应内容类型:+entity.getContentType());
long contentLength=entity.getContentLength();
System.out.println(“响应内容长度:
+entity.getContentLength());
如果(contentLength>0){
字节[]b=新字节[(int)contentLength];
entity.getContent().read(b);
System.out.println(“响应内容:+新字符串(b));
}
实体写入(系统输出);
}
//当不再需要HttpClient实例时,
//关闭连接管理器以确保
//立即释放所有系统资源
httpclient.getConnectionManager().shutdown();
long end=System.currentTimeMillis();
System.out.println(“时间花费:”+(结束-开始)+“毫秒”);
}
它不是创建文件夹,而是创建大小为0的文件

谢谢
Garvit

您的财产类型错误。您错误地使用了
cmis:propertyString
而不是
cmis:propertyString
请尝试以下操作

<cmis:propertyId propertyDefinitionId="cmis:objectTypeId">
    <cmis:value>cmis:folder</cmis:value>
</cmis:propertyId>

cmis:文件夹

正如@Gagravarr所说,如果您可以使用知名的客户机库,那么这样的问题很容易避免。如果你自己构造HTTP请求,你最好有一个很好的理由。

你到底为什么要手动执行CMIS操作?提供一个可爱的Java API,它将为您完成所有工作!谢谢威尔,它成功了。请告诉我如何使用cmis请求在alfresco中创建自定义元数据。嗨,Will,我刚刚在alfresco中添加了一个方面来添加自定义元数据,我只是想知道如何将此方面添加到所有新创建的文件中。我建议您进行web搜索。如果你找不到答案,你应该问一个关于stackoverflow的新问题。你的后续问题不太可能出现在这个评论帖子中。谢谢威尔,我这么做了,但是alfresco的在线文档很糟糕。
<cmis:propertyId propertyDefinitionId="cmis:objectTypeId">
    <cmis:value>cmis:folder</cmis:value>
</cmis:propertyId>