Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Upload report to BA server

  1. #1
    Join Date
    Nov 2015

    Question Upload report to BA server


    I am currently working on a project where I need to upload a report to the BA server repository (URL: ***/api/repo/publish/file). I would like to achieve this by using the HTTP Post step and an User Defined Java Class step that produces the request entity field.
    However I didn't manage to come up with a working code. Since my boss does not want me to use external libraries, I am sticking to the org.apache.commons.httpclient classes which are deployed with kettle.
    My approach is to create a Part[] array containing the FilePart and StringParts. The next step is to create a MultipartRequestEntity which is then writen to a ByteArrayOutputStream.

    File filePart = new File(fileReport);FilePart fileUpload  = new FilePart("fileUpload", filePart);
    StringPart applyAclPermissions = new StringPart("applyAclPermissions","true");
    StringPart overwriteAclPermissions = new StringPart("overwriteAclPermissions","true");
    StringPart overwriteFile  = new StringPart("overwriteFile", "true");
    StringPart logLevel = new StringPart("logLevel","TRACE");
    StringPart retainOwnership = new StringPart("retainOwnership", "false");
    StringPart fileNameOverride = new StringPart("fileNameOverride","blablub.prpt");
    StringPart importDir = new StringPart("importDir", "/public");
    Part[] parts = {
    HttpMethodParams params = new HttpMethodParams();
    MultipartRequestEntity requestEntity = new MultipartRequestEntity(
        parts, params
    ByteArrayOutputStream bOutput = new ByteArrayOutputStream();
    String requestEntityValue = new String(bOutput.toByteArray());
    String contentType = requestEntity.getContentType();
    String contentLength = String.valueOf(requestEntity.getContentLength());
    Object[] outputRow = createOutputRow(r, data.outputRowMeta.size());
    get(Fields.Out, "requestEntityValue").setValue(outputRow, requestEntityValue);
    get(Fields.Out, "contentType").setValue(outputRow, contentType);
    get(Fields.Out, "contentLength").setValue(outputRow, contentLength);
    putRow(data.outputRowMeta, outputRow);
    return true;
    In the next step the data is sent with the HTTP Post Step. However the server is not satisfied with this approach.

    Do you guys have any idea what I am doing wrong?

    Thanks for your help!

  2. #2
    Join Date
    Nov 2015


    I had to write my own step, to solve this problem....

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.