Example usage for javax.xml.bind DatatypeConverter parseDateTime

List of usage examples for javax.xml.bind DatatypeConverter parseDateTime

Introduction

In this page you can find the example usage for javax.xml.bind DatatypeConverter parseDateTime.

Prototype

public static java.util.Calendar parseDateTime(String lexicalXSDDateTime) 

Source Link

Document

Converts the string argument into a Calendar value.

Usage

From source file:com.microsoft.windowsazure.management.compute.DeploymentOperationsImpl.java

/**
* Identifies the list of reboot events due to planned maintenance that
* impacted a deployment in the optionally provided timeframe.
*
* @param serviceName Required. The name of the cloud service.
* @param deploymentName Required. The name of the deployment.
* @param startTime Required. Datetime in UTC representing the start time of
* the query./*  w  w  w  . j  a v a2s.co  m*/
* @param endTime Required. Datetime in UTC representing the end time of the
* query.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @return Identifies the list of reboot events due to planned maintenance
* that impacted a deployment in the optionally provided timeframe.
*/
@Override
public DeploymentEventListResponse listEvents(String serviceName, String deploymentName, Calendar startTime,
        Calendar endTime) throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate
    if (serviceName == null) {
        throw new NullPointerException("serviceName");
    }
    if (deploymentName == null) {
        throw new NullPointerException("deploymentName");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("serviceName", serviceName);
        tracingParameters.put("deploymentName", deploymentName);
        tracingParameters.put("startTime", startTime);
        tracingParameters.put("endTime", endTime);
        CloudTracing.enter(invocationId, this, "listEventsAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/hostedservices/";
    url = url + URLEncoder.encode(serviceName, "UTF-8");
    url = url + "/deployments/";
    url = url + URLEncoder.encode(deploymentName, "UTF-8");
    url = url + "/events";
    ArrayList<String> queryParameters = new ArrayList<String>();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    queryParameters
            .add("starttime=" + URLEncoder.encode(simpleDateFormat.format(startTime.getTime()), "UTF-8"));
    SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
    simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC"));
    queryParameters.add("endtime=" + URLEncoder.encode(simpleDateFormat2.format(endTime.getTime()), "UTF-8"));
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        DeploymentEventListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new DeploymentEventListResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element deploymentEventCollectionElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "DeploymentEventCollection");
            if (deploymentEventCollectionElement != null) {
                Element rebootEventsSequenceElement = XmlUtility.getElementByTagNameNS(
                        deploymentEventCollectionElement, "http://schemas.microsoft.com/windowsazure",
                        "RebootEvents");
                if (rebootEventsSequenceElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(rebootEventsSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "RebootEvent")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element rebootEventsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(rebootEventsSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "RebootEvent")
                                .get(i1));
                        RebootEvent rebootEventInstance = new RebootEvent();
                        result.getDeploymentEvents().add(rebootEventInstance);

                        Element roleNameElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "RoleName");
                        if (roleNameElement != null) {
                            String roleNameInstance;
                            roleNameInstance = roleNameElement.getTextContent();
                            rebootEventInstance.setRoleName(roleNameInstance);
                        }

                        Element instanceNameElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "InstanceName");
                        if (instanceNameElement != null) {
                            String instanceNameInstance;
                            instanceNameInstance = instanceNameElement.getTextContent();
                            rebootEventInstance.setInstanceName(instanceNameInstance);
                        }

                        Element rebootReasonElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "RebootReason");
                        if (rebootReasonElement != null) {
                            String rebootReasonInstance;
                            rebootReasonInstance = rebootReasonElement.getTextContent();
                            rebootEventInstance.setRebootReason(rebootReasonInstance);
                        }

                        Element rebootStartTimeElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "RebootStartTime");
                        if (rebootStartTimeElement != null && rebootStartTimeElement.getTextContent() != null
                                && !rebootStartTimeElement.getTextContent().isEmpty()) {
                            Calendar rebootStartTimeInstance;
                            rebootStartTimeInstance = DatatypeConverter
                                    .parseDateTime(rebootStartTimeElement.getTextContent());
                            rebootEventInstance.setRebootStartTime(rebootStartTimeInstance);
                        }
                    }
                }

                Element continuationTokenElement = XmlUtility.getElementByTagNameNS(
                        deploymentEventCollectionElement, "http://schemas.microsoft.com/windowsazure",
                        "ContinuationToken");
                if (continuationTokenElement != null) {
                    String continuationTokenInstance;
                    continuationTokenInstance = continuationTokenElement.getTextContent();
                    result.setContinuationToken(continuationTokenInstance);
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:com.microsoft.windowsazure.management.compute.DeploymentOperationsImpl.java

/**
* Identifies the list of reboot events due to planned maintenance that
* impacted a deployment in the optionally provided timeframe.
*
* @param serviceName Required. The name of the cloud service.
* @param deploymentSlot Required. The deployment slot.
* @param startTime Required. Datetime in UTC representing the start time of
* the query./*w w w .  j  a  v a  2 s .  c  om*/
* @param endTime Required. Datetime in UTC representing the end time of the
* query.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @return Identifies the list of reboot events due to planned maintenance
* that impacted a deployment in the optionally provided timeframe.
*/
@Override
public DeploymentEventListResponse listEventsBySlot(String serviceName, DeploymentSlot deploymentSlot,
        Calendar startTime, Calendar endTime)
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate
    if (serviceName == null) {
        throw new NullPointerException("serviceName");
    }
    if (deploymentSlot == null) {
        throw new NullPointerException("deploymentSlot");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("serviceName", serviceName);
        tracingParameters.put("deploymentSlot", deploymentSlot);
        tracingParameters.put("startTime", startTime);
        tracingParameters.put("endTime", endTime);
        CloudTracing.enter(invocationId, this, "listEventsBySlotAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/hostedservices/";
    url = url + URLEncoder.encode(serviceName, "UTF-8");
    url = url + "/deploymentslots/";
    url = url + URLEncoder.encode(deploymentSlot.toString(), "UTF-8");
    url = url + "/events";
    ArrayList<String> queryParameters = new ArrayList<String>();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    queryParameters
            .add("starttime=" + URLEncoder.encode(simpleDateFormat.format(startTime.getTime()), "UTF-8"));
    SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
    simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC"));
    queryParameters.add("endtime=" + URLEncoder.encode(simpleDateFormat2.format(endTime.getTime()), "UTF-8"));
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        DeploymentEventListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new DeploymentEventListResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element deploymentEventCollectionElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "DeploymentEventCollection");
            if (deploymentEventCollectionElement != null) {
                Element rebootEventsSequenceElement = XmlUtility.getElementByTagNameNS(
                        deploymentEventCollectionElement, "http://schemas.microsoft.com/windowsazure",
                        "RebootEvents");
                if (rebootEventsSequenceElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(rebootEventsSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "RebootEvent")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element rebootEventsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(rebootEventsSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "RebootEvent")
                                .get(i1));
                        RebootEvent rebootEventInstance = new RebootEvent();
                        result.getDeploymentEvents().add(rebootEventInstance);

                        Element roleNameElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "RoleName");
                        if (roleNameElement != null) {
                            String roleNameInstance;
                            roleNameInstance = roleNameElement.getTextContent();
                            rebootEventInstance.setRoleName(roleNameInstance);
                        }

                        Element instanceNameElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "InstanceName");
                        if (instanceNameElement != null) {
                            String instanceNameInstance;
                            instanceNameInstance = instanceNameElement.getTextContent();
                            rebootEventInstance.setInstanceName(instanceNameInstance);
                        }

                        Element rebootReasonElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "RebootReason");
                        if (rebootReasonElement != null) {
                            String rebootReasonInstance;
                            rebootReasonInstance = rebootReasonElement.getTextContent();
                            rebootEventInstance.setRebootReason(rebootReasonInstance);
                        }

                        Element rebootStartTimeElement = XmlUtility.getElementByTagNameNS(rebootEventsElement,
                                "http://schemas.microsoft.com/windowsazure", "RebootStartTime");
                        if (rebootStartTimeElement != null && rebootStartTimeElement.getTextContent() != null
                                && !rebootStartTimeElement.getTextContent().isEmpty()) {
                            Calendar rebootStartTimeInstance;
                            rebootStartTimeInstance = DatatypeConverter
                                    .parseDateTime(rebootStartTimeElement.getTextContent());
                            rebootEventInstance.setRebootStartTime(rebootStartTimeInstance);
                        }
                    }
                }

                Element continuationTokenElement = XmlUtility.getElementByTagNameNS(
                        deploymentEventCollectionElement, "http://schemas.microsoft.com/windowsazure",
                        "ContinuationToken");
                if (continuationTokenElement != null) {
                    String continuationTokenInstance;
                    continuationTokenInstance = continuationTokenElement.getTextContent();
                    result.setContinuationToken(continuationTokenInstance);
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:com.microsoft.windowsazure.scheduler.JobOperationsImpl.java

/**
* Update the state of a job.//from  w w  w  .ja  va 2s . c o m
*
* @param jobId Required. Id of the job to update.
* @param parameters Required. Parameters supplied to the Update Job State
* operation.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return The Update Job State operation response.
*/
@Override
public JobUpdateStateResponse updateState(String jobId, JobUpdateStateParameters parameters)
        throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (jobId == null) {
        throw new NullPointerException("jobId");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getState() == null) {
        throw new NullPointerException("parameters.State");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("jobId", jobId);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "updateStateAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/cloudservices/";
    url = url + URLEncoder.encode(this.getClient().getCloudServiceName(), "UTF-8");
    url = url + "/resources/";
    url = url + "scheduler";
    url = url + "/~/";
    url = url + "JobCollections";
    url = url + "/";
    url = url + URLEncoder.encode(this.getClient().getJobCollectionName(), "UTF-8");
    url = url + "/jobs/";
    url = url + URLEncoder.encode(jobId, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2014-04-01");
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpPatch httpRequest = new HttpPatch(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json; charset=utf-8");
    httpRequest.setHeader("x-ms-version", "2013-03-01");

    // Serialize Request
    String requestContent = null;
    JsonNode requestDoc = null;

    ObjectMapper objectMapper = new ObjectMapper();
    ObjectNode jobUpdateStateParametersValue = objectMapper.createObjectNode();
    requestDoc = jobUpdateStateParametersValue;

    ((ObjectNode) jobUpdateStateParametersValue).put("state",
            SchedulerClientImpl.jobStateToString(parameters.getState()));

    if (parameters.getUpdateStateReason() != null) {
        ((ObjectNode) jobUpdateStateParametersValue).put("stateDetails", parameters.getUpdateStateReason());
    }

    StringWriter stringWriter = new StringWriter();
    objectMapper.writeValue(stringWriter, requestDoc);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/json; charset=utf-8");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        JobUpdateStateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new JobUpdateStateResponse();
            JsonNode responseDoc = null;
            String responseDocContent = IOUtils.toString(responseContent);
            if (responseDocContent == null == false && responseDocContent.length() > 0) {
                responseDoc = objectMapper.readTree(responseDocContent);
            }

            if (responseDoc != null && responseDoc instanceof NullNode == false) {
                Job jobInstance = new Job();
                result.setJob(jobInstance);

                JsonNode idValue = responseDoc.get("id");
                if (idValue != null && idValue instanceof NullNode == false) {
                    String idInstance;
                    idInstance = idValue.getTextValue();
                    jobInstance.setId(idInstance);
                }

                JsonNode startTimeValue = responseDoc.get("startTime");
                if (startTimeValue != null && startTimeValue instanceof NullNode == false) {
                    Calendar startTimeInstance;
                    startTimeInstance = DatatypeConverter.parseDateTime(startTimeValue.getTextValue());
                    jobInstance.setStartTime(startTimeInstance);
                }

                JsonNode actionValue = responseDoc.get("action");
                if (actionValue != null && actionValue instanceof NullNode == false) {
                    JobAction actionInstance = new JobAction();
                    jobInstance.setAction(actionInstance);

                    JsonNode typeValue = actionValue.get("type");
                    if (typeValue != null && typeValue instanceof NullNode == false) {
                        JobActionType typeInstance;
                        typeInstance = SchedulerClientImpl.parseJobActionType(typeValue.getTextValue());
                        actionInstance.setType(typeInstance);
                    }

                    JsonNode retryPolicyValue = actionValue.get("retryPolicy");
                    if (retryPolicyValue != null && retryPolicyValue instanceof NullNode == false) {
                        RetryPolicy retryPolicyInstance = new RetryPolicy();
                        actionInstance.setRetryPolicy(retryPolicyInstance);

                        JsonNode retryTypeValue = retryPolicyValue.get("retryType");
                        if (retryTypeValue != null && retryTypeValue instanceof NullNode == false) {
                            RetryType retryTypeInstance;
                            retryTypeInstance = SchedulerClientImpl
                                    .parseRetryType(retryTypeValue.getTextValue());
                            retryPolicyInstance.setRetryType(retryTypeInstance);
                        }

                        JsonNode retryIntervalValue = retryPolicyValue.get("retryInterval");
                        if (retryIntervalValue != null && retryIntervalValue instanceof NullNode == false) {
                            Duration retryIntervalInstance;
                            retryIntervalInstance = TimeSpan8601Converter
                                    .parse(retryIntervalValue.getTextValue());
                            retryPolicyInstance.setRetryInterval(retryIntervalInstance);
                        }

                        JsonNode retryCountValue = retryPolicyValue.get("retryCount");
                        if (retryCountValue != null && retryCountValue instanceof NullNode == false) {
                            int retryCountInstance;
                            retryCountInstance = retryCountValue.getIntValue();
                            retryPolicyInstance.setRetryCount(retryCountInstance);
                        }
                    }

                    JsonNode errorActionValue = actionValue.get("errorAction");
                    if (errorActionValue != null && errorActionValue instanceof NullNode == false) {
                        JobErrorAction errorActionInstance = new JobErrorAction();
                        actionInstance.setErrorAction(errorActionInstance);

                        JsonNode typeValue2 = errorActionValue.get("type");
                        if (typeValue2 != null && typeValue2 instanceof NullNode == false) {
                            JobActionType typeInstance2;
                            typeInstance2 = SchedulerClientImpl.parseJobActionType(typeValue2.getTextValue());
                            errorActionInstance.setType(typeInstance2);
                        }

                        JsonNode requestValue = errorActionValue.get("request");
                        if (requestValue != null && requestValue instanceof NullNode == false) {
                            JobHttpRequest requestInstance = new JobHttpRequest();
                            errorActionInstance.setRequest(requestInstance);

                            JsonNode uriValue = requestValue.get("uri");
                            if (uriValue != null && uriValue instanceof NullNode == false) {
                                URI uriInstance;
                                uriInstance = new URI(uriValue.getTextValue());
                                requestInstance.setUri(uriInstance);
                            }

                            JsonNode methodValue = requestValue.get("method");
                            if (methodValue != null && methodValue instanceof NullNode == false) {
                                String methodInstance;
                                methodInstance = methodValue.getTextValue();
                                requestInstance.setMethod(methodInstance);
                            }

                            JsonNode headersSequenceElement = ((JsonNode) requestValue.get("headers"));
                            if (headersSequenceElement != null
                                    && headersSequenceElement instanceof NullNode == false) {
                                Iterator<Map.Entry<String, JsonNode>> itr = headersSequenceElement.getFields();
                                while (itr.hasNext()) {
                                    Map.Entry<String, JsonNode> property = itr.next();
                                    String headersKey = property.getKey();
                                    String headersValue = property.getValue().getTextValue();
                                    requestInstance.getHeaders().put(headersKey, headersValue);
                                }
                            }

                            JsonNode bodyValue = requestValue.get("body");
                            if (bodyValue != null && bodyValue instanceof NullNode == false) {
                                String bodyInstance;
                                bodyInstance = bodyValue.getTextValue();
                                requestInstance.setBody(bodyInstance);
                            }

                            JsonNode authenticationValue = requestValue.get("authentication");
                            if (authenticationValue != null
                                    && authenticationValue instanceof NullNode == false) {
                                String typeName = authenticationValue.get("type").getTextValue();
                                if ("ClientCertificate".equals(typeName)) {
                                    ClientCertAuthentication clientCertAuthenticationInstance = new ClientCertAuthentication();

                                    JsonNode passwordValue = authenticationValue.get("password");
                                    if (passwordValue != null && passwordValue instanceof NullNode == false) {
                                        String passwordInstance;
                                        passwordInstance = passwordValue.getTextValue();
                                        clientCertAuthenticationInstance.setPassword(passwordInstance);
                                    }

                                    JsonNode pfxValue = authenticationValue.get("pfx");
                                    if (pfxValue != null && pfxValue instanceof NullNode == false) {
                                        String pfxInstance;
                                        pfxInstance = pfxValue.getTextValue();
                                        clientCertAuthenticationInstance.setPfx(pfxInstance);
                                    }

                                    JsonNode certificateThumbprintValue = authenticationValue
                                            .get("certificateThumbprint");
                                    if (certificateThumbprintValue != null
                                            && certificateThumbprintValue instanceof NullNode == false) {
                                        String certificateThumbprintInstance;
                                        certificateThumbprintInstance = certificateThumbprintValue
                                                .getTextValue();
                                        clientCertAuthenticationInstance
                                                .setCertificateThumbprint(certificateThumbprintInstance);
                                    }

                                    JsonNode certificateExpirationValue = authenticationValue
                                            .get("certificateExpiration");
                                    if (certificateExpirationValue != null
                                            && certificateExpirationValue instanceof NullNode == false) {
                                        Calendar certificateExpirationInstance;
                                        certificateExpirationInstance = DatatypeConverter
                                                .parseDateTime(certificateExpirationValue.getTextValue());
                                        clientCertAuthenticationInstance
                                                .setCertificateExpiration(certificateExpirationInstance);
                                    }

                                    JsonNode certificateSubjectNameValue = authenticationValue
                                            .get("certificateSubjectName");
                                    if (certificateSubjectNameValue != null
                                            && certificateSubjectNameValue instanceof NullNode == false) {
                                        String certificateSubjectNameInstance;
                                        certificateSubjectNameInstance = certificateSubjectNameValue
                                                .getTextValue();
                                        clientCertAuthenticationInstance
                                                .setCertificateSubjectName(certificateSubjectNameInstance);
                                    }

                                    JsonNode typeValue3 = authenticationValue.get("type");
                                    if (typeValue3 != null && typeValue3 instanceof NullNode == false) {
                                        HttpAuthenticationType typeInstance3;
                                        typeInstance3 = SchedulerClientImpl
                                                .parseHttpAuthenticationType(typeValue3.getTextValue());
                                        clientCertAuthenticationInstance.setType(typeInstance3);
                                    }
                                    requestInstance.setAuthentication(clientCertAuthenticationInstance);
                                }
                                if ("ActiveDirectoryOAuth".equals(typeName)) {
                                    AADOAuthAuthentication aADOAuthAuthenticationInstance = new AADOAuthAuthentication();

                                    JsonNode secretValue = authenticationValue.get("secret");
                                    if (secretValue != null && secretValue instanceof NullNode == false) {
                                        String secretInstance;
                                        secretInstance = secretValue.getTextValue();
                                        aADOAuthAuthenticationInstance.setSecret(secretInstance);
                                    }

                                    JsonNode tenantValue = authenticationValue.get("tenant");
                                    if (tenantValue != null && tenantValue instanceof NullNode == false) {
                                        String tenantInstance;
                                        tenantInstance = tenantValue.getTextValue();
                                        aADOAuthAuthenticationInstance.setTenant(tenantInstance);
                                    }

                                    JsonNode audienceValue = authenticationValue.get("audience");
                                    if (audienceValue != null && audienceValue instanceof NullNode == false) {
                                        String audienceInstance;
                                        audienceInstance = audienceValue.getTextValue();
                                        aADOAuthAuthenticationInstance.setAudience(audienceInstance);
                                    }

                                    JsonNode clientIdValue = authenticationValue.get("clientId");
                                    if (clientIdValue != null && clientIdValue instanceof NullNode == false) {
                                        String clientIdInstance;
                                        clientIdInstance = clientIdValue.getTextValue();
                                        aADOAuthAuthenticationInstance.setClientId(clientIdInstance);
                                    }

                                    JsonNode typeValue4 = authenticationValue.get("type");
                                    if (typeValue4 != null && typeValue4 instanceof NullNode == false) {
                                        HttpAuthenticationType typeInstance4;
                                        typeInstance4 = SchedulerClientImpl
                                                .parseHttpAuthenticationType(typeValue4.getTextValue());
                                        aADOAuthAuthenticationInstance.setType(typeInstance4);
                                    }
                                    requestInstance.setAuthentication(aADOAuthAuthenticationInstance);
                                }
                                if ("Basic".equals(typeName)) {
                                    BasicAuthentication basicAuthenticationInstance = new BasicAuthentication();

                                    JsonNode usernameValue = authenticationValue.get("username");
                                    if (usernameValue != null && usernameValue instanceof NullNode == false) {
                                        String usernameInstance;
                                        usernameInstance = usernameValue.getTextValue();
                                        basicAuthenticationInstance.setUsername(usernameInstance);
                                    }

                                    JsonNode passwordValue2 = authenticationValue.get("password");
                                    if (passwordValue2 != null && passwordValue2 instanceof NullNode == false) {
                                        String passwordInstance2;
                                        passwordInstance2 = passwordValue2.getTextValue();
                                        basicAuthenticationInstance.setPassword(passwordInstance2);
                                    }

                                    JsonNode typeValue5 = authenticationValue.get("type");
                                    if (typeValue5 != null && typeValue5 instanceof NullNode == false) {
                                        HttpAuthenticationType typeInstance5;
                                        typeInstance5 = SchedulerClientImpl
                                                .parseHttpAuthenticationType(typeValue5.getTextValue());
                                        basicAuthenticationInstance.setType(typeInstance5);
                                    }
                                    requestInstance.setAuthentication(basicAuthenticationInstance);
                                }
                            }
                        }

                        JsonNode queueMessageValue = errorActionValue.get("queueMessage");
                        if (queueMessageValue != null && queueMessageValue instanceof NullNode == false) {
                            JobQueueMessage queueMessageInstance = new JobQueueMessage();
                            errorActionInstance.setQueueMessage(queueMessageInstance);

                            JsonNode storageAccountValue = queueMessageValue.get("storageAccount");
                            if (storageAccountValue != null
                                    && storageAccountValue instanceof NullNode == false) {
                                String storageAccountInstance;
                                storageAccountInstance = storageAccountValue.getTextValue();
                                queueMessageInstance.setStorageAccountName(storageAccountInstance);
                            }

                            JsonNode queueNameValue = queueMessageValue.get("queueName");
                            if (queueNameValue != null && queueNameValue instanceof NullNode == false) {
                                String queueNameInstance;
                                queueNameInstance = queueNameValue.getTextValue();
                                queueMessageInstance.setQueueName(queueNameInstance);
                            }

                            JsonNode sasTokenValue = queueMessageValue.get("sasToken");
                            if (sasTokenValue != null && sasTokenValue instanceof NullNode == false) {
                                String sasTokenInstance;
                                sasTokenInstance = sasTokenValue.getTextValue();
                                queueMessageInstance.setSasToken(sasTokenInstance);
                            }

                            JsonNode messageValue = queueMessageValue.get("message");
                            if (messageValue != null && messageValue instanceof NullNode == false) {
                                String messageInstance;
                                messageInstance = messageValue.getTextValue();
                                queueMessageInstance.setMessage(messageInstance);
                            }
                        }

                        JsonNode serviceBusTopicMessageValue = errorActionValue.get("serviceBusTopicMessage");
                        if (serviceBusTopicMessageValue != null
                                && serviceBusTopicMessageValue instanceof NullNode == false) {
                            JobServiceBusTopicMessage serviceBusTopicMessageInstance = new JobServiceBusTopicMessage();
                            errorActionInstance.setServiceBusTopicMessage(serviceBusTopicMessageInstance);

                            JsonNode topicPathValue = serviceBusTopicMessageValue.get("topicPath");
                            if (topicPathValue != null && topicPathValue instanceof NullNode == false) {
                                String topicPathInstance;
                                topicPathInstance = topicPathValue.getTextValue();
                                serviceBusTopicMessageInstance.setTopicPath(topicPathInstance);
                            }

                            JsonNode namespaceValue = serviceBusTopicMessageValue.get("namespace");
                            if (namespaceValue != null && namespaceValue instanceof NullNode == false) {
                                String namespaceInstance;
                                namespaceInstance = namespaceValue.getTextValue();
                                serviceBusTopicMessageInstance.setNamespace(namespaceInstance);
                            }

                            JsonNode transportTypeValue = serviceBusTopicMessageValue.get("transportType");
                            if (transportTypeValue != null && transportTypeValue instanceof NullNode == false) {
                                JobServiceBusTransportType transportTypeInstance;
                                transportTypeInstance = SchedulerClientImpl
                                        .parseJobServiceBusTransportType(transportTypeValue.getTextValue());
                                serviceBusTopicMessageInstance.setTransportType(transportTypeInstance);
                            }

                            JsonNode authenticationValue2 = serviceBusTopicMessageValue.get("authentication");
                            if (authenticationValue2 != null
                                    && authenticationValue2 instanceof NullNode == false) {
                                JobServiceBusAuthentication authenticationInstance = new JobServiceBusAuthentication();
                                serviceBusTopicMessageInstance.setAuthentication(authenticationInstance);

                                JsonNode sasKeyNameValue = authenticationValue2.get("sasKeyName");
                                if (sasKeyNameValue != null && sasKeyNameValue instanceof NullNode == false) {
                                    String sasKeyNameInstance;
                                    sasKeyNameInstance = sasKeyNameValue.getTextValue();
                                    authenticationInstance.setSasKeyName(sasKeyNameInstance);
                                }

                                JsonNode sasKeyValue = authenticationValue2.get("sasKey");
                                if (sasKeyValue != null && sasKeyValue instanceof NullNode == false) {
                                    String sasKeyInstance;
                                    sasKeyInstance = sasKeyValue.getTextValue();
                                    authenticationInstance.setSasKey(sasKeyInstance);
                                }

                                JsonNode typeValue6 = authenticationValue2.get("type");
                                if (typeValue6 != null && typeValue6 instanceof NullNode == false) {
                                    JobServiceBusAuthenticationType typeInstance6;
                                    typeInstance6 = SchedulerClientImpl
                                            .parseJobServiceBusAuthenticationType(typeValue6.getTextValue());
                                    authenticationInstance.setType(typeInstance6);
                                }
                            }

                            JsonNode messageValue2 = serviceBusTopicMessageValue.get("message");
                            if (messageValue2 != null && messageValue2 instanceof NullNode == false) {
                                String messageInstance2;
                                messageInstance2 = messageValue2.getTextValue();
                                serviceBusTopicMessageInstance.setMessage(messageInstance2);
                            }

                            JsonNode brokeredMessagePropertiesValue = serviceBusTopicMessageValue
                                    .get("brokeredMessageProperties");
                            if (brokeredMessagePropertiesValue != null
                                    && brokeredMessagePropertiesValue instanceof NullNode == false) {
                                JobServiceBusBrokeredMessageProperties brokeredMessagePropertiesInstance = new JobServiceBusBrokeredMessageProperties();
                                serviceBusTopicMessageInstance
                                        .setBrokeredMessageProperties(brokeredMessagePropertiesInstance);

                                JsonNode contentTypeValue = brokeredMessagePropertiesValue.get("contentType");
                                if (contentTypeValue != null && contentTypeValue instanceof NullNode == false) {
                                    String contentTypeInstance;
                                    contentTypeInstance = contentTypeValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setContentType(contentTypeInstance);
                                }

                                JsonNode correlationIdValue = brokeredMessagePropertiesValue
                                        .get("correlationId");
                                if (correlationIdValue != null
                                        && correlationIdValue instanceof NullNode == false) {
                                    String correlationIdInstance;
                                    correlationIdInstance = correlationIdValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setCorrelationId(correlationIdInstance);
                                }

                                JsonNode forcePersistenceValue = brokeredMessagePropertiesValue
                                        .get("forcePersistence");
                                if (forcePersistenceValue != null
                                        && forcePersistenceValue instanceof NullNode == false) {
                                    boolean forcePersistenceInstance;
                                    forcePersistenceInstance = forcePersistenceValue.getBooleanValue();
                                    brokeredMessagePropertiesInstance
                                            .setForcePersistence(forcePersistenceInstance);
                                }

                                JsonNode labelValue = brokeredMessagePropertiesValue.get("label");
                                if (labelValue != null && labelValue instanceof NullNode == false) {
                                    String labelInstance;
                                    labelInstance = labelValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setLabel(labelInstance);
                                }

                                JsonNode messageIdValue = brokeredMessagePropertiesValue.get("messageId");
                                if (messageIdValue != null && messageIdValue instanceof NullNode == false) {
                                    String messageIdInstance;
                                    messageIdInstance = messageIdValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setMessageId(messageIdInstance);
                                }

                                JsonNode partitionKeyValue = brokeredMessagePropertiesValue.get("partitionKey");
                                if (partitionKeyValue != null
                                        && partitionKeyValue instanceof NullNode == false) {
                                    String partitionKeyInstance;
                                    partitionKeyInstance = partitionKeyValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setPartitionKey(partitionKeyInstance);
                                }

                                JsonNode replyToValue = brokeredMessagePropertiesValue.get("replyTo");
                                if (replyToValue != null && replyToValue instanceof NullNode == false) {
                                    String replyToInstance;
                                    replyToInstance = replyToValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setReplyTo(replyToInstance);
                                }

                                JsonNode replyToSessionIdValue = brokeredMessagePropertiesValue
                                        .get("replyToSessionId");
                                if (replyToSessionIdValue != null
                                        && replyToSessionIdValue instanceof NullNode == false) {
                                    String replyToSessionIdInstance;
                                    replyToSessionIdInstance = replyToSessionIdValue.getTextValue();
                                    brokeredMessagePropertiesInstance
                                            .setReplyToSessionId(replyToSessionIdInstance);
                                }

                                JsonNode scheduledEnqueueTimeUtcValue = brokeredMessagePropertiesValue
                                        .get("scheduledEnqueueTimeUtc");
                                if (scheduledEnqueueTimeUtcValue != null
                                        && scheduledEnqueueTimeUtcValue instanceof NullNode == false) {
                                    Calendar scheduledEnqueueTimeUtcInstance;
                                    scheduledEnqueueTimeUtcInstance = DatatypeConverter
                                            .parseDateTime(scheduledEnqueueTimeUtcValue.getTextValue());
                                    brokeredMessagePropertiesInstance
                                            .setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtcInstance);
                                }

                                JsonNode sessionIdValue = brokeredMessagePropertiesValue.get("sessionId");
                                if (sessionIdValue != null && sessionIdValue instanceof NullNode == false) {
                                    String sessionIdInstance;
                                    sessionIdInstance = sessionIdValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setSessionId(sessionIdInstance);
                                }

                                JsonNode timeToLiveValue = brokeredMessagePropertiesValue.get("timeToLive");
                                if (timeToLiveValue != null && timeToLiveValue instanceof NullNode == false) {
                                    Calendar timeToLiveInstance;
                                    timeToLiveInstance = DatatypeConverter
                                            .parseDateTime(timeToLiveValue.getTextValue());
                                    brokeredMessagePropertiesInstance.setTimeToLive(timeToLiveInstance);
                                }

                                JsonNode toValue = brokeredMessagePropertiesValue.get("to");
                                if (toValue != null && toValue instanceof NullNode == false) {
                                    String toInstance;
                                    toInstance = toValue.getTextValue();
                                    brokeredMessagePropertiesInstance.setTo(toInstance);
                                }

                                JsonNode viaPartitionKeyValue = brokeredMessagePropertiesValue
                                        .get("viaPartitionKey");
                                if (viaPartitionKeyValue != null
                                        && viaPartitionKeyValue instanceof NullNode == false) {
                                    String viaPartitionKeyInstance;
                                    viaPartitionKeyInstance = viaPartitionKeyValue.getTextValue();
                                    brokeredMessagePropertiesInstance
                                            .setViaPartitionKey(viaPartitionKeyInstance);
                                }
                            }

                            JsonNode customMessagePropertiesSequenceElement = ((JsonNode) serviceBusTopicMessageValue
                                    .get("customMessageProperties"));
                            if (customMessagePropertiesSequenceElement != null
                                    && customMessagePropertiesSequenceElement instanceof NullNode == false) {
                                Iterator<Map.Entry<String, JsonNode>> itr2 = customMessagePropertiesSequenceElement
                                        .getFields();
                                while (itr2.hasNext()) {
                                    Map.Entry<String, JsonNode> property2 = itr2.next();
                                    String customMessagePropertiesKey = property2.getKey();
                                    String customMessagePropertiesValue = property2.getValue().getTextValue();
                                    serviceBusTopicMessageInstance.getCustomMessageProperties()
                                            .put(customMessagePropertiesKey, customMessagePropertiesValue);
                                }
                            }
                        }

                        JsonNode serviceBusQueueMessageValue = errorActionValue.get("serviceBusQueueMessage");
                        if (serviceBusQueueMessageValue != null
                                && serviceBusQueueMessageValue instanceof NullNode == false) {
                            JobServiceBusQueueMessage serviceBusQueueMessageInstance = new JobServiceBusQueueMessage();
                            errorActionInstance.setServiceBusQueueMessage(serviceBusQueueMessageInstance);

                            JsonNode queueNameValue2 = serviceBusQueueMessageValue.get("queueName");
                            if (queueNameValue2 != null && queueNameValue2 instanceof NullNode == false) {
                                String queueNameInstance2;
                                queueNameInstance2 = queueNameValue2.getTextValue();
                                serviceBusQueueMessageInstance.setQueueName(queueNameInstance2);
                            }

                            JsonNode namespaceValue2 = serviceBusQueueMessageValue.get("namespace");
                            if (namespaceValue2 != null && namespaceValue2 instanceof NullNode == false) {
                                String namespaceInstance2;
                                namespaceInstance2 = namespaceValue2.getTextValue();
                                serviceBusQueueMessageInstance.setNamespace(namespaceInstance2);
                            }

                            JsonNode transportTypeValue2 = serviceBusQueueMessageValue.get("transportType");
                            if (transportTypeValue2 != null
                                    && transportTypeValue2 instanceof NullNode == false) {
                                JobServiceBusTransportType transportTypeInstance2;
                                transportTypeInstance2 = SchedulerClientImpl
                                        .parseJobServiceBusTransportType(transportTypeValue2.getTextValue());
                                serviceBusQueueMessageInstance.setTransportType(transportTypeInstance2);
                            }

                            JsonNode authenticationValue3 = serviceBusQueueMessageValue.get("authentication");
                            if (authenticationValue3 != null
                                    && authenticationValue3 instanceof NullNode == false) {
                                JobServiceBusAuthentication authenticationInstance2 = new JobServiceBusAuthentication();
                                serviceBusQueueMessageInstance.setAuthentication(authenticationInstance2);

                                JsonNode sasKeyNameValue2 = authenticationValue3.get("sasKeyName");
                                if (sasKeyNameValue2 != null && sasKeyNameValue2 instanceof NullNode == false) {
                                    String sasKeyNameInstance2;
                                    sasKeyNameInstance2 = sasKeyNameValue2.getTextValue();
                                    authenticationInstance2.setSasKeyName(sasKeyNameInstance2);
                                }

                                JsonNode sasKeyValue2 = authenticationValue3.get("sasKey");
                                if (sasKeyValue2 != null && sasKeyValue2 instanceof NullNode == false) {
                                    String sasKeyInstance2;
                                    sasKeyInstance2 = sasKeyValue2.getTextValue();
                                    authenticationInstance2.setSasKey(sasKeyInstance2);
                                }

                                JsonNode typeValue7 = authenticationValue3.get("type");
                                if (typeValue7 != null && typeValue7 instanceof NullNode == false) {
                                    JobServiceBusAuthenticationType typeInstance7;
                                    typeInstance7 = SchedulerClientImpl
                                            .parseJobServiceBusAuthenticationType(typeValue7.getTextValue());
                                    authenticationInstance2.setType(typeInstance7);
                                }
                            }

                            JsonNode messageValue3 = serviceBusQueueMessageValue.get("message");
                            if (messageValue3 != null && messageValue3 instanceof NullNode == false) {
                                String messageInstance3;
                                messageInstance3 = messageValue3.getTextValue();
                                serviceBusQueueMessageInstance.setMessage(messageInstance3);
                            }

                            JsonNode brokeredMessagePropertiesValue2 = serviceBusQueueMessageValue
                                    .get("brokeredMessageProperties");
                            if (brokeredMessagePropertiesValue2 != null
                                    && brokeredMessagePropertiesValue2 instanceof NullNode == false) {
                                JobServiceBusBrokeredMessageProperties brokeredMessagePropertiesInstance2 = new JobServiceBusBrokeredMessageProperties();
                                serviceBusQueueMessageInstance
                                        .setBrokeredMessageProperties(brokeredMessagePropertiesInstance2);

                                JsonNode contentTypeValue2 = brokeredMessagePropertiesValue2.get("contentType");
                                if (contentTypeValue2 != null
                                        && contentTypeValue2 instanceof NullNode == false) {
                                    String contentTypeInstance2;
                                    contentTypeInstance2 = contentTypeValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setContentType(contentTypeInstance2);
                                }

                                JsonNode correlationIdValue2 = brokeredMessagePropertiesValue2
                                        .get("correlationId");
                                if (correlationIdValue2 != null
                                        && correlationIdValue2 instanceof NullNode == false) {
                                    String correlationIdInstance2;
                                    correlationIdInstance2 = correlationIdValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setCorrelationId(correlationIdInstance2);
                                }

                                JsonNode forcePersistenceValue2 = brokeredMessagePropertiesValue2
                                        .get("forcePersistence");
                                if (forcePersistenceValue2 != null
                                        && forcePersistenceValue2 instanceof NullNode == false) {
                                    boolean forcePersistenceInstance2;
                                    forcePersistenceInstance2 = forcePersistenceValue2.getBooleanValue();
                                    brokeredMessagePropertiesInstance2
                                            .setForcePersistence(forcePersistenceInstance2);
                                }

                                JsonNode labelValue2 = brokeredMessagePropertiesValue2.get("label");
                                if (labelValue2 != null && labelValue2 instanceof NullNode == false) {
                                    String labelInstance2;
                                    labelInstance2 = labelValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setLabel(labelInstance2);
                                }

                                JsonNode messageIdValue2 = brokeredMessagePropertiesValue2.get("messageId");
                                if (messageIdValue2 != null && messageIdValue2 instanceof NullNode == false) {
                                    String messageIdInstance2;
                                    messageIdInstance2 = messageIdValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setMessageId(messageIdInstance2);
                                }

                                JsonNode partitionKeyValue2 = brokeredMessagePropertiesValue2
                                        .get("partitionKey");
                                if (partitionKeyValue2 != null
                                        && partitionKeyValue2 instanceof NullNode == false) {
                                    String partitionKeyInstance2;
                                    partitionKeyInstance2 = partitionKeyValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setPartitionKey(partitionKeyInstance2);
                                }

                                JsonNode replyToValue2 = brokeredMessagePropertiesValue2.get("replyTo");
                                if (replyToValue2 != null && replyToValue2 instanceof NullNode == false) {
                                    String replyToInstance2;
                                    replyToInstance2 = replyToValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setReplyTo(replyToInstance2);
                                }

                                JsonNode replyToSessionIdValue2 = brokeredMessagePropertiesValue2
                                        .get("replyToSessionId");
                                if (replyToSessionIdValue2 != null
                                        && replyToSessionIdValue2 instanceof NullNode == false) {
                                    String replyToSessionIdInstance2;
                                    replyToSessionIdInstance2 = replyToSessionIdValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2
                                            .setReplyToSessionId(replyToSessionIdInstance2);
                                }

                                JsonNode scheduledEnqueueTimeUtcValue2 = brokeredMessagePropertiesValue2
                                        .get("scheduledEnqueueTimeUtc");
                                if (scheduledEnqueueTimeUtcValue2 != null
                                        && scheduledEnqueueTimeUtcValue2 instanceof NullNode == false) {
                                    Calendar scheduledEnqueueTimeUtcInstance2;
                                    scheduledEnqueueTimeUtcInstance2 = DatatypeConverter
                                            .parseDateTime(scheduledEnqueueTimeUtcValue2.getTextValue());
                                    brokeredMessagePropertiesInstance2
                                            .setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtcInstance2);
                                }

                                JsonNode sessionIdValue2 = brokeredMessagePropertiesValue2.get("sessionId");
                                if (sessionIdValue2 != null && sessionIdValue2 instanceof NullNode == false) {
                                    String sessionIdInstance2;
                                    sessionIdInstance2 = sessionIdValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setSessionId(sessionIdInstance2);
                                }

                                JsonNode timeToLiveValue2 = brokeredMessagePropertiesValue2.get("timeToLive");
                                if (timeToLiveValue2 != null && timeToLiveValue2 instanceof NullNode == false) {
                                    Calendar timeToLiveInstance2;
                                    timeToLiveInstance2 = DatatypeConverter
                                            .parseDateTime(timeToLiveValue2.getTextValue());
                                    brokeredMessagePropertiesInstance2.setTimeToLive(timeToLiveInstance2);
                                }

                                JsonNode toValue2 = brokeredMessagePropertiesValue2.get("to");
                                if (toValue2 != null && toValue2 instanceof NullNode == false) {
                                    String toInstance2;
                                    toInstance2 = toValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2.setTo(toInstance2);
                                }

                                JsonNode viaPartitionKeyValue2 = brokeredMessagePropertiesValue2
                                        .get("viaPartitionKey");
                                if (viaPartitionKeyValue2 != null
                                        && viaPartitionKeyValue2 instanceof NullNode == false) {
                                    String viaPartitionKeyInstance2;
                                    viaPartitionKeyInstance2 = viaPartitionKeyValue2.getTextValue();
                                    brokeredMessagePropertiesInstance2
                                            .setViaPartitionKey(viaPartitionKeyInstance2);
                                }
                            }

                            JsonNode customMessagePropertiesSequenceElement2 = ((JsonNode) serviceBusQueueMessageValue
                                    .get("customMessageProperties"));
                            if (customMessagePropertiesSequenceElement2 != null
                                    && customMessagePropertiesSequenceElement2 instanceof NullNode == false) {
                                Iterator<Map.Entry<String, JsonNode>> itr3 = customMessagePropertiesSequenceElement2
                                        .getFields();
                                while (itr3.hasNext()) {
                                    Map.Entry<String, JsonNode> property3 = itr3.next();
                                    String customMessagePropertiesKey2 = property3.getKey();
                                    String customMessagePropertiesValue2 = property3.getValue().getTextValue();
                                    serviceBusQueueMessageInstance.getCustomMessageProperties()
                                            .put(customMessagePropertiesKey2, customMessagePropertiesValue2);
                                }
                            }
                        }
                    }

                    JsonNode requestValue2 = actionValue.get("request");
                    if (requestValue2 != null && requestValue2 instanceof NullNode == false) {
                        JobHttpRequest requestInstance2 = new JobHttpRequest();
                        actionInstance.setRequest(requestInstance2);

                        JsonNode uriValue2 = requestValue2.get("uri");
                        if (uriValue2 != null && uriValue2 instanceof NullNode == false) {
                            URI uriInstance2;
                            uriInstance2 = new URI(uriValue2.getTextValue());
                            requestInstance2.setUri(uriInstance2);
                        }

                        JsonNode methodValue2 = requestValue2.get("method");
                        if (methodValue2 != null && methodValue2 instanceof NullNode == false) {
                            String methodInstance2;
                            methodInstance2 = methodValue2.getTextValue();
                            requestInstance2.setMethod(methodInstance2);
                        }

                        JsonNode headersSequenceElement2 = ((JsonNode) requestValue2.get("headers"));
                        if (headersSequenceElement2 != null
                                && headersSequenceElement2 instanceof NullNode == false) {
                            Iterator<Map.Entry<String, JsonNode>> itr4 = headersSequenceElement2.getFields();
                            while (itr4.hasNext()) {
                                Map.Entry<String, JsonNode> property4 = itr4.next();
                                String headersKey2 = property4.getKey();
                                String headersValue2 = property4.getValue().getTextValue();
                                requestInstance2.getHeaders().put(headersKey2, headersValue2);
                            }
                        }

                        JsonNode bodyValue2 = requestValue2.get("body");
                        if (bodyValue2 != null && bodyValue2 instanceof NullNode == false) {
                            String bodyInstance2;
                            bodyInstance2 = bodyValue2.getTextValue();
                            requestInstance2.setBody(bodyInstance2);
                        }

                        JsonNode authenticationValue4 = requestValue2.get("authentication");
                        if (authenticationValue4 != null && authenticationValue4 instanceof NullNode == false) {
                            String typeName2 = authenticationValue4.get("type").getTextValue();
                            if ("ClientCertificate".equals(typeName2)) {
                                ClientCertAuthentication clientCertAuthenticationInstance2 = new ClientCertAuthentication();

                                JsonNode passwordValue3 = authenticationValue4.get("password");
                                if (passwordValue3 != null && passwordValue3 instanceof NullNode == false) {
                                    String passwordInstance3;
                                    passwordInstance3 = passwordValue3.getTextValue();
                                    clientCertAuthenticationInstance2.setPassword(passwordInstance3);
                                }

                                JsonNode pfxValue2 = authenticationValue4.get("pfx");
                                if (pfxValue2 != null && pfxValue2 instanceof NullNode == false) {
                                    String pfxInstance2;
                                    pfxInstance2 = pfxValue2.getTextValue();
                                    clientCertAuthenticationInstance2.setPfx(pfxInstance2);
                                }

                                JsonNode certificateThumbprintValue2 = authenticationValue4
                                        .get("certificateThumbprint");
                                if (certificateThumbprintValue2 != null
                                        && certificateThumbprintValue2 instanceof NullNode == false) {
                                    String certificateThumbprintInstance2;
                                    certificateThumbprintInstance2 = certificateThumbprintValue2.getTextValue();
                                    clientCertAuthenticationInstance2
                                            .setCertificateThumbprint(certificateThumbprintInstance2);
                                }

                                JsonNode certificateExpirationValue2 = authenticationValue4
                                        .get("certificateExpiration");
                                if (certificateExpirationValue2 != null
                                        && certificateExpirationValue2 instanceof NullNode == false) {
                                    Calendar certificateExpirationInstance2;
                                    certificateExpirationInstance2 = DatatypeConverter
                                            .parseDateTime(certificateExpirationValue2.getTextValue());
                                    clientCertAuthenticationInstance2
                                            .setCertificateExpiration(certificateExpirationInstance2);
                                }

                                JsonNode certificateSubjectNameValue2 = authenticationValue4
                                        .get("certificateSubjectName");
                                if (certificateSubjectNameValue2 != null
                                        && certificateSubjectNameValue2 instanceof NullNode == false) {
                                    String certificateSubjectNameInstance2;
                                    certificateSubjectNameInstance2 = certificateSubjectNameValue2
                                            .getTextValue();
                                    clientCertAuthenticationInstance2
                                            .setCertificateSubjectName(certificateSubjectNameInstance2);
                                }

                                JsonNode typeValue8 = authenticationValue4.get("type");
                                if (typeValue8 != null && typeValue8 instanceof NullNode == false) {
                                    HttpAuthenticationType typeInstance8;
                                    typeInstance8 = SchedulerClientImpl
                                            .parseHttpAuthenticationType(typeValue8.getTextValue());
                                    clientCertAuthenticationInstance2.setType(typeInstance8);
                                }
                                requestInstance2.setAuthentication(clientCertAuthenticationInstance2);
                            }
                            if ("ActiveDirectoryOAuth".equals(typeName2)) {
                                AADOAuthAuthentication aADOAuthAuthenticationInstance2 = new AADOAuthAuthentication();

                                JsonNode secretValue2 = authenticationValue4.get("secret");
                                if (secretValue2 != null && secretValue2 instanceof NullNode == false) {
                                    String secretInstance2;
                                    secretInstance2 = secretValue2.getTextValue();
                                    aADOAuthAuthenticationInstance2.setSecret(secretInstance2);
                                }

                                JsonNode tenantValue2 = authenticationValue4.get("tenant");
                                if (tenantValue2 != null && tenantValue2 instanceof NullNode == false) {
                                    String tenantInstance2;
                                    tenantInstance2 = tenantValue2.getTextValue();
                                    aADOAuthAuthenticationInstance2.setTenant(tenantInstance2);
                                }

                                JsonNode audienceValue2 = authenticationValue4.get("audience");
                                if (audienceValue2 != null && audienceValue2 instanceof NullNode == false) {
                                    String audienceInstance2;
                                    audienceInstance2 = audienceValue2.getTextValue();
                                    aADOAuthAuthenticationInstance2.setAudience(audienceInstance2);
                                }

                                JsonNode clientIdValue2 = authenticationValue4.get("clientId");
                                if (clientIdValue2 != null && clientIdValue2 instanceof NullNode == false) {
                                    String clientIdInstance2;
                                    clientIdInstance2 = clientIdValue2.getTextValue();
                                    aADOAuthAuthenticationInstance2.setClientId(clientIdInstance2);
                                }

                                JsonNode typeValue9 = authenticationValue4.get("type");
                                if (typeValue9 != null && typeValue9 instanceof NullNode == false) {
                                    HttpAuthenticationType typeInstance9;
                                    typeInstance9 = SchedulerClientImpl
                                            .parseHttpAuthenticationType(typeValue9.getTextValue());
                                    aADOAuthAuthenticationInstance2.setType(typeInstance9);
                                }
                                requestInstance2.setAuthentication(aADOAuthAuthenticationInstance2);
                            }
                            if ("Basic".equals(typeName2)) {
                                BasicAuthentication basicAuthenticationInstance2 = new BasicAuthentication();

                                JsonNode usernameValue2 = authenticationValue4.get("username");
                                if (usernameValue2 != null && usernameValue2 instanceof NullNode == false) {
                                    String usernameInstance2;
                                    usernameInstance2 = usernameValue2.getTextValue();
                                    basicAuthenticationInstance2.setUsername(usernameInstance2);
                                }

                                JsonNode passwordValue4 = authenticationValue4.get("password");
                                if (passwordValue4 != null && passwordValue4 instanceof NullNode == false) {
                                    String passwordInstance4;
                                    passwordInstance4 = passwordValue4.getTextValue();
                                    basicAuthenticationInstance2.setPassword(passwordInstance4);
                                }

                                JsonNode typeValue10 = authenticationValue4.get("type");
                                if (typeValue10 != null && typeValue10 instanceof NullNode == false) {
                                    HttpAuthenticationType typeInstance10;
                                    typeInstance10 = SchedulerClientImpl
                                            .parseHttpAuthenticationType(typeValue10.getTextValue());
                                    basicAuthenticationInstance2.setType(typeInstance10);
                                }
                                requestInstance2.setAuthentication(basicAuthenticationInstance2);
                            }
                        }
                    }

                    JsonNode queueMessageValue2 = actionValue.get("queueMessage");
                    if (queueMessageValue2 != null && queueMessageValue2 instanceof NullNode == false) {
                        JobQueueMessage queueMessageInstance2 = new JobQueueMessage();
                        actionInstance.setQueueMessage(queueMessageInstance2);

                        JsonNode storageAccountValue2 = queueMessageValue2.get("storageAccount");
                        if (storageAccountValue2 != null && storageAccountValue2 instanceof NullNode == false) {
                            String storageAccountInstance2;
                            storageAccountInstance2 = storageAccountValue2.getTextValue();
                            queueMessageInstance2.setStorageAccountName(storageAccountInstance2);
                        }

                        JsonNode queueNameValue3 = queueMessageValue2.get("queueName");
                        if (queueNameValue3 != null && queueNameValue3 instanceof NullNode == false) {
                            String queueNameInstance3;
                            queueNameInstance3 = queueNameValue3.getTextValue();
                            queueMessageInstance2.setQueueName(queueNameInstance3);
                        }

                        JsonNode sasTokenValue2 = queueMessageValue2.get("sasToken");
                        if (sasTokenValue2 != null && sasTokenValue2 instanceof NullNode == false) {
                            String sasTokenInstance2;
                            sasTokenInstance2 = sasTokenValue2.getTextValue();
                            queueMessageInstance2.setSasToken(sasTokenInstance2);
                        }

                        JsonNode messageValue4 = queueMessageValue2.get("message");
                        if (messageValue4 != null && messageValue4 instanceof NullNode == false) {
                            String messageInstance4;
                            messageInstance4 = messageValue4.getTextValue();
                            queueMessageInstance2.setMessage(messageInstance4);
                        }
                    }

                    JsonNode serviceBusTopicMessageValue2 = actionValue.get("serviceBusTopicMessage");
                    if (serviceBusTopicMessageValue2 != null
                            && serviceBusTopicMessageValue2 instanceof NullNode == false) {
                        JobServiceBusTopicMessage serviceBusTopicMessageInstance2 = new JobServiceBusTopicMessage();
                        actionInstance.setServiceBusTopicMessage(serviceBusTopicMessageInstance2);

                        JsonNode topicPathValue2 = serviceBusTopicMessageValue2.get("topicPath");
                        if (topicPathValue2 != null && topicPathValue2 instanceof NullNode == false) {
                            String topicPathInstance2;
                            topicPathInstance2 = topicPathValue2.getTextValue();
                            serviceBusTopicMessageInstance2.setTopicPath(topicPathInstance2);
                        }

                        JsonNode namespaceValue3 = serviceBusTopicMessageValue2.get("namespace");
                        if (namespaceValue3 != null && namespaceValue3 instanceof NullNode == false) {
                            String namespaceInstance3;
                            namespaceInstance3 = namespaceValue3.getTextValue();
                            serviceBusTopicMessageInstance2.setNamespace(namespaceInstance3);
                        }

                        JsonNode transportTypeValue3 = serviceBusTopicMessageValue2.get("transportType");
                        if (transportTypeValue3 != null && transportTypeValue3 instanceof NullNode == false) {
                            JobServiceBusTransportType transportTypeInstance3;
                            transportTypeInstance3 = SchedulerClientImpl
                                    .parseJobServiceBusTransportType(transportTypeValue3.getTextValue());
                            serviceBusTopicMessageInstance2.setTransportType(transportTypeInstance3);
                        }

                        JsonNode authenticationValue5 = serviceBusTopicMessageValue2.get("authentication");
                        if (authenticationValue5 != null && authenticationValue5 instanceof NullNode == false) {
                            JobServiceBusAuthentication authenticationInstance3 = new JobServiceBusAuthentication();
                            serviceBusTopicMessageInstance2.setAuthentication(authenticationInstance3);

                            JsonNode sasKeyNameValue3 = authenticationValue5.get("sasKeyName");
                            if (sasKeyNameValue3 != null && sasKeyNameValue3 instanceof NullNode == false) {
                                String sasKeyNameInstance3;
                                sasKeyNameInstance3 = sasKeyNameValue3.getTextValue();
                                authenticationInstance3.setSasKeyName(sasKeyNameInstance3);
                            }

                            JsonNode sasKeyValue3 = authenticationValue5.get("sasKey");
                            if (sasKeyValue3 != null && sasKeyValue3 instanceof NullNode == false) {
                                String sasKeyInstance3;
                                sasKeyInstance3 = sasKeyValue3.getTextValue();
                                authenticationInstance3.setSasKey(sasKeyInstance3);
                            }

                            JsonNode typeValue11 = authenticationValue5.get("type");
                            if (typeValue11 != null && typeValue11 instanceof NullNode == false) {
                                JobServiceBusAuthenticationType typeInstance11;
                                typeInstance11 = SchedulerClientImpl
                                        .parseJobServiceBusAuthenticationType(typeValue11.getTextValue());
                                authenticationInstance3.setType(typeInstance11);
                            }
                        }

                        JsonNode messageValue5 = serviceBusTopicMessageValue2.get("message");
                        if (messageValue5 != null && messageValue5 instanceof NullNode == false) {
                            String messageInstance5;
                            messageInstance5 = messageValue5.getTextValue();
                            serviceBusTopicMessageInstance2.setMessage(messageInstance5);
                        }

                        JsonNode brokeredMessagePropertiesValue3 = serviceBusTopicMessageValue2
                                .get("brokeredMessageProperties");
                        if (brokeredMessagePropertiesValue3 != null
                                && brokeredMessagePropertiesValue3 instanceof NullNode == false) {
                            JobServiceBusBrokeredMessageProperties brokeredMessagePropertiesInstance3 = new JobServiceBusBrokeredMessageProperties();
                            serviceBusTopicMessageInstance2
                                    .setBrokeredMessageProperties(brokeredMessagePropertiesInstance3);

                            JsonNode contentTypeValue3 = brokeredMessagePropertiesValue3.get("contentType");
                            if (contentTypeValue3 != null && contentTypeValue3 instanceof NullNode == false) {
                                String contentTypeInstance3;
                                contentTypeInstance3 = contentTypeValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setContentType(contentTypeInstance3);
                            }

                            JsonNode correlationIdValue3 = brokeredMessagePropertiesValue3.get("correlationId");
                            if (correlationIdValue3 != null
                                    && correlationIdValue3 instanceof NullNode == false) {
                                String correlationIdInstance3;
                                correlationIdInstance3 = correlationIdValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setCorrelationId(correlationIdInstance3);
                            }

                            JsonNode forcePersistenceValue3 = brokeredMessagePropertiesValue3
                                    .get("forcePersistence");
                            if (forcePersistenceValue3 != null
                                    && forcePersistenceValue3 instanceof NullNode == false) {
                                boolean forcePersistenceInstance3;
                                forcePersistenceInstance3 = forcePersistenceValue3.getBooleanValue();
                                brokeredMessagePropertiesInstance3
                                        .setForcePersistence(forcePersistenceInstance3);
                            }

                            JsonNode labelValue3 = brokeredMessagePropertiesValue3.get("label");
                            if (labelValue3 != null && labelValue3 instanceof NullNode == false) {
                                String labelInstance3;
                                labelInstance3 = labelValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setLabel(labelInstance3);
                            }

                            JsonNode messageIdValue3 = brokeredMessagePropertiesValue3.get("messageId");
                            if (messageIdValue3 != null && messageIdValue3 instanceof NullNode == false) {
                                String messageIdInstance3;
                                messageIdInstance3 = messageIdValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setMessageId(messageIdInstance3);
                            }

                            JsonNode partitionKeyValue3 = brokeredMessagePropertiesValue3.get("partitionKey");
                            if (partitionKeyValue3 != null && partitionKeyValue3 instanceof NullNode == false) {
                                String partitionKeyInstance3;
                                partitionKeyInstance3 = partitionKeyValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setPartitionKey(partitionKeyInstance3);
                            }

                            JsonNode replyToValue3 = brokeredMessagePropertiesValue3.get("replyTo");
                            if (replyToValue3 != null && replyToValue3 instanceof NullNode == false) {
                                String replyToInstance3;
                                replyToInstance3 = replyToValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setReplyTo(replyToInstance3);
                            }

                            JsonNode replyToSessionIdValue3 = brokeredMessagePropertiesValue3
                                    .get("replyToSessionId");
                            if (replyToSessionIdValue3 != null
                                    && replyToSessionIdValue3 instanceof NullNode == false) {
                                String replyToSessionIdInstance3;
                                replyToSessionIdInstance3 = replyToSessionIdValue3.getTextValue();
                                brokeredMessagePropertiesInstance3
                                        .setReplyToSessionId(replyToSessionIdInstance3);
                            }

                            JsonNode scheduledEnqueueTimeUtcValue3 = brokeredMessagePropertiesValue3
                                    .get("scheduledEnqueueTimeUtc");
                            if (scheduledEnqueueTimeUtcValue3 != null
                                    && scheduledEnqueueTimeUtcValue3 instanceof NullNode == false) {
                                Calendar scheduledEnqueueTimeUtcInstance3;
                                scheduledEnqueueTimeUtcInstance3 = DatatypeConverter
                                        .parseDateTime(scheduledEnqueueTimeUtcValue3.getTextValue());
                                brokeredMessagePropertiesInstance3
                                        .setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtcInstance3);
                            }

                            JsonNode sessionIdValue3 = brokeredMessagePropertiesValue3.get("sessionId");
                            if (sessionIdValue3 != null && sessionIdValue3 instanceof NullNode == false) {
                                String sessionIdInstance3;
                                sessionIdInstance3 = sessionIdValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setSessionId(sessionIdInstance3);
                            }

                            JsonNode timeToLiveValue3 = brokeredMessagePropertiesValue3.get("timeToLive");
                            if (timeToLiveValue3 != null && timeToLiveValue3 instanceof NullNode == false) {
                                Calendar timeToLiveInstance3;
                                timeToLiveInstance3 = DatatypeConverter
                                        .parseDateTime(timeToLiveValue3.getTextValue());
                                brokeredMessagePropertiesInstance3.setTimeToLive(timeToLiveInstance3);
                            }

                            JsonNode toValue3 = brokeredMessagePropertiesValue3.get("to");
                            if (toValue3 != null && toValue3 instanceof NullNode == false) {
                                String toInstance3;
                                toInstance3 = toValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setTo(toInstance3);
                            }

                            JsonNode viaPartitionKeyValue3 = brokeredMessagePropertiesValue3
                                    .get("viaPartitionKey");
                            if (viaPartitionKeyValue3 != null
                                    && viaPartitionKeyValue3 instanceof NullNode == false) {
                                String viaPartitionKeyInstance3;
                                viaPartitionKeyInstance3 = viaPartitionKeyValue3.getTextValue();
                                brokeredMessagePropertiesInstance3.setViaPartitionKey(viaPartitionKeyInstance3);
                            }
                        }

                        JsonNode customMessagePropertiesSequenceElement3 = ((JsonNode) serviceBusTopicMessageValue2
                                .get("customMessageProperties"));
                        if (customMessagePropertiesSequenceElement3 != null
                                && customMessagePropertiesSequenceElement3 instanceof NullNode == false) {
                            Iterator<Map.Entry<String, JsonNode>> itr5 = customMessagePropertiesSequenceElement3
                                    .getFields();
                            while (itr5.hasNext()) {
                                Map.Entry<String, JsonNode> property5 = itr5.next();
                                String customMessagePropertiesKey3 = property5.getKey();
                                String customMessagePropertiesValue3 = property5.getValue().getTextValue();
                                serviceBusTopicMessageInstance2.getCustomMessageProperties()
                                        .put(customMessagePropertiesKey3, customMessagePropertiesValue3);
                            }
                        }
                    }

                    JsonNode serviceBusQueueMessageValue2 = actionValue.get("serviceBusQueueMessage");
                    if (serviceBusQueueMessageValue2 != null
                            && serviceBusQueueMessageValue2 instanceof NullNode == false) {
                        JobServiceBusQueueMessage serviceBusQueueMessageInstance2 = new JobServiceBusQueueMessage();
                        actionInstance.setServiceBusQueueMessage(serviceBusQueueMessageInstance2);

                        JsonNode queueNameValue4 = serviceBusQueueMessageValue2.get("queueName");
                        if (queueNameValue4 != null && queueNameValue4 instanceof NullNode == false) {
                            String queueNameInstance4;
                            queueNameInstance4 = queueNameValue4.getTextValue();
                            serviceBusQueueMessageInstance2.setQueueName(queueNameInstance4);
                        }

                        JsonNode namespaceValue4 = serviceBusQueueMessageValue2.get("namespace");
                        if (namespaceValue4 != null && namespaceValue4 instanceof NullNode == false) {
                            String namespaceInstance4;
                            namespaceInstance4 = namespaceValue4.getTextValue();
                            serviceBusQueueMessageInstance2.setNamespace(namespaceInstance4);
                        }

                        JsonNode transportTypeValue4 = serviceBusQueueMessageValue2.get("transportType");
                        if (transportTypeValue4 != null && transportTypeValue4 instanceof NullNode == false) {
                            JobServiceBusTransportType transportTypeInstance4;
                            transportTypeInstance4 = SchedulerClientImpl
                                    .parseJobServiceBusTransportType(transportTypeValue4.getTextValue());
                            serviceBusQueueMessageInstance2.setTransportType(transportTypeInstance4);
                        }

                        JsonNode authenticationValue6 = serviceBusQueueMessageValue2.get("authentication");
                        if (authenticationValue6 != null && authenticationValue6 instanceof NullNode == false) {
                            JobServiceBusAuthentication authenticationInstance4 = new JobServiceBusAuthentication();
                            serviceBusQueueMessageInstance2.setAuthentication(authenticationInstance4);

                            JsonNode sasKeyNameValue4 = authenticationValue6.get("sasKeyName");
                            if (sasKeyNameValue4 != null && sasKeyNameValue4 instanceof NullNode == false) {
                                String sasKeyNameInstance4;
                                sasKeyNameInstance4 = sasKeyNameValue4.getTextValue();
                                authenticationInstance4.setSasKeyName(sasKeyNameInstance4);
                            }

                            JsonNode sasKeyValue4 = authenticationValue6.get("sasKey");
                            if (sasKeyValue4 != null && sasKeyValue4 instanceof NullNode == false) {
                                String sasKeyInstance4;
                                sasKeyInstance4 = sasKeyValue4.getTextValue();
                                authenticationInstance4.setSasKey(sasKeyInstance4);
                            }

                            JsonNode typeValue12 = authenticationValue6.get("type");
                            if (typeValue12 != null && typeValue12 instanceof NullNode == false) {
                                JobServiceBusAuthenticationType typeInstance12;
                                typeInstance12 = SchedulerClientImpl
                                        .parseJobServiceBusAuthenticationType(typeValue12.getTextValue());
                                authenticationInstance4.setType(typeInstance12);
                            }
                        }

                        JsonNode messageValue6 = serviceBusQueueMessageValue2.get("message");
                        if (messageValue6 != null && messageValue6 instanceof NullNode == false) {
                            String messageInstance6;
                            messageInstance6 = messageValue6.getTextValue();
                            serviceBusQueueMessageInstance2.setMessage(messageInstance6);
                        }

                        JsonNode brokeredMessagePropertiesValue4 = serviceBusQueueMessageValue2
                                .get("brokeredMessageProperties");
                        if (brokeredMessagePropertiesValue4 != null
                                && brokeredMessagePropertiesValue4 instanceof NullNode == false) {
                            JobServiceBusBrokeredMessageProperties brokeredMessagePropertiesInstance4 = new JobServiceBusBrokeredMessageProperties();
                            serviceBusQueueMessageInstance2
                                    .setBrokeredMessageProperties(brokeredMessagePropertiesInstance4);

                            JsonNode contentTypeValue4 = brokeredMessagePropertiesValue4.get("contentType");
                            if (contentTypeValue4 != null && contentTypeValue4 instanceof NullNode == false) {
                                String contentTypeInstance4;
                                contentTypeInstance4 = contentTypeValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setContentType(contentTypeInstance4);
                            }

                            JsonNode correlationIdValue4 = brokeredMessagePropertiesValue4.get("correlationId");
                            if (correlationIdValue4 != null
                                    && correlationIdValue4 instanceof NullNode == false) {
                                String correlationIdInstance4;
                                correlationIdInstance4 = correlationIdValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setCorrelationId(correlationIdInstance4);
                            }

                            JsonNode forcePersistenceValue4 = brokeredMessagePropertiesValue4
                                    .get("forcePersistence");
                            if (forcePersistenceValue4 != null
                                    && forcePersistenceValue4 instanceof NullNode == false) {
                                boolean forcePersistenceInstance4;
                                forcePersistenceInstance4 = forcePersistenceValue4.getBooleanValue();
                                brokeredMessagePropertiesInstance4
                                        .setForcePersistence(forcePersistenceInstance4);
                            }

                            JsonNode labelValue4 = brokeredMessagePropertiesValue4.get("label");
                            if (labelValue4 != null && labelValue4 instanceof NullNode == false) {
                                String labelInstance4;
                                labelInstance4 = labelValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setLabel(labelInstance4);
                            }

                            JsonNode messageIdValue4 = brokeredMessagePropertiesValue4.get("messageId");
                            if (messageIdValue4 != null && messageIdValue4 instanceof NullNode == false) {
                                String messageIdInstance4;
                                messageIdInstance4 = messageIdValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setMessageId(messageIdInstance4);
                            }

                            JsonNode partitionKeyValue4 = brokeredMessagePropertiesValue4.get("partitionKey");
                            if (partitionKeyValue4 != null && partitionKeyValue4 instanceof NullNode == false) {
                                String partitionKeyInstance4;
                                partitionKeyInstance4 = partitionKeyValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setPartitionKey(partitionKeyInstance4);
                            }

                            JsonNode replyToValue4 = brokeredMessagePropertiesValue4.get("replyTo");
                            if (replyToValue4 != null && replyToValue4 instanceof NullNode == false) {
                                String replyToInstance4;
                                replyToInstance4 = replyToValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setReplyTo(replyToInstance4);
                            }

                            JsonNode replyToSessionIdValue4 = brokeredMessagePropertiesValue4
                                    .get("replyToSessionId");
                            if (replyToSessionIdValue4 != null
                                    && replyToSessionIdValue4 instanceof NullNode == false) {
                                String replyToSessionIdInstance4;
                                replyToSessionIdInstance4 = replyToSessionIdValue4.getTextValue();
                                brokeredMessagePropertiesInstance4
                                        .setReplyToSessionId(replyToSessionIdInstance4);
                            }

                            JsonNode scheduledEnqueueTimeUtcValue4 = brokeredMessagePropertiesValue4
                                    .get("scheduledEnqueueTimeUtc");
                            if (scheduledEnqueueTimeUtcValue4 != null
                                    && scheduledEnqueueTimeUtcValue4 instanceof NullNode == false) {
                                Calendar scheduledEnqueueTimeUtcInstance4;
                                scheduledEnqueueTimeUtcInstance4 = DatatypeConverter
                                        .parseDateTime(scheduledEnqueueTimeUtcValue4.getTextValue());
                                brokeredMessagePropertiesInstance4
                                        .setScheduledEnqueueTimeUtc(scheduledEnqueueTimeUtcInstance4);
                            }

                            JsonNode sessionIdValue4 = brokeredMessagePropertiesValue4.get("sessionId");
                            if (sessionIdValue4 != null && sessionIdValue4 instanceof NullNode == false) {
                                String sessionIdInstance4;
                                sessionIdInstance4 = sessionIdValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setSessionId(sessionIdInstance4);
                            }

                            JsonNode timeToLiveValue4 = brokeredMessagePropertiesValue4.get("timeToLive");
                            if (timeToLiveValue4 != null && timeToLiveValue4 instanceof NullNode == false) {
                                Calendar timeToLiveInstance4;
                                timeToLiveInstance4 = DatatypeConverter
                                        .parseDateTime(timeToLiveValue4.getTextValue());
                                brokeredMessagePropertiesInstance4.setTimeToLive(timeToLiveInstance4);
                            }

                            JsonNode toValue4 = brokeredMessagePropertiesValue4.get("to");
                            if (toValue4 != null && toValue4 instanceof NullNode == false) {
                                String toInstance4;
                                toInstance4 = toValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setTo(toInstance4);
                            }

                            JsonNode viaPartitionKeyValue4 = brokeredMessagePropertiesValue4
                                    .get("viaPartitionKey");
                            if (viaPartitionKeyValue4 != null
                                    && viaPartitionKeyValue4 instanceof NullNode == false) {
                                String viaPartitionKeyInstance4;
                                viaPartitionKeyInstance4 = viaPartitionKeyValue4.getTextValue();
                                brokeredMessagePropertiesInstance4.setViaPartitionKey(viaPartitionKeyInstance4);
                            }
                        }

                        JsonNode customMessagePropertiesSequenceElement4 = ((JsonNode) serviceBusQueueMessageValue2
                                .get("customMessageProperties"));
                        if (customMessagePropertiesSequenceElement4 != null
                                && customMessagePropertiesSequenceElement4 instanceof NullNode == false) {
                            Iterator<Map.Entry<String, JsonNode>> itr6 = customMessagePropertiesSequenceElement4
                                    .getFields();
                            while (itr6.hasNext()) {
                                Map.Entry<String, JsonNode> property6 = itr6.next();
                                String customMessagePropertiesKey4 = property6.getKey();
                                String customMessagePropertiesValue4 = property6.getValue().getTextValue();
                                serviceBusQueueMessageInstance2.getCustomMessageProperties()
                                        .put(customMessagePropertiesKey4, customMessagePropertiesValue4);
                            }
                        }
                    }
                }

                JsonNode recurrenceValue = responseDoc.get("recurrence");
                if (recurrenceValue != null && recurrenceValue instanceof NullNode == false) {
                    JobRecurrence recurrenceInstance = new JobRecurrence();
                    jobInstance.setRecurrence(recurrenceInstance);

                    JsonNode frequencyValue = recurrenceValue.get("frequency");
                    if (frequencyValue != null && frequencyValue instanceof NullNode == false) {
                        JobRecurrenceFrequency frequencyInstance;
                        frequencyInstance = SchedulerClientImpl
                                .parseJobRecurrenceFrequency(frequencyValue.getTextValue());
                        recurrenceInstance.setFrequency(frequencyInstance);
                    }

                    JsonNode intervalValue = recurrenceValue.get("interval");
                    if (intervalValue != null && intervalValue instanceof NullNode == false) {
                        int intervalInstance;
                        intervalInstance = intervalValue.getIntValue();
                        recurrenceInstance.setInterval(intervalInstance);
                    }

                    JsonNode countValue = recurrenceValue.get("count");
                    if (countValue != null && countValue instanceof NullNode == false) {
                        int countInstance;
                        countInstance = countValue.getIntValue();
                        recurrenceInstance.setCount(countInstance);
                    }

                    JsonNode endTimeValue = recurrenceValue.get("endTime");
                    if (endTimeValue != null && endTimeValue instanceof NullNode == false) {
                        Calendar endTimeInstance;
                        endTimeInstance = DatatypeConverter.parseDateTime(endTimeValue.getTextValue());
                        recurrenceInstance.setEndTime(endTimeInstance);
                    }

                    JsonNode scheduleValue = recurrenceValue.get("schedule");
                    if (scheduleValue != null && scheduleValue instanceof NullNode == false) {
                        JobRecurrenceSchedule scheduleInstance = new JobRecurrenceSchedule();
                        recurrenceInstance.setSchedule(scheduleInstance);

                        JsonNode minutesArray = scheduleValue.get("minutes");
                        if (minutesArray != null && minutesArray instanceof NullNode == false) {
                            scheduleInstance.setMinutes(new ArrayList<Integer>());
                            for (JsonNode minutesValue : ((ArrayNode) minutesArray)) {
                                scheduleInstance.getMinutes().add(minutesValue.getIntValue());
                            }
                        }

                        JsonNode hoursArray = scheduleValue.get("hours");
                        if (hoursArray != null && hoursArray instanceof NullNode == false) {
                            scheduleInstance.setHours(new ArrayList<Integer>());
                            for (JsonNode hoursValue : ((ArrayNode) hoursArray)) {
                                scheduleInstance.getHours().add(hoursValue.getIntValue());
                            }
                        }

                        JsonNode weekDaysArray = scheduleValue.get("weekDays");
                        if (weekDaysArray != null && weekDaysArray instanceof NullNode == false) {
                            scheduleInstance.setDays(new ArrayList<JobScheduleDay>());
                            for (JsonNode weekDaysValue : ((ArrayNode) weekDaysArray)) {
                                scheduleInstance.getDays().add(
                                        SchedulerClientImpl.parseJobScheduleDay(weekDaysValue.getTextValue()));
                            }
                        }

                        JsonNode monthsArray = scheduleValue.get("months");
                        if (monthsArray != null && monthsArray instanceof NullNode == false) {
                            scheduleInstance.setMonths(new ArrayList<Integer>());
                            for (JsonNode monthsValue : ((ArrayNode) monthsArray)) {
                                scheduleInstance.getMonths().add(monthsValue.getIntValue());
                            }
                        }

                        JsonNode monthDaysArray = scheduleValue.get("monthDays");
                        if (monthDaysArray != null && monthDaysArray instanceof NullNode == false) {
                            scheduleInstance.setMonthDays(new ArrayList<Integer>());
                            for (JsonNode monthDaysValue : ((ArrayNode) monthDaysArray)) {
                                scheduleInstance.getMonthDays().add(monthDaysValue.getIntValue());
                            }
                        }

                        JsonNode monthlyOccurrencesArray = scheduleValue.get("monthlyOccurrences");
                        if (monthlyOccurrencesArray != null
                                && monthlyOccurrencesArray instanceof NullNode == false) {
                            scheduleInstance
                                    .setMonthlyOccurrences(new ArrayList<JobScheduleMonthlyOccurrence>());
                            for (JsonNode monthlyOccurrencesValue : ((ArrayNode) monthlyOccurrencesArray)) {
                                JobScheduleMonthlyOccurrence jobScheduleMonthlyOccurrenceInstance = new JobScheduleMonthlyOccurrence();
                                scheduleInstance.getMonthlyOccurrences()
                                        .add(jobScheduleMonthlyOccurrenceInstance);

                                JsonNode dayValue = monthlyOccurrencesValue.get("day");
                                if (dayValue != null && dayValue instanceof NullNode == false) {
                                    JobScheduleDay dayInstance;
                                    dayInstance = SchedulerClientImpl
                                            .parseJobScheduleDay(dayValue.getTextValue());
                                    jobScheduleMonthlyOccurrenceInstance.setDay(dayInstance);
                                }

                                JsonNode occurrenceValue = monthlyOccurrencesValue.get("occurrence");
                                if (occurrenceValue != null && occurrenceValue instanceof NullNode == false) {
                                    int occurrenceInstance;
                                    occurrenceInstance = occurrenceValue.getIntValue();
                                    jobScheduleMonthlyOccurrenceInstance.setOccurrence(occurrenceInstance);
                                }
                            }
                        }
                    }
                }

                JsonNode statusValue = responseDoc.get("status");
                if (statusValue != null && statusValue instanceof NullNode == false) {
                    JobStatus statusInstance = new JobStatus();
                    jobInstance.setStatus(statusInstance);

                    JsonNode lastExecutionTimeValue = statusValue.get("lastExecutionTime");
                    if (lastExecutionTimeValue != null && lastExecutionTimeValue instanceof NullNode == false) {
                        Calendar lastExecutionTimeInstance;
                        lastExecutionTimeInstance = DatatypeConverter
                                .parseDateTime(lastExecutionTimeValue.getTextValue());
                        statusInstance.setLastExecutionTime(lastExecutionTimeInstance);
                    }

                    JsonNode nextExecutionTimeValue = statusValue.get("nextExecutionTime");
                    if (nextExecutionTimeValue != null && nextExecutionTimeValue instanceof NullNode == false) {
                        Calendar nextExecutionTimeInstance;
                        nextExecutionTimeInstance = DatatypeConverter
                                .parseDateTime(nextExecutionTimeValue.getTextValue());
                        statusInstance.setNextExecutionTime(nextExecutionTimeInstance);
                    }

                    JsonNode executionCountValue = statusValue.get("executionCount");
                    if (executionCountValue != null && executionCountValue instanceof NullNode == false) {
                        int executionCountInstance;
                        executionCountInstance = executionCountValue.getIntValue();
                        statusInstance.setExecutionCount(executionCountInstance);
                    }

                    JsonNode failureCountValue = statusValue.get("failureCount");
                    if (failureCountValue != null && failureCountValue instanceof NullNode == false) {
                        int failureCountInstance;
                        failureCountInstance = failureCountValue.getIntValue();
                        statusInstance.setFailureCount(failureCountInstance);
                    }

                    JsonNode faultedCountValue = statusValue.get("faultedCount");
                    if (faultedCountValue != null && faultedCountValue instanceof NullNode == false) {
                        int faultedCountInstance;
                        faultedCountInstance = faultedCountValue.getIntValue();
                        statusInstance.setFaultedCount(faultedCountInstance);
                    }
                }

                JsonNode stateValue = responseDoc.get("state");
                if (stateValue != null && stateValue instanceof NullNode == false) {
                    JobState stateInstance;
                    stateInstance = SchedulerClientImpl.parseJobState(stateValue.getTextValue());
                    jobInstance.setState(stateInstance);
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:org.arkanos.pivotal_analytics.pivotal.Ticket.java

/**
 * Constructs the Ticket based on an XML node given by the API.
 * //from   ww w. j  a va  2s . c  om
 * @param jo specifies the ticket information in a JSON object.
 * @param users provides a user lookup table for reading names from IDs.
 */
public Ticket(JSONObject jo, UserLookup users) {
    try {
        this.ID = ((Long) jo.get("id")).intValue();
        this.StoryType = (String) jo.get("story_type");
        this.URL = new URL((String) jo.get("url"));
        if (jo.get("estimate") != null) {
            this.estimate = ((Long) jo.get("estimate")).intValue();
        } else {
            this.estimate = 0;
        }
        this.currentState = (String) jo.get("current_state");
        this.title = (String) jo.get("name");
        this.requestedBy = users.getUser(jo.get("requested_by_id").toString());

        this.ownedBy = null;
        if (jo.get("owner_ids") != null) {
            JSONArray owners = (JSONArray) jo.get("owner_ids");
            for (Object o : owners.toArray()) {
                if (this.ownedBy != null) {
                    this.ownedBy += ",";
                    this.ownedBy += users.getUser(o.toString());
                } else {
                    this.ownedBy = users.getUser(o.toString());
                }
            }
        }

        this.createdAt = DatatypeConverter.parseDateTime((String) jo.get("created_at")).getTime();
        if (currentState.compareTo("accepted") == 0) {
            this.acceptedAt = DatatypeConverter.parseDateTime((String) jo.get("accepted_at")).getTime();
        } else {
            this.acceptedAt = null;
        }

        this.labels = null;
        for (Object l : ((JSONArray) jo.get("labels")).toArray()) {
            if (this.labels != null) {
                this.labels += "," + ((JSONObject) l).get("name");
            } else {
                this.labels = ((JSONObject) l).get("name").toString();
            }

        }
    } catch (MalformedURLException e) {
        System.out.println("Malformed URL. " + (String) jo.get("url"));
        //e.printStackTrace();
    } catch (NullPointerException e) {
        System.out.println("Ticket could not be made, strange null error. Data: " + jo.toJSONString());
        //e.printStackTrace();
    }
}

From source file:org.candlepin.resource.util.ResourceDateParser.java

public static Date parseDateString(String activeOn) {
    Date d;/*from www  .  ja v a2 s  .co m*/
    if (StringUtils.isBlank(activeOn)) {
        return null;
    }
    try {
        d = DatatypeConverter.parseDateTime(activeOn).getTime();
    } catch (IllegalArgumentException e) {
        throw new BadRequestException("Invalid date, must use ISO 8601 format");
    }
    return d;
}

From source file:org.codice.ddf.catalog.content.monitor.InPlaceMetacardProcessor.java

private AttributeImpl overrideAttributeValue(AttributeDescriptor attributeDescriptor,
        Serializable overrideValue) {
    List<Serializable> newValue = new ArrayList<>();
    for (Object o : overrideValue instanceof List ? (List) overrideValue
            : Collections.singletonList(overrideValue)) {
        try {//  ww  w  .j  a  v a2  s  .  c  om
            String override = String.valueOf(o);
            switch (attributeDescriptor.getType().getAttributeFormat()) {
            case INTEGER:
                newValue.add(Integer.parseInt(override));
                break;
            case FLOAT:
                newValue.add(Float.parseFloat(override));
                break;
            case DOUBLE:
                newValue.add(Double.parseDouble(override));
                break;
            case SHORT:
                newValue.add(Short.parseShort(override));
                break;
            case LONG:
                newValue.add(Long.parseLong(override));
                break;
            case DATE:
                Calendar calendar = DatatypeConverter.parseDateTime(override);
                newValue.add(calendar.getTime());
                break;
            case BOOLEAN:
                newValue.add(Boolean.parseBoolean(override));
                break;
            case BINARY:
                newValue.add(override.getBytes(Charset.forName("UTF-8")));
                break;
            case OBJECT:
            case STRING:
            case GEOMETRY:
            case XML:
                newValue.add(override);
                break;
            }
        } catch (IllegalArgumentException e) {
            return null;
        }
    }
    return new AttributeImpl(attributeDescriptor.getName(), newValue);
}

From source file:org.codice.ddf.catalog.plugin.metacard.util.AttributeFactory.java

/**
 * Attempts to parse a value for an {@link Attribute} according to the provided {@link
 * AttributeDescriptor} whose value is represented by the given string {@param value}. Returns
 * {@code null} if {@param value} could not be parsed.
 *
 * <p>The input {@param value} must be effectively {@link Serializable}.
 *
 * @param attributeDescriptor The descriptor to use to parse the value.
 * @param value The string containing the value to be parsed.
 * @return The deserialized object of {@param value} according to {@param attributeDescriptor}.
 *//*from   ww w . j a  v  a2s.  c  o m*/
@Nullable
public Serializable parseAttributeValue(AttributeDescriptor attributeDescriptor, String value) {
    try {
        notNull(attributeDescriptor);
        notEmpty(value);

        Serializable deserializedValue;
        AttributeType attributeType = attributeDescriptor.getType();
        AttributeType.AttributeFormat attributeFormat = attributeType.getAttributeFormat();

        switch (attributeFormat) {
        case INTEGER:
            deserializedValue = Integer.parseInt(value);
            break;

        case FLOAT:
            deserializedValue = Float.parseFloat(value);
            break;

        case DOUBLE:
            deserializedValue = Double.parseDouble(value);
            break;

        case SHORT:
            deserializedValue = Short.parseShort(value);
            break;

        case LONG:
            deserializedValue = Long.parseLong(value);
            break;

        case DATE:
            Calendar calendar = DatatypeConverter.parseDateTime(value);
            deserializedValue = calendar.getTime();
            break;

        case BOOLEAN:
            deserializedValue = Boolean.parseBoolean(value);
            break;

        case BINARY:
            deserializedValue = value.getBytes(Charset.forName("UTF-8"));
            break;

        case OBJECT:
        case STRING:
        case GEOMETRY:
        case XML:
            deserializedValue = value;
            break;

        default:
            return null;
        }

        return deserializedValue;

    } catch (IllegalArgumentException e) {
        return null;
    }
}

From source file:org.codice.ddf.confluence.source.ConfluenceSource.java

private AttributeImpl overrideAttributeValue(AttributeDescriptor attributeDescriptor,
        Set<String> overrideValue) {
    List<Serializable> newValue = new ArrayList<>();
    for (String override : overrideValue) {
        try {//from   w  w w.  j  a  v  a2 s  .c om
            switch (attributeDescriptor.getType().getAttributeFormat()) {
            case INTEGER:
                newValue.add(Integer.parseInt(override));
                break;
            case FLOAT:
                newValue.add(Float.parseFloat(override));
                break;
            case DOUBLE:
                newValue.add(Double.parseDouble(override));
                break;
            case SHORT:
                newValue.add(Short.parseShort(override));
                break;
            case LONG:
                newValue.add(Long.parseLong(override));
                break;
            case DATE:
                Calendar calendar = DatatypeConverter.parseDateTime(override);
                newValue.add(calendar.getTime());
                break;
            case BOOLEAN:
                newValue.add(Boolean.parseBoolean(override));
                break;
            case BINARY:
                newValue.add(override.getBytes(Charset.forName("UTF-8")));
                break;
            case OBJECT:
            case STRING:
            case GEOMETRY:
            case XML:
                newValue.add(override);
                break;
            }
        } catch (IllegalArgumentException e) {
            LOGGER.debug(
                    "IllegalArgument value [{}] for attribute type [{}] found when performing overrides for [{}]",
                    override, attributeDescriptor.getType().getAttributeFormat(),
                    attributeDescriptor.getName());
        }
    }
    return new AttributeImpl(attributeDescriptor.getName(), newValue);
}

From source file:org.codice.ddf.confluence.source.ConfluenceSourceTest.java

@Test
public void testAttributeOverrides() throws Exception {
    QueryRequest request = new QueryRequestImpl(
            new QueryImpl(builder.attribute("anyText").is().like().text("searchValue"), 1, 1,
                    new SortByImpl("title", SortOrder.DESCENDING), false, 1000));
    InputStream entity = new ByteArrayInputStream(JSON_RESPONSE.getBytes(StandardCharsets.UTF_8));
    when(clientResponse.getEntity()).thenReturn(entity);
    when(clientResponse.getStatus()).thenReturn(Response.Status.OK.getStatusCode());

    setupRegistryEntry("dateAttribute", BasicTypes.DATE_TYPE);
    setupRegistryEntry("boolAttribute", BasicTypes.BOOLEAN_TYPE);
    setupRegistryEntry("longAttribute", BasicTypes.LONG_TYPE);
    setupRegistryEntry("intAttribute", BasicTypes.INTEGER_TYPE);
    setupRegistryEntry("shortAttribute", BasicTypes.SHORT_TYPE);
    setupRegistryEntry("floatAttribute", BasicTypes.FLOAT_TYPE);
    setupRegistryEntry("doubleAttribute", BasicTypes.DOUBLE_TYPE);
    setupRegistryEntry("binaryAttribute", BasicTypes.BINARY_TYPE);
    setupRegistryEntry("badAttribute", BasicTypes.INTEGER_TYPE);
    when(registry.lookup("missingAttribute")).thenReturn(Optional.empty());

    Instant now = Instant.now();

    List<String> additionalAttributes = new ArrayList<>();
    additionalAttributes.add("attrib1=val1");
    additionalAttributes.add("attrib2=val1,val2,val3");
    additionalAttributes.add("dateAttribute=2018-06-28T10:44:00+07:00");
    additionalAttributes.add("boolAttribute=true");
    additionalAttributes.add("longAttribute=12345678900000");
    additionalAttributes.add("intAttribute=1234");
    additionalAttributes.add("shortAttribute=1");
    additionalAttributes.add("floatAttribute=1.1");
    additionalAttributes.add("doubleAttribute=1.23456");
    additionalAttributes.add("binaryAttribute=binaryString");
    additionalAttributes.add("badAttribute=1.23456");
    additionalAttributes.add("missingAttribute=something");

    confluence.setAttributeOverrides(additionalAttributes);

    SourceResponse response = confluence.query(request);
    assertThat(response.getHits(), is(1L));
    Metacard mcard = response.getResults().get(0).getMetacard();
    assertThat(mcard, notNullValue());// w  w w. j  av a 2 s  .co m
    assertThat(mcard.getAttribute("attrib1").getValue(), is("val1"));
    assertThat(mcard.getAttribute("attrib2").getValues().size(), is(3));
    assertThat(mcard.getAttribute("dateAttribute").getValue(),
            is(DatatypeConverter.parseDateTime("2018-06-28T10:44:00+07:00").getTime()));
    assertThat(mcard.getAttribute("boolAttribute").getValue(), is(true));
    assertThat(mcard.getAttribute("longAttribute").getValue(), is(12345678900000L));
    assertThat(mcard.getAttribute("intAttribute").getValue(), is(1234));
    assertThat(mcard.getAttribute("shortAttribute").getValue(), is((short) 1));
    assertThat(mcard.getAttribute("floatAttribute").getValue(), is(1.1f));
    assertThat(mcard.getAttribute("doubleAttribute").getValue(), is(1.23456));
    assertThat(mcard.getAttribute("binaryAttribute").getValue(),
            is("binaryString".getBytes(Charset.forName("UTF-8"))));
    assertThat(mcard.getAttribute("badAttribute"), is(nullValue()));
    assertThat(mcard.getAttribute("missingAttribute"), is(nullValue()));
}

From source file:org.codice.ddf.confluence.source.ConfluenceSourceTest.java

@Test
public void verifyAllMappings() throws Exception {
    QueryRequest request = new QueryRequestImpl(
            new QueryImpl(builder.attribute("anyText").is().like().text("searchValue"), 1, 1,
                    new SortByImpl("title", SortOrder.DESCENDING), false, 1000));
    InputStream entity = new ByteArrayInputStream(JSON_RESPONSE.getBytes(StandardCharsets.UTF_8));
    when(clientResponse.getEntity()).thenReturn(entity);
    when(clientResponse.getStatus()).thenReturn(Response.Status.OK.getStatusCode());

    SourceResponse response = confluence.query(request);
    assertThat(response.getHits(), is(1L));
    Metacard mcard = response.getResults().get(0).getMetacard();
    assertThat(mcard.getCreatedDate(),//from w  w w .j a  va 2s . c  o  m
            is(DatatypeConverter.parseDateTime("2013-09-18T14:50:42.616-07:00").getTime()));
    assertThat(mcard.getModifiedDate(),
            is(DatatypeConverter.parseDateTime("2015-06-16T19:21:39.141-07:00").getTime()));
    assertThat(mcard.getAttribute(Core.METACARD_CREATED).getValue(),
            is(DatatypeConverter.parseDateTime("2013-09-18T14:50:42.616-07:00").getTime()));
    assertThat(mcard.getAttribute(Core.METACARD_MODIFIED).getValue(),
            is(DatatypeConverter.parseDateTime("2015-06-16T19:21:39.141-07:00").getTime()));
    assertThat(mcard.getTags(), contains("confluence", "resource"));
    assertThat(mcard.getId(), is("1179681"));
    assertThat(mcard.getTitle(), is("Formatting Source Code"));
    assertThat(mcard.getAttribute(Associations.EXTERNAL).getValues(),
            contains("https://codice.atlassian.net/wiki/display/DDF/Formatting+Source+Code"));
    assertThat(mcard.getAttribute(Contact.CREATOR_NAME).getValue(), is("another"));
    assertThat(mcard.getAttribute(Contact.CONTRIBUTOR_NAME).getValue(), is("first.last"));
    assertThat(mcard.getAttribute(Media.TYPE).getValue(), is("text/html"));
    assertThat(mcard.getAttribute(Security.ACCESS_GROUPS).getValue(), is("ddf-developers"));
    assertThat(mcard.getAttribute(Security.ACCESS_INDIVIDUALS).getValue(), is("first.last"));
    assertThat(mcard.getAttribute(Topic.CATEGORY).getValue(), is("page"));
    assertThat(mcard.getAttribute(Topic.VOCABULARY).getValue(), is(
            "https://developer.atlassian.com/confdev/confluence-server-rest-api/advanced-searching-using-cql/cql-field-reference#CQLFieldReference-titleTitleType"));
    assertThat(mcard.getAttribute(Topic.KEYWORD).getValue(), is("testlabel"));
}