CRISP Dev Studio Application

Introduction

The CRISP Dev Studio feature has been supported since v14.1.0.

When testing and debugging backend API invocations, it often takes unignorable time and effort for developers to figure out what the working REST API URIs, parameters, headers, encoding, etc. look like. Especially if each developer needs to set up security configuration (e.g, OAuth2 client ID and secrets) against the backend with their favorite REST API test tools, it becomes more difficult. They can use some debugging techniques to tweak parameters through debuggers, but it is still less productive.

CRISP Dev Studio provides a web application module, which can be downloaded and run automatically in local development environments. The web application has a reverse proxy servlet which uses the same CRISP ResourceServiceBroker and the existing ResourceResolver configurations, so developers may invoke the reverse proxy servlet to retrieve data from the backend without having to worry about copying the same base URLs, headers, etc.

For example, after enabling CRISP Dev Studio web application in the cargo.run profile, when the developer executes the following example command, they can get a JSON output from the backend ("theforce" in this case) through the internal reverse proxy servlet, which actually invokes the ResourceServiceBroker with the resource space name, "theforce", and other inputs from the HTTP client ("curl" in this case), such as HTTP method, HTTP headers, form parameters, etc.

$ curl -i -H "Content-Type: application/json" http://localhost:8080/crispstudio/theforce/services/data/v39.0/sobjects/Account/LAPALOMA0CCGCGBBGBG

As the internal reverse proxy servlet invokes ResourceServiceBroker with all the inputs from the HTTP client, developers no more need to worry about other complicated configurations such as OAuth2 client ID and secrets.

Limitation

As CRISP Dev Studio is deployed as a separate web application in the local Tomcat server without any specific CRISP API configurations, this feature is supported only when you install the CRISP API as a shared module. See the Install CRISP Addon as Shared Module page for the details on the installation option.

Configuration

To enable CRISP Dev Studio web application in your local development environment, add the following to the cargo.run profile in the root pom.xml:

    <profile>
      <id>cargo.run</id>
      <!-- SNIP -->
      <dependencies>
        <dependency>
          <groupId>org.onehippo.cms7</groupId>
          <artifactId>hippo-addon-crisp-studio</artifactId>
          <version>${hippo.addon-crisp.version}</version>
          <type>war</type>
          <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <configuration>
              <!-- SNIP -->
              <deployables>
                <!-- SNIP -->
                <deployable>
                  <groupId>org.onehippo.cms7</groupId>
                  <artifactId>hippo-addon-crisp-studio</artifactId>
                  <type>war</type>
                  <properties>
                    <context>/crispstudio</context>
                  </properties>
                </deployable>
                <!-- SNIP -->
              </deployables>
              <!-- SNIP -->
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

Basically, the preceding does the following:

  • Add the dependency on the CRISP Dev Studio web application artifact (org.onehippo.cms7:hippo-addon-crisp-studio:war).
  • Add the CRISP Dev Studio as a deployable web application (context path: "/crispstudio") in the <deployables> section. The web application artifact will be downloaded automatically from the maven repository.
  • Now, if you run the project using "cargo.run" profile, the /crispstudio web application on your local Tomcat server will be available.
Note that the CRISP Dev Studio web application module is mainly intended to help developers in the local development environment (e.g, running with "cargo.run" profile). It may cause severe security problems if you enable it in an online deployed environment without considering how to secure the access properly in prior.

Command examples

The internal reverse proxy servlet in CRISP Dev Studio web application resolves the resource space name next to the context path and passes all the input URI path, HTTP method, HTTP headers and HTTP body entity (if existing) to the backend APIs through ResourceServiceBroker and ExchangeHint. Also, it writes the output from the backend back to the HTTP client.

Therefore, there is no limitation using various HTTP methods, such as PUT, DELETE, etc., or other type of inputs that might be supported by the backend.

Here are some examples to show how to interact with the backend indirectly.

GET invocation

The following command makes an invocation on the "theforce" resource space with the path, "/services/data/v39.0/sobjects/Account/0012o00002R3tekAAB", using HTTP GET method and the specified headers. You can get the output from the backend afterward.

$ curl -i -H "Content-Type: application/json" http://localhost:8080/crispstudio/theforce/services/data/v39.0/sobjects/Account/0012o00002R3tekAAB

HTTP/1.1 200 
...
Last-Modified: Tue, 03 Dec 2019 14:04:34 GMT
Date: Fri, 13 Dec 2019 01:57:04 GMT
Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
Vary: Accept-Encoding
Content-Type: application/json;charset=UTF-8
Content-Length: 2341

{"attributes":{"type":"Account","url":"/services/data/v39.0/sobjects/Account/LAPALOMA0CCGCGBBGBG"},
"Id":"LAPALOMA0CCGCGBBGBG","Name":"Sebastián Iradier", ... }}

POST invocation

The following command makes an invocation on the "theforce" resource space with the path, "/services/apexrest/ccrz/ccproduct/v8/find", using HTTP POST method, the specified headers and the HTTP request body entity in JSON. You can get the output from the backend afterward.

$ curl -i -d '{"LOCALE":"en_US","PRODUCTLIMIT":9,"INCLUDECOUNT":true,"SEARCHTERM":"server"}' \
  -H "Content-Type: application/json" \
  -X POST \
  http://localhost:8080/crispstudio/theforce/services/apexrest/ccrz/ccproduct/v8/find

HTTP/1.1 200 
...
Date: Tue, 03 Dec 2019 20:48:22 GMT
Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: application/json
Transfer-Encoding: chunked

{"productPricingData":{"a1F2o00000MvaUcEAJ":{"basePrice":{"itemType":null,"price":29.99,"priceList":"a112o00000I9iT5AAJ","sfid":"a102o00000JIJ0NAAX"}, ... }}}}

 

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?