JBoss Community Archive (Read Only)

ModeShape 5

ModeShape's REST Service

ModeShape's RESTful API was intended to be used by HTTP clients, so it's quite easy to write a simple client application to read and write repository content using the RESTful API. However, since our trusty web browser is indeed a simple HTTP client, we can use it to directly interact with the RESTful API. It might not be pretty, but it works beautifully.


Depending on whether you want to use the REST endpoint in the JBoss Application Server or another web server, there are 2 different options:


To embed the REST endpoint in your own application, you need to use the modeshape-web-jcr-rest-war artifact which comes pre-packaged with all the default dependencies (including ModeShape). The easiest way to use & customize this is to first add the artifact as a dependency in your project:


after which you need to overwrite (overlay) your own web.xml, repository configuration and optional additional dependencies. The former is the most important as it contains a reference towards your own custom repository configuration:

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    <display-name>ModeShape JCR RESTful Interface Custom Configuration</display-name>

         This parameter defines the location of the configuration file, or can specify
         the JNDI location of the Repository or Repositories implementation.
         (If the object in JNDI is a ModeShape Repositories instance, then this web application
         will support multiple repositories.)

         If a file is specified, ModeShape will first check for a file at this path in the filesystem.
         If not file exists at this path, ModeShape will attempt to load this as a resource
         from the classpath.

         The JNDI location can be specified in the form jndi:<jndi_name>

         This parameter defines the JAX-RS application class, which is really just a metadata class
         that lets the JAX-RS engine (RESTEasy in this case) know which classes implement pieces
         of the JAX-RS specification like exception handling and resource serving.

         This should not be modified.

    <!-- Required parameter for RESTEasy - should not be modified -->

    <!-- Required parameter for ModeShape REST - should not be modified -->

    <!-- Required parameter for RESTEasy - should not be modified -->

    <!-- Required parameter for ModeShape REST - should not be modified -->

Maven automatically overlays dependencies of type war, so all you need to do is make sure your project structure contains the correct paths: src/main/resource and src/main/webapp/WEB-INF/web.xml.

See also our examples for such a configuration.

JBoss Wildfly

Once installed into Wildfly, the ModeShape Wildfly kit provides the RESTful API out-of-the-box, via a web application named modeshape-rest.war. This application is configured by default via the standalone-modeshape.xml server configuration file and allows access to all the repositories configured & deployed via Wildfly.

        <subsystem xmlns="urn:jboss:domain:modeshape:2.0">
            <!--The list of web applications that is packaged inside the kit and should be deployed when the subsystem starts up-->
            <webapp name="modeshape-rest.war"/>

See also Using Repositories with REST in Wildfly

By default, both web applications use Basic HTTP Authentication and require a role named connect to be present in the authenticated user's set of roles.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:12:50 UTC, last content change 2016-04-07 07:05:43 UTC.