agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/managers/monitors/parsers/DefaultJsonStatusResponseParser.java
/**
	 * Parses the {@code schedulerResponseText} as a {@link ObjectNode} and checks the value of the "status" field
	 * in the object. Valid status values match any {@link DefaultJobStatus#getCode()} in a case insensitive way.
	 *
	 * @param remoteJobId           the remote job id to parse from the response
	 * @param schedulerResponseText the response text from the remote scheduler
	 * @return a {@link JobStatusResponse} containing remote status info about the job with {@code remoteJobId}
	 * @throws RemoteJobMonitorEmptyResponseException   if {@code schedulerResponseText} is blank
	 * @throws RemoteJobMonitorResponseParsingException if {@code schedulerResponseText} could not be parsed
	 */
Parses the  schedulerResponseText as a  ObjectNode and checks the value of the "status" field
in the object. Valid status values match any  DefaultJobStatus#getCode() in a case insensitive way.


Parses the schedulerResponseText as a ObjectNode and checks the value of the " status " field in the object . Valid status values match any DefaultJobStatus#getCode () in a case insensitive way .
@Override
	public JobStatusResponse parse(String remoteJobId, String schedulerResponseText) throws RemoteJobMonitorEmptyResponseException, RemoteJobMonitorResponseParsingException {
		if (StringUtils.isBlank(schedulerResponseText)) {
			throw new RemoteJobMonitorEmptyResponseException(
					"Empty response received from job status check on the remote system.");
		} else if (!schedulerResponseText.contains("|")) {
			throw new RemoteJobMonitorResponseParsingException(
					"Unexpected fields in the response from the scheduler: " + schedulerResponseText);
		} else {
			ObjectMapper mapper = new ObjectMapper();
			JsonNode json;
			try {
				json = mapper.readTree(schedulerResponseText);
				if (json.isObject()) {
					if (json.has("status")) {
						String statusValue = json.get("status").asText();
						DefaultJobStatus remoteJobStatus = DefaultJobStatus.valueOfCode(statusValue);
						String exitCode = "0";
						return new JobStatusResponse<>(remoteJobId, remoteJobStatus, exitCode);
					} else {
						throw new RemoteJobMonitorResponseParsingException(
								"No status field found in JSON response from the scheduler: " + schedulerResponseText);
					}
				} else {
					throw new RemoteJobMonitorResponseParsingException(
							"JSON array found in response from the scheduler. " +
							"JSON object with status field required: " + schedulerResponseText);
				}
			} catch (IOException e) {
				throw new RemoteJobMonitorResponseParsingException("Invalid JSON response from the scheduler: " + schedulerResponseText, e);
			}
		}
	}
@ Override public JobStatusResponse parse ( String remoteJobId , String schedulerResponseText ) throws RemoteJobMonitorEmptyResponseException , RemoteJobMonitorResponseParsingException { if ( StringUtils . isBlank ( schedulerResponseText ) ) { throw new RemoteJobMonitorEmptyResponseException ( "Empty response received from job status check on the remote system." ) ; } else if ( ! schedulerResponseText . contains ( "|" ) ) { throw new RemoteJobMonitorResponseParsingException ( "Unexpected fields in the response from the scheduler: " + schedulerResponseText ) ; } else { ObjectMapper mapper = new ObjectMapper ( ) ; JsonNode json ; try { json = mapper . readTree ( schedulerResponseText ) ; if ( json . isObject ( ) ) { if ( json . has ( "status" ) ) { String statusValue = json . get ( "status" ) . asText ( ) ; DefaultJobStatus remoteJobStatus = DefaultJobStatus . valueOfCode ( statusValue ) ; String exitCode = "0" ; return new JobStatusResponse < > ( remoteJobId , remoteJobStatus , exitCode ) ; } else { throw new RemoteJobMonitorResponseParsingException ( "No status field found in JSON response from the scheduler: " + schedulerResponseText ) ; } } else { throw new RemoteJobMonitorResponseParsingException ( "JSON array found in response from the scheduler. " + "JSON object with status field required: " + schedulerResponseText ) ; } } catch ( IOException e ) { throw new RemoteJobMonitorResponseParsingException ( "Invalid JSON response from the scheduler: " + schedulerResponseText , e ) ; } } }
Parses the {@code schedulerResponseText} as a {@link ObjectNode} and checks the value of the "status" field
 in the object.
Parses the { @code schedulerResponseText } as a { @link ObjectNode } and checks the value of the " status " field in the object .