agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/JobRequestInputProcessor.java
/**
     * Processes a single json array provided for a {@link SoftwareInput} field in a
     * job request
     * @param softwareInput the software input for which we are parsing the value
     * @param valueArray an JSON {@link ArrayNode} of single input string values
     * @return the sanitized json array of input values
     * @throws PermissionException if the user does not have permission to access the input
     */
Processes a single json array provided for a  SoftwareInput field in a
job request
@param softwareInput the software input for which we are parsing the value
@param valueArray an JSON  ArrayNode of single input string values
@return the sanitized json array of input values
@throws PermissionException if the user does not have permission to access the input
Processes a single json array provided for a SoftwareInput field in a job request @param softwareInput the software input for which we are parsing the value @param valueArray an JSON ArrayNode of single input string values @return the sanitized json array of input values @throws PermissionException if the user does not have permission to access the input
protected ArrayNode doProcessSoftwareInputValue(SoftwareInput softwareInput, ArrayNode valueArray)
            throws PermissionException, JobProcessingException {
        ArrayNode jobRequestInputValue = getMapper().createArrayNode();
        ArrayNode filteredValueArray = getMapper().createArrayNode();
        if (valueArray == null) {
            filteredValueArray = getMapper().createArrayNode();
        } else {
            for (JsonNode inputJsonNode: valueArray) {
                if (!inputJsonNode.isNull() || StringUtils.isNotBlank(inputJsonNode.textValue())) {
                    filteredValueArray.add(inputJsonNode.textValue());
                }
            }
        }
        if (softwareInput.getMinCardinality() > filteredValueArray.size()) {
            throw new JobProcessingException(400,
                    softwareInput.getKey() + " requires at least "
                            + softwareInput.getMinCardinality()
                            + " values");
        }
        else if (softwareInput.getMaxCardinality() != -1
                && softwareInput.getMaxCardinality() < filteredValueArray.size()) {
            throw new JobProcessingException(400,
                    softwareInput.getKey() + " may have at most "
                            + softwareInput.getMaxCardinality()
                            + " values");
        }
        else {
            for (JsonNode json : filteredValueArray) {
                if (!json.isValueNode()) {
                    throw new JobProcessingException(400,
                            "Invalid input value, "
                                    + json
                                    + ", for "
                                    + softwareInput.getKey()
                                    + ". Value must be a string value representing "
                                    + "a file or folder for which you have access.");
                }
                else if (json.isNull()) {
                    continue;
                }
                String sValue = doProcessSingleValue(softwareInput, json.textValue());
                jobRequestInputValue.add(sValue);
            }
            return jobRequestInputValue;
        }
    }
protected ArrayNode doProcessSoftwareInputValue ( SoftwareInput softwareInput , ArrayNode valueArray ) throws PermissionException , JobProcessingException { ArrayNode jobRequestInputValue = getMapper ( ) . createArrayNode ( ) ; ArrayNode filteredValueArray = getMapper ( ) . createArrayNode ( ) ; if ( valueArray == null ) { filteredValueArray = getMapper ( ) . createArrayNode ( ) ; } else { for ( JsonNode inputJsonNode : valueArray ) { if ( ! inputJsonNode . isNull ( ) || StringUtils . isNotBlank ( inputJsonNode . textValue ( ) ) ) { filteredValueArray . add ( inputJsonNode . textValue ( ) ) ; } } } if ( softwareInput . getMinCardinality ( ) > filteredValueArray . size ( ) ) { throw new JobProcessingException ( 400 , softwareInput . getKey ( ) + " requires at least " + softwareInput . getMinCardinality ( ) + " values" ) ; } else if ( softwareInput . getMaxCardinality ( ) != - 1 && softwareInput . getMaxCardinality ( ) < filteredValueArray . size ( ) ) { throw new JobProcessingException ( 400 , softwareInput . getKey ( ) + " may have at most " + softwareInput . getMaxCardinality ( ) + " values" ) ; } else { for ( JsonNode json : filteredValueArray ) { if ( ! json . isValueNode ( ) ) { throw new JobProcessingException ( 400 , "Invalid input value, " + json + ", for " + softwareInput . getKey ( ) + ". Value must be a string value representing " + "a file or folder for which you have access." ) ; } else if ( json . isNull ( ) ) { continue ; } String sValue = doProcessSingleValue ( softwareInput , json . textValue ( ) ) ; jobRequestInputValue . add ( sValue ) ; } return jobRequestInputValue ; } }
Processes a single json array provided for a {@link SoftwareInput} field in a
 job request
 @param softwareInput the software input for which we are parsing the value
 @param valueArray an JSON {@link ArrayNode} of single input string values
 @return the sanitized json array of input values
 @throws PermissionException if the user does not have permission to access the input
Processes a single json array provided for a { @link SoftwareInput } field in a job request @param softwareInput the software input for which we are parsing the value @param valueArray an JSON { @link ArrayNode } of single input string values @return the sanitized json array of input values @throws PermissionException if the user does not have permission to access the input
// strip out all null and empty values // check for too many values provided // check for too few values provided // process each value individually // only string values are supported // ignore empty values. default values are not autofilled by agave. // users must supply them on their own. The long exception being // when a SoftwareInput is not visible. In that situation, the // default value is always injected into the job request and // already present here.