01-15-2009 10:10 AM
01-23-2009 06:12 AM
06-24-2009 04:18 AM
import java.io.File;
import java.io.FileInputStream;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.bouncycastle.util.encoders.Base64;
public class CreateFolderPost {
public static void main(String[] args) {
try {
String url ="http://localhost:8080/alfresco/service/api/path/workspace/SpacesStore/Company%20Home/Sites/children";
String creds = "admin" + ":" + "admin";
HttpClient httpClient = new HttpClient();
PostMethod method = new PostMethod(url);
method.setRequestHeader("Authorization", "Basic "
+ new String(Base64.encode(creds.getBytes())));
String filePath ="createfolderpost.xml";
String contentType = "application/atom+xml;type=entry";
File createDoc = new File(filePath);
method.setRequestHeader("name", createDoc.getName());
method.setRequestHeader("Content-type", contentType);
method.setRequestBody(new FileInputStream(createDoc));
int status = httpClient.executeMethod(method);
System.out.println("return code is: " + status + "\n\n" + " return body is :"
+ method.getResponseBodyAsString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200901" xmlns:alf="http://www.alfresco.org">
<link rel="type" href="http://localhost:8080/alfresco/service/api/type/folder'/>
<link rel="repository" href="http://localhost:8080/alfresco/service/api/repository'/>
<title>sales</title>
<summary>sales space</summary>
<cmis:object>
<cmis:properties>
<cmis:propertyId cmis:name="ObjectTypeId"><cmis:value>folder</cmis:value></cmis:propertyId>
</cmis:properties>
</cmis:object>
</entry>
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.