此内容没有您所选择的语言版本。
4.3. Using Repositories with REST in EAP
4.3.1. RESTful API 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The RESTful API is a simple JAX-RS web application that is packaged as a WAR file, and the kit automatically deploys this WAR file. HTTP clients use the hierarchical database's RESTful API. Hence it is easy to write a simple client application to read and write repository content using the RESTful API. However, since your web browser is a simple HTTP client, you can use it to directly interact with the RESTful API. The RESTful API automatically installs when you install the hierarchical database into a JBoss EAP installation.
Procedure 4.12. Task
- To use the RESTful API to check the health and availability of the repositories, point your browser to http://localhost:8080/modeshape-rest/. This results in a JSON response that is similar to the following:The response document lists the named repositories that are available. In this case, there is only one "sample" repository, and its nested document provides the name, resources and metadata for the repository. The "resources" nested document contains the usable (relative) link.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To use the link to get more information about the repository, issue a GET to the resource at http://localhost:8080/modeshape-rest/sample, which you can do by pointing your browser to this URL. When you do this, the RESTful service returns a JSON response document describing the "sample" repository as shown below:This document describes the repository and lists the named workspaces. In this case, there is a single "default" workspace, and the following resources available for use:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - http://localhost:8080/modeshape-rest/sample/default/items exposes the repository's nodes via RESTful methods.
- http://localhost:8080/modeshape-rest/sample/default/query allows RESTful clients to POST queries and receive responses containing the results.
- Continue to navigate the content of the "default" workspace in the "sample" repository. You can not issue a POST with your web browser without some HTML/JavaScript content on the page. For example, if you point your browser to http://localhost:8080/modeshape-rest/sample/default/items, you will get a response that describes the root node of that workspace:Here, the root node has two properties, jcr:primaryType and jcr:uuid (since the node is also mix:referenceable), and one child node jcr:system.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can append the child name to your URL (for example, http://localhost:8080/modeshape-rest/sample/default/items/jcr:system) to get the information about the "/jcr:system" node:Here, the "/jcr:system" node has only one property but has four children.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can look at the mode:namespaces child node by pointing your browser to http://localhost:8080/modeshape-rest/sample/default/items/jcr:system/mode:namespaces to get its JSON representation:Here, you can see only one property, while there are 9 children, one for each registered namespace, where the node name is the namespace prefix.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can get the JSON representation of the "jcr" namespace by pointing your browser to http://localhost:8080/modeshape-rest/sample/default/items/jcr:system/mode:namespaces/jcr:Here, the "/jcr:system/mode:namespaces/jcr" node has three properties and no children.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow