AnsweredAssumed Answered

New to web script...please help

Question asked by vjayabalan on Aug 5, 2011
Latest reply on Sep 1, 2011 by brogits
Hello everyone,

I am new to web scripts. I am trying to create a folder under Company Home in my Alfresco repository. I am using the following code to execute a POST method that would create the folder:

String url = "http://localhost:11080/alfresco/service/cmis/pCompany%20Home/children"
PostMethod method = new PostMethod(url)
String filePath = "C:/testDoc.xml";
String contentType = "application/atom+xml;type=entry";
      
File upload = new File(filePath);
method.setRequestHeader("name", upload.getName());
method.setRequestHeader("Content-type", contentType);
      
method.setRequestBody(new FileInputStream(upload));
try{
      int respCode = client.executeMethod(method)
}
catch(IOException io){
      io.printStackTrace()
}
catch(HttpException hte){
      hte.printStackTrace()
}


The testDoc.xml looks like this (I found it online :)):

<?xml version='1.0' encoding='utf-8'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:cmis='http://www.cmis.org/2008/05'>
<title>VJ Folder</title>
<summary>VJ's folder</summary>
<content type="text/html">${CONTENT}</content>
<cmis:object>
<cmis:properties>
<cmis:propertyString cmis:name='ObjectTypeId'><cmis:value>folder</cmis:value></cmis:propertyString>
</cmis:properties>
</cmis:object>
</entry>

When I run the code, I get the following exception. I don't want to bore you with the complete error message, but here is a snippet:

<table>
            <tr><td><b>404 Description:</b></td><td> Requested resource is not available.</td></tr>
            <tr><td> </td></tr>
            <tr><td><b>Message:</b></td><td>Cannot find object for ObjectPathReference[storeRef=workspace://SpacesStore,path=/app:company_homeCompany Home]</td></tr>
            <tr><td><b>Server</b>:</td><td>Community v3.4.0 (d 3370) schema 4,113</td></tr>
            <tr><td><b>Time</b>:</td><td>Aug 4, 2011 5:10:14 PM</td></tr>
            <tr><td></td><td> </td></tr>
            <tr><td><b>Diagnostics</b>:</td><td><a href="/alfresco/service/script/org/alfresco/cmis/children.post">Inspect Web Script (org/alfresco/cmis/children.post)</a></td></tr>
         </table>

I don't know what I am doing wrong here. Please help!

Outcomes