Deployment via Repository Client

The following example shows how to deploy a robot and a type from the local file system using the RepositoryClient


String user = "test";
String password = "test1234";
RepositoryClient client = new RepositoryClient("http://localhost:50080", user, password);
try {
    FileInputStream robotStream = new FileInputStream("c:\\MyRobots\\Library\\Test.robot");
    FileInputStream typeStream = new FileInputStream("c:\\MyRobots\\Library\\Test.type");

    // Use the Kapow Java APIs StreamUtil to convert InputStream to byte[].
    // For production we recommend IOUtils.toByteArray(InputStream i) in the commons-io library from apache.
    byte[] robotBytes = StreamUtil.readStream(robotStream).toByteArray();
    byte[] typeBytes = StreamUtil.readStream(typeStream).toByteArray();

    // we assume that no one has deleted the Default project
    client.deployRobot("Default project", "Test.robot", robotBytes, true);
    client.deployType("Default project", "Test.type", typeBytes, true);
}
catch (RepositoryClientException e) {
    // an error connecting to the repository
    e.printStackTrace();
}
catch (FileNotFoundException e) {
    System.out.println("Could not load file from disk " + e.getMessage());
}
catch (IOException e) {
    System.out.println("Could not read bytes from stream " + e.getMessage());
}
catch (FileAlreadyExistsException e) {
    // either the type or file already exist in the give project
    System.out.println(e.getMessage());
}
    

Deployment using RepositoryClient