4.9. S-RAMP Command Line

4.9.1. Start the S-RAMP Shell

  1. Navigate to the ../bin directory.
  2. Run this command: ./s-ramp.sh

Result

The following appears on the screen:

**********************************************************************
           _____       ______  ___ ___  ________
          /  ___|      | ___ \/ _ \|  \/  | ___ \
          \ `--. ______| |_/ / /_\ \ .  . | |_/ /
           `--. \______|    /|  _  | |\/| |  __/
          /\__/ /      | |\ \| | | | |  | | |
          \____/       \_| \_\_| |_|_|  |_|_|

  JBoss S-RAMP Kurt Stam and Eric Wittmann, Licensed under the
  Apache License, V2.0, Copyright 2012
**********************************************************************
s-ramp>
The shell supports auto-completion and keeps a command history for duration of the session.

4.9.2. Connect to the S-RAMP Server

Connecting to the S-RAMP server gives you access to the S-RAMP dashboard and repository. This allows you to access artifacts and their metadata in one place. Once you have signed in, you can browse the repository and inspect your data.
  1. Open a command terminal and navigate to EAP_HOME/bin directory.
  2. Start the JBoss EAP server by entering following command:
    $ ./standalone.sh
  3. Open another terminal and type connect and press Tab key. The command will auto-complete to say s-ramp:connect http://localhost:8080/s-ramp-server.
    Enter username and password to connect via the S-RAMP shell. The username and password are defined in sramp.properties.

Result

When you press Tab key, the command will auto-complete to say s-ramp:connect http://localhost:8080/s-ramp-server and when you press the return key the cursor will go from red to green indicating successful connection to S-ramp server.

4.9.3. Browse the S-RAMP Repository

Running the commands in this task will allow you to access the S-RAMP repository and peruse its contents. You can view server output and metadata for artifacts. This lets you view additional details of indexed items.
  1. Run this command: s-ramp:query /s-ramp
    Here is an example of the output of this command:
    Querying the S-RAMP repository:
        /s-ramp
    Atom Feed (9 entries)
      Idx                    Type Name
      ---                    ---- ----
        1           ImageDocument user-properties.png
        2                Document overlord.demo.CheckDeployment-taskform.flt
        3         BrmsPkgDocument SRAMPPackage.pkg
        4           ImageDocument overlord.demo.SimpleReleaseProcess-image.png
        5           ImageDocument run-build-install.png
        6                Document overlord.demo.SimpleReleaseProcess-taskform.flt
        7           ImageDocument audio-input-microphone-3.png
        8            BpmnDocument overlord.demo.SimpleReleaseProcess.bpmn
        9            TextDocument HttpClientWorkDefinitions.wid
    
  2. To obtain the metaData of overlord.demo.SimpleReleaseProcess.bpmn (which is number 8 in the list in the output example), issue this command: s-ramp:getMetaData feed:8
    Meta Data for: 31b3acbc-cda8-4856-9e34-d3e645283035
    --------------
      -- Core S-RAMP Info --
      Type: BpmnDocument
      Model: ext
      UUID: 31b3acbc-cda8-4856-9e34-d3e645283035
      Name: overlord.demo.SimpleReleaseProcess.bpmn
      Derived: false
      Created By: anonymous
      Created On: 2013-03-08T14:00:37.036-05:00
      Modified By: anonymous
      Modified On: 2013-03-18T14:58:46.328-04:00
    s-ramp>
    

4.9.4. Update Artifact Metadata

  1. To update a property on the artifact, enter s-ramp:property set and hit the tab key.
    This lists the properties that you can update.
    description       name           version
  2. Add a description: s-ramp:property set description "BPMN2 artifact representing the SimpleReleaseProcess".
    Successfully set property description.
    s-ramp> s-ramp:updateMetaData
    Successfully updated artifact overlord.demo.SimpleReleaseProcess.bpmn.
  3. Verify the change, by entering s-ramp:getMetaData feed:8.
    The change will appear at the bottom of the output:
    Meta Data for: 31b3acbc-cda8-4856-9e34-d3e645283035
    --------------
      -- Core S-RAMP Info --
      Type: BpmnDocument
      Model: ext
      UUID: 31b3acbc-cda8-4856-9e34-d3e645283035
      Name: overlord.demo.SimpleReleaseProcess.bpmn
      Derived: false
      Created By: anonymous
      Created On: 2013-03-08T14:00:37.036-05:00
      Modified By: anonymous
      Modified On: 2013-03-18T16:09:56.879-04:00
      -- Description --
    BPMN2 artifact representing the SimpleReleaseProcess

4.9.5. Add Custom Properties

  1. To add a custom property, run the s-ramp> s-ramp:property set month December command, where month is the name of the property and December is the value.
    Successfully set property month.
  2. To update artifact, run the s-ramp> s-ramp:updateMetaData command.
    Successfully updated artifact overlord.demo.SimpleReleaseProcess.bpmn.
  3. Verify the change, by entering s-ramp:getMetaData feed:8.
    The change will appear at the bottom of the output:
    Meta Data for: 31b3acbc-cda8-4856-9e34-d3e645283035
    --------------
      -- Core S-RAMP Info --
      Type: BpmnDocument
      Model: ext
      UUID: 31b3acbc-cda8-4856-9e34-d3e645283035
      Name: overlord.demo.SimpleReleaseProcess.bpmn
      Derived: false
      Created By: anonymous
      Created On: 2013-03-08T14:00:37.036-05:00
      Modified By: anonymous
      Modified On: 2013-03-18T16:21:16.119-04:00
      -- Description --
    BPMN2 artifact representing the SimpleReleaseProcess
      -- Custom Properties --
      month: December
  4. Now when you enter s-ramp:property set and hit the tab key, you can see your newly added custom property:
    description    month           name           version

4.9.6. Add Classifications

  1. To add a classification of deployment-status to your artifact, use the s-ramp> s-ramp:classification add "http://www.jboss.org/overlord/deployment-status.owl#Dev" command.
    Successfully added classification 'http://www.jboss.org/overlord/deployment-status.owl#Dev'.
  2. To update artifact, run the s-ramp> s-ramp:updateMetaData command.
    Successfully updated artifact overlord.demo.SimpleReleaseProcess.bpmn.
  3. Verify the change, by entering s-ramp:getMetaData feed:8.
    The change will appear at the bottom of the output:
    Meta Data for: 31b3acbc-cda8-4856-9e34-d3e645283035
    --------------
      -- Core S-RAMP Info --
      Type: BpmnDocument
      Model: ext
      UUID: 31b3acbc-cda8-4856-9e34-d3e645283035
      Name: overlord.demo.SimpleReleaseProcess.bpmn
      Derived: false
      Created By: anonymous
      Created On: 2013-03-08T14:00:37.036-05:00
      Modified By: anonymous
      Modified On: 2013-03-18T16:30:42.641-04:00
      -- Description --
    BPMN2 artifact representing the SimpleReleaseProcess
      -- Classifications --
      Classified By: http://www.jboss.org/overlord/deployment-status.owl#Dev
      -- Custom Properties --
      month: December

4.9.7. Query the S-RAMP Repository using XPath2 Syntax

  1. S-RAMP supports an XPath2 Syntax for querying. For example, to obtain all WSDL models in the repository, use the s-ramp:query /s-ramp/wsdl/WsdlDocument command.
    Querying the S-RAMP repository:
        /s-ramp/wsdl/WsdlDocumenta
    Atom Feed (1 entries)
      Idx                    Type Name
      ---                    ---- ----
        1            WsdlDocument OrderService.wsdl
    When this WSDL file is uploaded, the derived information is extracted from it and stored a WSDL model.
  2. To see the various data structures the WSDL file derives, enter s-ramp:query /s-ramp/wsdl command and press the tab key.
    Binding                  BindingOperation         BindingOperationFault    BindingOperationInput    BindingOperationOutput
    Fault                    Message                  Operation                OperationInput           OperationOutput
    Part                     Port                     PortType                 WsdlDocument             WsdlExtension
    WsdlService
    The derived data is read-only.
  3. To obtain all Operations in this WSDL, use the s-ramp:query /s-ramp/wsdl/Operation command.
    Querying the S-RAMP repository:
        /s-ramp/wsdl/Operation
    Atom Feed (1 entries)
      Idx                    Type Name
      ---                    ---- ----
        1               Operation submitOrder
    To narrow down this query, add a condition that the name needs to start with submit: s-ramp:query "/s-ramp/wsdl/Operation[xp2:matches(@name, 'submit.*')]"
    Querying the S-RAMP repository:
        /s-ramp/wsdl/Operation[xp2:matches(@name, 'submit.*')]
    Atom Feed (1 entries)
      Idx                    Type Name
      ---                    ---- ----
        1               Operation submitOrder
    Ensure that you use the surrounding quotes, and a . (dot) after submit as required by XPath2.
  4. To obtain all the artifacts that were derived from an artifact, use the following command:
    /s-ramp[relatedDocument[@uuid = '<uuid>'
    In this case, you can use the uuid of a wsdl and get all the artifacts derived from the wsdl:
    s-ramp:query "/s-ramp[relatedDocument[@uuid = '15a94308-a088-4a03-ad83-e60239af74e4']]"
    Querying the S-RAMP repository:
    	/s-ramp[relatedDocument[@uuid = '15a94308-a088-4a03-ad83-e60239af74e4']]
    Atom Feed (16 entries)
      Idx                    Type Name
      ---                    ---- ----
        1          OperationInput submitOrder
        2             WsdlService OrderService
        3             SoapAddress soap:address
        4   BindingOperationInput wsdl:input
        5             SoapBinding soap:binding
        6                    Part parameters
        7                 Binding OrderServiceBinding
        8  BindingOperationOutput wsdl:output
        9                 Message submitOrderResponse
       10         OperationOutput submitOrderResponse
       11        BindingOperation submitOrder
       12                 Message submitOrder
       13               Operation submitOrder
       14                    Port OrderServicePort
       15                    Part parameters
       16                PortType OrderService
  5. To get a list of all artifacts that were extracted from another archive, use the following command:
    s-ramp:query "/s-ramp[expandedFromDocument[@uuid = '<uuid>']"
    For example, if you uploaded a jar file containing switchyard artifacts, with uddi 67c6f2d3-0f10-4f0d-ada6-d85f92f02a33:
    s-ramp:query "/s-ramp[expandedFromDocument[@uuid = '67c6f2d3-0f10-4f0d-ada6-d85f92f02a33']]"
    Querying the S-RAMP repository:
    	/s-ramp[expandedFromDocument[@uuid = '67c6f2d3-0f10-4f0d-ada6-d85f92f02a33']]
    Atom Feed (3 entries)
      Idx                    Type Name
      ---                    ---- ----
        1             XmlDocument switchyard.xml
        2             XmlDocument beans.xml
        3             XmlDocument faces-config.xml

4.9.8. Extending the S-RAMP CLI

The S-RAMP CLI has a number of built-in commands that are ready to be used. However, it is also possible to extend the CLI with new custom commands. This section describes how to do it.
New CLI commands are contributed by creating a class that implements the ShellCommandProvider interface. The provider indicates a namespace for its commands along with a Map of commands (command name > command). The provider and command implementations should be packaged up into a JAR along with a file called META-INF/services/org.overlord.sramp.shell.api.ShellCommandProvider.
Ensure to make the JAR available to the S-RAMP CLI, either by putting it on the classpath, or else by putting it in the ~/.s-ramp/commands directory.