eXo Platform 3.5

- Prev
- Next

## Chapter 86. RestServicesList Service

## Overview.

RestServicesList service is intendet to provide information about rest services deployed to the application server.

- Path - path to service

- Regex - service's URL regular expression

- FQN - full qualified name of service's class

The list can be provided in two formats: HTML and JSON.

## Usage

### Note

Class does not implement org.exoplatform.services.rest.resource.ResourceContainer and must never be binded to RESTful framework by using eXoContainer. This service must works as per-request resource.

### HTML format

To get the list of services in HTML format use listHTML() method:

    @GET

    @Produces({MediaType.TEXT_HTML})

    public byte[] listHTML()

    {

       ...

    }

To do this, perform a simple GET request to the RestServicesList link.

f.e. curl -u root:exo http://localhost:8080/rest/ will return such HTML code:

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

       <head>

          <title>eXo JAXRS Implementation</title>

       </head>

       <body>

          <h3 style="text-align:center;">Root resources</h3>

          <table   width="90%"   style="table-layout:fixed;">

             <tr>

                <th>Path</th>

                <th>Regex</th>

                <th>FQN</th>

             </tr>

             <tr>

                <td>script/groovy</td>

                <td>/script/groovy(/.*)?</td>

                <td>org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader</td>

             </tr>

             <tr>

                <td>/lnkproducer/</td>

                <td>/lnkproducer(/.*)?</td>

                <td>org.exoplatform.services.jcr.webdav.lnkproducer.LnkProducer</td>

             </tr>

             <tr>

                <td>/registry/</td>

                <td>/registry(/.*)?</td>

                <td>org.exoplatform.services.jcr.ext.registry.RESTRegistryService</td>

             </tr>

             <tr>

                <td>/jcr</td>

                <td>/jcr(/.*)?</td>

                <td>org.exoplatform.services.jcr.webdav.WebDavServiceImpl</td>

             </tr>

             <tr>

                <td>/</td>

                <td>(/.*)?</td>

                <td>org.exoplatform.services.rest.ext.service.RestServicesList</td>

             </tr>

          </table>

       </body>

    </html>

If you perform the same request with your browser, you'll see the table with the list of deployed services like this:

Path | Regex | FQN
--- | --- | ---
script/groovy | /script/groovy(/.*)? | org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader
/lnkproducer/ | /lnkproducer(/.*)? | org.exoplatform.services.jcr.webdav.lnkproducer.LnkProducer
/registry/ | /registry(/.*)? | org.exoplatform.services.jcr.ext.registry.RESTRegistryService
/jcr | /jcr(/.*)? | org.exoplatform.services.jcr.webdav.WebDavServiceImpl
/ | (/.*)? | org.exoplatform.services.rest.ext.service.RestServicesList

### JSON format

To get the list of services in HTML format use listJSON() method:

    @GET

    @Produces({MediaType.APPLICATION_JSON})

    public RootResourcesList listJSON()

    {

       ...

    }

To do this, add "Accept:application/json" header to your GET request

f.e. curl -u root:exo http://localhost:8080/rest/ -H "Accept:application/json" will return such JSON:

    {"rootResources":[
       {
          "fqn":"org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader",
          "regex":"/script/groovy(/.*)?",
          "path":"script/groovy"
       },
       {
          "fqn":"org.exoplatform.services.jcr.webdav.lnkproducer.LnkProducer",
          "regex":"/lnkproducer(/.*)?",
          "path":"/lnkproducer/"
       },
       {
          "fqn":"org.exoplatform.services.jcr.ext.registry.RESTRegistryService",
          "regex":"/registry(/.*)?",
          "path":"/registry/"
       },
       {
          "fqn":"org.exoplatform.services.jcr.webdav.WebDavServiceImpl",
          "regex":"/jcr(/.*)?",
          "path":"/jcr"
       },
       {
          "fqn":"org.exoplatform.services.rest.ext.service.RestServicesList",
          "regex":"(/.*)?",
          "path":"/"
       }
    ]}

- Prev
- Up
- Home
- Next