1 2 Previous Next 29 Replies Latest reply on Jun 26, 2014 12:03 PM by antonid

    restful api modeshape

    antonid

      hello,

      I would like to know whether is there any webapi to get list of nodes for a given workspace ? (there exist for workspaces and repositories)

       

      URL: http://<host>:<port>/<context>/<repository_name>  ??

       

      -----

       

      this is ur syntax to create a modeshape node

      http://<host>:<port>/<context>/<repository_name>/<workspace_name>/items/<node_path>

      ----

       

      i would like to know what is <context> ; workspace_name ; items ; node_path

       

      this is my config file :

       

      {

          "name" : "Persisted_Repository",

          "workspaces" : {

              "predefined" : ["otherWorkspace"],

              "default" : "default",

              "allowCreation" : true

          },

         

          "security" : {

              "anonymous" : {

                  "roles" : ["readonly","readwrite","admin"],

                  "useOnFailedLogin" : false

              }

          },

          "storage" : {

              "cacheConfiguration" : "infinispan_configuration.xml",

              "cacheName" : "Persisted_Repository",

              "binaryStorage" : {

                  "type" : "file",

                  "directory": "target/content/binaries",

                  "minimumBinarySizeInBytes" : 4096

              }

          },

          "query":{

              "enabled":true,

              "rebuildUponStartup":"if_missing",

              "indexStorage": {

                  "type":"filesystem",

                  "location":"target/content/index",

                  "lockingStrategy":"simple",

                  "fileSystemAccessType":"auto"

              }

          },

      }

      ----------

       

      and in your syntax you mention that     Request Format:   and reponse  Format:

       

      should i do anything in my config json file.........

        • 1. Re: restful api modeshape
          antonid

          is there any eexmple on create node webservice ? on user syas that we dont need to use web.xml instead we use context.xml ? really need help  !!!!! advance thanks ....

          • 2. Re: restful api modeshape
            rhauch

            I would like to know whether is there any webapi to get list of nodes for a given workspace ? (there exist for workspaces and repositories)

            There is no way to get a list of all of the nodes in a workspace; the workspace might contain millions of nodes, so returning them all at once is impractical.

             

            I wonder if you want to find the list of workspace names (not nodes). If so, that is possible and it's actually very easy: just issue a GET on the repository URL. So, for a server running locally on port 8080 with the out-of-the-box context of "modeshape-rest" and a repository named "Persisted_Repository", then the URL would be:

             

                 http://localhost:8080/modeshape-rest/items/Persisted_Repository

             

            The response will be a JSON file that contains information about the repository, including the workspace names.

             

            BTW, we've already documented this technique: https://docs.jboss.org/author/display/MODE/REST+Service+3.x#RESTService3.x-2.Retrievealistofworkspacesforarepository

             

             

            Finally, the "context" term is very commonly used in servlet-based applications, and typically refers to the location where the application is started within the server. By default this is "modeshape-rest", although you can change it to something else by modifying the web.xml in the WAR file.

            • 3. Re: restful api modeshape
              antonid

              i try to produce a frontend. like a directory in windows

               so i create a node of type nt:folder and add child node of type nt:file and attach the contents to nt;files.

               

               

               

               

              so that i need a list of nodes type nt:folder and nt:files to display.

               

               

               

               

              .this ur syntax to create a node :

              Create a node

               

              Creates a node at the given path, using the body of request as JSON content

               

              URL: http:// a écrit :

               

               

               

              JBoss Community

              restful api modeshape

              reply from Randall Hauch in ModeShape - View the full discussion

              • 4. Re: restful api modeshape
                rhauch
                • 5. Re: restful api modeshape
                  antonid

                  Hello,

                  one person told me "i recommend doing it in a separate web project, because ModeShape uses RestEasy in such a way that it doesn't leave any URLs for your own web application. "


                  My plan ;
                  on the left hand side i would like to have nodes type nt: fiolder adn at the right hand side nodes of type nt:files

                  so i the user clicks on folder at the left hand side we should have the files at the right hand side (i have attached an image output.jpg)


                  i'm supposed to use mvc ; thats why i have client (as shown in the previous picture) which is called by my html file and i have server where i construct my json format (@Produces(MediaType.APPLICATION_JSON)) :
                  and i have a class that works with engine and nodes. I use this class

                  so i thought one application i will use the modshape war and in another i have web.xml(and i dont know how to link these 2 apps)
                  And i'm supposed to use angularjs (no jsp) which provides the mvc pattern on the client side.





                  thanks

                  cordialement
                  Antoni

                  • 6. Re: restful api modeshape
                    antonid

                    any answere

                    • 7. Re: restful api modeshape
                      rhauch

                      Is there part of the documentation that isn't clear? It has answers for all of the questions that you asked.

                      • 8. Re: restful api modeshape
                        antonid

                        if it so i would not ask u the question ?

                        you dont have one downloadable exmple to create a node with you webservice api.

                        one modeshape user tells that web.xml(which define url pattern in standard restful webservice) is provided modeshape-web-jcr-rest-war.


                        advance thanks

                         

                        • 9. Re: restful api modeshape
                          antonid

                          i have used the syntax :

                          your syntax :

                          http://<host>:<port>/<context>/<repository_name>

                          my ex :

                          "http://localhost:8080/modeshape-rest/Persisted_Repository

                           

                          i could not advance.

                          one simple complete exemple with pom web xml file will do. SOS

                          advance thanks

                           

                           

                           

                          my service :

                           

                          @Path("/user")

                          public class ModesShape {

                              @GET

                              @Path("/Modeshape") 

                              @Produces(MediaType.APPLICATION_JSON)

                                public String sayJsonNodesList() {

                                  return "";

                              }

                          }

                          ----------

                          public class ModesShapeClient {

                              public static void main(String[] args) {

                                  ClientConfig config = new DefaultClientConfig();

                                  Client client = Client.create(config);

                                  WebResource service = client.resource(getBaseURI());

                                  //System.out.println(service.path("Rest/user/Modeshape").accept(MediaType.APPLICATION_JSON).get(String.class));

                                  System.out.println(service.path("Rest/user/Modeshape").accept(MediaType.APPLICATION_JSON).get(String.class));

                              }

                           

                              private static URI getBaseURI() {

                                  return UriBuilder.fromUri("http://localhost:8080/modeshape-rest/Persisted_Repository").build();

                              }

                          }

                          ---------

                          my project structure :

                           

                          • 10. Re: restful api modeshape
                            rhauch

                            There are lots of ways of building a REST client application, so you're going to have to work that on your own.

                             

                            First of all, if you read my earlier response carefully, my example URL was for the repository. To get or update or remove nodes, you'll have to add the workspace name, "items", and then the path of the node. Getting nodes is easy, since that's simply an HTTP GET (which you can do in your browser). Other operations will require using HTTP PUT, POST and DELETE. Again, all of that is documented here: https://docs.jboss.org/author/display/MODE/REST+Service+3.x

                             

                            You might find it useful to use the "curl" command-line tool, since you can specify exactly which HTTP methods you want to use.

                            • 11. Re: restful api modeshape
                              antonid

                              As you sais  i use this uri in the function

                               

                              function Ltworksp($scope, $http) {

                                  $http.get('http://localhost:8080/modeshape-rest/items/Persisted_Repository');

                                      success(function(data) {

                                          $scope.lwkspace = data;

                                      });

                              }

                               

                               

                              which returns nothing ; so i copied the url in the browser

                              http://localhost:8080/modeshape-rest/items/Persisted_Repository

                               

                              when i use the above uri ; i have following eror  :

                               

                               

                               

                              Error 404 - Not Found

                              No context on this server matched or handled this request.Contexts known to this server are:

                              this is my config file

                               

                              {

                                  "name" : "Persisted_Repository",

                                  "workspaces" : {

                                      "predefined" : ["otherWorkspace"],

                                      "default" : "default",

                                      "allowCreation" : true

                                  },

                                 

                                  "security" : {

                                      "anonymous" : {

                                          "roles" : ["readonly","readwrite","admin"],

                                          "useOnFailedLogin" : false

                                      }

                                  },

                                 

                                  "storage" : {

                                      "cacheConfiguration" : "infinispan_configuration.xml",

                                      "cacheName" : "Persisted_Repository",

                                      "binaryStorage" : {

                                          "type" : "file",

                                          "directory": "target/content/binaries",

                                          "minimumBinarySizeInBytes" : 4096

                                      }

                                  },

                                 

                                  "query":{

                                      "enabled":true,

                                      "rebuildUponStartup":"if_missing",

                                      "indexStorage": {

                                          "type":"filesystem",

                                          "location":"target/content/index",

                                          "lockingStrategy":"simple",

                                          "fileSystemAccessType":"auto"

                                      }

                                  },

                              }

                              advance thanks

                              • 12. Re: restful api modeshape
                                rhauch

                                http://localhost:8080/modeshape-rest/items/Persisted_Repository

                                 

                                Sorry, I posted the wrong URL. Use this to list all of the workspaces in the "Persisted_Repository":

                                 

                                http://localhost:8080/modeshape-rest/Persisted_Repository

                                 

                                and this URL to see the top-level node in the "default" workspace of the "Persisted_Repository":

                                 

                                http://localhost:8080/modeshape-rest/Persisted_Repository/default/items

                                 

                                and this URL to see the node at the path "/a/b/c" in the "default" workspace of the "Persisted_Repository":

                                 

                                http://localhost:8080/modeshape-rest/Persisted_Repository/default/items/a/b/c

                                 

                                These are all GET operations, but the URL pattern is the same for all the other kinds of operations, again as described in the documentation.

                                • 13. Re: restful api modeshape
                                  antonid

                                  i have still the same problem ;

                                  could you please validate my steps.

                                   

                                  i use the following dependency in my POM file :

                                   

                                  <dependency>

                                  <groupId>org.modeshape</groupId>

                                  <artifactId>modeshape-web-jcr-rest-war</artifactId>

                                  <version>3.8.0.Final</version>

                                  <type>war</type>

                                  </dependency>

                                   

                                  i have verified my database whether  the table exists;

                                  if i start the tomcat server vie eclipse and if i paste this

                                  http://localhost:8080/modeshape-rest/Persisted_Repository ;int the url (since my fuinction does not work) i'm supposed to have the workspace in the browser ?

                                  Error 404 - Not Found

                                   

                                  cdt

                                  • 14. Re: restful api modeshape
                                    rhauch

                                    LOL. How am I supposed to validate what you did by just looking at a POM dependency?

                                     

                                    The URL you're using is correct, and your ModeShape repository configuration is valid. But I have no idea how or where you're deploying the WAR file, and whether you've properly set up the classpath, and whether you've put the configuration files in the correct locations. All of this is completely dependent upon the server on which you're deploying.

                                    1 2 Previous Next