9 Replies Latest reply on Sep 11, 2012 10:03 AM by gkalabin

    Rest api: unable to unpublish node

    gkalabin

      I'm using ModeShape 2.8.2 and JBoss 7.1.1. ModeShape rest server deployed as usual web application. And I have a kind of a stupid question.

      I can to publish a file - it uploads to the storage and everything is fine.

      But when I try to unpublish - I have an exception.

      According to the api I have to provide workspace, path and file as parameters. But how to combine path and file parameters?

      For example, I want to unpublish node at /repo/file path. The following code not working:

      File file = new File("file");
      Status status = restClient.unpublish(workspace, "/repo", file);
      

       

      log:

      12:53:26,163 ERROR [org.modeshape.web.jcr.rest.client.json.JsonRestClient] (http--127.0.0.1-8080-1) response code=405 method=unpublish
      12:53:26,166 ERROR [com.demo.app.Controller](http--127.0.0.1-8080-1) The file "C:\jboss-as-7.1.1.Final\bin\file" could not be unpublished in 
      workspace "workspace1" at path "/repo".: java.lang.RuntimeException: The file "file" could not be unpublished in workspace "workspace1" at path "/repo".
      

       

      But an url from

      (new FileNode(workspace,"/repo",file)).getUrl()

       

      is correct and get/delete requests works as expected.

       

      Also I tried:

      File file = new File("/repo/file");
      Status status = restClient.unpublish(workspace, "/", file); // if set "" instead of "/" result the same
      

      But an url from getUrl method is wrong.

      Thank you for any help.

        • 1. Re: Rest api: unable to unpublish node
          rhauch

          The "File" object is an instance of java.io.File, which means it should represent a file on the client's file system. Currently having the local file is required.

          1 of 1 people found this helpful
          • 2. Re: Rest api: unable to unpublish node
            gkalabin

            I tried to create file (and it have been created) and call unpublish of existent file, but result is the same.

            • 3. Re: Rest api: unable to unpublish node
              rhauch

              Does the Status returned from the 'unpublish' method contain an exception?

              • 4. Re: Rest api: unable to unpublish node
                gkalabin

                Yes, it does. The exception is the same as mentioned in question:

                 

                12:53:26,163 ERROR [org.modeshape.web.jcr.rest.client.json.JsonRestClient] (http--127.0.0.1-8080-1) response code=405 method=unpublish
                12:53:26,166 ERROR [com.demo.app.Controller](http--127.0.0.1-8080-1) The file "C:\jboss-as-7.1.1.Final\bin\file" could not be unpublished in workspace "workspace1" at path "/repo".: java.lang.RuntimeException: The file "file" could not be unpublished in workspace "workspace1" at path "/repo".

                • 5. Re: Rest api: unable to unpublish node
                  rhauch

                  I'm not sure what's going on without more investigation. Can you log a bug in our JIRA system?

                   

                  Note that the REST Client is merely a (very) simple client-side library for working with the RESTful service, and the REST Client only exposes a subset of the RESTful service functionality. You might consider having your code directly use the RESTful API directly.

                  1 of 1 people found this helpful
                  • 6. Re: Rest api: unable to unpublish node
                    gkalabin

                    I just created Issue.

                     

                    Thank you for clarification. That's good idea.

                    • 7. Re: Rest api: unable to unpublish node
                      rhauch

                      Thanks for creating the issue. We'll look at it soon.

                      • 8. Re: Rest api: unable to unpublish node
                        hchiorean

                        Grigory Kalabin wrote:

                        12:53:26,163 ERROR [org.modeshape.web.jcr.rest.client.json.JsonRestClient] (http--127.0.0.1-8080-1) response code=405 method=unpublish
                        12:53:26,166 ERROR [com.demo.app.Controller](http--127.0.0.1-8080-1) The file "C:\jboss-as-7.1.1.Final\bin\file" could not be unpublished in workspace "workspace1" at path "/repo".: java.lang.RuntimeException: The file "file" could not be unpublished in workspace "workspace1" at path "/repo".

                         

                        Are you sure HTTP DELETE is enabled on the web server ? (unpublish issues a http delete and the 405 code seems to indicate that http delete is not enabled)

                        • 9. Re: Rest api: unable to unpublish node
                          gkalabin

                          I'm sure that it's enabled because I can delete a node using http clients (for example, Fiddler)