VMS RPC java

The vms rpc client makes it possible to connect to the vms more easily. This is achieved by taking away some of the complexities like connecting to the vms. This document provides a technical summary of the vms rpc client for Java.

This manual should answer all of the questions. For any remaining questions send an e-mail to support@bluebillywig.com.

Getting Started

Download location: vmsrpc.jar

There are extra jar files needed for the json parse example to work:

javax.json-api-1.0.jar
javax.json-1.0.3.jar

Make sure the jar files are in a location that's included in the classpath of the project.

Import these classes:

import java.io.*;
import java.util.*;
import javax.json.*;
import javax.json.stream.*;
import com.bluebillywig.VmsRpc;

Create a new instance of vmsrpc:

VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");

The following example demonstrates how to search for a couple of mediaclips and immediately print the embed code for each mediaclip:

Map<String,String> properties = new HashMap<String,String>();
properties.put("query","type:mediaclip AND status:published");
properties.put("limit","10");
properties.put("sort","createddate desc");

String json = vmsRpc.json( "search", null, properties );

byte[] bytes = json.getBytes();

InputStream inputStream = new ByteArrayInputStream(bytes);

JsonParser parser = Json.createParser( inputStream );

boolean idFound = false;

while (parser.hasNext()) {
    JsonParser.Event event = parser.next();
    switch(event) {
        case KEY_NAME:
            if( parser.getString().equals("id") ){
                idFound = true;
            }
            break;
        case VALUE_STRING:
        case VALUE_NUMBER:
            if( idFound ){
                String embedCode = "<script type=\"text/javascript\" src=\"http://publication.bbvms.com/p/default/c/" + parser.getString()  + ".js\"></script>";
                System.out.println( embedCode );
            }
            idFound = false;
            break;
        case START_ARRAY:
        case END_ARRAY:
        case START_OBJECT:
        case END_OBJECT:
        case VALUE_FALSE:
        case VALUE_NULL:
        case VALUE_TRUE:
    }
}

Function list

Here you can find the available functions within the RPC, which make it possible to execute API requests. More information concerning API requests can be found here: https://support.bluebillywig.com/vms-api-guide

3.1 doAction

Execute API request/action and return the result as an array.

Array doAction(String entity, String action, Map properties)

entity: The relevant api entity that you want to query to obtain the desired result. For example mediaclip, mediacliplist, publication or playout.

action: The action you want to execute. The actions differ per entity, see the API documentation for details. For example for the mediaclip entity possible actions are get, put or getUsageStats.

properties: This array will contain required or optional properties needed for the specific request. For example for the action put of the entity mediaclip you'll need to provide at least the property xml, see the example below.

Here an example to update a mediaclip:

VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");

String xml = "<media-clip id=\"1234567\" status=\"draft\"></media-clip>";

Map<String,String> properties = new HashMap<String,String>();
//Set the status to draft
properties.put("xml",xml);

vmsRpc.doAction("mediaclip","put",properties);

And an example to add a new mediaclip including a video-file:

VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");

String xml = "<media-clip title=\"Some title\" usetype=\"editorial\" status=\"published\">";
Map<String,String> properties = new HashMap<String,String>();
properties.put("xml",xml);
properties.put("Filedata","@/tmp/a_video_file.mp4");

vmsRpc.doAction("mediaclip","put",properties);

3.2 JSON

Execute API request/action and return the result in JSON format. At this moment it's only possible to get results in JSON format for get and search actions on mediaclips, timelines, widgets and zones.

String json(String entity)

String json(String entity, int objectId, Map properties)

entity: The relevant api entity that you want to query to obtain the desired result. For example mediaclip, mediacliplist, publication or playout.

objectId: (optional) The id of a certain entity, for example the mediaclipid. If objectId is set the action will become get.

properties: (optional) This array contains required or optional properties needed for the specific request.

Below an example to search for a couple of mediaclips.

VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");

Map<String,String> properties = new HashMap<String,String>();
properties.put("query","type:mediaclip AND status:published");
properties.put("limit","10");
properties.put("sort","createddate desc");

String json = vmsRpc.json( "search", null, properties );

3.3 XML

Execute API request/action and return the result in XML format.

String xml(String entity)

String xml(String entity, int objectId, Map properties)

entity: The relevant api entity that you want to query to obtain the desired result. For example mediaclip, mediacliplist, publication or playout.

objectId: (optional) The id of a certain entity, for example the mediaclipid. If objectId is set the action will become get.

properties: (optional) This array contains required or optional properties needed for the specific request. If not set the default action will become get.

Below an example to get global configurations of a publication.

VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");

String xml = vmsRpc.xml( "publication" );

3.4 URI

Execute an API request/action and send all properties for the specific request on the query string. This may be useful whether multiple properties with the same key need to be provided, which could be the case for Solr requests.

String uri(String apiEntityUrl)

String uri(String apiEntityUrl, String qs)

apiEntityUrl: The relevant api entity that you want to query to obtain the desired result. For example json/mediaclip or json/qstats.

qs: (optional) The Query String to be send with the request.

Below an example to get the mainconfig.xml, which contains configuration of your publication such as asset-paths.

VmsRpc vmsRpc = new VmsRpc("http://<publication>.bbvms.com","<username>","<password>");

String mainconfigXml = vmsRpc.uri("","mainconfig.xml");