2016-07-23 132 views
1

我想在露天使用apache化学创建文本文档。我的代码是用于创建文档是Alfresco:流已关闭

文献文档= FileUtils.createTextDocument( “/”, “test.txt的”, “测试文档”,BaseTypeId.CMIS_DOCUMENT.value(),VersioningState.MAJOR,会议);

当我执行我的代码,我得到以下异常

org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException:无法访问“http://localhost:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom/children?id=5717e8a0-61b2-4bcb-8a91-2f4b61ebfefa&versioningState=major”:流已经关闭! 在org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:233) 在org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invokePOST( DefaultHttpInvoker.java:68) at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.post(AbstractAtomPubService.java:713) at org.apache.chemistry.opencmis.client.bindings.spi。 atompub.ObjectServiceImpl.createDocument(ObjectServiceImpl.java:122) at org.apache.chemistry.opencmis.client.runtime.SessionImpl.createDocument(SessionImpl.java:1165) at org.apache.chemistry.opencmis.client.runtime。 FolderImpl.createDocument(FolderImpl.java:77) at org.apache.chemistry.opencmis.client.runtime.FolderImpl.createDocument(FolderImpl.java:460) 在org.apache.chemistry.opencmis.client.util.FileUtils.createTextDocument(FileUtils.java:168)

+0

退房以下页面:HTTPS: //chemistry.apache.org/docs/cmis-samples/samples/create-objects/index.html#creating-a-document https://chemistry.apache.org/docs/cmis-samples/samples/content/ index.html –

+0

尝试我的例子,并给我们一个反馈 –

回答

1

试试这个工作对我罚款

public static void main(String args[]) { 
String serverUrl = args[0]; 
String username = args[1]; 
String password = args[2]; 
Session session = getSession(serverUrl, username, password); 
Folder root = session.getRootFolder(); 
Map<String, Object> properties = new HashMap<String, Object>(); 
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_ 
DOCUMENT.value()); 
String name = "New Document (" + System.currentTimeMillis() + 
").txt"; 
properties.put(PropertyIds.NAME, name); 
List<Ace> addAces = new LinkedList<Ace>(); 
List<Ace> removeAces = new LinkedList<Ace>(); 
List<Policy> policies = new LinkedList<Policy>(); 
String content = "The quick brown fox jumps over the lazy dog."; 
ContentStream contentStream = new ContentStreamImpl("text.txt", 
BigInteger.valueOf(content.length()), 
"text/plain", new ByteArrayInputStream(content. 
getBytes())); 
Document newDocument = root.createDocument(properties, 
contentStream, VersioningState.MAJOR, policies, addAces, removeAces, 
session.getDefaultContext()); 
System.out.println(newDocument.getId()); 
}     
+0

有没有什么问题@rish –

+0

thnx回复,是代码运行良好,我有一个问题,我可以创建一个文件夹链接到其他fol就像在windows机器上创建文件夹或文件的快捷方式一样。 thnx再 – deen

+0

打开一个新的话题,我会尽力帮助你,不要忘记给我一个关于'Alfresco:无法创建目录'的反馈信息, –