Job Submission to Google Cloud Print

Prints the file specified by File type data item with the specified printer, and stores its communication log in a String type data item

    A. Set OAuth2 Config Name (at [OAuth 2.0 Setting])Single-line inputRequired
    B. Select STRING/SELECT for Printer ID (Non-existent Error)Data selectString(single line)orSelect(radio/select/search)Required
    C. Select FILE DATA for PrintData selectFileRequired
    D. Select STRING/SELECT for Cloud Job TicketData selectString(single line)orSelect(radio/select/search)
    X. Select STRING DATA for Access Log (update)Data selectString(multiple line)
    -variable namevariable label
    Aconf_OAuth2Set OAuth2 Config Name (at [OAuth 2.0 Setting])
    Bconf_DataIdBSelect STRING/SELECT for Printer ID (Non-existent Error)
    Cconf_DataIdCSelect FILE DATA for Print
    Dconf_DataIdDSelect STRING/SELECT for Cloud Job Ticket
    Xconf_DataIdXSelect STRING DATA for Access Log (update)
    // Submit a Print Job via Google Cloud Print Service (ver. 20161107)
    // (c) 2016, Questetra, Inc. (the MIT License)
    
    //// == 工程コンフィグの参照 / Config Retrieving ==
    var oauth2 = configs.get( "conf_OAuth2" );
    var dataIdB = configs.get( "conf_DataIdB" ); // (returns Number)
    var dataIdC = configs.get( "conf_DataIdC" ); // (returns Number)
    var dataIdD = configs.get( "conf_DataIdD" ); // (returns Number)
    var dataIdX = configs.get( "conf_DataIdX" ) + ""; // (returns Number)
    
    //// == ワークフローデータの参照 / Data Retrieving ==
    var printerId = "";
    if( data.get( dataIdB ) instanceof java.util.ArrayList ){
      printerId = data.get( dataIdB ).get(0).getValue() + "";
    }else if( data.get( dataIdB ) instanceof java.lang.String ){
      printerId = data.get( dataIdB ) + "";
    }
    var files = data.get( dataIdC );
    var cloudJobTicket = "";
    if( data.get( dataIdD ) instanceof java.util.ArrayList ){
      cloudJobTicket = data.get( dataIdD ).get(0).getValue() + "";
    }else if( data.get( dataIdD ) instanceof java.lang.String ){
      cloudJobTicket = data.get( dataIdD ) + "";
    }
    if( cloudJobTicket === "" ){
      cloudJobTicket = '{"version": "1.0", "print": {}}';
    }
    var jobTitle = "Questetra-" + processInstance.getProcessInstanceId() + "";
    
    //// == 演算 / Calculating ==
    var accessLog = "";
    var token = httpClient.getOAuth2Token( oauth2 );
    
    for( var i = 0; i < files.size(); i++  ){
      var uri = "https://www.google.com/cloudprint/submit";
      var response = httpClient.begin()
        .bearer( token )
        .multipart( "printerid", printerId )
        .multipart( "title", jobTitle )
        .multipart( "ticket", cloudJobTicket )
        .multipart( "content", files.get(i) )
        .post( uri );
      accessLog += "---POST request--- " + response.getStatusCode() + "\n";
      accessLog += response.getResponseAsString() + "\n";
    }
    
    //// == ワークフローデータへの代入 / Data Updating ==
    if( dataIdX !== "" ){
      retVal.put( dataIdX, accessLog );
    }
    

    • B’: Printer ID stored in the Data Item selected at config B
    • C’: File stored in the Data Item selected at config C
    • D’: Cloud Job Ticket stored in the Data Item selected at config D
    • File group C’ will be printed out by the specified printer
    • The communication log will be stored in the Data Item selected at X
    • It requires registering OAuth2 Communication at Google API Manager in advance
    • If Cloud Job Ticket isn’t specified, they will be printed out in the standard setting of printer{"version": "1.0", "print": {}}
    • B&W 2 copies: {"version":"1.0","print":{"vendor_ticket_item": [],"color":{"type": "STANDARD_MONOCHROME"}, "copies": {"copies": 2}}}
    • Single version specifies Printer ID fixedly in the automated step config