此内容没有您所选择的语言版本。

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

  1. 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:
    {
        "sample": {
            "repository": {
                "name": "sample",
                "resources": {
                    "workspaces": "/modeshape-rest/sample"
                },
                "metadata": {
                    "option.retention.supported": "false",
                    ...
                }
            }
        }
    }
    
    Copy to Clipboard Toggle word wrap
    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.
  2. 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:
    {
        "default": {
            "workspace": {
                "name": "default",
                "resources": {
                    "query": "/modeshape-rest/sample/default/query",
                    "items": "/modeshape-rest/sample/default/items"
                }
            }
        }
    }
    
    Copy to Clipboard Toggle word wrap
    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:
    • 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.
  3. 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:
    {
        "properties": {
            "jcr:primaryType": "mode:root",
            "jcr:uuid": "81513257505d64/"
        },
        "children": ["jcr:system"]
    }
    
    Copy to Clipboard Toggle word wrap
    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.
  4. 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:
    {
        "properties": {
            "jcr:primaryType": "mode:system"
        },
        "children": ["jcr:nodeTypes", "jcr:versionStorage", "mode:namespaces", "mode:locks"]
    }
    Copy to Clipboard Toggle word wrap
    Here, the "/jcr:system" node has only one property but has four children.
  5. 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:
    {
        "properties": {
            "jcr:primaryType": "mode:namespaces"
        },
        "children": ["jcr", "nt", "mix", "sv", "mode", "xml", "xmlns", "xs", "xsi"]
    }
    
    
    Copy to Clipboard Toggle word wrap
    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.
  6. 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:
    {
        "properties": {
            "jcr:primaryType": "mode:namespace",
            "mode:generated": "false",
            "mode:uri": "http:\/\/www.jcp.org\/jcr\/1.0"
        }
    }
    
    Copy to Clipboard Toggle word wrap
    Here, the "/jcr:system/mode:namespaces/jcr" node has three properties and no children.
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat