cancel
Showing results for 
Search instead for 
Did you mean: 

Posting a folder results in a document without content

mgagnon
Champ in-the-making
Champ in-the-making
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>"+
          "<cmisSmiley Surprisedbject>"+
          "<cmisSmiley Tongueroperties>"+
          "<cmisSmiley TongueropertyId cmis:name='ObjectTypeId'><cmis:value>folder</cmis:value></cmisSmiley TongueropertyId>"+
          "</cmisSmiley Tongueroperties>"+
          "</cmisSmiley Surprisedbject>"+
          "</entry>";     
       
          String href = "http://cmis.alfresco.com:80/service/cmis/s/workspaceSmiley FrustratedpacesStore/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());       
        }
          
    }
1 REPLY 1

jpotts
World-Class Innovator
World-Class Innovator
Old post, but in case it helps, the objectTypeId value should be "cmis:folder" not "folder".

Jeff