Example usage for org.apache.http.client.methods HttpPatch HttpPatch

List of usage examples for org.apache.http.client.methods HttpPatch HttpPatch

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpPatch HttpPatch.

Prototype

public HttpPatch(final String uri) 

Source Link

Usage

From source file:com.microsoft.windowsazure.management.network.GatewayOperationsImpl.java

/**
* The Begin Resize Virtual network Gateway operation resizes an existing
* gateway to a different GatewaySKU.//from  w  ww .  j  ava 2s.  c om
*
* @param networkName Required. The name of the virtual network for this
* gateway.
* @param parameters Required. Parameters supplied to the Begin Resize
* Virtual Network Gateway operation.
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @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.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public GatewayOperationResponse beginResize(String networkName, ResizeGatewayParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (networkName == null) {
        throw new NullPointerException("networkName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

    // 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("networkName", networkName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginResizeAsync", 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/networking/";
    url = url + URLEncoder.encode(networkName, "UTF-8");
    url = url + "/gateway";
    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/xml");
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    Element updateGatewayParametersElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "UpdateGatewayParameters");
    requestDoc.appendChild(updateGatewayParametersElement);

    if (parameters.getGatewaySKU() != null) {
        Element gatewaySizeElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "GatewaySize");
        gatewaySizeElement.appendChild(requestDoc.createTextNode(parameters.getGatewaySKU()));
        updateGatewayParametersElement.appendChild(gatewaySizeElement);
    }

    if (parameters.getOperation() != null) {
        Element operationElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "Operation");
        operationElement.appendChild(requestDoc.createTextNode("Resize"));
        updateGatewayParametersElement.appendChild(operationElement);
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // 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_ACCEPTED) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

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

            Element gatewayOperationAsyncResponseElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "GatewayOperationAsyncResponse");
            if (gatewayOperationAsyncResponseElement != null) {
                Element idElement = XmlUtility.getElementByTagNameNS(gatewayOperationAsyncResponseElement,
                        "http://schemas.microsoft.com/windowsazure", "ID");
                if (idElement != null) {
                    String idInstance;
                    idInstance = idElement.getTextContent();
                    result.setOperationId(idInstance);
                }
            }

        }
        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.network.GatewayOperationsImpl.java

/**
* The Begin Resize Virtual network Gateway operation resizes an existing
* gateway to a different GatewaySKU./*from   www  .ja  v a 2s  .c o m*/
*
* @param gatewayId Required. The virtual network for this gateway id.
* @param parameters Required. Parameters supplied to the Begin Resize
* Virtual Network Gateway operation.
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @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.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public GatewayOperationResponse beginResizeVirtualNetworkGateway(String gatewayId,
        ResizeGatewayParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (gatewayId == null) {
        throw new NullPointerException("gatewayId");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

    // 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("gatewayId", gatewayId);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginResizeVirtualNetworkGatewayAsync", 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/networking/virtualnetworkgateways/";
    url = url + URLEncoder.encode(gatewayId, "UTF-8");
    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/xml");
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    Element updateGatewayParametersElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "UpdateGatewayParameters");
    requestDoc.appendChild(updateGatewayParametersElement);

    if (parameters.getGatewaySKU() != null) {
        Element gatewaySizeElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "GatewaySize");
        gatewaySizeElement.appendChild(requestDoc.createTextNode(parameters.getGatewaySKU()));
        updateGatewayParametersElement.appendChild(gatewaySizeElement);
    }

    if (parameters.getOperation() != null) {
        Element operationElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "Operation");
        operationElement.appendChild(requestDoc.createTextNode("Resize"));
        updateGatewayParametersElement.appendChild(operationElement);
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // 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_ACCEPTED) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

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

            Element gatewayOperationAsyncResponseElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "GatewayOperationAsyncResponse");
            if (gatewayOperationAsyncResponseElement != null) {
                Element idElement = XmlUtility.getElementByTagNameNS(gatewayOperationAsyncResponseElement,
                        "http://schemas.microsoft.com/windowsazure", "ID");
                if (idElement != null) {
                    String idInstance;
                    idInstance = idElement.getTextContent();
                    result.setOperationId(idInstance);
                }
            }

        }
        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.network.GatewayOperationsImpl.java

/**
* The Begin Set Virtual Network Gateway IPsec Parameters operation sets the
* IPsec parameters on the virtual network gateway for the specified
* connection to the specified local network in Azure.
*
* @param networkName Required. The name of the virtual network for this
* gateway./*from   w ww  .jav a2s.  c o  m*/
* @param localNetworkName Required. The name of the local network.
* @param parameters Required. Parameters supplied to the Begin Virtual
* Network Gateway Set IPsec Parameters request.
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @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.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public GatewayOperationResponse beginSetIPsecParameters(String networkName, String localNetworkName,
        GatewaySetIPsecParametersParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (networkName == null) {
        throw new NullPointerException("networkName");
    }
    if (localNetworkName == null) {
        throw new NullPointerException("localNetworkName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

    // 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("networkName", networkName);
        tracingParameters.put("localNetworkName", localNetworkName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginSetIPsecParametersAsync", 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/networking/";
    url = url + URLEncoder.encode(networkName, "UTF-8");
    url = url + "/gateway/connection/";
    url = url + URLEncoder.encode(localNetworkName, "UTF-8");
    url = url + "/ipsecparameters";
    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/xml");
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    if (parameters.getParameters() != null) {
        Element iPsecParametersElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "IPsecParameters");
        requestDoc.appendChild(iPsecParametersElement);

        if (parameters.getParameters().getEncryptionType() != null) {
            Element encryptionTypeElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "EncryptionType");
            encryptionTypeElement
                    .appendChild(requestDoc.createTextNode(parameters.getParameters().getEncryptionType()));
            iPsecParametersElement.appendChild(encryptionTypeElement);
        }

        if (parameters.getParameters().getPfsGroup() != null) {
            Element pfsGroupElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                    "PfsGroup");
            pfsGroupElement.appendChild(requestDoc.createTextNode(parameters.getParameters().getPfsGroup()));
            iPsecParametersElement.appendChild(pfsGroupElement);
        }

        Element sADataSizeKilobytesElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "SADataSizeKilobytes");
        sADataSizeKilobytesElement.appendChild(requestDoc
                .createTextNode(Integer.toString(parameters.getParameters().getSADataSizeKilobytes())));
        iPsecParametersElement.appendChild(sADataSizeKilobytesElement);

        Element sALifeTimeSecondsElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "SALifeTimeSeconds");
        sALifeTimeSecondsElement.appendChild(
                requestDoc.createTextNode(Integer.toString(parameters.getParameters().getSALifeTimeSeconds())));
        iPsecParametersElement.appendChild(sALifeTimeSecondsElement);

        if (parameters.getParameters().getHashAlgorithm() != null) {
            Element hashAlgorithmElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "HashAlgorithm");
            hashAlgorithmElement
                    .appendChild(requestDoc.createTextNode(parameters.getParameters().getHashAlgorithm()));
            iPsecParametersElement.appendChild(hashAlgorithmElement);
        }
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // 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_ACCEPTED) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

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

            Element gatewayOperationAsyncResponseElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "GatewayOperationAsyncResponse");
            if (gatewayOperationAsyncResponseElement != null) {
                Element idElement = XmlUtility.getElementByTagNameNS(gatewayOperationAsyncResponseElement,
                        "http://schemas.microsoft.com/windowsazure", "ID");
                if (idElement != null) {
                    String idInstance;
                    idInstance = idElement.getTextContent();
                    result.setOperationId(idInstance);
                }
            }

        }
        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.network.GatewayOperationsImpl.java

/**
* The Begin Set Virtual Network Gateway IPsec Parameters V2 operation sets
* the IPsec parameters on the virtual network gateway connection.
*
* @param gatewayId Required. The virtual network for this gateway Id.
* @param connectedentityId Required. The connected entity Id.
* @param parameters Required. Parameters supplied to the Begin Virtual
* Network Gateway Set IPsec Parameters V2 request.
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body./*from   w w  w  .  java 2s  .c o  m*/
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @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.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public GatewayOperationResponse beginSetIPsecParametersV2(String gatewayId, String connectedentityId,
        GatewaySetIPsecParametersParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (gatewayId == null) {
        throw new NullPointerException("gatewayId");
    }
    if (connectedentityId == null) {
        throw new NullPointerException("connectedentityId");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

    // 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("gatewayId", gatewayId);
        tracingParameters.put("connectedentityId", connectedentityId);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginSetIPsecParametersV2Async", 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/networking/virtualnetworkgateways/";
    url = url + URLEncoder.encode(gatewayId, "UTF-8");
    url = url + "/connectedentity/";
    url = url + URLEncoder.encode(connectedentityId, "UTF-8");
    url = url + "/ipsecparameters";
    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/xml");
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    if (parameters.getParameters() != null) {
        Element iPsecParametersElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "IPsecParameters");
        requestDoc.appendChild(iPsecParametersElement);

        if (parameters.getParameters().getEncryptionType() != null) {
            Element encryptionTypeElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "EncryptionType");
            encryptionTypeElement
                    .appendChild(requestDoc.createTextNode(parameters.getParameters().getEncryptionType()));
            iPsecParametersElement.appendChild(encryptionTypeElement);
        }

        if (parameters.getParameters().getPfsGroup() != null) {
            Element pfsGroupElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                    "PfsGroup");
            pfsGroupElement.appendChild(requestDoc.createTextNode(parameters.getParameters().getPfsGroup()));
            iPsecParametersElement.appendChild(pfsGroupElement);
        }

        Element sADataSizeKilobytesElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "SADataSizeKilobytes");
        sADataSizeKilobytesElement.appendChild(requestDoc
                .createTextNode(Integer.toString(parameters.getParameters().getSADataSizeKilobytes())));
        iPsecParametersElement.appendChild(sADataSizeKilobytesElement);

        Element sALifeTimeSecondsElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "SALifeTimeSeconds");
        sALifeTimeSecondsElement.appendChild(
                requestDoc.createTextNode(Integer.toString(parameters.getParameters().getSALifeTimeSeconds())));
        iPsecParametersElement.appendChild(sALifeTimeSecondsElement);

        if (parameters.getParameters().getHashAlgorithm() != null) {
            Element hashAlgorithmElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "HashAlgorithm");
            hashAlgorithmElement
                    .appendChild(requestDoc.createTextNode(parameters.getParameters().getHashAlgorithm()));
            iPsecParametersElement.appendChild(hashAlgorithmElement);
        }
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // 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_ACCEPTED) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

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

            Element gatewayOperationAsyncResponseElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "GatewayOperationAsyncResponse");
            if (gatewayOperationAsyncResponseElement != null) {
                Element idElement = XmlUtility.getElementByTagNameNS(gatewayOperationAsyncResponseElement,
                        "http://schemas.microsoft.com/windowsazure", "ID");
                if (idElement != null) {
                    String idInstance;
                    idInstance = idElement.getTextContent();
                    result.setOperationId(idInstance);
                }
            }

        }
        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.network.GatewayOperationsImpl.java

/**
* Operation to update existing gateway connection.
*
* @param gatewayId Required. The virtual network gateway Id.
* @param connectedentityId Required. The connected entity Id.
* @param parameters Required. Parameters supplied to the Begin Update
* gateway conneciton operation.//from ww  w .java2 s  . c  o m
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @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.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public GatewayOperationResponse beginUpdateGatewayConnection(String gatewayId, String connectedentityId,
        UpdateGatewayConnectionParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (gatewayId == null) {
        throw new NullPointerException("gatewayId");
    }
    if (connectedentityId == null) {
        throw new NullPointerException("connectedentityId");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

    // 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("gatewayId", gatewayId);
        tracingParameters.put("connectedentityId", connectedentityId);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginUpdateGatewayConnectionAsync", 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/networking/gatewayconnections/virtualnetworkgateway/";
    url = url + URLEncoder.encode(gatewayId, "UTF-8");
    url = url + "/connectedentity/";
    url = url + URLEncoder.encode(connectedentityId, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-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/xml");
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    Element updateGatewayConnectionParametersElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "UpdateGatewayConnectionParameters");
    requestDoc.appendChild(updateGatewayConnectionParametersElement);

    Element routingWeightElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "RoutingWeight");
    routingWeightElement
            .appendChild(requestDoc.createTextNode(Integer.toString(parameters.getRoutingWeight())));
    updateGatewayConnectionParametersElement.appendChild(routingWeightElement);

    if (parameters.getSharedKey() != null) {
        Element sharedKeyElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "SharedKey");
        sharedKeyElement.appendChild(requestDoc.createTextNode(parameters.getSharedKey()));
        updateGatewayConnectionParametersElement.appendChild(sharedKeyElement);
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // 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_ACCEPTED) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

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

            Element gatewayOperationAsyncResponseElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "GatewayOperationAsyncResponse");
            if (gatewayOperationAsyncResponseElement != null) {
                Element idElement = XmlUtility.getElementByTagNameNS(gatewayOperationAsyncResponseElement,
                        "http://schemas.microsoft.com/windowsazure", "ID");
                if (idElement != null) {
                    String idInstance;
                    idInstance = idElement.getTextContent();
                    result.setOperationId(idInstance);
                }
            }

        }
        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.network.GatewayOperationsImpl.java

/**
* The Update Local Network Gateway operation updates a local network gateway
*
* @param gatewayId Required. The virtual network for this gateway.
* @param parameters Required. Parameters supplied to update the Local
* Network Gateway operation./*from   w w w  . j a  v  a  2 s  .c  o  m*/
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @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.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public OperationResponse updateLocalNetworkGateway(String gatewayId,
        UpdateLocalNetworkGatewayParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (gatewayId == null) {
        throw new NullPointerException("gatewayId");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

    // 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("gatewayId", gatewayId);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "updateLocalNetworkGatewayAsync", 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/networking/localnetworkgateways/";
    url = url + URLEncoder.encode(gatewayId, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-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/xml");
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Serialize Request
    String requestContent = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document requestDoc = documentBuilder.newDocument();

    Element updateLocalNetworkGatewayParametersElement = requestDoc.createElementNS(
            "http://schemas.microsoft.com/windowsazure", "UpdateLocalNetworkGatewayParameters");
    requestDoc.appendChild(updateLocalNetworkGatewayParametersElement);

    if (parameters.getAddressSpace() != null) {
        if (parameters.getAddressSpace() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getAddressSpace()).isInitialized()) {
            Element addressSpaceSequenceElement = requestDoc.createElementNS(
                    "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "AddressSpace");
            for (String addressSpaceItem : parameters.getAddressSpace()) {
                Element addressSpaceItemElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string");
                addressSpaceItemElement.appendChild(requestDoc.createTextNode(addressSpaceItem));
                addressSpaceSequenceElement.appendChild(addressSpaceItemElement);
            }
            updateLocalNetworkGatewayParametersElement.appendChild(addressSpaceSequenceElement);
        }
    }

    DOMSource domSource = new DOMSource(requestDoc);
    StringWriter stringWriter = new StringWriter();
    StreamResult streamResult = new StreamResult(stringWriter);
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.transform(domSource, streamResult);
    requestContent = stringWriter.toString();
    StringEntity entity = new StringEntity(requestContent);
    httpRequest.setEntity(entity);
    httpRequest.setHeader("Content-Type", "application/xml");

    // 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, requestContent, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        OperationResponse result = null;
        // Deserialize Response
        result = new OperationResponse();
        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 all jobs in a job collections.
*
* @param parameters Required. Parameters supplied to the Update Jobs State
* operation.//from  w  ww. j  a va2 s .co m
* @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 Jobs State operation response.
*/
@Override
public JobCollectionJobsUpdateStateResponse updateJobCollectionState(
        JobCollectionJobsUpdateStateParameters parameters)
        throws IOException, ServiceException, URISyntaxException {
    // Validate
    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("parameters", parameters);
        CloudTracing.enter(invocationId, this, "updateJobCollectionStateAsync", 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";
    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 jobCollectionJobsUpdateStateParametersValue = objectMapper.createObjectNode();
    requestDoc = jobCollectionJobsUpdateStateParametersValue;

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

    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
        JobCollectionJobsUpdateStateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new JobCollectionJobsUpdateStateResponse();
            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) {
                JsonNode jobsArray = responseDoc;
                if (jobsArray != null && jobsArray instanceof NullNode == false) {
                    for (JsonNode jobsValue : ((ArrayNode) jobsArray)) {
                        Job jobInstance = new Job();
                        result.getJobs().add(jobInstance);

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

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

                        JsonNode actionValue = jobsValue.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 = jobsValue.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 = jobsValue.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 = jobsValue.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:com.microsoft.windowsazure.scheduler.JobOperationsImpl.java

/**
* Update the state of a job.//from  ww w.  j  av  a2  s .com
*
* @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.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.java

@Override
protected HTTPSampleResult sample(URL url, String method, boolean areFollowingRedirect, int frameDepth) {

    if (log.isDebugEnabled()) {
        log.debug("Start : sample " + url.toString());
        log.debug("method " + method + " followingRedirect " + areFollowingRedirect + " depth " + frameDepth);
    }/*from   w  w w . ja  v a 2  s  .  co  m*/

    HTTPSampleResult res = createSampleResult(url, method);

    HttpClient httpClient = setupClient(url, res);

    HttpRequestBase httpRequest = null;
    try {
        URI uri = url.toURI();
        if (method.equals(HTTPConstants.POST)) {
            httpRequest = new HttpPost(uri);
        } else if (method.equals(HTTPConstants.GET)) {
            httpRequest = new HttpGet(uri);
        } else if (method.equals(HTTPConstants.PUT)) {
            httpRequest = new HttpPut(uri);
        } else if (method.equals(HTTPConstants.HEAD)) {
            httpRequest = new HttpHead(uri);
        } else if (method.equals(HTTPConstants.TRACE)) {
            httpRequest = new HttpTrace(uri);
        } else if (method.equals(HTTPConstants.OPTIONS)) {
            httpRequest = new HttpOptions(uri);
        } else if (method.equals(HTTPConstants.DELETE)) {
            httpRequest = new HttpDelete(uri);
        } else if (method.equals(HTTPConstants.PATCH)) {
            httpRequest = new HttpPatch(uri);
        } else if (HttpWebdav.isWebdavMethod(method)) {
            httpRequest = new HttpWebdav(method, uri);
        } else {
            throw new IllegalArgumentException("Unexpected method: '" + method + "'");
        }
        setupRequest(url, httpRequest, res); // can throw IOException
    } catch (Exception e) {
        res.sampleStart();
        res.sampleEnd();
        errorResult(e, res);
        return res;
    }

    HttpContext localContext = new BasicHttpContext();
    setupClientContextBeforeSample(localContext);

    res.sampleStart();

    final CacheManager cacheManager = getCacheManager();
    if (cacheManager != null && HTTPConstants.GET.equalsIgnoreCase(method)) {
        if (cacheManager.inCache(url)) {
            return updateSampleResultForResourceInCache(res);
        }
    }

    try {
        currentRequest = httpRequest;
        handleMethod(method, res, httpRequest, localContext);
        // store the SampleResult in LocalContext to compute connect time
        localContext.setAttribute(SAMPLER_RESULT_TOKEN, res);
        // perform the sample
        HttpResponse httpResponse = executeRequest(httpClient, httpRequest, localContext, url);

        // Needs to be done after execute to pick up all the headers
        final HttpRequest request = (HttpRequest) localContext.getAttribute(HttpCoreContext.HTTP_REQUEST);
        extractClientContextAfterSample(localContext);
        // We've finished with the request, so we can add the LocalAddress to it for display
        final InetAddress localAddr = (InetAddress) httpRequest.getParams()
                .getParameter(ConnRoutePNames.LOCAL_ADDRESS);
        if (localAddr != null) {
            request.addHeader(HEADER_LOCAL_ADDRESS, localAddr.toString());
        }
        res.setRequestHeaders(getConnectionHeaders(request));

        Header contentType = httpResponse.getLastHeader(HTTPConstants.HEADER_CONTENT_TYPE);
        if (contentType != null) {
            String ct = contentType.getValue();
            res.setContentType(ct);
            res.setEncodingAndType(ct);
        }
        HttpEntity entity = httpResponse.getEntity();
        if (entity != null) {
            res.setResponseData(readResponse(res, entity.getContent(), (int) entity.getContentLength()));
        }

        res.sampleEnd(); // Done with the sampling proper.
        currentRequest = null;

        // Now collect the results into the HTTPSampleResult:
        StatusLine statusLine = httpResponse.getStatusLine();
        int statusCode = statusLine.getStatusCode();
        res.setResponseCode(Integer.toString(statusCode));
        res.setResponseMessage(statusLine.getReasonPhrase());
        res.setSuccessful(isSuccessCode(statusCode));

        res.setResponseHeaders(getResponseHeaders(httpResponse, localContext));
        if (res.isRedirect()) {
            final Header headerLocation = httpResponse.getLastHeader(HTTPConstants.HEADER_LOCATION);
            if (headerLocation == null) { // HTTP protocol violation, but avoids NPE
                throw new IllegalArgumentException(
                        "Missing location header in redirect for " + httpRequest.getRequestLine());
            }
            String redirectLocation = headerLocation.getValue();
            res.setRedirectLocation(redirectLocation);
        }

        // record some sizes to allow HTTPSampleResult.getBytes() with different options
        HttpConnectionMetrics metrics = (HttpConnectionMetrics) localContext.getAttribute(CONTEXT_METRICS);
        long headerBytes = res.getResponseHeaders().length() // condensed length (without \r)
                + httpResponse.getAllHeaders().length // Add \r for each header
                + 1 // Add \r for initial header
                + 2; // final \r\n before data
        long totalBytes = metrics.getReceivedBytesCount();
        res.setHeadersSize((int) headerBytes);
        res.setBodySize((int) (totalBytes - headerBytes));
        if (log.isDebugEnabled()) {
            log.debug("ResponseHeadersSize=" + res.getHeadersSize() + " Content-Length=" + res.getBodySize()
                    + " Total=" + (res.getHeadersSize() + res.getBodySize()));
        }

        // If we redirected automatically, the URL may have changed
        if (getAutoRedirects()) {
            HttpUriRequest req = (HttpUriRequest) localContext.getAttribute(HttpCoreContext.HTTP_REQUEST);
            HttpHost target = (HttpHost) localContext.getAttribute(HttpCoreContext.HTTP_TARGET_HOST);
            URI redirectURI = req.getURI();
            if (redirectURI.isAbsolute()) {
                res.setURL(redirectURI.toURL());
            } else {
                res.setURL(new URL(new URL(target.toURI()), redirectURI.toString()));
            }
        }

        // Store any cookies received in the cookie manager:
        saveConnectionCookies(httpResponse, res.getURL(), getCookieManager());

        // Save cache information
        if (cacheManager != null) {
            cacheManager.saveDetails(httpResponse, res);
        }

        // Follow redirects and download page resources if appropriate:
        res = resultProcessing(areFollowingRedirect, frameDepth, res);

    } catch (IOException e) {
        log.debug("IOException", e);
        if (res.getEndTime() == 0) {
            res.sampleEnd();
        }
        // pick up headers if failed to execute the request
        if (res.getRequestHeaders() != null) {
            log.debug("Overwriting request old headers: " + res.getRequestHeaders());
        }
        res.setRequestHeaders(
                getConnectionHeaders((HttpRequest) localContext.getAttribute(HttpCoreContext.HTTP_REQUEST)));
        errorResult(e, res);
        return res;
    } catch (RuntimeException e) {
        log.debug("RuntimeException", e);
        if (res.getEndTime() == 0) {
            res.sampleEnd();
        }
        errorResult(e, res);
        return res;
    } finally {
        currentRequest = null;
        JMeterContextService.getContext().getSamplerContext().remove(HTTPCLIENT_TOKEN);
    }
    return res;
}

From source file:org.apache.nutch.protocol.httpclient.HttpClientRedirectStrategy.java

public HttpUriRequest getRedirect(final HttpRequest request, final HttpResponse response,
        final HttpContext context) throws ProtocolException {
    URI uri = getLocationURI(request, response, context);
    String method = request.getRequestLine().getMethod();
    if (method.equalsIgnoreCase(HttpHead.METHOD_NAME)) {
        return new HttpHead(uri);
    } else if (method.equalsIgnoreCase(HttpGet.METHOD_NAME)) {
        return new HttpGet(uri);
    } else {/* w  w  w.  j av  a2s .  c om*/
        int status = response.getStatusLine().getStatusCode();
        if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
            if (method.equalsIgnoreCase(HttpPost.METHOD_NAME)) {
                return copyEntity(new HttpPost(uri), request);
            } else if (method.equalsIgnoreCase(HttpPut.METHOD_NAME)) {
                return copyEntity(new HttpPut(uri), request);
            } else if (method.equalsIgnoreCase(HttpDelete.METHOD_NAME)) {
                return new HttpDelete(uri);
            } else if (method.equalsIgnoreCase(HttpTrace.METHOD_NAME)) {
                return new HttpTrace(uri);
            } else if (method.equalsIgnoreCase(HttpOptions.METHOD_NAME)) {
                return new HttpOptions(uri);
            } else if (method.equalsIgnoreCase(HttpPatch.METHOD_NAME)) {
                return copyEntity(new HttpPatch(uri), request);
            }
        }
        return new HttpGet(uri);
    }
}