eXo Platform 3.0

- Prev
- Next

## Chapter 3. Services configuration

Let's see the description and configuration of server-side services, used by eXo IDE application.

## Repository Discovery Service (now @Path("/services/discovery"))

IDE was built with support for virtual file system that can have many implementations. Repository Discovery Service is used to provide the client a list of entry points, including the access protocol. For now only the WebDav protocol is supported.

RepositoryDiscoveryService is configured in such a way:

    <component>
       <type>org.exoplatform.ide.discovery.RepositoryDiscoveryService
       </type>
    </component>

### Get Entry Points

/services/discovery/entrypoints

    Get the list of available entry points (root directories).

URL:

    http://[host]:[port]/[rest context]/services/discovery/entrypoints

Method: GET

Response Format: application/json

Parameters: no

Returns:

- when success:

JSON bean of org.exoplatform.ide.discovery.EntryPointList:

    {"entryPoints":[{"scheme":"jcr-webdav","href":"http://localhost:8080/IDE-application/rest/private/
    jcr/repository/production/"},
    {"scheme":"jcr-webdav","href":"http://localhost:8080/IDE-application/rest/private/jcr/repository/
    dev-monit/"}]}

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## Upload Service (now @Path("/services/upload"))

Use next configuration for Upload Service:

    <component>
       <type>org.exoplatform.ide.upload.UploadServiceApplication</type>
    </component>

### Upload Local File

/services/upload

    Stores files from local system drive to the repository.

URL:

    http://[host]:[port]/[rest context]/services/upload/

Method: POST

Request Format: multipart/form-data

Parameters:

- location path of uploading file (full Webdav href) in the repository;

- mimeType MIME type of uploaded file;

- nodeType node type of uploaded file;

- jcrContentNodeType node type for jcr:content node.

Returns::

- when success:

    status code = 201

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
    status code = 409            - parent not found for item
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## Loopback Content Service (now @Path("/services/loopbackcontent"))

Loopback Content Service is used for getting the content of local file through server.

To make request client must create a HTML form (<form> element), and set only one field that indicates file input.

After this client must set form parameters such as method, encoding and submit url ( action ):

    <form method="post" enctype="multipart/form-data"  action="/rest/private/services/loopbackcontent">
       <input type="file" name="*file*">
    </form>

Add following configuration for Loopback Content Service:

    <component>
       <type>org.exoplatform.ide.upload.LoopbackContentService</type>
    </component>

### Get Local File's Content

/services/loopbackcontent

    Get local file's content.

URL:

    http://[host]:[port]/[rest context]/services/loopbackcontent/

Method: POST

Request Format: multipart/form-data

Response Format: text/html The result of the response is XML inclosed in "<pre>...</pre>" tag from server with encoded file's content inside.

Parameters: no

Returns::

- when success:

    status code = 200

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## Download Content Service (now @Path("/services/downloadcontent"))

Download Content Service is used for downloading files and forces the browser to open download window. Use the configuration below for Download Content Service:

    <component>
       <type>org.exoplatform.ide.download.DownloadContentService</type>
    </component>

### Download File

services/downloadcontent/

URL:

    http://[host]:[port]/[rest context]/services/downloadcontent/{fileName:.*}?repoPath=[path to file]

Method: POST

Response Format: downloading file's content type

Parameters:

- fileName name of the file to download;

- repoPath href to file via WebDav.

Returns::

- when success:

    status code = 200

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
                                 - file for download is not found
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## Groovy Script Service (now @Path("/services/groovy"))

Groovy Script Service is used for validating, deploying and undeploying groovy services. Use next configuration to set up Groovy Script Service:

    <component>
       <type>org.exoplatform.ide.groovy.GroovyScriptServiceApplication</type>
    </component>

### Validation Groovy Script

/services/groovy/validate

    Validates Groovy script.

URL:

    http://[host]:[port]/[rest context]/services/groovy/validate

Method: POST

Request Format: script/groovy Send content of groovy script file

Parameters:

- location header parameter, which indicates the path to groovy script

Returns::

- when success:

    status code = 200

- when failure:

    status code = 400            - validation failed
    status code = 401            - unauthorized
    status code = 404            - service is not deployed
    status code = 500            - the unknown error
    failure message in response  - the description of failure

### Deploy/Undeploy Groovy Script

/services/groovy/load

    Deploys or undeploys Groovy script on server.

URL:

    http://[host]:[port]/[rest context]/services/groovy/load?state=[load state]

Method: POST

Parameters:

- state indicates load action with groovy script (true for deploy, false for undeploy);

- location header parameter, which indicates the path to groovy script

Returns::

- when success:

    status code = 204

- when failure:

                                 - validation failed (for deploy)
    status code = 400            - it is not root resource (for deploy)
                                 - root resource with the same URI pattern already registered (for deploy)
                                 - not bound (for undeploy)
                                 - wrong mapping to the resource class ((for undeploy))
    status code = 401            - unauthorized
    status code = 404            - service is not deployed
                                 - script is not found
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## Gadget Service (now @Path("/ideall/gadget"))

Gadget service is used for operations with Google gadgets, such as deploy and undeploy it in portal.

Add following component to your configuration file:

    <component>
       <type>org.exoplatform.ide.service.gatein.RestGadgetRegistryService</type>
    </component>

### Deploy Gadget

ideall/gadget/deploy

    Deploy gadget in portal.

URL:

    http://[host]:[port]/[rest context]/ideall/gadget/deploy?gadgetURL=[gadget path]&privateContext=[private context]&publicContext=[public context]

Method: POST

Parameters:

- gadgetURL gadget's location in the repository;

- privateContext private REST context;

- publicContext public REST context.

Returns::

- when success:

    status code = 200

- when failure:

    status code = 400            - invalid gadget structure
    status code = 401            - unauthorized
    status code = 500            - the unknown error
    failure message in response  - the description of failure

### Undeploy gadget

ideall/gadget/undeploy

    Undeploy gadget in portal.

URL:

    http://[host]:[port]/[rest context]/ideall/gadget/undeploy?gadgetURL=[gadget path]&privateContext=
    [private context]&publicContext=[public context]

Method: POST

Parameters:

- gadgetURL gadget location in the repository;

- privateContext private REST context;

- publicContext public REST context.

Returns::

- when success:

    status code = 204

- when failure:

    status code = 401            - unauthorized
    status code = 404            - gadget is not deployed
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## REST Conversation State Service (now @Path("/conversation-state"))

REST Conversation State service is used to get logged user in portal.

Configuration is the following:

    <component>
       <type>org.exoplatform.ide.conversationstate.RestConversationState</type>
    </component>

### Whoami

conversation-state/whoami

    Get logged user name in portal.

URL:

    http://[host]:[port]/[rest context]/conversation-state/whoami

Method: GET

Response Format: text/plain

Permitted Security Role: users

Parameters: no

Returns::

- when success:

Logged user name:

    root

    status code = 204

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## REST Registry Service

To store and get eXo IDE application's settings, REST registry service is used.

Add the following to configuration file:

    <component>
       <type>org.exoplatform.services.jcr.ext.registry.RegistryService</type>
       <init-params>
          <properties-param>
             <name>locations</name>
          </properties-param>
       </init-params>
    </component>

    <component>
       <type>org.exoplatform.services.jcr.ext.registry.RESTRegistryService</type>
    </component>

### Save Application Settings

registry/repository/exo:users/user/IDE/

    Save application settings.

URL:

    http://[host]:[port]/[rest context]/registry/repository/exo:users/{user}/IDE/?createIfNotExist=[create]

Method: PUT

Request Format: application/xml Send in body settings:

    <settings>
       <toolbar-items_list>
          <item>---</item>
          <item>File%2FOpen%20File%20With...</item>
          <item>File%2FUpload%20File...</item>
          <item>File%2FNew%20*</item>
          ...
       </toolbar-items_list>
       <hotkeys_map>
          <item>
             <key>Ctrl%2B83</key>
             <value>File%2FSave</value>
          </item>
          <item>
             <key>Ctrl%2B70</key>
             <value>Edit%2FFind-Replace...</value>
          </item>
          ...
       </hotkeys_map>
    </settings>

where:

- toolbar-itemslist list of toolbar items;

  - item name of toolbar item;

- hotkeysmap list of hot keys used in application;

  - item hot key item;

    - key key combination;

    - value command to be run for this hot key.

Parameters:

- createIfNotExist indicates whether to create item if it doesn't exist or not;

- user logged user name.

Returns::

- when success:

    status code = 201

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
                                 - settings not found
    status code = 500            - the unknown error
    failure message in response  - the description of failure

### Get Application Settings

registry/repository/exo:users/user/IDE/

    Get saved application settings.

URL:

    http://[host]:[port]/[rest context]/registry/repository/exo:users/{user}/IDE/

Method: GET

Response Format: application/xml

Parameters: no

Returns::

- when success:

Settings response in XML bean org.exoplatform.ide.client.model.settings.ApplicationSettings

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <IDE jcr:primaryType="exo:registryGroup">
       <settings jcr:primaryType="exo:registryEntry">
          <toolbar-items_list jcr:primaryType="nt:unstructured">
             <item jcr:primaryType="nt:unstructured">File%2FOpen%20File%20With...</item>
             ...
          </toolbar-items_list>
          <hotkeys_map jcr:primaryType="nt:unstructured">
             <item jcr:primaryType="nt:unstructured">
                <key jcr:primaryType="nt:unstructured">Ctrl%2B83</key>
                <value jcr:primaryType="nt:unstructured">File%2FSave</value>
             </item>
             ...
          </hotkeys_map>
       </settings>
    </IDE>

where:

- toolbar-itemslist list of toolbar items;

  - item toolbar item's name;

- hotkeysmap list of hot keys, used in application;

  - item hot key item;

    - key key combination;

    - value command to be run for this hot key.

- when failure:

    status code = 401            - unauthorized
    status code = 404            - service is not deployed
                                 - settings not found
    status code = 500            - the unknown error
    failure message in response  - the description of failure

## Proxy Service

As far as GWT applications use AJAX and it doesn't allow cross site requests, proxy service may be helpful. It gets your URL from "url" query parameter and gets the required content instead of client and gives it back. To use it add written bellow to your configuration:

    <component>
       <type>org.exoplatform.services.rest.ext.proxy.ProxyService</type>
    </component>

## WebDav Service

The main protocol for communication with the server in eXo IDE is WebDav. WebDav is used for storing, managing files and folders in the repository. GWT supports only GET and POST HTTP methods for sending requests.

Only GET and POST http methods are supported in GWT. Considering this limitation, the client sets a special header ("X-HTTP-Method-Override") for each request to the server, which indicates the original WebDav method.

WebDav service will be available, if the following configuration is added:

    <component>
       <key>org.exoplatform.services.jcr.webdav.WebDavServiceImpl</key>
       <type>org.exoplatform.services.jcr.webdav.WebDavServiceImpl</type>
          <init-params>
             <value-param>
                <name>auto-mix-lockable</name>
                <value>false</value>
             </value-param>
             <value-param>
                <name>def-folder-node-type</name>
                <value>nt:folder</value>
             </value-param>
             <value-param>
                <name>def-file-node-type</name>
                <value>nt:file</value>
             </value-param>
             <value-param>
                <name>def-file-mimetype</name>
                <value>text/plain</value>
             </value-param>
             <value-param>
                <name>update-policy</name>
                <value>create-version</value>
          </value-param>
        </init-params>
     </component>

- Prev
- Up
- Home
- Next