HTTP Files Retrieve

HTTP Files Get
http-filesGet-20171119-addonxml.txt
(md5:306e584cb33959ada9709927f1bcdeed)

    • A’: URL of the copy source file stored in the Data Item selected at config A
    • Retrieving the file which has been published at URL of A’, stores it into the data item selected at config B
    • The communication logs are stored in the data item selected in config X

    A. Select STRING/SELECT DATA for File URLData selectString(single line)orSelect(radio/select/search)Required
    B. Select FILE DATA for File Saved (update)Data selectFileRequired
    X. Select STRING DATA for Access Log (update)Data selectString(multiple line)
    -variable namevariable label
    Aconf_DataIdASelect STRING/SELECT DATA for File URL
    Bconf_DataIdBSelect FILE DATA for File Saved (update)
    Xconf_DataIdXSelect STRING DATA for Access Log (update)
    // HTTP Files Get (ver. 20171119)
    // (c) 2017, Questetra, Inc. (the MIT License)
    
    
    //// == Config Retrieving / 工程コンフィグの参照 ==
    var dataIdA = configs.get( "conf_DataIdA" ) + "";
    var dataIdB = configs.get( "conf_DataIdB" ) + "";
    var dataIdX = configs.get( "conf_DataIdX" ) + "";
    // convert 'java.lang.String' to 'javascript string'
    
    
    //// == Data Retrieving / ワークフローデータの参照 ==
    var fileUrl = "";
    if( engine.findDataDefinitionByNumber( dataIdA ).matchDataType( "SELECT_SINGLE" ) ){
        fileUrl = engine.findDataByNumber( dataIdA ).get(0).getValue() + "";
    }else{
        fileUrl = engine.findDataByNumber( dataIdA ) + "";
    }
    var processFiles = engine.findDataByNumber( dataIdB );
    // java.util.ArrayList 
    if (processFiles === null) {
      processFiles = new java.util.ArrayList();
    }
    
    
    //// == Calculating / 演算 ==
    // File Name
    //var arrStr   = fileUrl.split("/");
    //var fileName = arrStr[arrStr.length - 1];
    var fileName = fileUrl.match(".+/(.+?)([\?#;].*)?$")[1];
    if (fileName === ""){ fileName = "NoName"; }
    
    // Access to the URL
    var httpRequest = httpClient.begin(); // HttpRequestWrapper
    // com.questetra.bpms.core.event.scripttask.HttpClientWrapper
    var response = httpRequest.get( fileUrl ); // HttpResponseWrapper
    var httpStatus = response.getStatusCode() + "";
    var accessLog = "---GET request--- " + httpStatus + "\n";
    
    // Error Handling
    // (no action)
    
    
    //// == Data Updating / ワークフローデータへの代入 ==
    processFiles.add(
      new com.questetra.bpms.core.event.scripttask.NewQfile( 
        fileName, response.getContentType(), response.getResponse()
      )
    );
    engine.setDataByNumber( dataIdB, processFiles );
    if ( dataIdX !== "" ){ engine.setDataByNumber( dataIdX, accessLog ); }