Posting a folder results in a document without content

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2010 05:18 PM
I've seen a few posts with this same problem. I'm trying to create a folder but instead it creates a document.
In the related posts they solved their problem by changing the namespace in the xml
xmlns:cmis='http://www.cmis.org/2008/05'>
I tried that but no-go. Any help would be appreciated.
Here is my post code
——————————-
//———————————————–
public void PostInfo()
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try
{
String xmlData = "<?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'>"+
"<title>445_123</title>"+
"<summary>445_123</summary>"+
"<cmis
bject>"+
"<cmis
roperties>"+
"<cmis
ropertyId cmis:name='ObjectTypeId'><cmis:value>folder</cmis:value></cmis
ropertyId>"+
"</cmis
roperties>"+
"</cmis
bject>"+
"</entry>";
String href = "http://cmis.alfresco.com:80/service/cmis/s/workspace
pacesStore/i/998e23c5-570f-4fc8-a86a-e895e019c04...";
URL url = new URL (href);
String userPassword = "admin:admin";
// Encode String
String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
// Need to work with URLConnection to set request property
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true); //Only if you expect to read a response…
// uc.setUseCaches(false); //Highly recommended…
//uc.setRequestProperty("Content-Type", "application/atom+xml");
uc.setRequestProperty("Content-Type", "application/atom+xml;type=entry");
uc.setRequestProperty ("Authorization", "Basic " + encoding);
OutputStreamWriter out = new OutputStreamWriter(uc.getOutputStream());
out.write(xmlData);
out.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(
uc.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
in.close();
}
catch (MalformedURLException e)
{
pw.println ("Invalid URL");
}
catch (Exception e)
{
System.out.println ("Error reading URL"+e.getMessage());
}
}
In the related posts they solved their problem by changing the namespace in the xml
xmlns:cmis='http://www.cmis.org/2008/05'>
I tried that but no-go. Any help would be appreciated.
Here is my post code
——————————-
//———————————————–
public void PostInfo()
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try
{
String xmlData = "<?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'>"+
"<title>445_123</title>"+
"<summary>445_123</summary>"+
"<cmis

"<cmis

"<cmis


"</cmis

"</cmis

"</entry>";
String href = "http://cmis.alfresco.com:80/service/cmis/s/workspace

URL url = new URL (href);
String userPassword = "admin:admin";
// Encode String
String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
// Need to work with URLConnection to set request property
URLConnection uc = url.openConnection();
uc.setDoOutput(true);
uc.setDoInput(true); //Only if you expect to read a response…
// uc.setUseCaches(false); //Highly recommended…
//uc.setRequestProperty("Content-Type", "application/atom+xml");
uc.setRequestProperty("Content-Type", "application/atom+xml;type=entry");
uc.setRequestProperty ("Authorization", "Basic " + encoding);
OutputStreamWriter out = new OutputStreamWriter(uc.getOutputStream());
out.write(xmlData);
out.close();
BufferedReader in = new BufferedReader(
new InputStreamReader(
uc.getInputStream()));
String decodedString;
while ((decodedString = in.readLine()) != null) {
System.out.println(decodedString);
}
in.close();
}
catch (MalformedURLException e)
{
pw.println ("Invalid URL");
}
catch (Exception e)
{
System.out.println ("Error reading URL"+e.getMessage());
}
}
Labels:
- Labels:
-
Archive
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2012 02:11 PM
Old post, but in case it helps, the objectTypeId value should be "cmis:folder" not "folder".
Jeff
Jeff
