Example usage for javax.xml.bind DatatypeConverter parseDateTime

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

Introduction

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

Prototype

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

Source Link

Document

Converts the string argument into a Calendar value.

Usage

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

/**
* The List OS Images operation retrieves a list of the operating system
* images from the image repository.  (see
* http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx for
* more information)// w  w  w  . j av  a  2s  .  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 ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return The List OS Images operation response.
*/
@Override
public VirtualMachineOSImageListResponse list()
        throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException {
    // Validate

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        CloudTracing.enter(invocationId, this, "listAsync", 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/images";
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

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

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

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

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

            Element imagesSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "Images");
            if (imagesSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(imagesSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "OSImage")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element imagesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(imagesSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "OSImage")
                            .get(i1));
                    VirtualMachineOSImageListResponse.VirtualMachineOSImage oSImageInstance = new VirtualMachineOSImageListResponse.VirtualMachineOSImage();
                    result.getImages().add(oSImageInstance);

                    Element affinityGroupElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "AffinityGroup");
                    if (affinityGroupElement != null) {
                        String affinityGroupInstance;
                        affinityGroupInstance = affinityGroupElement.getTextContent();
                        oSImageInstance.setAffinityGroup(affinityGroupInstance);
                    }

                    Element categoryElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Category");
                    if (categoryElement != null) {
                        String categoryInstance;
                        categoryInstance = categoryElement.getTextContent();
                        oSImageInstance.setCategory(categoryInstance);
                    }

                    Element labelElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Label");
                    if (labelElement != null) {
                        String labelInstance;
                        labelInstance = labelElement.getTextContent();
                        oSImageInstance.setLabel(labelInstance);
                    }

                    Element locationElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Location");
                    if (locationElement != null) {
                        String locationInstance;
                        locationInstance = locationElement.getTextContent();
                        oSImageInstance.setLocation(locationInstance);
                    }

                    Element logicalSizeInGBElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "LogicalSizeInGB");
                    if (logicalSizeInGBElement != null) {
                        double logicalSizeInGBInstance;
                        logicalSizeInGBInstance = DatatypeConverter
                                .parseDouble(logicalSizeInGBElement.getTextContent());
                        oSImageInstance.setLogicalSizeInGB(logicalSizeInGBInstance);
                    }

                    Element mediaLinkElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "MediaLink");
                    if (mediaLinkElement != null) {
                        URI mediaLinkInstance;
                        mediaLinkInstance = new URI(mediaLinkElement.getTextContent());
                        oSImageInstance.setMediaLinkUri(mediaLinkInstance);
                    }

                    Element nameElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Name");
                    if (nameElement != null) {
                        String nameInstance;
                        nameInstance = nameElement.getTextContent();
                        oSImageInstance.setName(nameInstance);
                    }

                    Element osElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "OS");
                    if (osElement != null) {
                        String osInstance;
                        osInstance = osElement.getTextContent();
                        oSImageInstance.setOperatingSystemType(osInstance);
                    }

                    Element eulaElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Eula");
                    if (eulaElement != null) {
                        String eulaInstance;
                        eulaInstance = eulaElement.getTextContent();
                        oSImageInstance.setEula(eulaInstance);
                    }

                    Element descriptionElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Description");
                    if (descriptionElement != null) {
                        String descriptionInstance;
                        descriptionInstance = descriptionElement.getTextContent();
                        oSImageInstance.setDescription(descriptionInstance);
                    }

                    Element imageFamilyElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ImageFamily");
                    if (imageFamilyElement != null) {
                        String imageFamilyInstance;
                        imageFamilyInstance = imageFamilyElement.getTextContent();
                        oSImageInstance.setImageFamily(imageFamilyInstance);
                    }

                    Element showInGuiElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ShowInGui");
                    if (showInGuiElement != null && showInGuiElement.getTextContent() != null
                            && !showInGuiElement.getTextContent().isEmpty()) {
                        boolean showInGuiInstance;
                        showInGuiInstance = DatatypeConverter
                                .parseBoolean(showInGuiElement.getTextContent().toLowerCase());
                        oSImageInstance.setShowInGui(showInGuiInstance);
                    }

                    Element publishedDateElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PublishedDate");
                    if (publishedDateElement != null) {
                        Calendar publishedDateInstance;
                        publishedDateInstance = DatatypeConverter
                                .parseDateTime(publishedDateElement.getTextContent());
                        oSImageInstance.setPublishedDate(publishedDateInstance);
                    }

                    Element isPremiumElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IsPremium");
                    if (isPremiumElement != null && isPremiumElement.getTextContent() != null
                            && !isPremiumElement.getTextContent().isEmpty()) {
                        boolean isPremiumInstance;
                        isPremiumInstance = DatatypeConverter
                                .parseBoolean(isPremiumElement.getTextContent().toLowerCase());
                        oSImageInstance.setIsPremium(isPremiumInstance);
                    }

                    Element privacyUriElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PrivacyUri");
                    if (privacyUriElement != null) {
                        URI privacyUriInstance;
                        privacyUriInstance = new URI(privacyUriElement.getTextContent());
                        oSImageInstance.setPrivacyUri(privacyUriInstance);
                    }

                    Element recommendedVMSizeElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "RecommendedVMSize");
                    if (recommendedVMSizeElement != null) {
                        String recommendedVMSizeInstance;
                        recommendedVMSizeInstance = recommendedVMSizeElement.getTextContent();
                        oSImageInstance.setRecommendedVMSize(recommendedVMSizeInstance);
                    }

                    Element publisherNameElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PublisherName");
                    if (publisherNameElement != null) {
                        String publisherNameInstance;
                        publisherNameInstance = publisherNameElement.getTextContent();
                        oSImageInstance.setPublisherName(publisherNameInstance);
                    }

                    Element pricingDetailLinkElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PricingDetailLink");
                    if (pricingDetailLinkElement != null) {
                        URI pricingDetailLinkInstance;
                        pricingDetailLinkInstance = new URI(pricingDetailLinkElement.getTextContent());
                        oSImageInstance.setPricingDetailUri(pricingDetailLinkInstance);
                    }

                    Element iconUriElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IconUri");
                    if (iconUriElement != null) {
                        String iconUriInstance;
                        iconUriInstance = iconUriElement.getTextContent();
                        oSImageInstance.setIconUri(iconUriInstance);
                    }

                    Element smallIconUriElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "SmallIconUri");
                    if (smallIconUriElement != null) {
                        String smallIconUriInstance;
                        smallIconUriInstance = smallIconUriElement.getTextContent();
                        oSImageInstance.setSmallIconUri(smallIconUriInstance);
                    }

                    Element languageElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Language");
                    if (languageElement != null) {
                        String languageInstance;
                        languageInstance = languageElement.getTextContent();
                        oSImageInstance.setLanguage(languageInstance);
                    }

                    Element iOTypeElement = XmlUtility.getElementByTagNameNS(imagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IOType");
                    if (iOTypeElement != null) {
                        String iOTypeInstance;
                        iOTypeInstance = iOTypeElement.getTextContent();
                        oSImageInstance.setIOType(iOTypeInstance);
                    }
                }
            }

        }
        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

/**
* Creates a new Job, allowing the service to generate a job id. Use
* CreateOrUpdate if a user-chosen job id is required.
*
* @param parameters Required. Parameters specifying the job definition for
* a Create Job operation.//  www . ja v  a 2 s  . c o  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 Create Job operation response.
*/
@Override
public JobCreateResponse create(JobCreateParameters parameters)
        throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getAction() == null) {
        throw new NullPointerException("parameters.Action");
    }
    if (parameters.getAction().getErrorAction() != null) {
        if (parameters.getAction().getErrorAction().getQueueMessage() != null) {
            if (parameters.getAction().getErrorAction().getQueueMessage().getMessage() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.QueueMessage.Message");
            }
            if (parameters.getAction().getErrorAction().getQueueMessage().getQueueName() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.QueueMessage.QueueName");
            }
            if (parameters.getAction().getErrorAction().getQueueMessage().getSasToken() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.QueueMessage.SasToken");
            }
            if (parameters.getAction().getErrorAction().getQueueMessage().getStorageAccountName() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.QueueMessage.StorageAccountName");
            }
        }
        if (parameters.getAction().getErrorAction().getRequest() != null) {
            if (parameters.getAction().getErrorAction().getRequest().getMethod() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.Request.Method");
            }
            if (parameters.getAction().getErrorAction().getRequest().getUri() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.Request.Uri");
            }
        }
        if (parameters.getAction().getErrorAction().getServiceBusQueueMessage() != null) {
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                    .getAuthentication() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.Authentication");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage().getAuthentication()
                    .getSasKey() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.Authentication.SasKey");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage().getAuthentication()
                    .getSasKeyName() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.Authentication.SasKeyName");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage().getAuthentication()
                    .getType() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.Authentication.Type");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage().getMessage() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.ServiceBusQueueMessage.Message");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage().getNamespace() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.Namespace");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage().getQueueName() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.QueueName");
            }
            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                    .getTransportType() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusQueueMessage.TransportType");
            }
        }
        if (parameters.getAction().getErrorAction().getServiceBusTopicMessage() != null) {
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                    .getAuthentication() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.Authentication");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage().getAuthentication()
                    .getSasKey() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.Authentication.SasKey");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage().getAuthentication()
                    .getSasKeyName() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.Authentication.SasKeyName");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage().getAuthentication()
                    .getType() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.Authentication.Type");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage().getMessage() == null) {
                throw new NullPointerException("parameters.Action.ErrorAction.ServiceBusTopicMessage.Message");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage().getNamespace() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.Namespace");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage().getTopicPath() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.TopicPath");
            }
            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                    .getTransportType() == null) {
                throw new NullPointerException(
                        "parameters.Action.ErrorAction.ServiceBusTopicMessage.TransportType");
            }
        }
        if (parameters.getAction().getErrorAction().getType() == null) {
            throw new NullPointerException("parameters.Action.ErrorAction.Type");
        }
    }
    if (parameters.getAction().getQueueMessage() != null) {
        if (parameters.getAction().getQueueMessage().getMessage() == null) {
            throw new NullPointerException("parameters.Action.QueueMessage.Message");
        }
        if (parameters.getAction().getQueueMessage().getQueueName() == null) {
            throw new NullPointerException("parameters.Action.QueueMessage.QueueName");
        }
        if (parameters.getAction().getQueueMessage().getSasToken() == null) {
            throw new NullPointerException("parameters.Action.QueueMessage.SasToken");
        }
        if (parameters.getAction().getQueueMessage().getStorageAccountName() == null) {
            throw new NullPointerException("parameters.Action.QueueMessage.StorageAccountName");
        }
    }
    if (parameters.getAction().getRequest() != null) {
        if (parameters.getAction().getRequest().getMethod() == null) {
            throw new NullPointerException("parameters.Action.Request.Method");
        }
        if (parameters.getAction().getRequest().getUri() == null) {
            throw new NullPointerException("parameters.Action.Request.Uri");
        }
    }
    if (parameters.getAction().getRetryPolicy() != null) {
        if (parameters.getAction().getRetryPolicy().getRetryType() == null) {
            throw new NullPointerException("parameters.Action.RetryPolicy.RetryType");
        }
    }
    if (parameters.getAction().getServiceBusQueueMessage() != null) {
        if (parameters.getAction().getServiceBusQueueMessage().getAuthentication() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.Authentication");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getAuthentication().getSasKey() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.Authentication.SasKey");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getAuthentication().getSasKeyName() == null) {
            throw new NullPointerException(
                    "parameters.Action.ServiceBusQueueMessage.Authentication.SasKeyName");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getAuthentication().getType() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.Authentication.Type");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getMessage() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.Message");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getNamespace() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.Namespace");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getQueueName() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.QueueName");
        }
        if (parameters.getAction().getServiceBusQueueMessage().getTransportType() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusQueueMessage.TransportType");
        }
    }
    if (parameters.getAction().getServiceBusTopicMessage() != null) {
        if (parameters.getAction().getServiceBusTopicMessage().getAuthentication() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.Authentication");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getAuthentication().getSasKey() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.Authentication.SasKey");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getAuthentication().getSasKeyName() == null) {
            throw new NullPointerException(
                    "parameters.Action.ServiceBusTopicMessage.Authentication.SasKeyName");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getAuthentication().getType() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.Authentication.Type");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getMessage() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.Message");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getNamespace() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.Namespace");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getTopicPath() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.TopicPath");
        }
        if (parameters.getAction().getServiceBusTopicMessage().getTransportType() == null) {
            throw new NullPointerException("parameters.Action.ServiceBusTopicMessage.TransportType");
        }
    }
    if (parameters.getAction().getType() == null) {
        throw new NullPointerException("parameters.Action.Type");
    }
    if (parameters.getRecurrence() != null) {
        if (parameters.getRecurrence().getFrequency() == null) {
            throw new NullPointerException("parameters.Recurrence.Frequency");
        }
        if (parameters.getRecurrence().getSchedule() != null) {
            if (parameters.getRecurrence().getSchedule().getMonthlyOccurrences() != null) {
                for (JobScheduleMonthlyOccurrence monthlyOccurrencesParameterItem : parameters.getRecurrence()
                        .getSchedule().getMonthlyOccurrences()) {
                    if (monthlyOccurrencesParameterItem.getDay() == null) {
                        throw new NullPointerException("parameters.Recurrence.Schedule.MonthlyOccurrences.Day");
                    }
                }
            }
        }
    }

    // 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, "createAsync", 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";
    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
    HttpPost httpRequest = new HttpPost(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 jobCreateParametersValue = objectMapper.createObjectNode();
    requestDoc = jobCreateParametersValue;

    if (parameters.getStartTime() != null) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        ((ObjectNode) jobCreateParametersValue).put("startTime",
                simpleDateFormat.format(parameters.getStartTime().getTime()));
    }

    ObjectNode actionValue = objectMapper.createObjectNode();
    ((ObjectNode) jobCreateParametersValue).put("action", actionValue);

    ((ObjectNode) actionValue).put("type",
            SchedulerClientImpl.jobActionTypeToString(parameters.getAction().getType()));

    if (parameters.getAction().getRetryPolicy() != null) {
        ObjectNode retryPolicyValue = objectMapper.createObjectNode();
        ((ObjectNode) actionValue).put("retryPolicy", retryPolicyValue);

        ((ObjectNode) retryPolicyValue).put("retryType",
                SchedulerClientImpl.retryTypeToString(parameters.getAction().getRetryPolicy().getRetryType()));

        if (parameters.getAction().getRetryPolicy().getRetryInterval() != null) {
            ((ObjectNode) retryPolicyValue).put("retryInterval",
                    TimeSpan8601Converter.format(parameters.getAction().getRetryPolicy().getRetryInterval()));
        }

        if (parameters.getAction().getRetryPolicy().getRetryCount() != null) {
            ((ObjectNode) retryPolicyValue).put("retryCount",
                    parameters.getAction().getRetryPolicy().getRetryCount());
        }
    }

    if (parameters.getAction().getErrorAction() != null) {
        ObjectNode errorActionValue = objectMapper.createObjectNode();
        ((ObjectNode) actionValue).put("errorAction", errorActionValue);

        ((ObjectNode) errorActionValue).put("type",
                SchedulerClientImpl.jobActionTypeToString(parameters.getAction().getErrorAction().getType()));

        if (parameters.getAction().getErrorAction().getRequest() != null) {
            ObjectNode requestValue = objectMapper.createObjectNode();
            ((ObjectNode) errorActionValue).put("request", requestValue);

            ((ObjectNode) requestValue).put("uri",
                    parameters.getAction().getErrorAction().getRequest().getUri().toString());

            ((ObjectNode) requestValue).put("method",
                    parameters.getAction().getErrorAction().getRequest().getMethod());

            if (parameters.getAction().getErrorAction().getRequest().getHeaders() != null) {
                if (parameters.getAction().getErrorAction().getRequest()
                        .getHeaders() instanceof LazyCollection == false
                        || ((LazyCollection) parameters.getAction().getErrorAction().getRequest().getHeaders())
                                .isInitialized()) {
                    ObjectNode headersDictionary = objectMapper.createObjectNode();
                    for (Map.Entry<String, String> entry : parameters.getAction().getErrorAction().getRequest()
                            .getHeaders().entrySet()) {
                        String headersKey = entry.getKey();
                        String headersValue = entry.getValue();
                        ((ObjectNode) headersDictionary).put(headersKey, headersValue);
                    }
                    ((ObjectNode) requestValue).put("headers", headersDictionary);
                }
            }

            if (parameters.getAction().getErrorAction().getRequest().getBody() != null) {
                ((ObjectNode) requestValue).put("body",
                        parameters.getAction().getErrorAction().getRequest().getBody());
            }

            if (parameters.getAction().getErrorAction().getRequest().getAuthentication() != null) {
                ObjectNode authenticationValue = objectMapper.createObjectNode();
                ((ObjectNode) requestValue).put("authentication", authenticationValue);
                if (parameters.getAction().getErrorAction().getRequest()
                        .getAuthentication() instanceof ClientCertAuthentication) {
                    ((ObjectNode) authenticationValue).put("type", "ClientCertificate");
                    ClientCertAuthentication derived = ((ClientCertAuthentication) parameters.getAction()
                            .getErrorAction().getRequest().getAuthentication());

                    if (derived.getPassword() != null) {
                        ((ObjectNode) authenticationValue).put("password", derived.getPassword());
                    }

                    if (derived.getPfx() != null) {
                        ((ObjectNode) authenticationValue).put("pfx", derived.getPfx());
                    }

                    if (derived.getCertificateThumbprint() != null) {
                        ((ObjectNode) authenticationValue).put("certificateThumbprint",
                                derived.getCertificateThumbprint());
                    }

                    if (derived.getCertificateExpiration() != null) {
                        SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat(
                                "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                        simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC"));
                        ((ObjectNode) authenticationValue).put("certificateExpiration",
                                simpleDateFormat2.format(derived.getCertificateExpiration().getTime()));
                    }

                    if (derived.getCertificateSubjectName() != null) {
                        ((ObjectNode) authenticationValue).put("certificateSubjectName",
                                derived.getCertificateSubjectName());
                    }

                    if (derived.getType() != null) {
                        ((ObjectNode) authenticationValue).put("type",
                                SchedulerClientImpl.httpAuthenticationTypeToString(derived.getType()));
                    }
                }
                if (parameters.getAction().getErrorAction().getRequest()
                        .getAuthentication() instanceof AADOAuthAuthentication) {
                    ((ObjectNode) authenticationValue).put("type", "ActiveDirectoryOAuth");
                    AADOAuthAuthentication derived2 = ((AADOAuthAuthentication) parameters.getAction()
                            .getErrorAction().getRequest().getAuthentication());

                    if (derived2.getSecret() != null) {
                        ((ObjectNode) authenticationValue).put("secret", derived2.getSecret());
                    }

                    if (derived2.getTenant() != null) {
                        ((ObjectNode) authenticationValue).put("tenant", derived2.getTenant());
                    }

                    if (derived2.getAudience() != null) {
                        ((ObjectNode) authenticationValue).put("audience", derived2.getAudience());
                    }

                    if (derived2.getClientId() != null) {
                        ((ObjectNode) authenticationValue).put("clientId", derived2.getClientId());
                    }

                    if (derived2.getType() != null) {
                        ((ObjectNode) authenticationValue).put("type",
                                SchedulerClientImpl.httpAuthenticationTypeToString(derived2.getType()));
                    }
                }
                if (parameters.getAction().getErrorAction().getRequest()
                        .getAuthentication() instanceof BasicAuthentication) {
                    ((ObjectNode) authenticationValue).put("type", "Basic");
                    BasicAuthentication derived3 = ((BasicAuthentication) parameters.getAction()
                            .getErrorAction().getRequest().getAuthentication());

                    ((ObjectNode) authenticationValue).put("username", derived3.getUsername());

                    if (derived3.getPassword() != null) {
                        ((ObjectNode) authenticationValue).put("password", derived3.getPassword());
                    }

                    if (derived3.getType() != null) {
                        ((ObjectNode) authenticationValue).put("type",
                                SchedulerClientImpl.httpAuthenticationTypeToString(derived3.getType()));
                    }
                }
            }
        }

        if (parameters.getAction().getErrorAction().getQueueMessage() != null) {
            ObjectNode queueMessageValue = objectMapper.createObjectNode();
            ((ObjectNode) errorActionValue).put("queueMessage", queueMessageValue);

            ((ObjectNode) queueMessageValue).put("storageAccount",
                    parameters.getAction().getErrorAction().getQueueMessage().getStorageAccountName());

            ((ObjectNode) queueMessageValue).put("queueName",
                    parameters.getAction().getErrorAction().getQueueMessage().getQueueName());

            ((ObjectNode) queueMessageValue).put("sasToken",
                    parameters.getAction().getErrorAction().getQueueMessage().getSasToken());

            ((ObjectNode) queueMessageValue).put("message",
                    parameters.getAction().getErrorAction().getQueueMessage().getMessage());
        }

        if (parameters.getAction().getErrorAction().getServiceBusTopicMessage() != null) {
            ObjectNode serviceBusTopicMessageValue = objectMapper.createObjectNode();
            ((ObjectNode) errorActionValue).put("serviceBusTopicMessage", serviceBusTopicMessageValue);

            ((ObjectNode) serviceBusTopicMessageValue).put("topicPath",
                    parameters.getAction().getErrorAction().getServiceBusTopicMessage().getTopicPath());

            ((ObjectNode) serviceBusTopicMessageValue).put("namespace",
                    parameters.getAction().getErrorAction().getServiceBusTopicMessage().getNamespace());

            ((ObjectNode) serviceBusTopicMessageValue).put("transportType",
                    SchedulerClientImpl.jobServiceBusTransportTypeToString(parameters.getAction()
                            .getErrorAction().getServiceBusTopicMessage().getTransportType()));

            ObjectNode authenticationValue2 = objectMapper.createObjectNode();
            ((ObjectNode) serviceBusTopicMessageValue).put("authentication", authenticationValue2);

            ((ObjectNode) authenticationValue2).put("sasKeyName", parameters.getAction().getErrorAction()
                    .getServiceBusTopicMessage().getAuthentication().getSasKeyName());

            ((ObjectNode) authenticationValue2).put("sasKey", parameters.getAction().getErrorAction()
                    .getServiceBusTopicMessage().getAuthentication().getSasKey());

            ((ObjectNode) authenticationValue2).put("type",
                    SchedulerClientImpl.jobServiceBusAuthenticationTypeToString(parameters.getAction()
                            .getErrorAction().getServiceBusTopicMessage().getAuthentication().getType()));

            ((ObjectNode) serviceBusTopicMessageValue).put("message",
                    parameters.getAction().getErrorAction().getServiceBusTopicMessage().getMessage());

            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                    .getBrokeredMessageProperties() != null) {
                ObjectNode brokeredMessagePropertiesValue = objectMapper.createObjectNode();
                ((ObjectNode) serviceBusTopicMessageValue).put("brokeredMessageProperties",
                        brokeredMessagePropertiesValue);

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getContentType() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("contentType",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getContentType());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getCorrelationId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("correlationId",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getCorrelationId());
                }

                ((ObjectNode) brokeredMessagePropertiesValue).put("forcePersistence",
                        parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                .getBrokeredMessageProperties().isForcePersistence());

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getLabel() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("label",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getLabel());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getMessageId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("messageId",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getMessageId());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getPartitionKey() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("partitionKey",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getPartitionKey());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getReplyTo() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("replyTo",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getReplyTo());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getReplyToSessionId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("replyToSessionId",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getReplyToSessionId());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getScheduledEnqueueTimeUtc() != null) {
                    SimpleDateFormat simpleDateFormat3 = new SimpleDateFormat(
                            "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                    simpleDateFormat3.setTimeZone(TimeZone.getTimeZone("UTC"));
                    ((ObjectNode) brokeredMessagePropertiesValue).put("scheduledEnqueueTimeUtc",
                            simpleDateFormat3.format(parameters.getAction().getErrorAction()
                                    .getServiceBusTopicMessage().getBrokeredMessageProperties()
                                    .getScheduledEnqueueTimeUtc().getTime()));
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getSessionId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("sessionId",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getSessionId());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getTimeToLive() != null) {
                    SimpleDateFormat simpleDateFormat4 = new SimpleDateFormat(
                            "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                    simpleDateFormat4.setTimeZone(TimeZone.getTimeZone("UTC"));
                    ((ObjectNode) brokeredMessagePropertiesValue).put("timeToLive",
                            simpleDateFormat4
                                    .format(parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                            .getBrokeredMessageProperties().getTimeToLive().getTime()));
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getTo() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("to",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getTo());
                }

                if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                        .getBrokeredMessageProperties().getViaPartitionKey() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue).put("viaPartitionKey",
                            parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                                    .getBrokeredMessageProperties().getViaPartitionKey());
                }
            }

            if (parameters.getAction().getErrorAction().getServiceBusTopicMessage()
                    .getCustomMessageProperties() != null) {
                ObjectNode customMessagePropertiesDictionary = objectMapper.createObjectNode();
                for (Map.Entry<String, String> entry2 : parameters.getAction().getErrorAction()
                        .getServiceBusTopicMessage().getCustomMessageProperties().entrySet()) {
                    String customMessagePropertiesKey = entry2.getKey();
                    String customMessagePropertiesValue = entry2.getValue();
                    ((ObjectNode) customMessagePropertiesDictionary).put(customMessagePropertiesKey,
                            customMessagePropertiesValue);
                }
                ((ObjectNode) serviceBusTopicMessageValue).put("customMessageProperties",
                        customMessagePropertiesDictionary);
            }
        }

        if (parameters.getAction().getErrorAction().getServiceBusQueueMessage() != null) {
            ObjectNode serviceBusQueueMessageValue = objectMapper.createObjectNode();
            ((ObjectNode) errorActionValue).put("serviceBusQueueMessage", serviceBusQueueMessageValue);

            ((ObjectNode) serviceBusQueueMessageValue).put("queueName",
                    parameters.getAction().getErrorAction().getServiceBusQueueMessage().getQueueName());

            ((ObjectNode) serviceBusQueueMessageValue).put("namespace",
                    parameters.getAction().getErrorAction().getServiceBusQueueMessage().getNamespace());

            ((ObjectNode) serviceBusQueueMessageValue).put("transportType",
                    SchedulerClientImpl.jobServiceBusTransportTypeToString(parameters.getAction()
                            .getErrorAction().getServiceBusQueueMessage().getTransportType()));

            ObjectNode authenticationValue3 = objectMapper.createObjectNode();
            ((ObjectNode) serviceBusQueueMessageValue).put("authentication", authenticationValue3);

            ((ObjectNode) authenticationValue3).put("sasKeyName", parameters.getAction().getErrorAction()
                    .getServiceBusQueueMessage().getAuthentication().getSasKeyName());

            ((ObjectNode) authenticationValue3).put("sasKey", parameters.getAction().getErrorAction()
                    .getServiceBusQueueMessage().getAuthentication().getSasKey());

            ((ObjectNode) authenticationValue3).put("type",
                    SchedulerClientImpl.jobServiceBusAuthenticationTypeToString(parameters.getAction()
                            .getErrorAction().getServiceBusQueueMessage().getAuthentication().getType()));

            ((ObjectNode) serviceBusQueueMessageValue).put("message",
                    parameters.getAction().getErrorAction().getServiceBusQueueMessage().getMessage());

            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                    .getBrokeredMessageProperties() != null) {
                ObjectNode brokeredMessagePropertiesValue2 = objectMapper.createObjectNode();
                ((ObjectNode) serviceBusQueueMessageValue).put("brokeredMessageProperties",
                        brokeredMessagePropertiesValue2);

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getContentType() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("contentType",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getContentType());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getCorrelationId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("correlationId",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getCorrelationId());
                }

                ((ObjectNode) brokeredMessagePropertiesValue2).put("forcePersistence",
                        parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                .getBrokeredMessageProperties().isForcePersistence());

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getLabel() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("label",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getLabel());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getMessageId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("messageId",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getMessageId());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getPartitionKey() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("partitionKey",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getPartitionKey());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getReplyTo() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("replyTo",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getReplyTo());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getReplyToSessionId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("replyToSessionId",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getReplyToSessionId());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getScheduledEnqueueTimeUtc() != null) {
                    SimpleDateFormat simpleDateFormat5 = new SimpleDateFormat(
                            "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                    simpleDateFormat5.setTimeZone(TimeZone.getTimeZone("UTC"));
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("scheduledEnqueueTimeUtc",
                            simpleDateFormat5.format(parameters.getAction().getErrorAction()
                                    .getServiceBusQueueMessage().getBrokeredMessageProperties()
                                    .getScheduledEnqueueTimeUtc().getTime()));
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getSessionId() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("sessionId",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getSessionId());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getTimeToLive() != null) {
                    SimpleDateFormat simpleDateFormat6 = new SimpleDateFormat(
                            "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                    simpleDateFormat6.setTimeZone(TimeZone.getTimeZone("UTC"));
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("timeToLive",
                            simpleDateFormat6
                                    .format(parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                            .getBrokeredMessageProperties().getTimeToLive().getTime()));
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getTo() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("to",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getTo());
                }

                if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                        .getBrokeredMessageProperties().getViaPartitionKey() != null) {
                    ((ObjectNode) brokeredMessagePropertiesValue2).put("viaPartitionKey",
                            parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                                    .getBrokeredMessageProperties().getViaPartitionKey());
                }
            }

            if (parameters.getAction().getErrorAction().getServiceBusQueueMessage()
                    .getCustomMessageProperties() != null) {
                ObjectNode customMessagePropertiesDictionary2 = objectMapper.createObjectNode();
                for (Map.Entry<String, String> entry3 : parameters.getAction().getErrorAction()
                        .getServiceBusQueueMessage().getCustomMessageProperties().entrySet()) {
                    String customMessagePropertiesKey2 = entry3.getKey();
                    String customMessagePropertiesValue2 = entry3.getValue();
                    ((ObjectNode) customMessagePropertiesDictionary2).put(customMessagePropertiesKey2,
                            customMessagePropertiesValue2);
                }
                ((ObjectNode) serviceBusQueueMessageValue).put("customMessageProperties",
                        customMessagePropertiesDictionary2);
            }
        }
    }

    if (parameters.getAction().getRequest() != null) {
        ObjectNode requestValue2 = objectMapper.createObjectNode();
        ((ObjectNode) actionValue).put("request", requestValue2);

        ((ObjectNode) requestValue2).put("uri", parameters.getAction().getRequest().getUri().toString());

        ((ObjectNode) requestValue2).put("method", parameters.getAction().getRequest().getMethod());

        if (parameters.getAction().getRequest().getHeaders() != null) {
            if (parameters.getAction().getRequest().getHeaders() instanceof LazyCollection == false
                    || ((LazyCollection) parameters.getAction().getRequest().getHeaders()).isInitialized()) {
                ObjectNode headersDictionary2 = objectMapper.createObjectNode();
                for (Map.Entry<String, String> entry4 : parameters.getAction().getRequest().getHeaders()
                        .entrySet()) {
                    String headersKey2 = entry4.getKey();
                    String headersValue2 = entry4.getValue();
                    ((ObjectNode) headersDictionary2).put(headersKey2, headersValue2);
                }
                ((ObjectNode) requestValue2).put("headers", headersDictionary2);
            }
        }

        if (parameters.getAction().getRequest().getBody() != null) {
            ((ObjectNode) requestValue2).put("body", parameters.getAction().getRequest().getBody());
        }

        if (parameters.getAction().getRequest().getAuthentication() != null) {
            ObjectNode authenticationValue4 = objectMapper.createObjectNode();
            ((ObjectNode) requestValue2).put("authentication", authenticationValue4);
            if (parameters.getAction().getRequest().getAuthentication() instanceof ClientCertAuthentication) {
                ((ObjectNode) authenticationValue4).put("type", "ClientCertificate");
                ClientCertAuthentication derived4 = ((ClientCertAuthentication) parameters.getAction()
                        .getRequest().getAuthentication());

                if (derived4.getPassword() != null) {
                    ((ObjectNode) authenticationValue4).put("password", derived4.getPassword());
                }

                if (derived4.getPfx() != null) {
                    ((ObjectNode) authenticationValue4).put("pfx", derived4.getPfx());
                }

                if (derived4.getCertificateThumbprint() != null) {
                    ((ObjectNode) authenticationValue4).put("certificateThumbprint",
                            derived4.getCertificateThumbprint());
                }

                if (derived4.getCertificateExpiration() != null) {
                    SimpleDateFormat simpleDateFormat7 = new SimpleDateFormat(
                            "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                    simpleDateFormat7.setTimeZone(TimeZone.getTimeZone("UTC"));
                    ((ObjectNode) authenticationValue4).put("certificateExpiration",
                            simpleDateFormat7.format(derived4.getCertificateExpiration().getTime()));
                }

                if (derived4.getCertificateSubjectName() != null) {
                    ((ObjectNode) authenticationValue4).put("certificateSubjectName",
                            derived4.getCertificateSubjectName());
                }

                if (derived4.getType() != null) {
                    ((ObjectNode) authenticationValue4).put("type",
                            SchedulerClientImpl.httpAuthenticationTypeToString(derived4.getType()));
                }
            }
            if (parameters.getAction().getRequest().getAuthentication() instanceof AADOAuthAuthentication) {
                ((ObjectNode) authenticationValue4).put("type", "ActiveDirectoryOAuth");
                AADOAuthAuthentication derived5 = ((AADOAuthAuthentication) parameters.getAction().getRequest()
                        .getAuthentication());

                if (derived5.getSecret() != null) {
                    ((ObjectNode) authenticationValue4).put("secret", derived5.getSecret());
                }

                if (derived5.getTenant() != null) {
                    ((ObjectNode) authenticationValue4).put("tenant", derived5.getTenant());
                }

                if (derived5.getAudience() != null) {
                    ((ObjectNode) authenticationValue4).put("audience", derived5.getAudience());
                }

                if (derived5.getClientId() != null) {
                    ((ObjectNode) authenticationValue4).put("clientId", derived5.getClientId());
                }

                if (derived5.getType() != null) {
                    ((ObjectNode) authenticationValue4).put("type",
                            SchedulerClientImpl.httpAuthenticationTypeToString(derived5.getType()));
                }
            }
            if (parameters.getAction().getRequest().getAuthentication() instanceof BasicAuthentication) {
                ((ObjectNode) authenticationValue4).put("type", "Basic");
                BasicAuthentication derived6 = ((BasicAuthentication) parameters.getAction().getRequest()
                        .getAuthentication());

                ((ObjectNode) authenticationValue4).put("username", derived6.getUsername());

                if (derived6.getPassword() != null) {
                    ((ObjectNode) authenticationValue4).put("password", derived6.getPassword());
                }

                if (derived6.getType() != null) {
                    ((ObjectNode) authenticationValue4).put("type",
                            SchedulerClientImpl.httpAuthenticationTypeToString(derived6.getType()));
                }
            }
        }
    }

    if (parameters.getAction().getQueueMessage() != null) {
        ObjectNode queueMessageValue2 = objectMapper.createObjectNode();
        ((ObjectNode) actionValue).put("queueMessage", queueMessageValue2);

        ((ObjectNode) queueMessageValue2).put("storageAccount",
                parameters.getAction().getQueueMessage().getStorageAccountName());

        ((ObjectNode) queueMessageValue2).put("queueName",
                parameters.getAction().getQueueMessage().getQueueName());

        ((ObjectNode) queueMessageValue2).put("sasToken",
                parameters.getAction().getQueueMessage().getSasToken());

        ((ObjectNode) queueMessageValue2).put("message", parameters.getAction().getQueueMessage().getMessage());
    }

    if (parameters.getAction().getServiceBusTopicMessage() != null) {
        ObjectNode serviceBusTopicMessageValue2 = objectMapper.createObjectNode();
        ((ObjectNode) actionValue).put("serviceBusTopicMessage", serviceBusTopicMessageValue2);

        ((ObjectNode) serviceBusTopicMessageValue2).put("topicPath",
                parameters.getAction().getServiceBusTopicMessage().getTopicPath());

        ((ObjectNode) serviceBusTopicMessageValue2).put("namespace",
                parameters.getAction().getServiceBusTopicMessage().getNamespace());

        ((ObjectNode) serviceBusTopicMessageValue2).put("transportType",
                SchedulerClientImpl.jobServiceBusTransportTypeToString(
                        parameters.getAction().getServiceBusTopicMessage().getTransportType()));

        ObjectNode authenticationValue5 = objectMapper.createObjectNode();
        ((ObjectNode) serviceBusTopicMessageValue2).put("authentication", authenticationValue5);

        ((ObjectNode) authenticationValue5).put("sasKeyName",
                parameters.getAction().getServiceBusTopicMessage().getAuthentication().getSasKeyName());

        ((ObjectNode) authenticationValue5).put("sasKey",
                parameters.getAction().getServiceBusTopicMessage().getAuthentication().getSasKey());

        ((ObjectNode) authenticationValue5).put("type",
                SchedulerClientImpl.jobServiceBusAuthenticationTypeToString(
                        parameters.getAction().getServiceBusTopicMessage().getAuthentication().getType()));

        ((ObjectNode) serviceBusTopicMessageValue2).put("message",
                parameters.getAction().getServiceBusTopicMessage().getMessage());

        if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties() != null) {
            ObjectNode brokeredMessagePropertiesValue3 = objectMapper.createObjectNode();
            ((ObjectNode) serviceBusTopicMessageValue2).put("brokeredMessageProperties",
                    brokeredMessagePropertiesValue3);

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getContentType() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("contentType", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getContentType());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getCorrelationId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("correlationId", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getCorrelationId());
            }

            ((ObjectNode) brokeredMessagePropertiesValue3).put("forcePersistence", parameters.getAction()
                    .getServiceBusTopicMessage().getBrokeredMessageProperties().isForcePersistence());

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getLabel() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("label", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getLabel());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getMessageId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("messageId", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getMessageId());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getPartitionKey() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("partitionKey", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getPartitionKey());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getReplyTo() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("replyTo", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getReplyTo());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getReplyToSessionId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("replyToSessionId", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getReplyToSessionId());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getScheduledEnqueueTimeUtc() != null) {
                SimpleDateFormat simpleDateFormat8 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                simpleDateFormat8.setTimeZone(TimeZone.getTimeZone("UTC"));
                ((ObjectNode) brokeredMessagePropertiesValue3).put("scheduledEnqueueTimeUtc",
                        simpleDateFormat8.format(parameters.getAction().getServiceBusTopicMessage()
                                .getBrokeredMessageProperties().getScheduledEnqueueTimeUtc().getTime()));
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getSessionId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("sessionId", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getSessionId());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getTimeToLive() != null) {
                SimpleDateFormat simpleDateFormat9 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                simpleDateFormat9.setTimeZone(TimeZone.getTimeZone("UTC"));
                ((ObjectNode) brokeredMessagePropertiesValue3).put("timeToLive",
                        simpleDateFormat9.format(parameters.getAction().getServiceBusTopicMessage()
                                .getBrokeredMessageProperties().getTimeToLive().getTime()));
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getTo() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("to", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getTo());
            }

            if (parameters.getAction().getServiceBusTopicMessage().getBrokeredMessageProperties()
                    .getViaPartitionKey() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue3).put("viaPartitionKey", parameters.getAction()
                        .getServiceBusTopicMessage().getBrokeredMessageProperties().getViaPartitionKey());
            }
        }

        if (parameters.getAction().getServiceBusTopicMessage().getCustomMessageProperties() != null) {
            ObjectNode customMessagePropertiesDictionary3 = objectMapper.createObjectNode();
            for (Map.Entry<String, String> entry5 : parameters.getAction().getServiceBusTopicMessage()
                    .getCustomMessageProperties().entrySet()) {
                String customMessagePropertiesKey3 = entry5.getKey();
                String customMessagePropertiesValue3 = entry5.getValue();
                ((ObjectNode) customMessagePropertiesDictionary3).put(customMessagePropertiesKey3,
                        customMessagePropertiesValue3);
            }
            ((ObjectNode) serviceBusTopicMessageValue2).put("customMessageProperties",
                    customMessagePropertiesDictionary3);
        }
    }

    if (parameters.getAction().getServiceBusQueueMessage() != null) {
        ObjectNode serviceBusQueueMessageValue2 = objectMapper.createObjectNode();
        ((ObjectNode) actionValue).put("serviceBusQueueMessage", serviceBusQueueMessageValue2);

        ((ObjectNode) serviceBusQueueMessageValue2).put("queueName",
                parameters.getAction().getServiceBusQueueMessage().getQueueName());

        ((ObjectNode) serviceBusQueueMessageValue2).put("namespace",
                parameters.getAction().getServiceBusQueueMessage().getNamespace());

        ((ObjectNode) serviceBusQueueMessageValue2).put("transportType",
                SchedulerClientImpl.jobServiceBusTransportTypeToString(
                        parameters.getAction().getServiceBusQueueMessage().getTransportType()));

        ObjectNode authenticationValue6 = objectMapper.createObjectNode();
        ((ObjectNode) serviceBusQueueMessageValue2).put("authentication", authenticationValue6);

        ((ObjectNode) authenticationValue6).put("sasKeyName",
                parameters.getAction().getServiceBusQueueMessage().getAuthentication().getSasKeyName());

        ((ObjectNode) authenticationValue6).put("sasKey",
                parameters.getAction().getServiceBusQueueMessage().getAuthentication().getSasKey());

        ((ObjectNode) authenticationValue6).put("type",
                SchedulerClientImpl.jobServiceBusAuthenticationTypeToString(
                        parameters.getAction().getServiceBusQueueMessage().getAuthentication().getType()));

        ((ObjectNode) serviceBusQueueMessageValue2).put("message",
                parameters.getAction().getServiceBusQueueMessage().getMessage());

        if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties() != null) {
            ObjectNode brokeredMessagePropertiesValue4 = objectMapper.createObjectNode();
            ((ObjectNode) serviceBusQueueMessageValue2).put("brokeredMessageProperties",
                    brokeredMessagePropertiesValue4);

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getContentType() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("contentType", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getContentType());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getCorrelationId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("correlationId", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getCorrelationId());
            }

            ((ObjectNode) brokeredMessagePropertiesValue4).put("forcePersistence", parameters.getAction()
                    .getServiceBusQueueMessage().getBrokeredMessageProperties().isForcePersistence());

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getLabel() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("label", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getLabel());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getMessageId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("messageId", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getMessageId());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getPartitionKey() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("partitionKey", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getPartitionKey());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getReplyTo() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("replyTo", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getReplyTo());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getReplyToSessionId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("replyToSessionId", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getReplyToSessionId());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getScheduledEnqueueTimeUtc() != null) {
                SimpleDateFormat simpleDateFormat10 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                simpleDateFormat10.setTimeZone(TimeZone.getTimeZone("UTC"));
                ((ObjectNode) brokeredMessagePropertiesValue4).put("scheduledEnqueueTimeUtc",
                        simpleDateFormat10.format(parameters.getAction().getServiceBusQueueMessage()
                                .getBrokeredMessageProperties().getScheduledEnqueueTimeUtc().getTime()));
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getSessionId() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("sessionId", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getSessionId());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getTimeToLive() != null) {
                SimpleDateFormat simpleDateFormat11 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
                simpleDateFormat11.setTimeZone(TimeZone.getTimeZone("UTC"));
                ((ObjectNode) brokeredMessagePropertiesValue4).put("timeToLive",
                        simpleDateFormat11.format(parameters.getAction().getServiceBusQueueMessage()
                                .getBrokeredMessageProperties().getTimeToLive().getTime()));
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getTo() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("to", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getTo());
            }

            if (parameters.getAction().getServiceBusQueueMessage().getBrokeredMessageProperties()
                    .getViaPartitionKey() != null) {
                ((ObjectNode) brokeredMessagePropertiesValue4).put("viaPartitionKey", parameters.getAction()
                        .getServiceBusQueueMessage().getBrokeredMessageProperties().getViaPartitionKey());
            }
        }

        if (parameters.getAction().getServiceBusQueueMessage().getCustomMessageProperties() != null) {
            ObjectNode customMessagePropertiesDictionary4 = objectMapper.createObjectNode();
            for (Map.Entry<String, String> entry6 : parameters.getAction().getServiceBusQueueMessage()
                    .getCustomMessageProperties().entrySet()) {
                String customMessagePropertiesKey4 = entry6.getKey();
                String customMessagePropertiesValue4 = entry6.getValue();
                ((ObjectNode) customMessagePropertiesDictionary4).put(customMessagePropertiesKey4,
                        customMessagePropertiesValue4);
            }
            ((ObjectNode) serviceBusQueueMessageValue2).put("customMessageProperties",
                    customMessagePropertiesDictionary4);
        }
    }

    if (parameters.getRecurrence() != null) {
        ObjectNode recurrenceValue = objectMapper.createObjectNode();
        ((ObjectNode) jobCreateParametersValue).put("recurrence", recurrenceValue);

        ((ObjectNode) recurrenceValue).put("frequency",
                SchedulerClientImpl.jobRecurrenceFrequencyToString(parameters.getRecurrence().getFrequency()));

        if (parameters.getRecurrence().getInterval() != null) {
            ((ObjectNode) recurrenceValue).put("interval", parameters.getRecurrence().getInterval());
        }

        if (parameters.getRecurrence().getCount() != null) {
            ((ObjectNode) recurrenceValue).put("count", parameters.getRecurrence().getCount());
        }

        if (parameters.getRecurrence().getEndTime() != null) {
            SimpleDateFormat simpleDateFormat12 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'");
            simpleDateFormat12.setTimeZone(TimeZone.getTimeZone("UTC"));
            ((ObjectNode) recurrenceValue).put("endTime",
                    simpleDateFormat12.format(parameters.getRecurrence().getEndTime().getTime()));
        }

        if (parameters.getRecurrence().getSchedule() != null) {
            ObjectNode scheduleValue = objectMapper.createObjectNode();
            ((ObjectNode) recurrenceValue).put("schedule", scheduleValue);

            if (parameters.getRecurrence().getSchedule().getMinutes() != null) {
                ArrayNode minutesArray = objectMapper.createArrayNode();
                for (int minutesItem : parameters.getRecurrence().getSchedule().getMinutes()) {
                    minutesArray.add(minutesItem);
                }
                ((ObjectNode) scheduleValue).put("minutes", minutesArray);
            }

            if (parameters.getRecurrence().getSchedule().getHours() != null) {
                ArrayNode hoursArray = objectMapper.createArrayNode();
                for (int hoursItem : parameters.getRecurrence().getSchedule().getHours()) {
                    hoursArray.add(hoursItem);
                }
                ((ObjectNode) scheduleValue).put("hours", hoursArray);
            }

            if (parameters.getRecurrence().getSchedule().getDays() != null) {
                ArrayNode weekDaysArray = objectMapper.createArrayNode();
                for (JobScheduleDay weekDaysItem : parameters.getRecurrence().getSchedule().getDays()) {
                    weekDaysArray.add(SchedulerClientImpl.jobScheduleDayToString(weekDaysItem));
                }
                ((ObjectNode) scheduleValue).put("weekDays", weekDaysArray);
            }

            if (parameters.getRecurrence().getSchedule().getMonths() != null) {
                ArrayNode monthsArray = objectMapper.createArrayNode();
                for (int monthsItem : parameters.getRecurrence().getSchedule().getMonths()) {
                    monthsArray.add(monthsItem);
                }
                ((ObjectNode) scheduleValue).put("months", monthsArray);
            }

            if (parameters.getRecurrence().getSchedule().getMonthDays() != null) {
                ArrayNode monthDaysArray = objectMapper.createArrayNode();
                for (int monthDaysItem : parameters.getRecurrence().getSchedule().getMonthDays()) {
                    monthDaysArray.add(monthDaysItem);
                }
                ((ObjectNode) scheduleValue).put("monthDays", monthDaysArray);
            }

            if (parameters.getRecurrence().getSchedule().getMonthlyOccurrences() != null) {
                ArrayNode monthlyOccurrencesArray = objectMapper.createArrayNode();
                for (JobScheduleMonthlyOccurrence monthlyOccurrencesItem : parameters.getRecurrence()
                        .getSchedule().getMonthlyOccurrences()) {
                    ObjectNode jobScheduleMonthlyOccurrenceValue = objectMapper.createObjectNode();
                    monthlyOccurrencesArray.add(jobScheduleMonthlyOccurrenceValue);

                    ((ObjectNode) jobScheduleMonthlyOccurrenceValue).put("day",
                            SchedulerClientImpl.jobScheduleDayToString(monthlyOccurrencesItem.getDay()));

                    if (monthlyOccurrencesItem.getOccurrence() != null) {
                        ((ObjectNode) jobScheduleMonthlyOccurrenceValue).put("occurrence",
                                monthlyOccurrencesItem.getOccurrence());
                    }
                }
                ((ObjectNode) scheduleValue).put("monthlyOccurrences", monthlyOccurrencesArray);
            }
        }
    }

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

        // Create Result
        JobCreateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_CREATED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new JobCreateResponse();
            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 actionValue2 = responseDoc.get("action");
                if (actionValue2 != null && actionValue2 instanceof NullNode == false) {
                    JobAction actionInstance = new JobAction();
                    jobInstance.setAction(actionInstance);

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

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

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

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

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

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

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

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

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

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

                            JsonNode headersSequenceElement = ((JsonNode) requestValue3.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 headersKey3 = property.getKey();
                                    String headersValue3 = property.getValue().getTextValue();
                                    requestInstance.getHeaders().put(headersKey3, headersValue3);
                                }
                            }

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

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

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

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

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

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

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

                                    JsonNode typeValue3 = authenticationValue7.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 = authenticationValue7.get("secret");
                                    if (secretValue != null && secretValue instanceof NullNode == false) {
                                        String secretInstance;
                                        secretInstance = secretValue.getTextValue();
                                        aADOAuthAuthenticationInstance.setSecret(secretInstance);
                                    }

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

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

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

                                    JsonNode typeValue4 = authenticationValue7.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 = authenticationValue7.get("username");
                                    if (usernameValue != null && usernameValue instanceof NullNode == false) {
                                        String usernameInstance;
                                        usernameInstance = usernameValue.getTextValue();
                                        basicAuthenticationInstance.setUsername(usernameInstance);
                                    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            JsonNode customMessagePropertiesSequenceElement = ((JsonNode) serviceBusTopicMessageValue3
                                    .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 customMessagePropertiesKey5 = property2.getKey();
                                    String customMessagePropertiesValue5 = property2.getValue().getTextValue();
                                    serviceBusTopicMessageInstance.getCustomMessageProperties()
                                            .put(customMessagePropertiesKey5, customMessagePropertiesValue5);
                                }
                            }
                        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            JsonNode customMessagePropertiesSequenceElement2 = ((JsonNode) serviceBusQueueMessageValue3
                                    .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 customMessagePropertiesKey6 = property3.getKey();
                                    String customMessagePropertiesValue6 = property3.getValue().getTextValue();
                                    serviceBusQueueMessageInstance.getCustomMessageProperties()
                                            .put(customMessagePropertiesKey6, customMessagePropertiesValue6);
                                }
                            }
                        }
                    }

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

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

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

                        JsonNode headersSequenceElement2 = ((JsonNode) requestValue4.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 headersKey4 = property4.getKey();
                                String headersValue4 = property4.getValue().getTextValue();
                                requestInstance2.getHeaders().put(headersKey4, headersValue4);
                            }
                        }

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

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

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

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

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

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

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

                                JsonNode typeValue8 = authenticationValue10.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 = authenticationValue10.get("secret");
                                if (secretValue2 != null && secretValue2 instanceof NullNode == false) {
                                    String secretInstance2;
                                    secretInstance2 = secretValue2.getTextValue();
                                    aADOAuthAuthenticationInstance2.setSecret(secretInstance2);
                                }

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

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

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

                                JsonNode typeValue9 = authenticationValue10.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 = authenticationValue10.get("username");
                                if (usernameValue2 != null && usernameValue2 instanceof NullNode == false) {
                                    String usernameInstance2;
                                    usernameInstance2 = usernameValue2.getTextValue();
                                    basicAuthenticationInstance2.setUsername(usernameInstance2);
                                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        JsonNode customMessagePropertiesSequenceElement3 = ((JsonNode) serviceBusTopicMessageValue4
                                .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 customMessagePropertiesKey7 = property5.getKey();
                                String customMessagePropertiesValue7 = property5.getValue().getTextValue();
                                serviceBusTopicMessageInstance2.getCustomMessageProperties()
                                        .put(customMessagePropertiesKey7, customMessagePropertiesValue7);
                            }
                        }
                    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        JsonNode customMessagePropertiesSequenceElement4 = ((JsonNode) serviceBusQueueMessageValue4
                                .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 customMessagePropertiesKey8 = property6.getKey();
                                String customMessagePropertiesValue8 = property6.getValue().getTextValue();
                                serviceBusQueueMessageInstance2.getCustomMessageProperties()
                                        .put(customMessagePropertiesKey8, customMessagePropertiesValue8);
                            }
                        }
                    }
                }

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

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

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

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

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

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

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

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

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

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

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

                        JsonNode monthlyOccurrencesArray2 = scheduleValue2.get("monthlyOccurrences");
                        if (monthlyOccurrencesArray2 != null
                                && monthlyOccurrencesArray2 instanceof NullNode == false) {
                            scheduleInstance
                                    .setMonthlyOccurrences(new ArrayList<JobScheduleMonthlyOccurrence>());
                            for (JsonNode monthlyOccurrencesValue : ((ArrayNode) monthlyOccurrencesArray2)) {
                                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:com.marklogic.client.functionaltest.TestBiTemporal.java

@Test
// Test Period Range Query using ALN_CONTAINS. We use a single axis during query
public void testPeriodRangeQuerySingleAxisBasedOnALNContains() throws Exception {
    System.out.println("Inside testPeriodRangeQuerySingleAxisBasedOnALNContains");

    // Read documents based on document URI and ALN Contains. We are just
    // looking for count of documents to be correct

    String docId = "javaSingleJSONDoc.json";

    insertJSONSingleDocument(temporalCollectionName, docId, null);

    updateJSONSingleDocument(temporalCollectionName, docId);

    // Fetch documents associated with a search term (such as XML) in Address
    // element// ww  w  .  j a  v a2 s.c  o m
    QueryManager queryMgr = readerClient.newQueryManager();
    StructuredQueryBuilder sqb = queryMgr.newStructuredQueryBuilder();

    StructuredQueryDefinition termQuery = sqb.collection(docId);

    StructuredQueryBuilder.Axis validAxis = sqb.axis(axisValidName);
    Calendar start1 = DatatypeConverter.parseDateTime("2001-01-01T00:00:01");
    Calendar end1 = DatatypeConverter.parseDateTime("2011-12-31T23:59:58");
    StructuredQueryBuilder.Period period1 = sqb.period(start1, end1);
    StructuredQueryDefinition periodQuery = sqb.and(termQuery,
            sqb.temporalPeriodRange(validAxis, TemporalOperator.ALN_CONTAINS, period1));

    long start = 1;
    JSONDocumentManager docMgr = readerClient.newJSONDocumentManager();
    docMgr.setMetadataCategories(Metadata.ALL); // Get all metadata
    DocumentPage termQueryResults = docMgr.search(periodQuery, start);

    long count = 0;
    while (termQueryResults.hasNext()) {
        ++count;
        DocumentRecord record = termQueryResults.next();
        System.out.println("URI = " + record.getUri());

        DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
        record.getMetadata(metadataHandle);
        Iterator<String> resCollections = metadataHandle.getCollections().iterator();
        while (resCollections.hasNext()) {
            System.out.println("Collection = " + resCollections.next());
        }

        if (record.getFormat() == Format.XML) {
            DOMHandle recordHandle = new DOMHandle();
            record.getContent(recordHandle);
            System.out.println("Content = " + recordHandle.toString());
        } else {
            JacksonDatabindHandle<ObjectNode> recordHandle = new JacksonDatabindHandle<ObjectNode>(
                    ObjectNode.class);
            record.getContent(recordHandle);
            System.out.println("Content = " + recordHandle.toString());

            JsonFactory factory = new JsonFactory();
            ObjectMapper mapper = new ObjectMapper(factory);
            TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
            };

            HashMap<String, Object> docObject = mapper.readValue(recordHandle.toString(), typeRef);

            @SuppressWarnings("unchecked")
            HashMap<String, Object> systemNode = (HashMap<String, Object>) (docObject.get(systemNodeName));

            String systemStartDate = (String) systemNode.get(systemStartERIName);
            String systemEndDate = (String) systemNode.get(systemEndERIName);
            System.out.println("systemStartDate = " + systemStartDate);
            System.out.println("systemEndDate = " + systemEndDate);

            @SuppressWarnings("unchecked")
            HashMap<String, Object> validNode = (HashMap<String, Object>) (docObject.get(validNodeName));

            String validStartDate = (String) validNode.get(validStartERIName);
            String validEndDate = (String) validNode.get(validEndERIName);
            System.out.println("validStartDate = " + validStartDate);
            System.out.println("validEndDate = " + validEndDate);

            assertTrue("Valid start date check failed", (validStartDate.equals("2001-01-01T00:00:00")
                    && validEndDate.equals("2011-12-31T23:59:59")));
        }
    }

    System.out.println("Number of results using SQB = " + count);
    assertEquals("Wrong number of results", 1, count);
}

From source file:com.microsoft.windowsazure.management.servicebus.NamespaceOperationsImpl.java

/**
* The get authorization rule operation gets an authorization rule for a
* namespace by name.//from  www. j  ava  2 s  . c om
*
* @param namespaceName Required. The namespace to get the authorization
* rule for.
* @param entityName Required. The entity name to get the authorization rule
* for.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @return A response to a request for a particular authorization rule.
*/
@Override
public ServiceBusAuthorizationRuleResponse getAuthorizationRule(String namespaceName, String entityName)
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate
    if (namespaceName == null) {
        throw new NullPointerException("namespaceName");
    }
    if (entityName == null) {
        throw new NullPointerException("entityName");
    }

    // 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("namespaceName", namespaceName);
        tracingParameters.put("entityName", entityName);
        CloudTracing.enter(invocationId, this, "getAuthorizationRuleAsync", 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/servicebus/namespaces/";
    url = url + URLEncoder.encode(namespaceName, "UTF-8");
    url = url + "/AuthorizationRules/";
    url = url + URLEncoder.encode(entityName, "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
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers
    httpRequest.setHeader("Accept", "application/atom+xml");
    httpRequest.setHeader("Content-Type", "application/xml; charset=utf-8");
    httpRequest.setHeader("x-ms-version", "2013-08-01");

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

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

            Element entryElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://www.w3.org/2005/Atom",
                    "entry");
            if (entryElement != null) {
                Element contentElement = XmlUtility.getElementByTagNameNS(entryElement,
                        "http://www.w3.org/2005/Atom", "content");
                if (contentElement != null) {
                    Element sharedAccessAuthorizationRuleElement = XmlUtility.getElementByTagNameNS(
                            contentElement,
                            "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                            "SharedAccessAuthorizationRule");
                    if (sharedAccessAuthorizationRuleElement != null) {
                        ServiceBusSharedAccessAuthorizationRule sharedAccessAuthorizationRuleInstance = new ServiceBusSharedAccessAuthorizationRule();
                        result.setAuthorizationRule(sharedAccessAuthorizationRuleInstance);

                        Element claimTypeElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "ClaimType");
                        if (claimTypeElement != null) {
                            String claimTypeInstance;
                            claimTypeInstance = claimTypeElement.getTextContent();
                            sharedAccessAuthorizationRuleInstance.setClaimType(claimTypeInstance);
                        }

                        Element claimValueElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "ClaimValue");
                        if (claimValueElement != null) {
                            String claimValueInstance;
                            claimValueInstance = claimValueElement.getTextContent();
                            sharedAccessAuthorizationRuleInstance.setClaimValue(claimValueInstance);
                        }

                        Element rightsSequenceElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "Rights");
                        if (rightsSequenceElement != null) {
                            for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(rightsSequenceElement,
                                            "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                            "AccessRights")
                                    .size(); i1 = i1 + 1) {
                                org.w3c.dom.Element rightsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(rightsSequenceElement,
                                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                                "AccessRights")
                                        .get(i1));
                                sharedAccessAuthorizationRuleInstance.getRights()
                                        .add(AccessRight.valueOf(rightsElement.getTextContent()));
                            }
                        }

                        Element createdTimeElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "CreatedTime");
                        if (createdTimeElement != null) {
                            Calendar createdTimeInstance;
                            createdTimeInstance = DatatypeConverter
                                    .parseDateTime(createdTimeElement.getTextContent());
                            sharedAccessAuthorizationRuleInstance.setCreatedTime(createdTimeInstance);
                        }

                        Element modifiedTimeElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "ModifiedTime");
                        if (modifiedTimeElement != null) {
                            Calendar modifiedTimeInstance;
                            modifiedTimeInstance = DatatypeConverter
                                    .parseDateTime(modifiedTimeElement.getTextContent());
                            sharedAccessAuthorizationRuleInstance.setModifiedTime(modifiedTimeInstance);
                        }

                        Element keyNameElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "KeyName");
                        if (keyNameElement != null) {
                            String keyNameInstance;
                            keyNameInstance = keyNameElement.getTextContent();
                            sharedAccessAuthorizationRuleInstance.setKeyName(keyNameInstance);
                        }

                        Element primaryKeyElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "PrimaryKey");
                        if (primaryKeyElement != null) {
                            String primaryKeyInstance;
                            primaryKeyInstance = primaryKeyElement.getTextContent();
                            sharedAccessAuthorizationRuleInstance.setPrimaryKey(primaryKeyInstance);
                        }

                        Element secondaryKeyElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "SecondaryKey");
                        if (secondaryKeyElement != null) {
                            String secondaryKeyInstance;
                            secondaryKeyInstance = secondaryKeyElement.getTextContent();
                            sharedAccessAuthorizationRuleInstance.setSecondaryKey(secondaryKeyInstance);
                        }

                        Element revisionElement = XmlUtility.getElementByTagNameNS(
                                sharedAccessAuthorizationRuleElement,
                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                "Revision");
                        if (revisionElement != null) {
                            int revisionInstance;
                            revisionInstance = DatatypeConverter.parseInt(revisionElement.getTextContent());
                            sharedAccessAuthorizationRuleInstance.setRevision(revisionInstance);
                        }
                    }
                }
            }

        }
        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.azure.management.storage.StorageAccountOperationsImpl.java

/**
* Lists all the storage accounts available under the given resource group.
* Note that storage keys are not returned; use the ListKeys operation for
* this.//from   ww  w  .ja  v  a 2s.  com
*
* @param resourceGroupName Required. The name of the resource group within
* the user's subscription.
* @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 list storage accounts operation response.
*/
@Override
public StorageAccountListResponse listByResourceGroup(String resourceGroupName)
        throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }

    // 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("resourceGroupName", resourceGroupName);
        CloudTracing.enter(invocationId, this, "listByResourceGroupAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/subscriptions/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/resourceGroups/";
    url = url + URLEncoder.encode(resourceGroupName, "UTF-8");
    url = url + "/providers/Microsoft.Storage/storageAccounts";
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-06-15");
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

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

    // Set Headers
    httpRequest.setHeader("x-ms-client-request-id", UUID.randomUUID().toString());

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

        // Create Result
        StorageAccountListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new StorageAccountListResponse();
            ObjectMapper objectMapper = new ObjectMapper();
            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 valueArray = responseDoc.get("value");
                if (valueArray != null && valueArray instanceof NullNode == false) {
                    for (JsonNode valueValue : ((ArrayNode) valueArray)) {
                        StorageAccount storageAccountJsonInstance = new StorageAccount();
                        result.getStorageAccounts().add(storageAccountJsonInstance);

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

                        JsonNode nameValue = valueValue.get("name");
                        if (nameValue != null && nameValue instanceof NullNode == false) {
                            String nameInstance;
                            nameInstance = nameValue.getTextValue();
                            storageAccountJsonInstance.setName(nameInstance);
                        }

                        JsonNode typeValue = valueValue.get("type");
                        if (typeValue != null && typeValue instanceof NullNode == false) {
                            String typeInstance;
                            typeInstance = typeValue.getTextValue();
                            storageAccountJsonInstance.setType(typeInstance);
                        }

                        JsonNode locationValue = valueValue.get("location");
                        if (locationValue != null && locationValue instanceof NullNode == false) {
                            String locationInstance;
                            locationInstance = locationValue.getTextValue();
                            storageAccountJsonInstance.setLocation(locationInstance);
                        }

                        JsonNode tagsSequenceElement = ((JsonNode) valueValue.get("tags"));
                        if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) {
                            Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields();
                            while (itr.hasNext()) {
                                Map.Entry<String, JsonNode> property = itr.next();
                                String tagsKey = property.getKey();
                                String tagsValue = property.getValue().getTextValue();
                                storageAccountJsonInstance.getTags().put(tagsKey, tagsValue);
                            }
                        }

                        JsonNode propertiesValue = valueValue.get("properties");
                        if (propertiesValue != null && propertiesValue instanceof NullNode == false) {
                            JsonNode provisioningStateValue = propertiesValue.get("provisioningState");
                            if (provisioningStateValue != null
                                    && provisioningStateValue instanceof NullNode == false) {
                                ProvisioningState provisioningStateInstance;
                                provisioningStateInstance = EnumUtility.fromString(ProvisioningState.class,
                                        provisioningStateValue.getTextValue());
                                storageAccountJsonInstance.setProvisioningState(provisioningStateInstance);
                            }

                            JsonNode accountTypeValue = propertiesValue.get("accountType");
                            if (accountTypeValue != null && accountTypeValue instanceof NullNode == false) {
                                AccountType accountTypeInstance;
                                accountTypeInstance = StorageManagementClientImpl
                                        .parseAccountType(accountTypeValue.getTextValue());
                                storageAccountJsonInstance.setAccountType(accountTypeInstance);
                            }

                            JsonNode primaryEndpointsValue = propertiesValue.get("primaryEndpoints");
                            if (primaryEndpointsValue != null
                                    && primaryEndpointsValue instanceof NullNode == false) {
                                Endpoints primaryEndpointsInstance = new Endpoints();
                                storageAccountJsonInstance.setPrimaryEndpoints(primaryEndpointsInstance);

                                JsonNode blobValue = primaryEndpointsValue.get("blob");
                                if (blobValue != null && blobValue instanceof NullNode == false) {
                                    URI blobInstance;
                                    blobInstance = new URI(blobValue.getTextValue());
                                    primaryEndpointsInstance.setBlob(blobInstance);
                                }

                                JsonNode queueValue = primaryEndpointsValue.get("queue");
                                if (queueValue != null && queueValue instanceof NullNode == false) {
                                    URI queueInstance;
                                    queueInstance = new URI(queueValue.getTextValue());
                                    primaryEndpointsInstance.setQueue(queueInstance);
                                }

                                JsonNode tableValue = primaryEndpointsValue.get("table");
                                if (tableValue != null && tableValue instanceof NullNode == false) {
                                    URI tableInstance;
                                    tableInstance = new URI(tableValue.getTextValue());
                                    primaryEndpointsInstance.setTable(tableInstance);
                                }

                                JsonNode fileValue = primaryEndpointsValue.get("file");
                                if (fileValue != null && fileValue instanceof NullNode == false) {
                                    URI fileInstance;
                                    fileInstance = new URI(fileValue.getTextValue());
                                    primaryEndpointsInstance.setFile(fileInstance);
                                }
                            }

                            JsonNode primaryLocationValue = propertiesValue.get("primaryLocation");
                            if (primaryLocationValue != null
                                    && primaryLocationValue instanceof NullNode == false) {
                                String primaryLocationInstance;
                                primaryLocationInstance = primaryLocationValue.getTextValue();
                                storageAccountJsonInstance.setPrimaryLocation(primaryLocationInstance);
                            }

                            JsonNode statusOfPrimaryValue = propertiesValue.get("statusOfPrimary");
                            if (statusOfPrimaryValue != null
                                    && statusOfPrimaryValue instanceof NullNode == false) {
                                AccountStatus statusOfPrimaryInstance;
                                statusOfPrimaryInstance = EnumUtility.fromString(AccountStatus.class,
                                        statusOfPrimaryValue.getTextValue());
                                storageAccountJsonInstance.setStatusOfPrimary(statusOfPrimaryInstance);
                            }

                            JsonNode lastGeoFailoverTimeValue = propertiesValue.get("lastGeoFailoverTime");
                            if (lastGeoFailoverTimeValue != null
                                    && lastGeoFailoverTimeValue instanceof NullNode == false) {
                                Calendar lastGeoFailoverTimeInstance;
                                lastGeoFailoverTimeInstance = DatatypeConverter
                                        .parseDateTime(lastGeoFailoverTimeValue.getTextValue());
                                storageAccountJsonInstance.setLastGeoFailoverTime(lastGeoFailoverTimeInstance);
                            }

                            JsonNode secondaryLocationValue = propertiesValue.get("secondaryLocation");
                            if (secondaryLocationValue != null
                                    && secondaryLocationValue instanceof NullNode == false) {
                                String secondaryLocationInstance;
                                secondaryLocationInstance = secondaryLocationValue.getTextValue();
                                storageAccountJsonInstance.setSecondaryLocation(secondaryLocationInstance);
                            }

                            JsonNode statusOfSecondaryValue = propertiesValue.get("statusOfSecondary");
                            if (statusOfSecondaryValue != null
                                    && statusOfSecondaryValue instanceof NullNode == false) {
                                AccountStatus statusOfSecondaryInstance;
                                statusOfSecondaryInstance = EnumUtility.fromString(AccountStatus.class,
                                        statusOfSecondaryValue.getTextValue());
                                storageAccountJsonInstance.setStatusOfSecondary(statusOfSecondaryInstance);
                            }

                            JsonNode creationTimeValue = propertiesValue.get("creationTime");
                            if (creationTimeValue != null && creationTimeValue instanceof NullNode == false) {
                                Calendar creationTimeInstance;
                                creationTimeInstance = DatatypeConverter
                                        .parseDateTime(creationTimeValue.getTextValue());
                                storageAccountJsonInstance.setCreationTime(creationTimeInstance);
                            }

                            JsonNode customDomainValue = propertiesValue.get("customDomain");
                            if (customDomainValue != null && customDomainValue instanceof NullNode == false) {
                                CustomDomain customDomainInstance = new CustomDomain();
                                storageAccountJsonInstance.setCustomDomain(customDomainInstance);

                                JsonNode nameValue2 = customDomainValue.get("name");
                                if (nameValue2 != null && nameValue2 instanceof NullNode == false) {
                                    String nameInstance2;
                                    nameInstance2 = nameValue2.getTextValue();
                                    customDomainInstance.setName(nameInstance2);
                                }

                                JsonNode useSubDomainValue = customDomainValue.get("useSubDomain");
                                if (useSubDomainValue != null
                                        && useSubDomainValue instanceof NullNode == false) {
                                    boolean useSubDomainInstance;
                                    useSubDomainInstance = useSubDomainValue.getBooleanValue();
                                    customDomainInstance.setUseSubDomain(useSubDomainInstance);
                                }
                            }

                            JsonNode secondaryEndpointsValue = propertiesValue.get("secondaryEndpoints");
                            if (secondaryEndpointsValue != null
                                    && secondaryEndpointsValue instanceof NullNode == false) {
                                Endpoints secondaryEndpointsInstance = new Endpoints();
                                storageAccountJsonInstance.setSecondaryEndpoints(secondaryEndpointsInstance);

                                JsonNode blobValue2 = secondaryEndpointsValue.get("blob");
                                if (blobValue2 != null && blobValue2 instanceof NullNode == false) {
                                    URI blobInstance2;
                                    blobInstance2 = new URI(blobValue2.getTextValue());
                                    secondaryEndpointsInstance.setBlob(blobInstance2);
                                }

                                JsonNode queueValue2 = secondaryEndpointsValue.get("queue");
                                if (queueValue2 != null && queueValue2 instanceof NullNode == false) {
                                    URI queueInstance2;
                                    queueInstance2 = new URI(queueValue2.getTextValue());
                                    secondaryEndpointsInstance.setQueue(queueInstance2);
                                }

                                JsonNode tableValue2 = secondaryEndpointsValue.get("table");
                                if (tableValue2 != null && tableValue2 instanceof NullNode == false) {
                                    URI tableInstance2;
                                    tableInstance2 = new URI(tableValue2.getTextValue());
                                    secondaryEndpointsInstance.setTable(tableInstance2);
                                }

                                JsonNode fileValue2 = secondaryEndpointsValue.get("file");
                                if (fileValue2 != null && fileValue2 instanceof NullNode == false) {
                                    URI fileInstance2;
                                    fileInstance2 = new URI(fileValue2.getTextValue());
                                    secondaryEndpointsInstance.setFile(fileInstance2);
                                }
                            }
                        }
                    }
                }
            }

        }
        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.azure.management.sql.DatabaseActivationOperationsImpl.java

/**
* Start an Azure SQL Data Warehouse database resume operation. To determine
* the status of the operation call GetDatabaseActivationOperationStatus.
*
* @param resourceGroupName Required. The name of the Resource Group to
* which the Azure SQL Server belongs./*from  w w w. j  a v a  2  s.c o  m*/
* @param serverName Required. The name of the Azure SQL Server on which the
* data warehouse database is hosted.
* @param databaseName Required. The name of the Azure SQL Data Warehouse
* database to resume.
* @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 Response for long running Azure Sql Database operations.
*/
@Override
public DatabaseCreateOrUpdateResponse beginResume(String resourceGroupName, String serverName,
        String databaseName) throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (serverName == null) {
        throw new NullPointerException("serverName");
    }
    if (databaseName == null) {
        throw new NullPointerException("databaseName");
    }

    // 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("resourceGroupName", resourceGroupName);
        tracingParameters.put("serverName", serverName);
        tracingParameters.put("databaseName", databaseName);
        CloudTracing.enter(invocationId, this, "beginResumeAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/subscriptions/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/resourceGroups/";
    url = url + URLEncoder.encode(resourceGroupName, "UTF-8");
    url = url + "/providers/";
    url = url + "Microsoft.Sql";
    url = url + "/servers/";
    url = url + URLEncoder.encode(serverName, "UTF-8");
    url = url + "/databases/";
    url = url + URLEncoder.encode(databaseName, "UTF-8");
    url = url + "/resume";
    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
    HttpPost httpRequest = new HttpPost(url);

    // Set Headers
    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 && statusCode != HttpStatus.SC_ACCEPTED) {
            ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        DatabaseCreateOrUpdateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new DatabaseCreateOrUpdateResponse();
            ObjectMapper objectMapper = new ObjectMapper();
            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) {
                ErrorResponse errorInstance = new ErrorResponse();
                result.setError(errorInstance);

                JsonNode codeValue = responseDoc.get("code");
                if (codeValue != null && codeValue instanceof NullNode == false) {
                    String codeInstance;
                    codeInstance = codeValue.getTextValue();
                    errorInstance.setCode(codeInstance);
                }

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

                JsonNode targetValue = responseDoc.get("target");
                if (targetValue != null && targetValue instanceof NullNode == false) {
                    String targetInstance;
                    targetInstance = targetValue.getTextValue();
                    errorInstance.setTarget(targetInstance);
                }

                Database databaseInstance = new Database();
                result.setDatabase(databaseInstance);

                JsonNode propertiesValue = responseDoc.get("properties");
                if (propertiesValue != null && propertiesValue instanceof NullNode == false) {
                    DatabaseProperties propertiesInstance = new DatabaseProperties();
                    databaseInstance.setProperties(propertiesInstance);

                    JsonNode collationValue = propertiesValue.get("collation");
                    if (collationValue != null && collationValue instanceof NullNode == false) {
                        String collationInstance;
                        collationInstance = collationValue.getTextValue();
                        propertiesInstance.setCollation(collationInstance);
                    }

                    JsonNode creationDateValue = propertiesValue.get("creationDate");
                    if (creationDateValue != null && creationDateValue instanceof NullNode == false) {
                        Calendar creationDateInstance;
                        creationDateInstance = DatatypeConverter
                                .parseDateTime(creationDateValue.getTextValue());
                        propertiesInstance.setCreationDate(creationDateInstance);
                    }

                    JsonNode currentServiceObjectiveIdValue = propertiesValue.get("currentServiceObjectiveId");
                    if (currentServiceObjectiveIdValue != null
                            && currentServiceObjectiveIdValue instanceof NullNode == false) {
                        String currentServiceObjectiveIdInstance;
                        currentServiceObjectiveIdInstance = currentServiceObjectiveIdValue.getTextValue();
                        propertiesInstance.setCurrentServiceObjectiveId(currentServiceObjectiveIdInstance);
                    }

                    JsonNode databaseIdValue = propertiesValue.get("databaseId");
                    if (databaseIdValue != null && databaseIdValue instanceof NullNode == false) {
                        String databaseIdInstance;
                        databaseIdInstance = databaseIdValue.getTextValue();
                        propertiesInstance.setDatabaseId(databaseIdInstance);
                    }

                    JsonNode earliestRestoreDateValue = propertiesValue.get("earliestRestoreDate");
                    if (earliestRestoreDateValue != null
                            && earliestRestoreDateValue instanceof NullNode == false) {
                        Calendar earliestRestoreDateInstance;
                        earliestRestoreDateInstance = DatatypeConverter
                                .parseDateTime(earliestRestoreDateValue.getTextValue());
                        propertiesInstance.setEarliestRestoreDate(earliestRestoreDateInstance);
                    }

                    JsonNode editionValue = propertiesValue.get("edition");
                    if (editionValue != null && editionValue instanceof NullNode == false) {
                        String editionInstance;
                        editionInstance = editionValue.getTextValue();
                        propertiesInstance.setEdition(editionInstance);
                    }

                    JsonNode maxSizeBytesValue = propertiesValue.get("maxSizeBytes");
                    if (maxSizeBytesValue != null && maxSizeBytesValue instanceof NullNode == false) {
                        long maxSizeBytesInstance;
                        maxSizeBytesInstance = maxSizeBytesValue.getLongValue();
                        propertiesInstance.setMaxSizeBytes(maxSizeBytesInstance);
                    }

                    JsonNode requestedServiceObjectiveIdValue = propertiesValue
                            .get("requestedServiceObjectiveId");
                    if (requestedServiceObjectiveIdValue != null
                            && requestedServiceObjectiveIdValue instanceof NullNode == false) {
                        String requestedServiceObjectiveIdInstance;
                        requestedServiceObjectiveIdInstance = requestedServiceObjectiveIdValue.getTextValue();
                        propertiesInstance.setRequestedServiceObjectiveId(requestedServiceObjectiveIdInstance);
                    }

                    JsonNode requestedServiceObjectiveNameValue = propertiesValue
                            .get("requestedServiceObjectiveName");
                    if (requestedServiceObjectiveNameValue != null
                            && requestedServiceObjectiveNameValue instanceof NullNode == false) {
                        String requestedServiceObjectiveNameInstance;
                        requestedServiceObjectiveNameInstance = requestedServiceObjectiveNameValue
                                .getTextValue();
                        propertiesInstance
                                .setRequestedServiceObjectiveName(requestedServiceObjectiveNameInstance);
                    }

                    JsonNode serviceLevelObjectiveValue = propertiesValue.get("serviceLevelObjective");
                    if (serviceLevelObjectiveValue != null
                            && serviceLevelObjectiveValue instanceof NullNode == false) {
                        String serviceLevelObjectiveInstance;
                        serviceLevelObjectiveInstance = serviceLevelObjectiveValue.getTextValue();
                        propertiesInstance.setServiceObjective(serviceLevelObjectiveInstance);
                    }

                    JsonNode statusValue = propertiesValue.get("status");
                    if (statusValue != null && statusValue instanceof NullNode == false) {
                        String statusInstance;
                        statusInstance = statusValue.getTextValue();
                        propertiesInstance.setStatus(statusInstance);
                    }

                    JsonNode elasticPoolNameValue = propertiesValue.get("elasticPoolName");
                    if (elasticPoolNameValue != null && elasticPoolNameValue instanceof NullNode == false) {
                        String elasticPoolNameInstance;
                        elasticPoolNameInstance = elasticPoolNameValue.getTextValue();
                        propertiesInstance.setElasticPoolName(elasticPoolNameInstance);
                    }

                    JsonNode serviceTierAdvisorsArray = propertiesValue.get("serviceTierAdvisors");
                    if (serviceTierAdvisorsArray != null
                            && serviceTierAdvisorsArray instanceof NullNode == false) {
                        for (JsonNode serviceTierAdvisorsValue : ((ArrayNode) serviceTierAdvisorsArray)) {
                            ServiceTierAdvisor serviceTierAdvisorInstance = new ServiceTierAdvisor();
                            propertiesInstance.getServiceTierAdvisors().add(serviceTierAdvisorInstance);

                            JsonNode propertiesValue2 = serviceTierAdvisorsValue.get("properties");
                            if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) {
                                ServiceTierAdvisorProperties propertiesInstance2 = new ServiceTierAdvisorProperties();
                                serviceTierAdvisorInstance.setProperties(propertiesInstance2);

                                JsonNode observationPeriodStartValue = propertiesValue2
                                        .get("observationPeriodStart");
                                if (observationPeriodStartValue != null
                                        && observationPeriodStartValue instanceof NullNode == false) {
                                    Calendar observationPeriodStartInstance;
                                    observationPeriodStartInstance = DatatypeConverter
                                            .parseDateTime(observationPeriodStartValue.getTextValue());
                                    propertiesInstance2
                                            .setObservationPeriodStart(observationPeriodStartInstance);
                                }

                                JsonNode observationPeriodEndValue = propertiesValue2
                                        .get("observationPeriodEnd");
                                if (observationPeriodEndValue != null
                                        && observationPeriodEndValue instanceof NullNode == false) {
                                    Calendar observationPeriodEndInstance;
                                    observationPeriodEndInstance = DatatypeConverter
                                            .parseDateTime(observationPeriodEndValue.getTextValue());
                                    propertiesInstance2.setObservationPeriodEnd(observationPeriodEndInstance);
                                }

                                JsonNode activeTimeRatioValue = propertiesValue2.get("activeTimeRatio");
                                if (activeTimeRatioValue != null
                                        && activeTimeRatioValue instanceof NullNode == false) {
                                    double activeTimeRatioInstance;
                                    activeTimeRatioInstance = activeTimeRatioValue.getDoubleValue();
                                    propertiesInstance2.setActiveTimeRatio(activeTimeRatioInstance);
                                }

                                JsonNode minDtuValue = propertiesValue2.get("minDtu");
                                if (minDtuValue != null && minDtuValue instanceof NullNode == false) {
                                    double minDtuInstance;
                                    minDtuInstance = minDtuValue.getDoubleValue();
                                    propertiesInstance2.setMinDtu(minDtuInstance);
                                }

                                JsonNode avgDtuValue = propertiesValue2.get("avgDtu");
                                if (avgDtuValue != null && avgDtuValue instanceof NullNode == false) {
                                    double avgDtuInstance;
                                    avgDtuInstance = avgDtuValue.getDoubleValue();
                                    propertiesInstance2.setAvgDtu(avgDtuInstance);
                                }

                                JsonNode maxDtuValue = propertiesValue2.get("maxDtu");
                                if (maxDtuValue != null && maxDtuValue instanceof NullNode == false) {
                                    double maxDtuInstance;
                                    maxDtuInstance = maxDtuValue.getDoubleValue();
                                    propertiesInstance2.setMaxDtu(maxDtuInstance);
                                }

                                JsonNode maxSizeInGBValue = propertiesValue2.get("maxSizeInGB");
                                if (maxSizeInGBValue != null && maxSizeInGBValue instanceof NullNode == false) {
                                    double maxSizeInGBInstance;
                                    maxSizeInGBInstance = maxSizeInGBValue.getDoubleValue();
                                    propertiesInstance2.setMaxSizeInGB(maxSizeInGBInstance);
                                }

                                JsonNode serviceLevelObjectiveUsageMetricsArray = propertiesValue2
                                        .get("serviceLevelObjectiveUsageMetrics");
                                if (serviceLevelObjectiveUsageMetricsArray != null
                                        && serviceLevelObjectiveUsageMetricsArray instanceof NullNode == false) {
                                    for (JsonNode serviceLevelObjectiveUsageMetricsValue : ((ArrayNode) serviceLevelObjectiveUsageMetricsArray)) {
                                        SloUsageMetric sloUsageMetricInstance = new SloUsageMetric();
                                        propertiesInstance2.getServiceLevelObjectiveUsageMetrics()
                                                .add(sloUsageMetricInstance);

                                        JsonNode serviceLevelObjectiveValue2 = serviceLevelObjectiveUsageMetricsValue
                                                .get("serviceLevelObjective");
                                        if (serviceLevelObjectiveValue2 != null
                                                && serviceLevelObjectiveValue2 instanceof NullNode == false) {
                                            String serviceLevelObjectiveInstance2;
                                            serviceLevelObjectiveInstance2 = serviceLevelObjectiveValue2
                                                    .getTextValue();
                                            sloUsageMetricInstance
                                                    .setServiceLevelObjective(serviceLevelObjectiveInstance2);
                                        }

                                        JsonNode serviceLevelObjectiveIdValue = serviceLevelObjectiveUsageMetricsValue
                                                .get("serviceLevelObjectiveId");
                                        if (serviceLevelObjectiveIdValue != null
                                                && serviceLevelObjectiveIdValue instanceof NullNode == false) {
                                            String serviceLevelObjectiveIdInstance;
                                            serviceLevelObjectiveIdInstance = serviceLevelObjectiveIdValue
                                                    .getTextValue();
                                            sloUsageMetricInstance.setServiceLevelObjectiveId(
                                                    serviceLevelObjectiveIdInstance);
                                        }

                                        JsonNode inRangeTimeRatioValue = serviceLevelObjectiveUsageMetricsValue
                                                .get("inRangeTimeRatio");
                                        if (inRangeTimeRatioValue != null
                                                && inRangeTimeRatioValue instanceof NullNode == false) {
                                            double inRangeTimeRatioInstance;
                                            inRangeTimeRatioInstance = inRangeTimeRatioValue.getDoubleValue();
                                            sloUsageMetricInstance
                                                    .setInRangeTimeRatio(inRangeTimeRatioInstance);
                                        }

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

                                        JsonNode nameValue = serviceLevelObjectiveUsageMetricsValue.get("name");
                                        if (nameValue != null && nameValue instanceof NullNode == false) {
                                            String nameInstance;
                                            nameInstance = nameValue.getTextValue();
                                            sloUsageMetricInstance.setName(nameInstance);
                                        }

                                        JsonNode typeValue = serviceLevelObjectiveUsageMetricsValue.get("type");
                                        if (typeValue != null && typeValue instanceof NullNode == false) {
                                            String typeInstance;
                                            typeInstance = typeValue.getTextValue();
                                            sloUsageMetricInstance.setType(typeInstance);
                                        }

                                        JsonNode locationValue = serviceLevelObjectiveUsageMetricsValue
                                                .get("location");
                                        if (locationValue != null
                                                && locationValue instanceof NullNode == false) {
                                            String locationInstance;
                                            locationInstance = locationValue.getTextValue();
                                            sloUsageMetricInstance.setLocation(locationInstance);
                                        }

                                        JsonNode tagsSequenceElement = ((JsonNode) serviceLevelObjectiveUsageMetricsValue
                                                .get("tags"));
                                        if (tagsSequenceElement != null
                                                && tagsSequenceElement instanceof NullNode == false) {
                                            Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement
                                                    .getFields();
                                            while (itr.hasNext()) {
                                                Map.Entry<String, JsonNode> property = itr.next();
                                                String tagsKey = property.getKey();
                                                String tagsValue = property.getValue().getTextValue();
                                                sloUsageMetricInstance.getTags().put(tagsKey, tagsValue);
                                            }
                                        }
                                    }
                                }

                                JsonNode currentServiceLevelObjectiveValue = propertiesValue2
                                        .get("currentServiceLevelObjective");
                                if (currentServiceLevelObjectiveValue != null
                                        && currentServiceLevelObjectiveValue instanceof NullNode == false) {
                                    String currentServiceLevelObjectiveInstance;
                                    currentServiceLevelObjectiveInstance = currentServiceLevelObjectiveValue
                                            .getTextValue();
                                    propertiesInstance2.setCurrentServiceLevelObjective(
                                            currentServiceLevelObjectiveInstance);
                                }

                                JsonNode currentServiceLevelObjectiveIdValue = propertiesValue2
                                        .get("currentServiceLevelObjectiveId");
                                if (currentServiceLevelObjectiveIdValue != null
                                        && currentServiceLevelObjectiveIdValue instanceof NullNode == false) {
                                    String currentServiceLevelObjectiveIdInstance;
                                    currentServiceLevelObjectiveIdInstance = currentServiceLevelObjectiveIdValue
                                            .getTextValue();
                                    propertiesInstance2.setCurrentServiceLevelObjectiveId(
                                            currentServiceLevelObjectiveIdInstance);
                                }

                                JsonNode usageBasedRecommendationServiceLevelObjectiveValue = propertiesValue2
                                        .get("usageBasedRecommendationServiceLevelObjective");
                                if (usageBasedRecommendationServiceLevelObjectiveValue != null
                                        && usageBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) {
                                    String usageBasedRecommendationServiceLevelObjectiveInstance;
                                    usageBasedRecommendationServiceLevelObjectiveInstance = usageBasedRecommendationServiceLevelObjectiveValue
                                            .getTextValue();
                                    propertiesInstance2.setUsageBasedRecommendationServiceLevelObjective(
                                            usageBasedRecommendationServiceLevelObjectiveInstance);
                                }

                                JsonNode usageBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue2
                                        .get("usageBasedRecommendationServiceLevelObjectiveId");
                                if (usageBasedRecommendationServiceLevelObjectiveIdValue != null
                                        && usageBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) {
                                    String usageBasedRecommendationServiceLevelObjectiveIdInstance;
                                    usageBasedRecommendationServiceLevelObjectiveIdInstance = usageBasedRecommendationServiceLevelObjectiveIdValue
                                            .getTextValue();
                                    propertiesInstance2.setUsageBasedRecommendationServiceLevelObjectiveId(
                                            usageBasedRecommendationServiceLevelObjectiveIdInstance);
                                }

                                JsonNode databaseSizeBasedRecommendationServiceLevelObjectiveValue = propertiesValue2
                                        .get("databaseSizeBasedRecommendationServiceLevelObjective");
                                if (databaseSizeBasedRecommendationServiceLevelObjectiveValue != null
                                        && databaseSizeBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) {
                                    String databaseSizeBasedRecommendationServiceLevelObjectiveInstance;
                                    databaseSizeBasedRecommendationServiceLevelObjectiveInstance = databaseSizeBasedRecommendationServiceLevelObjectiveValue
                                            .getTextValue();
                                    propertiesInstance2.setDatabaseSizeBasedRecommendationServiceLevelObjective(
                                            databaseSizeBasedRecommendationServiceLevelObjectiveInstance);
                                }

                                JsonNode databaseSizeBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue2
                                        .get("databaseSizeBasedRecommendationServiceLevelObjectiveId");
                                if (databaseSizeBasedRecommendationServiceLevelObjectiveIdValue != null
                                        && databaseSizeBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) {
                                    String databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance;
                                    databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance = databaseSizeBasedRecommendationServiceLevelObjectiveIdValue
                                            .getTextValue();
                                    propertiesInstance2
                                            .setDatabaseSizeBasedRecommendationServiceLevelObjectiveId(
                                                    databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance);
                                }

                                JsonNode disasterPlanBasedRecommendationServiceLevelObjectiveValue = propertiesValue2
                                        .get("disasterPlanBasedRecommendationServiceLevelObjective");
                                if (disasterPlanBasedRecommendationServiceLevelObjectiveValue != null
                                        && disasterPlanBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) {
                                    String disasterPlanBasedRecommendationServiceLevelObjectiveInstance;
                                    disasterPlanBasedRecommendationServiceLevelObjectiveInstance = disasterPlanBasedRecommendationServiceLevelObjectiveValue
                                            .getTextValue();
                                    propertiesInstance2.setDisasterPlanBasedRecommendationServiceLevelObjective(
                                            disasterPlanBasedRecommendationServiceLevelObjectiveInstance);
                                }

                                JsonNode disasterPlanBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue2
                                        .get("disasterPlanBasedRecommendationServiceLevelObjectiveId");
                                if (disasterPlanBasedRecommendationServiceLevelObjectiveIdValue != null
                                        && disasterPlanBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) {
                                    String disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance;
                                    disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance = disasterPlanBasedRecommendationServiceLevelObjectiveIdValue
                                            .getTextValue();
                                    propertiesInstance2
                                            .setDisasterPlanBasedRecommendationServiceLevelObjectiveId(
                                                    disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance);
                                }

                                JsonNode overallRecommendationServiceLevelObjectiveValue = propertiesValue2
                                        .get("overallRecommendationServiceLevelObjective");
                                if (overallRecommendationServiceLevelObjectiveValue != null
                                        && overallRecommendationServiceLevelObjectiveValue instanceof NullNode == false) {
                                    String overallRecommendationServiceLevelObjectiveInstance;
                                    overallRecommendationServiceLevelObjectiveInstance = overallRecommendationServiceLevelObjectiveValue
                                            .getTextValue();
                                    propertiesInstance2.setOverallRecommendationServiceLevelObjective(
                                            overallRecommendationServiceLevelObjectiveInstance);
                                }

                                JsonNode overallRecommendationServiceLevelObjectiveIdValue = propertiesValue2
                                        .get("overallRecommendationServiceLevelObjectiveId");
                                if (overallRecommendationServiceLevelObjectiveIdValue != null
                                        && overallRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) {
                                    String overallRecommendationServiceLevelObjectiveIdInstance;
                                    overallRecommendationServiceLevelObjectiveIdInstance = overallRecommendationServiceLevelObjectiveIdValue
                                            .getTextValue();
                                    propertiesInstance2.setOverallRecommendationServiceLevelObjectiveId(
                                            overallRecommendationServiceLevelObjectiveIdInstance);
                                }

                                JsonNode confidenceValue = propertiesValue2.get("confidence");
                                if (confidenceValue != null && confidenceValue instanceof NullNode == false) {
                                    double confidenceInstance;
                                    confidenceInstance = confidenceValue.getDoubleValue();
                                    propertiesInstance2.setConfidence(confidenceInstance);
                                }
                            }

                            JsonNode idValue2 = serviceTierAdvisorsValue.get("id");
                            if (idValue2 != null && idValue2 instanceof NullNode == false) {
                                String idInstance2;
                                idInstance2 = idValue2.getTextValue();
                                serviceTierAdvisorInstance.setId(idInstance2);
                            }

                            JsonNode nameValue2 = serviceTierAdvisorsValue.get("name");
                            if (nameValue2 != null && nameValue2 instanceof NullNode == false) {
                                String nameInstance2;
                                nameInstance2 = nameValue2.getTextValue();
                                serviceTierAdvisorInstance.setName(nameInstance2);
                            }

                            JsonNode typeValue2 = serviceTierAdvisorsValue.get("type");
                            if (typeValue2 != null && typeValue2 instanceof NullNode == false) {
                                String typeInstance2;
                                typeInstance2 = typeValue2.getTextValue();
                                serviceTierAdvisorInstance.setType(typeInstance2);
                            }

                            JsonNode locationValue2 = serviceTierAdvisorsValue.get("location");
                            if (locationValue2 != null && locationValue2 instanceof NullNode == false) {
                                String locationInstance2;
                                locationInstance2 = locationValue2.getTextValue();
                                serviceTierAdvisorInstance.setLocation(locationInstance2);
                            }

                            JsonNode tagsSequenceElement2 = ((JsonNode) serviceTierAdvisorsValue.get("tags"));
                            if (tagsSequenceElement2 != null
                                    && tagsSequenceElement2 instanceof NullNode == false) {
                                Iterator<Map.Entry<String, JsonNode>> itr2 = tagsSequenceElement2.getFields();
                                while (itr2.hasNext()) {
                                    Map.Entry<String, JsonNode> property2 = itr2.next();
                                    String tagsKey2 = property2.getKey();
                                    String tagsValue2 = property2.getValue().getTextValue();
                                    serviceTierAdvisorInstance.getTags().put(tagsKey2, tagsValue2);
                                }
                            }
                        }
                    }

                    JsonNode upgradeHintValue = propertiesValue.get("upgradeHint");
                    if (upgradeHintValue != null && upgradeHintValue instanceof NullNode == false) {
                        UpgradeHint upgradeHintInstance = new UpgradeHint();
                        propertiesInstance.setUpgradeHint(upgradeHintInstance);

                        JsonNode targetServiceLevelObjectiveValue = upgradeHintValue
                                .get("targetServiceLevelObjective");
                        if (targetServiceLevelObjectiveValue != null
                                && targetServiceLevelObjectiveValue instanceof NullNode == false) {
                            String targetServiceLevelObjectiveInstance;
                            targetServiceLevelObjectiveInstance = targetServiceLevelObjectiveValue
                                    .getTextValue();
                            upgradeHintInstance
                                    .setTargetServiceLevelObjective(targetServiceLevelObjectiveInstance);
                        }

                        JsonNode targetServiceLevelObjectiveIdValue = upgradeHintValue
                                .get("targetServiceLevelObjectiveId");
                        if (targetServiceLevelObjectiveIdValue != null
                                && targetServiceLevelObjectiveIdValue instanceof NullNode == false) {
                            String targetServiceLevelObjectiveIdInstance;
                            targetServiceLevelObjectiveIdInstance = targetServiceLevelObjectiveIdValue
                                    .getTextValue();
                            upgradeHintInstance
                                    .setTargetServiceLevelObjectiveId(targetServiceLevelObjectiveIdInstance);
                        }

                        JsonNode idValue3 = upgradeHintValue.get("id");
                        if (idValue3 != null && idValue3 instanceof NullNode == false) {
                            String idInstance3;
                            idInstance3 = idValue3.getTextValue();
                            upgradeHintInstance.setId(idInstance3);
                        }

                        JsonNode nameValue3 = upgradeHintValue.get("name");
                        if (nameValue3 != null && nameValue3 instanceof NullNode == false) {
                            String nameInstance3;
                            nameInstance3 = nameValue3.getTextValue();
                            upgradeHintInstance.setName(nameInstance3);
                        }

                        JsonNode typeValue3 = upgradeHintValue.get("type");
                        if (typeValue3 != null && typeValue3 instanceof NullNode == false) {
                            String typeInstance3;
                            typeInstance3 = typeValue3.getTextValue();
                            upgradeHintInstance.setType(typeInstance3);
                        }

                        JsonNode locationValue3 = upgradeHintValue.get("location");
                        if (locationValue3 != null && locationValue3 instanceof NullNode == false) {
                            String locationInstance3;
                            locationInstance3 = locationValue3.getTextValue();
                            upgradeHintInstance.setLocation(locationInstance3);
                        }

                        JsonNode tagsSequenceElement3 = ((JsonNode) upgradeHintValue.get("tags"));
                        if (tagsSequenceElement3 != null && tagsSequenceElement3 instanceof NullNode == false) {
                            Iterator<Map.Entry<String, JsonNode>> itr3 = tagsSequenceElement3.getFields();
                            while (itr3.hasNext()) {
                                Map.Entry<String, JsonNode> property3 = itr3.next();
                                String tagsKey3 = property3.getKey();
                                String tagsValue3 = property3.getValue().getTextValue();
                                upgradeHintInstance.getTags().put(tagsKey3, tagsValue3);
                            }
                        }
                    }

                    JsonNode schemasArray = propertiesValue.get("schemas");
                    if (schemasArray != null && schemasArray instanceof NullNode == false) {
                        for (JsonNode schemasValue : ((ArrayNode) schemasArray)) {
                            Schema schemaInstance = new Schema();
                            propertiesInstance.getSchemas().add(schemaInstance);

                            JsonNode propertiesValue3 = schemasValue.get("properties");
                            if (propertiesValue3 != null && propertiesValue3 instanceof NullNode == false) {
                                SchemaProperties propertiesInstance3 = new SchemaProperties();
                                schemaInstance.setProperties(propertiesInstance3);

                                JsonNode tablesArray = propertiesValue3.get("tables");
                                if (tablesArray != null && tablesArray instanceof NullNode == false) {
                                    for (JsonNode tablesValue : ((ArrayNode) tablesArray)) {
                                        Table tableInstance = new Table();
                                        propertiesInstance3.getTables().add(tableInstance);

                                        JsonNode propertiesValue4 = tablesValue.get("properties");
                                        if (propertiesValue4 != null
                                                && propertiesValue4 instanceof NullNode == false) {
                                            TableProperties propertiesInstance4 = new TableProperties();
                                            tableInstance.setProperties(propertiesInstance4);

                                            JsonNode tableTypeValue = propertiesValue4.get("tableType");
                                            if (tableTypeValue != null
                                                    && tableTypeValue instanceof NullNode == false) {
                                                String tableTypeInstance;
                                                tableTypeInstance = tableTypeValue.getTextValue();
                                                propertiesInstance4.setTableType(tableTypeInstance);
                                            }

                                            JsonNode columnsArray = propertiesValue4.get("columns");
                                            if (columnsArray != null
                                                    && columnsArray instanceof NullNode == false) {
                                                for (JsonNode columnsValue : ((ArrayNode) columnsArray)) {
                                                    Column columnInstance = new Column();
                                                    propertiesInstance4.getColumns().add(columnInstance);

                                                    JsonNode propertiesValue5 = columnsValue.get("properties");
                                                    if (propertiesValue5 != null
                                                            && propertiesValue5 instanceof NullNode == false) {
                                                        ColumnProperties propertiesInstance5 = new ColumnProperties();
                                                        columnInstance.setProperties(propertiesInstance5);

                                                        JsonNode columnTypeValue = propertiesValue5
                                                                .get("columnType");
                                                        if (columnTypeValue != null
                                                                && columnTypeValue instanceof NullNode == false) {
                                                            String columnTypeInstance;
                                                            columnTypeInstance = columnTypeValue.getTextValue();
                                                            propertiesInstance5
                                                                    .setColumnType(columnTypeInstance);
                                                        }
                                                    }

                                                    JsonNode idValue4 = columnsValue.get("id");
                                                    if (idValue4 != null
                                                            && idValue4 instanceof NullNode == false) {
                                                        String idInstance4;
                                                        idInstance4 = idValue4.getTextValue();
                                                        columnInstance.setId(idInstance4);
                                                    }

                                                    JsonNode nameValue4 = columnsValue.get("name");
                                                    if (nameValue4 != null
                                                            && nameValue4 instanceof NullNode == false) {
                                                        String nameInstance4;
                                                        nameInstance4 = nameValue4.getTextValue();
                                                        columnInstance.setName(nameInstance4);
                                                    }

                                                    JsonNode typeValue4 = columnsValue.get("type");
                                                    if (typeValue4 != null
                                                            && typeValue4 instanceof NullNode == false) {
                                                        String typeInstance4;
                                                        typeInstance4 = typeValue4.getTextValue();
                                                        columnInstance.setType(typeInstance4);
                                                    }

                                                    JsonNode locationValue4 = columnsValue.get("location");
                                                    if (locationValue4 != null
                                                            && locationValue4 instanceof NullNode == false) {
                                                        String locationInstance4;
                                                        locationInstance4 = locationValue4.getTextValue();
                                                        columnInstance.setLocation(locationInstance4);
                                                    }

                                                    JsonNode tagsSequenceElement4 = ((JsonNode) columnsValue
                                                            .get("tags"));
                                                    if (tagsSequenceElement4 != null
                                                            && tagsSequenceElement4 instanceof NullNode == false) {
                                                        Iterator<Map.Entry<String, JsonNode>> itr4 = tagsSequenceElement4
                                                                .getFields();
                                                        while (itr4.hasNext()) {
                                                            Map.Entry<String, JsonNode> property4 = itr4.next();
                                                            String tagsKey4 = property4.getKey();
                                                            String tagsValue4 = property4.getValue()
                                                                    .getTextValue();
                                                            columnInstance.getTags().put(tagsKey4, tagsValue4);
                                                        }
                                                    }
                                                }
                                            }

                                            JsonNode recommendedIndexesArray = propertiesValue4
                                                    .get("recommendedIndexes");
                                            if (recommendedIndexesArray != null
                                                    && recommendedIndexesArray instanceof NullNode == false) {
                                                for (JsonNode recommendedIndexesValue : ((ArrayNode) recommendedIndexesArray)) {
                                                    RecommendedIndex recommendedIndexInstance = new RecommendedIndex();
                                                    propertiesInstance4.getRecommendedIndexes()
                                                            .add(recommendedIndexInstance);

                                                    JsonNode propertiesValue6 = recommendedIndexesValue
                                                            .get("properties");
                                                    if (propertiesValue6 != null
                                                            && propertiesValue6 instanceof NullNode == false) {
                                                        RecommendedIndexProperties propertiesInstance6 = new RecommendedIndexProperties();
                                                        recommendedIndexInstance
                                                                .setProperties(propertiesInstance6);

                                                        JsonNode actionValue = propertiesValue6.get("action");
                                                        if (actionValue != null
                                                                && actionValue instanceof NullNode == false) {
                                                            String actionInstance;
                                                            actionInstance = actionValue.getTextValue();
                                                            propertiesInstance6.setAction(actionInstance);
                                                        }

                                                        JsonNode stateValue = propertiesValue6.get("state");
                                                        if (stateValue != null
                                                                && stateValue instanceof NullNode == false) {
                                                            String stateInstance;
                                                            stateInstance = stateValue.getTextValue();
                                                            propertiesInstance6.setState(stateInstance);
                                                        }

                                                        JsonNode createdValue = propertiesValue6.get("created");
                                                        if (createdValue != null
                                                                && createdValue instanceof NullNode == false) {
                                                            Calendar createdInstance;
                                                            createdInstance = DatatypeConverter
                                                                    .parseDateTime(createdValue.getTextValue());
                                                            propertiesInstance6.setCreated(createdInstance);
                                                        }

                                                        JsonNode lastModifiedValue = propertiesValue6
                                                                .get("lastModified");
                                                        if (lastModifiedValue != null
                                                                && lastModifiedValue instanceof NullNode == false) {
                                                            Calendar lastModifiedInstance;
                                                            lastModifiedInstance = DatatypeConverter
                                                                    .parseDateTime(
                                                                            lastModifiedValue.getTextValue());
                                                            propertiesInstance6
                                                                    .setLastModified(lastModifiedInstance);
                                                        }

                                                        JsonNode indexTypeValue = propertiesValue6
                                                                .get("indexType");
                                                        if (indexTypeValue != null
                                                                && indexTypeValue instanceof NullNode == false) {
                                                            String indexTypeInstance;
                                                            indexTypeInstance = indexTypeValue.getTextValue();
                                                            propertiesInstance6.setIndexType(indexTypeInstance);
                                                        }

                                                        JsonNode schemaValue = propertiesValue6.get("schema");
                                                        if (schemaValue != null
                                                                && schemaValue instanceof NullNode == false) {
                                                            String schemaInstance2;
                                                            schemaInstance2 = schemaValue.getTextValue();
                                                            propertiesInstance6.setSchema(schemaInstance2);
                                                        }

                                                        JsonNode tableValue = propertiesValue6.get("table");
                                                        if (tableValue != null
                                                                && tableValue instanceof NullNode == false) {
                                                            String tableInstance2;
                                                            tableInstance2 = tableValue.getTextValue();
                                                            propertiesInstance6.setTable(tableInstance2);
                                                        }

                                                        JsonNode columnsArray2 = propertiesValue6
                                                                .get("columns");
                                                        if (columnsArray2 != null
                                                                && columnsArray2 instanceof NullNode == false) {
                                                            for (JsonNode columnsValue2 : ((ArrayNode) columnsArray2)) {
                                                                propertiesInstance6.getColumns()
                                                                        .add(columnsValue2.getTextValue());
                                                            }
                                                        }

                                                        JsonNode includedColumnsArray = propertiesValue6
                                                                .get("includedColumns");
                                                        if (includedColumnsArray != null
                                                                && includedColumnsArray instanceof NullNode == false) {
                                                            for (JsonNode includedColumnsValue : ((ArrayNode) includedColumnsArray)) {
                                                                propertiesInstance6.getIncludedColumns().add(
                                                                        includedColumnsValue.getTextValue());
                                                            }
                                                        }

                                                        JsonNode indexScriptValue = propertiesValue6
                                                                .get("indexScript");
                                                        if (indexScriptValue != null
                                                                && indexScriptValue instanceof NullNode == false) {
                                                            String indexScriptInstance;
                                                            indexScriptInstance = indexScriptValue
                                                                    .getTextValue();
                                                            propertiesInstance6
                                                                    .setIndexScript(indexScriptInstance);
                                                        }

                                                        JsonNode estimatedImpactArray = propertiesValue6
                                                                .get("estimatedImpact");
                                                        if (estimatedImpactArray != null
                                                                && estimatedImpactArray instanceof NullNode == false) {
                                                            for (JsonNode estimatedImpactValue : ((ArrayNode) estimatedImpactArray)) {
                                                                OperationImpact operationImpactInstance = new OperationImpact();
                                                                propertiesInstance6.getEstimatedImpact()
                                                                        .add(operationImpactInstance);

                                                                JsonNode nameValue5 = estimatedImpactValue
                                                                        .get("name");
                                                                if (nameValue5 != null
                                                                        && nameValue5 instanceof NullNode == false) {
                                                                    String nameInstance5;
                                                                    nameInstance5 = nameValue5.getTextValue();
                                                                    operationImpactInstance
                                                                            .setName(nameInstance5);
                                                                }

                                                                JsonNode unitValue = estimatedImpactValue
                                                                        .get("unit");
                                                                if (unitValue != null
                                                                        && unitValue instanceof NullNode == false) {
                                                                    String unitInstance;
                                                                    unitInstance = unitValue.getTextValue();
                                                                    operationImpactInstance
                                                                            .setUnit(unitInstance);
                                                                }

                                                                JsonNode changeValueAbsoluteValue = estimatedImpactValue
                                                                        .get("changeValueAbsolute");
                                                                if (changeValueAbsoluteValue != null
                                                                        && changeValueAbsoluteValue instanceof NullNode == false) {
                                                                    double changeValueAbsoluteInstance;
                                                                    changeValueAbsoluteInstance = changeValueAbsoluteValue
                                                                            .getDoubleValue();
                                                                    operationImpactInstance
                                                                            .setChangeValueAbsolute(
                                                                                    changeValueAbsoluteInstance);
                                                                }

                                                                JsonNode changeValueRelativeValue = estimatedImpactValue
                                                                        .get("changeValueRelative");
                                                                if (changeValueRelativeValue != null
                                                                        && changeValueRelativeValue instanceof NullNode == false) {
                                                                    double changeValueRelativeInstance;
                                                                    changeValueRelativeInstance = changeValueRelativeValue
                                                                            .getDoubleValue();
                                                                    operationImpactInstance
                                                                            .setChangeValueRelative(
                                                                                    changeValueRelativeInstance);
                                                                }
                                                            }
                                                        }

                                                        JsonNode reportedImpactArray = propertiesValue6
                                                                .get("reportedImpact");
                                                        if (reportedImpactArray != null
                                                                && reportedImpactArray instanceof NullNode == false) {
                                                            for (JsonNode reportedImpactValue : ((ArrayNode) reportedImpactArray)) {
                                                                OperationImpact operationImpactInstance2 = new OperationImpact();
                                                                propertiesInstance6.getReportedImpact()
                                                                        .add(operationImpactInstance2);

                                                                JsonNode nameValue6 = reportedImpactValue
                                                                        .get("name");
                                                                if (nameValue6 != null
                                                                        && nameValue6 instanceof NullNode == false) {
                                                                    String nameInstance6;
                                                                    nameInstance6 = nameValue6.getTextValue();
                                                                    operationImpactInstance2
                                                                            .setName(nameInstance6);
                                                                }

                                                                JsonNode unitValue2 = reportedImpactValue
                                                                        .get("unit");
                                                                if (unitValue2 != null
                                                                        && unitValue2 instanceof NullNode == false) {
                                                                    String unitInstance2;
                                                                    unitInstance2 = unitValue2.getTextValue();
                                                                    operationImpactInstance2
                                                                            .setUnit(unitInstance2);
                                                                }

                                                                JsonNode changeValueAbsoluteValue2 = reportedImpactValue
                                                                        .get("changeValueAbsolute");
                                                                if (changeValueAbsoluteValue2 != null
                                                                        && changeValueAbsoluteValue2 instanceof NullNode == false) {
                                                                    double changeValueAbsoluteInstance2;
                                                                    changeValueAbsoluteInstance2 = changeValueAbsoluteValue2
                                                                            .getDoubleValue();
                                                                    operationImpactInstance2
                                                                            .setChangeValueAbsolute(
                                                                                    changeValueAbsoluteInstance2);
                                                                }

                                                                JsonNode changeValueRelativeValue2 = reportedImpactValue
                                                                        .get("changeValueRelative");
                                                                if (changeValueRelativeValue2 != null
                                                                        && changeValueRelativeValue2 instanceof NullNode == false) {
                                                                    double changeValueRelativeInstance2;
                                                                    changeValueRelativeInstance2 = changeValueRelativeValue2
                                                                            .getDoubleValue();
                                                                    operationImpactInstance2
                                                                            .setChangeValueRelative(
                                                                                    changeValueRelativeInstance2);
                                                                }
                                                            }
                                                        }
                                                    }

                                                    JsonNode idValue5 = recommendedIndexesValue.get("id");
                                                    if (idValue5 != null
                                                            && idValue5 instanceof NullNode == false) {
                                                        String idInstance5;
                                                        idInstance5 = idValue5.getTextValue();
                                                        recommendedIndexInstance.setId(idInstance5);
                                                    }

                                                    JsonNode nameValue7 = recommendedIndexesValue.get("name");
                                                    if (nameValue7 != null
                                                            && nameValue7 instanceof NullNode == false) {
                                                        String nameInstance7;
                                                        nameInstance7 = nameValue7.getTextValue();
                                                        recommendedIndexInstance.setName(nameInstance7);
                                                    }

                                                    JsonNode typeValue5 = recommendedIndexesValue.get("type");
                                                    if (typeValue5 != null
                                                            && typeValue5 instanceof NullNode == false) {
                                                        String typeInstance5;
                                                        typeInstance5 = typeValue5.getTextValue();
                                                        recommendedIndexInstance.setType(typeInstance5);
                                                    }

                                                    JsonNode locationValue5 = recommendedIndexesValue
                                                            .get("location");
                                                    if (locationValue5 != null
                                                            && locationValue5 instanceof NullNode == false) {
                                                        String locationInstance5;
                                                        locationInstance5 = locationValue5.getTextValue();
                                                        recommendedIndexInstance.setLocation(locationInstance5);
                                                    }

                                                    JsonNode tagsSequenceElement5 = ((JsonNode) recommendedIndexesValue
                                                            .get("tags"));
                                                    if (tagsSequenceElement5 != null
                                                            && tagsSequenceElement5 instanceof NullNode == false) {
                                                        Iterator<Map.Entry<String, JsonNode>> itr5 = tagsSequenceElement5
                                                                .getFields();
                                                        while (itr5.hasNext()) {
                                                            Map.Entry<String, JsonNode> property5 = itr5.next();
                                                            String tagsKey5 = property5.getKey();
                                                            String tagsValue5 = property5.getValue()
                                                                    .getTextValue();
                                                            recommendedIndexInstance.getTags().put(tagsKey5,
                                                                    tagsValue5);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        JsonNode idValue6 = tablesValue.get("id");
                                        if (idValue6 != null && idValue6 instanceof NullNode == false) {
                                            String idInstance6;
                                            idInstance6 = idValue6.getTextValue();
                                            tableInstance.setId(idInstance6);
                                        }

                                        JsonNode nameValue8 = tablesValue.get("name");
                                        if (nameValue8 != null && nameValue8 instanceof NullNode == false) {
                                            String nameInstance8;
                                            nameInstance8 = nameValue8.getTextValue();
                                            tableInstance.setName(nameInstance8);
                                        }

                                        JsonNode typeValue6 = tablesValue.get("type");
                                        if (typeValue6 != null && typeValue6 instanceof NullNode == false) {
                                            String typeInstance6;
                                            typeInstance6 = typeValue6.getTextValue();
                                            tableInstance.setType(typeInstance6);
                                        }

                                        JsonNode locationValue6 = tablesValue.get("location");
                                        if (locationValue6 != null
                                                && locationValue6 instanceof NullNode == false) {
                                            String locationInstance6;
                                            locationInstance6 = locationValue6.getTextValue();
                                            tableInstance.setLocation(locationInstance6);
                                        }

                                        JsonNode tagsSequenceElement6 = ((JsonNode) tablesValue.get("tags"));
                                        if (tagsSequenceElement6 != null
                                                && tagsSequenceElement6 instanceof NullNode == false) {
                                            Iterator<Map.Entry<String, JsonNode>> itr6 = tagsSequenceElement6
                                                    .getFields();
                                            while (itr6.hasNext()) {
                                                Map.Entry<String, JsonNode> property6 = itr6.next();
                                                String tagsKey6 = property6.getKey();
                                                String tagsValue6 = property6.getValue().getTextValue();
                                                tableInstance.getTags().put(tagsKey6, tagsValue6);
                                            }
                                        }
                                    }
                                }
                            }

                            JsonNode idValue7 = schemasValue.get("id");
                            if (idValue7 != null && idValue7 instanceof NullNode == false) {
                                String idInstance7;
                                idInstance7 = idValue7.getTextValue();
                                schemaInstance.setId(idInstance7);
                            }

                            JsonNode nameValue9 = schemasValue.get("name");
                            if (nameValue9 != null && nameValue9 instanceof NullNode == false) {
                                String nameInstance9;
                                nameInstance9 = nameValue9.getTextValue();
                                schemaInstance.setName(nameInstance9);
                            }

                            JsonNode typeValue7 = schemasValue.get("type");
                            if (typeValue7 != null && typeValue7 instanceof NullNode == false) {
                                String typeInstance7;
                                typeInstance7 = typeValue7.getTextValue();
                                schemaInstance.setType(typeInstance7);
                            }

                            JsonNode locationValue7 = schemasValue.get("location");
                            if (locationValue7 != null && locationValue7 instanceof NullNode == false) {
                                String locationInstance7;
                                locationInstance7 = locationValue7.getTextValue();
                                schemaInstance.setLocation(locationInstance7);
                            }

                            JsonNode tagsSequenceElement7 = ((JsonNode) schemasValue.get("tags"));
                            if (tagsSequenceElement7 != null
                                    && tagsSequenceElement7 instanceof NullNode == false) {
                                Iterator<Map.Entry<String, JsonNode>> itr7 = tagsSequenceElement7.getFields();
                                while (itr7.hasNext()) {
                                    Map.Entry<String, JsonNode> property7 = itr7.next();
                                    String tagsKey7 = property7.getKey();
                                    String tagsValue7 = property7.getValue().getTextValue();
                                    schemaInstance.getTags().put(tagsKey7, tagsValue7);
                                }
                            }
                        }
                    }

                    JsonNode defaultSecondaryLocationValue = propertiesValue.get("defaultSecondaryLocation");
                    if (defaultSecondaryLocationValue != null
                            && defaultSecondaryLocationValue instanceof NullNode == false) {
                        String defaultSecondaryLocationInstance;
                        defaultSecondaryLocationInstance = defaultSecondaryLocationValue.getTextValue();
                        propertiesInstance.setDefaultSecondaryLocation(defaultSecondaryLocationInstance);
                    }
                }

                JsonNode idValue8 = responseDoc.get("id");
                if (idValue8 != null && idValue8 instanceof NullNode == false) {
                    String idInstance8;
                    idInstance8 = idValue8.getTextValue();
                    databaseInstance.setId(idInstance8);
                }

                JsonNode nameValue10 = responseDoc.get("name");
                if (nameValue10 != null && nameValue10 instanceof NullNode == false) {
                    String nameInstance10;
                    nameInstance10 = nameValue10.getTextValue();
                    databaseInstance.setName(nameInstance10);
                }

                JsonNode typeValue8 = responseDoc.get("type");
                if (typeValue8 != null && typeValue8 instanceof NullNode == false) {
                    String typeInstance8;
                    typeInstance8 = typeValue8.getTextValue();
                    databaseInstance.setType(typeInstance8);
                }

                JsonNode locationValue8 = responseDoc.get("location");
                if (locationValue8 != null && locationValue8 instanceof NullNode == false) {
                    String locationInstance8;
                    locationInstance8 = locationValue8.getTextValue();
                    databaseInstance.setLocation(locationInstance8);
                }

                JsonNode tagsSequenceElement8 = ((JsonNode) responseDoc.get("tags"));
                if (tagsSequenceElement8 != null && tagsSequenceElement8 instanceof NullNode == false) {
                    Iterator<Map.Entry<String, JsonNode>> itr8 = tagsSequenceElement8.getFields();
                    while (itr8.hasNext()) {
                        Map.Entry<String, JsonNode> property8 = itr8.next();
                        String tagsKey8 = property8.getKey();
                        String tagsValue8 = property8.getValue().getTextValue();
                        databaseInstance.getTags().put(tagsKey8, tagsValue8);
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Location").length > 0) {
            result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue()));
        }
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }
        if (statusCode == HttpStatus.SC_OK) {
            result.setStatus(OperationStatus.Succeeded);
        }

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

From source file:com.marklogic.client.functionaltest.TestBiTemporal.java

@Test
// Test Period Range Query usig ALN_CONTAINS. We use 2 axes during query
// Note that the query will be done for every axis across every period. And
// the results will be an OR of the result of each of the query done for every axis 
// across every period
public void testPeriodRangeQueryMultiplesAxesBasedOnALNContains() throws Exception {
    System.out.println("Inside testPeriodRangeQueryMultiplesAxesBasedOnALNContains");

    // Read documents based on document URI and ALN_OVERLAPS. We are just
    // looking/* w ww . jav  a 2  s . c om*/
    // for count of documents to be correct

    String docId = "javaSingleJSONDoc.json";

    insertJSONSingleDocument(temporalCollectionName, docId, null);
    updateJSONSingleDocument(temporalCollectionName, docId);

    // Fetch documents associated with a search term (such as XML) in Address
    // element
    QueryManager queryMgr = readerClient.newQueryManager();
    StructuredQueryBuilder sqb = queryMgr.newStructuredQueryBuilder();

    StructuredQueryDefinition termQuery = sqb.collection(docId);

    StructuredQueryBuilder.Axis validAxis1 = sqb.axis(axisValidName);
    Calendar start1 = DatatypeConverter.parseDateTime("2001-01-01T00:00:01");
    Calendar end1 = DatatypeConverter.parseDateTime("2011-12-31T23:59:58");
    StructuredQueryBuilder.Period period1 = sqb.period(start1, end1);

    StructuredQueryBuilder.Axis validAxis2 = sqb.axis(axisValidName);
    Calendar start2 = DatatypeConverter.parseDateTime("2003-01-01T00:00:01");
    Calendar end2 = DatatypeConverter.parseDateTime("2008-12-31T23:59:58");
    StructuredQueryBuilder.Period period2 = sqb.period(start2, end2);

    StructuredQueryBuilder.Axis[] axes = new StructuredQueryBuilder.Axis[] { validAxis1, validAxis2 };
    StructuredQueryBuilder.Period[] periods = new StructuredQueryBuilder.Period[] { period1, period2 };

    StructuredQueryDefinition periodQuery = sqb.and(termQuery,
            sqb.temporalPeriodRange(axes, TemporalOperator.ALN_CONTAINS, periods));

    // Note that the query will be done for every axis across every period. And
    // the results will be an OR of the result of each of the query done for every axis 
    // across every period
    long start = 1;
    JSONDocumentManager docMgr = readerClient.newJSONDocumentManager();
    docMgr.setMetadataCategories(Metadata.ALL); // Get all metadata
    DocumentPage termQueryResults = docMgr.search(periodQuery, start);

    long count = 0;
    while (termQueryResults.hasNext()) {
        ++count;
        DocumentRecord record = termQueryResults.next();
        System.out.println("URI = " + record.getUri());

        DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
        record.getMetadata(metadataHandle);
        Iterator<String> resCollections = metadataHandle.getCollections().iterator();
        while (resCollections.hasNext()) {
            System.out.println("Collection = " + resCollections.next());
        }

        if (record.getFormat() != Format.JSON) {
            assertFalse("Invalid document format: " + record.getFormat(), true);
        } else {
            JacksonDatabindHandle<ObjectNode> recordHandle = new JacksonDatabindHandle<ObjectNode>(
                    ObjectNode.class);
            record.getContent(recordHandle);
            System.out.println("Content = " + recordHandle.toString());

            JsonFactory factory = new JsonFactory();
            ObjectMapper mapper = new ObjectMapper(factory);
            TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() {
            };

            HashMap<String, Object> docObject = mapper.readValue(recordHandle.toString(), typeRef);

            @SuppressWarnings("unchecked")
            HashMap<String, Object> validNode = (HashMap<String, Object>) (docObject.get(validNodeName));

            String validStartDate = (String) validNode.get(validStartERIName);
            String validEndDate = (String) validNode.get(validEndERIName);
            System.out.println("validStartDate = " + validStartDate);
            System.out.println("validEndDate = " + validEndDate);

            assertTrue("Valid start date check failed", (validStartDate.equals("2001-01-01T00:00:00")
                    || validStartDate.equals("2003-01-01T00:00:00")));
            assertTrue("Valid end date check failed",
                    (validEndDate.equals("2011-12-31T23:59:59") || validEndDate.equals("2008-12-31T23:59:59")));
        }
    }

    System.out.println("Number of results using SQB = " + count);
    assertEquals("Wrong number of results", 2, count);
}

From source file:com.microsoft.azure.management.notificationhubs.NamespaceOperationsImpl.java

/**
* The Get namespace Delete Operation Status operation returns the status of
* the delete operation. After calling the operation, you can call Get
* namespace Delete Operation Status to determine whether the operation has
* succeeded, failed, or is still in progress. This method differs from
* GetLongRunningOperationStatus in providing NotificationHub service
* resource description.// w w  w. ja v  a 2s .c o m
*
* @param operationStatusLink Required. Location value returned by the Begin
* 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 response of the CreateOrUpdate Api Management service long
* running operation.
*/
@Override
public NamespaceLongRunningResponse getDeleteNamespaceOperationStatus(String operationStatusLink)
        throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (operationStatusLink == null) {
        throw new NullPointerException("operationStatusLink");
    }

    // 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("operationStatusLink", operationStatusLink);
        CloudTracing.enter(invocationId, this, "getDeleteNamespaceOperationStatusAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + operationStatusLink;
    url = url.replace(" ", "%20");

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

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

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

        // Create Result
        NamespaceLongRunningResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED
                || statusCode == HttpStatus.SC_NOT_FOUND) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new NamespaceLongRunningResponse();
            ObjectMapper objectMapper = new ObjectMapper();
            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) {
                NamespaceResource valueInstance = new NamespaceResource();
                result.setValue(valueInstance);

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

                JsonNode locationValue = responseDoc.get("location");
                if (locationValue != null && locationValue instanceof NullNode == false) {
                    String locationInstance;
                    locationInstance = locationValue.getTextValue();
                    valueInstance.setLocation(locationInstance);
                }

                JsonNode nameValue = responseDoc.get("name");
                if (nameValue != null && nameValue instanceof NullNode == false) {
                    String nameInstance;
                    nameInstance = nameValue.getTextValue();
                    valueInstance.setName(nameInstance);
                }

                JsonNode typeValue = responseDoc.get("type");
                if (typeValue != null && typeValue instanceof NullNode == false) {
                    String typeInstance;
                    typeInstance = typeValue.getTextValue();
                    valueInstance.setType(typeInstance);
                }

                JsonNode tagsSequenceElement = ((JsonNode) responseDoc.get("tags"));
                if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) {
                    Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields();
                    while (itr.hasNext()) {
                        Map.Entry<String, JsonNode> property = itr.next();
                        String tagsKey = property.getKey();
                        String tagsValue = property.getValue().getTextValue();
                        valueInstance.getTags().put(tagsKey, tagsValue);
                    }
                }

                JsonNode propertiesValue = responseDoc.get("properties");
                if (propertiesValue != null && propertiesValue instanceof NullNode == false) {
                    NamespaceProperties propertiesInstance = new NamespaceProperties();
                    valueInstance.setProperties(propertiesInstance);

                    JsonNode nameValue2 = propertiesValue.get("name");
                    if (nameValue2 != null && nameValue2 instanceof NullNode == false) {
                        String nameInstance2;
                        nameInstance2 = nameValue2.getTextValue();
                        propertiesInstance.setName(nameInstance2);
                    }

                    JsonNode provisioningStateValue = propertiesValue.get("provisioningState");
                    if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) {
                        String provisioningStateInstance;
                        provisioningStateInstance = provisioningStateValue.getTextValue();
                        propertiesInstance.setProvisioningState(provisioningStateInstance);
                    }

                    JsonNode regionValue = propertiesValue.get("region");
                    if (regionValue != null && regionValue instanceof NullNode == false) {
                        String regionInstance;
                        regionInstance = regionValue.getTextValue();
                        propertiesInstance.setRegion(regionInstance);
                    }

                    JsonNode statusValue = propertiesValue.get("status");
                    if (statusValue != null && statusValue instanceof NullNode == false) {
                        String statusInstance;
                        statusInstance = statusValue.getTextValue();
                        propertiesInstance.setStatus(statusInstance);
                    }

                    JsonNode createdAtValue = propertiesValue.get("createdAt");
                    if (createdAtValue != null && createdAtValue instanceof NullNode == false) {
                        Calendar createdAtInstance;
                        createdAtInstance = DatatypeConverter.parseDateTime(createdAtValue.getTextValue());
                        propertiesInstance.setCreatedAt(createdAtInstance);
                    }

                    JsonNode serviceBusEndpointValue = propertiesValue.get("serviceBusEndpoint");
                    if (serviceBusEndpointValue != null
                            && serviceBusEndpointValue instanceof NullNode == false) {
                        URI serviceBusEndpointInstance;
                        serviceBusEndpointInstance = new URI(serviceBusEndpointValue.getTextValue());
                        propertiesInstance.setServiceBusEndpoint(serviceBusEndpointInstance);
                    }

                    JsonNode subscriptionIdValue = propertiesValue.get("subscriptionId");
                    if (subscriptionIdValue != null && subscriptionIdValue instanceof NullNode == false) {
                        String subscriptionIdInstance;
                        subscriptionIdInstance = subscriptionIdValue.getTextValue();
                        propertiesInstance.setSubscriptionId(subscriptionIdInstance);
                    }

                    JsonNode scaleUnitValue = propertiesValue.get("scaleUnit");
                    if (scaleUnitValue != null && scaleUnitValue instanceof NullNode == false) {
                        String scaleUnitInstance;
                        scaleUnitInstance = scaleUnitValue.getTextValue();
                        propertiesInstance.setScaleUnit(scaleUnitInstance);
                    }

                    JsonNode enabledValue = propertiesValue.get("enabled");
                    if (enabledValue != null && enabledValue instanceof NullNode == false) {
                        boolean enabledInstance;
                        enabledInstance = enabledValue.getBooleanValue();
                        propertiesInstance.setEnabled(enabledInstance);
                    }

                    JsonNode criticalValue = propertiesValue.get("critical");
                    if (criticalValue != null && criticalValue instanceof NullNode == false) {
                        boolean criticalInstance;
                        criticalInstance = criticalValue.getBooleanValue();
                        propertiesInstance.setCritical(criticalInstance);
                    }

                    JsonNode namespaceTypeValue = propertiesValue.get("namespaceType");
                    if (namespaceTypeValue != null && namespaceTypeValue instanceof NullNode == false) {
                        NamespaceType namespaceTypeInstance;
                        namespaceTypeInstance = Enum.valueOf(NamespaceType.class,
                                namespaceTypeValue.getTextValue());
                        propertiesInstance.setNamespaceType(namespaceTypeInstance);
                    }
                }

                ResourceError errorInstance = new ResourceError();
                result.setError(errorInstance);

                JsonNode codeValue = responseDoc.get("code");
                if (codeValue != null && codeValue instanceof NullNode == false) {
                    String codeInstance;
                    codeInstance = codeValue.getTextValue();
                    errorInstance.setCode(codeInstance);
                }

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

                JsonNode detailsSequenceElement = ((JsonNode) responseDoc.get("details"));
                if (detailsSequenceElement != null && detailsSequenceElement instanceof NullNode == false) {
                    Iterator<Map.Entry<String, JsonNode>> itr2 = detailsSequenceElement.getFields();
                    while (itr2.hasNext()) {
                        Map.Entry<String, JsonNode> property2 = itr2.next();
                        String detailsKey = property2.getKey();
                        String detailsValue = property2.getValue().getTextValue();
                        errorInstance.getDetails().put(detailsKey, detailsValue);
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Location").length > 0) {
            result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue()));
        }
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }
        if (statusCode == HttpStatus.SC_BAD_REQUEST) {
            result.setStatus(OperationStatus.Failed);
        }
        if (statusCode == HttpStatus.SC_OK) {
            result.setStatus(OperationStatus.Succeeded);
        }
        if (statusCode == HttpStatus.SC_NOT_FOUND) {
            result.setStatus(OperationStatus.Succeeded);
        }

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

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

/**
* The List Virtual Machine Images operation retrieves a list of the virtual
* machine images./*from  w  w  w .ja  v a2s  . c o 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 ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return The List VM Images operation response.
*/
@Override
public VirtualMachineVMImageListResponse list()
        throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException {
    // Validate

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        CloudTracing.enter(invocationId, this, "listAsync", 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/vmimages";
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

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

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

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

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

            Element vMImagesSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "VMImages");
            if (vMImagesSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(vMImagesSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "VMImage")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element vMImagesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(vMImagesSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "VMImage")
                            .get(i1));
                    VirtualMachineVMImageListResponse.VirtualMachineVMImage vMImageInstance = new VirtualMachineVMImageListResponse.VirtualMachineVMImage();
                    result.getVMImages().add(vMImageInstance);

                    Element nameElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Name");
                    if (nameElement != null) {
                        String nameInstance;
                        nameInstance = nameElement.getTextContent();
                        vMImageInstance.setName(nameInstance);
                    }

                    Element labelElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Label");
                    if (labelElement != null) {
                        String labelInstance;
                        labelInstance = labelElement.getTextContent();
                        vMImageInstance.setLabel(labelInstance);
                    }

                    Element categoryElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Category");
                    if (categoryElement != null) {
                        String categoryInstance;
                        categoryInstance = categoryElement.getTextContent();
                        vMImageInstance.setCategory(categoryInstance);
                    }

                    Element descriptionElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Description");
                    if (descriptionElement != null) {
                        String descriptionInstance;
                        descriptionInstance = descriptionElement.getTextContent();
                        vMImageInstance.setDescription(descriptionInstance);
                    }

                    Element oSDiskConfigurationElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "OSDiskConfiguration");
                    if (oSDiskConfigurationElement != null) {
                        VirtualMachineVMImageListResponse.OSDiskConfiguration oSDiskConfigurationInstance = new VirtualMachineVMImageListResponse.OSDiskConfiguration();
                        vMImageInstance.setOSDiskConfiguration(oSDiskConfigurationInstance);

                        Element nameElement2 = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement,
                                "http://schemas.microsoft.com/windowsazure", "Name");
                        if (nameElement2 != null) {
                            String nameInstance2;
                            nameInstance2 = nameElement2.getTextContent();
                            oSDiskConfigurationInstance.setName(nameInstance2);
                        }

                        Element hostCachingElement = XmlUtility.getElementByTagNameNS(
                                oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure",
                                "HostCaching");
                        if (hostCachingElement != null) {
                            String hostCachingInstance;
                            hostCachingInstance = hostCachingElement.getTextContent();
                            oSDiskConfigurationInstance.setHostCaching(hostCachingInstance);
                        }

                        Element oSStateElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement,
                                "http://schemas.microsoft.com/windowsazure", "OSState");
                        if (oSStateElement != null) {
                            String oSStateInstance;
                            oSStateInstance = oSStateElement.getTextContent();
                            oSDiskConfigurationInstance.setOSState(oSStateInstance);
                        }

                        Element osElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement,
                                "http://schemas.microsoft.com/windowsazure", "OS");
                        if (osElement != null) {
                            String osInstance;
                            osInstance = osElement.getTextContent();
                            oSDiskConfigurationInstance.setOperatingSystem(osInstance);
                        }

                        Element mediaLinkElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement,
                                "http://schemas.microsoft.com/windowsazure", "MediaLink");
                        if (mediaLinkElement != null) {
                            URI mediaLinkInstance;
                            mediaLinkInstance = new URI(mediaLinkElement.getTextContent());
                            oSDiskConfigurationInstance.setMediaLink(mediaLinkInstance);
                        }

                        Element logicalDiskSizeInGBElement = XmlUtility.getElementByTagNameNS(
                                oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure",
                                "LogicalDiskSizeInGB");
                        if (logicalDiskSizeInGBElement != null) {
                            int logicalDiskSizeInGBInstance;
                            logicalDiskSizeInGBInstance = DatatypeConverter
                                    .parseInt(logicalDiskSizeInGBElement.getTextContent());
                            oSDiskConfigurationInstance.setLogicalDiskSizeInGB(logicalDiskSizeInGBInstance);
                        }

                        Element iOTypeElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement,
                                "http://schemas.microsoft.com/windowsazure", "IOType");
                        if (iOTypeElement != null) {
                            String iOTypeInstance;
                            iOTypeInstance = iOTypeElement.getTextContent();
                            oSDiskConfigurationInstance.setIOType(iOTypeInstance);
                        }
                    }

                    Element dataDiskConfigurationsSequenceElement = XmlUtility.getElementByTagNameNS(
                            vMImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "DataDiskConfigurations");
                    if (dataDiskConfigurationsSequenceElement != null) {
                        for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(dataDiskConfigurationsSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "DataDiskConfiguration")
                                .size(); i2 = i2 + 1) {
                            org.w3c.dom.Element dataDiskConfigurationsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(dataDiskConfigurationsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure",
                                            "DataDiskConfiguration")
                                    .get(i2));
                            VirtualMachineVMImageListResponse.DataDiskConfiguration dataDiskConfigurationInstance = new VirtualMachineVMImageListResponse.DataDiskConfiguration();
                            vMImageInstance.getDataDiskConfigurations().add(dataDiskConfigurationInstance);

                            Element nameElement3 = XmlUtility.getElementByTagNameNS(
                                    dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure",
                                    "Name");
                            if (nameElement3 != null) {
                                String nameInstance3;
                                nameInstance3 = nameElement3.getTextContent();
                                dataDiskConfigurationInstance.setName(nameInstance3);
                            }

                            Element hostCachingElement2 = XmlUtility.getElementByTagNameNS(
                                    dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure",
                                    "HostCaching");
                            if (hostCachingElement2 != null) {
                                String hostCachingInstance2;
                                hostCachingInstance2 = hostCachingElement2.getTextContent();
                                dataDiskConfigurationInstance.setHostCaching(hostCachingInstance2);
                            }

                            Element lunElement = XmlUtility.getElementByTagNameNS(dataDiskConfigurationsElement,
                                    "http://schemas.microsoft.com/windowsazure", "Lun");
                            if (lunElement != null && lunElement.getTextContent() != null
                                    && !lunElement.getTextContent().isEmpty()) {
                                int lunInstance;
                                lunInstance = DatatypeConverter.parseInt(lunElement.getTextContent());
                                dataDiskConfigurationInstance.setLogicalUnitNumber(lunInstance);
                            }

                            Element mediaLinkElement2 = XmlUtility.getElementByTagNameNS(
                                    dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure",
                                    "MediaLink");
                            if (mediaLinkElement2 != null) {
                                URI mediaLinkInstance2;
                                mediaLinkInstance2 = new URI(mediaLinkElement2.getTextContent());
                                dataDiskConfigurationInstance.setMediaLink(mediaLinkInstance2);
                            }

                            Element logicalDiskSizeInGBElement2 = XmlUtility.getElementByTagNameNS(
                                    dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure",
                                    "LogicalDiskSizeInGB");
                            if (logicalDiskSizeInGBElement2 != null) {
                                int logicalDiskSizeInGBInstance2;
                                logicalDiskSizeInGBInstance2 = DatatypeConverter
                                        .parseInt(logicalDiskSizeInGBElement2.getTextContent());
                                dataDiskConfigurationInstance
                                        .setLogicalDiskSizeInGB(logicalDiskSizeInGBInstance2);
                            }

                            Element iOTypeElement2 = XmlUtility.getElementByTagNameNS(
                                    dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure",
                                    "IOType");
                            if (iOTypeElement2 != null) {
                                String iOTypeInstance2;
                                iOTypeInstance2 = iOTypeElement2.getTextContent();
                                dataDiskConfigurationInstance.setIOType(iOTypeInstance2);
                            }
                        }
                    }

                    Element serviceNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ServiceName");
                    if (serviceNameElement != null) {
                        String serviceNameInstance;
                        serviceNameInstance = serviceNameElement.getTextContent();
                        vMImageInstance.setServiceName(serviceNameInstance);
                    }

                    Element deploymentNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "DeploymentName");
                    if (deploymentNameElement != null) {
                        String deploymentNameInstance;
                        deploymentNameInstance = deploymentNameElement.getTextContent();
                        vMImageInstance.setDeploymentName(deploymentNameInstance);
                    }

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

                    Element affinityGroupElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "AffinityGroup");
                    if (affinityGroupElement != null) {
                        String affinityGroupInstance;
                        affinityGroupInstance = affinityGroupElement.getTextContent();
                        vMImageInstance.setAffinityGroup(affinityGroupInstance);
                    }

                    Element locationElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Location");
                    if (locationElement != null) {
                        String locationInstance;
                        locationInstance = locationElement.getTextContent();
                        vMImageInstance.setLocation(locationInstance);
                    }

                    Element createdTimeElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "CreatedTime");
                    if (createdTimeElement != null && createdTimeElement.getTextContent() != null
                            && !createdTimeElement.getTextContent().isEmpty()) {
                        Calendar createdTimeInstance;
                        createdTimeInstance = DatatypeConverter
                                .parseDateTime(createdTimeElement.getTextContent());
                        vMImageInstance.setCreatedTime(createdTimeInstance);
                    }

                    Element modifiedTimeElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ModifiedTime");
                    if (modifiedTimeElement != null && modifiedTimeElement.getTextContent() != null
                            && !modifiedTimeElement.getTextContent().isEmpty()) {
                        Calendar modifiedTimeInstance;
                        modifiedTimeInstance = DatatypeConverter
                                .parseDateTime(modifiedTimeElement.getTextContent());
                        vMImageInstance.setModifiedTime(modifiedTimeInstance);
                    }

                    Element languageElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Language");
                    if (languageElement != null) {
                        String languageInstance;
                        languageInstance = languageElement.getTextContent();
                        vMImageInstance.setLanguage(languageInstance);
                    }

                    Element imageFamilyElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ImageFamily");
                    if (imageFamilyElement != null) {
                        String imageFamilyInstance;
                        imageFamilyInstance = imageFamilyElement.getTextContent();
                        vMImageInstance.setImageFamily(imageFamilyInstance);
                    }

                    Element recommendedVMSizeElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "RecommendedVMSize");
                    if (recommendedVMSizeElement != null) {
                        String recommendedVMSizeInstance;
                        recommendedVMSizeInstance = recommendedVMSizeElement.getTextContent();
                        vMImageInstance.setRecommendedVMSize(recommendedVMSizeInstance);
                    }

                    Element isPremiumElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IsPremium");
                    if (isPremiumElement != null && isPremiumElement.getTextContent() != null
                            && !isPremiumElement.getTextContent().isEmpty()) {
                        boolean isPremiumInstance;
                        isPremiumInstance = DatatypeConverter
                                .parseBoolean(isPremiumElement.getTextContent().toLowerCase());
                        vMImageInstance.setIsPremium(isPremiumInstance);
                    }

                    Element eulaElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Eula");
                    if (eulaElement != null) {
                        String eulaInstance;
                        eulaInstance = eulaElement.getTextContent();
                        vMImageInstance.setEula(eulaInstance);
                    }

                    Element iconUriElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IconUri");
                    if (iconUriElement != null) {
                        String iconUriInstance;
                        iconUriInstance = iconUriElement.getTextContent();
                        vMImageInstance.setIconUri(iconUriInstance);
                    }

                    Element smallIconUriElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "SmallIconUri");
                    if (smallIconUriElement != null) {
                        String smallIconUriInstance;
                        smallIconUriInstance = smallIconUriElement.getTextContent();
                        vMImageInstance.setSmallIconUri(smallIconUriInstance);
                    }

                    Element privacyUriElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PrivacyUri");
                    if (privacyUriElement != null) {
                        URI privacyUriInstance;
                        privacyUriInstance = new URI(privacyUriElement.getTextContent());
                        vMImageInstance.setPrivacyUri(privacyUriInstance);
                    }

                    Element publisherNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PublisherName");
                    if (publisherNameElement != null) {
                        String publisherNameInstance;
                        publisherNameInstance = publisherNameElement.getTextContent();
                        vMImageInstance.setPublisherName(publisherNameInstance);
                    }

                    Element publishedDateElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PublishedDate");
                    if (publishedDateElement != null && publishedDateElement.getTextContent() != null
                            && !publishedDateElement.getTextContent().isEmpty()) {
                        Calendar publishedDateInstance;
                        publishedDateInstance = DatatypeConverter
                                .parseDateTime(publishedDateElement.getTextContent());
                        vMImageInstance.setPublishedDate(publishedDateInstance);
                    }

                    Element showInGuiElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ShowInGui");
                    if (showInGuiElement != null && showInGuiElement.getTextContent() != null
                            && !showInGuiElement.getTextContent().isEmpty()) {
                        boolean showInGuiInstance;
                        showInGuiInstance = DatatypeConverter
                                .parseBoolean(showInGuiElement.getTextContent().toLowerCase());
                        vMImageInstance.setShowInGui(showInGuiInstance);
                    }

                    Element pricingDetailLinkElement = XmlUtility.getElementByTagNameNS(vMImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "PricingDetailLink");
                    if (pricingDetailLinkElement != null) {
                        URI pricingDetailLinkInstance;
                        pricingDetailLinkInstance = new URI(pricingDetailLinkElement.getTextContent());
                        vMImageInstance.setPricingDetailLink(pricingDetailLinkInstance);
                    }
                }
            }

        }
        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.sql.DatabaseOperationsImpl.java

/**
* Updates the properties of an Azure SQL Database.
*
* @param serverName Required. The name of the Azure SQL Database Server
* where the database is hosted./*from w  ww .j a  va 2s  . co  m*/
* @param databaseName Required. The name of the Azure SQL Database to be
* updated.
* @param parameters Required. The parameters for the Update Database
* 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 Contains the response from a request to Update Database.
*/
@Override
public DatabaseUpdateResponse update(String serverName, String databaseName,
        DatabaseUpdateParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (serverName == null) {
        throw new NullPointerException("serverName");
    }
    if (databaseName == null) {
        throw new NullPointerException("databaseName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getEdition() == null) {
        throw new NullPointerException("parameters.Edition");
    }

    // 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("serverName", serverName);
        tracingParameters.put("databaseName", databaseName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "updateAsync", 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/sqlservers/servers/";
    url = url + URLEncoder.encode(serverName, "UTF-8");
    url = url + "/databases/";
    url = url + URLEncoder.encode(databaseName, "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
    HttpPut httpRequest = new HttpPut(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/xml");
    httpRequest.setHeader("x-ms-version", "2012-03-01");

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

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

    if (parameters.getName() != null) {
        Element nameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Name");
        nameElement.appendChild(requestDoc.createTextNode(parameters.getName()));
        serviceResourceElement.appendChild(nameElement);
    }

    Element editionElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Edition");
    editionElement.appendChild(requestDoc.createTextNode(parameters.getEdition()));
    serviceResourceElement.appendChild(editionElement);

    if (parameters.getMaximumDatabaseSizeInGB() != null) {
        Element maxSizeGBElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "MaxSizeGB");
        maxSizeGBElement.appendChild(
                requestDoc.createTextNode(Integer.toString(parameters.getMaximumDatabaseSizeInGB())));
        serviceResourceElement.appendChild(maxSizeGBElement);
    }

    if (parameters.getMaximumDatabaseSizeInBytes() != null) {
        Element maxSizeBytesElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "MaxSizeBytes");
        maxSizeBytesElement.appendChild(
                requestDoc.createTextNode(Long.toString(parameters.getMaximumDatabaseSizeInBytes())));
        serviceResourceElement.appendChild(maxSizeBytesElement);
    }

    if (parameters.getServiceObjectiveId() != null) {
        Element serviceObjectiveIdElement = requestDoc
                .createElementNS("http://schemas.microsoft.com/windowsazure", "ServiceObjectiveId");
        serviceObjectiveIdElement.appendChild(requestDoc.createTextNode(parameters.getServiceObjectiveId()));
        serviceResourceElement.appendChild(serviceObjectiveIdElement);
    }

    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
        DatabaseUpdateResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new DatabaseUpdateResponse();
            DocumentBuilderFactory documentBuilderFactory2 = DocumentBuilderFactory.newInstance();
            documentBuilderFactory2.setNamespaceAware(true);
            DocumentBuilder documentBuilder2 = documentBuilderFactory2.newDocumentBuilder();
            Document responseDoc = documentBuilder2.parse(new BOMInputStream(responseContent));

            Element serviceResourceElement2 = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "ServiceResource");
            if (serviceResourceElement2 != null) {
                Database serviceResourceInstance = new Database();
                result.setDatabase(serviceResourceInstance);

                Element idElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "Id");
                if (idElement != null) {
                    int idInstance;
                    idInstance = DatatypeConverter.parseInt(idElement.getTextContent());
                    serviceResourceInstance.setId(idInstance);
                }

                Element editionElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "Edition");
                if (editionElement2 != null) {
                    String editionInstance;
                    editionInstance = editionElement2.getTextContent();
                    serviceResourceInstance.setEdition(editionInstance);
                }

                Element maxSizeGBElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "MaxSizeGB");
                if (maxSizeGBElement2 != null) {
                    int maxSizeGBInstance;
                    maxSizeGBInstance = DatatypeConverter.parseInt(maxSizeGBElement2.getTextContent());
                    serviceResourceInstance.setMaximumDatabaseSizeInGB(maxSizeGBInstance);
                }

                Element maxSizeBytesElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "MaxSizeBytes");
                if (maxSizeBytesElement2 != null) {
                    long maxSizeBytesInstance;
                    maxSizeBytesInstance = DatatypeConverter.parseLong(maxSizeBytesElement2.getTextContent());
                    serviceResourceInstance.setMaximumDatabaseSizeInBytes(maxSizeBytesInstance);
                }

                Element collationNameElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "CollationName");
                if (collationNameElement != null) {
                    String collationNameInstance;
                    collationNameInstance = collationNameElement.getTextContent();
                    serviceResourceInstance.setCollationName(collationNameInstance);
                }

                Element creationDateElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "CreationDate");
                if (creationDateElement != null) {
                    Calendar creationDateInstance;
                    creationDateInstance = DatatypeConverter
                            .parseDateTime(creationDateElement.getTextContent());
                    serviceResourceInstance.setCreationDate(creationDateInstance);
                }

                Element isFederationRootElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "IsFederationRoot");
                if (isFederationRootElement != null) {
                    boolean isFederationRootInstance;
                    isFederationRootInstance = DatatypeConverter
                            .parseBoolean(isFederationRootElement.getTextContent().toLowerCase());
                    serviceResourceInstance.setIsFederationRoot(isFederationRootInstance);
                }

                Element isSystemObjectElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "IsSystemObject");
                if (isSystemObjectElement != null) {
                    boolean isSystemObjectInstance;
                    isSystemObjectInstance = DatatypeConverter
                            .parseBoolean(isSystemObjectElement.getTextContent().toLowerCase());
                    serviceResourceInstance.setIsSystemObject(isSystemObjectInstance);
                }

                Element sizeMBElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "SizeMB");
                if (sizeMBElement != null) {
                    String sizeMBInstance;
                    sizeMBInstance = sizeMBElement.getTextContent();
                    serviceResourceInstance.setSizeMB(sizeMBInstance);
                }

                Element serviceObjectiveAssignmentErrorCodeElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "ServiceObjectiveAssignmentErrorCode");
                if (serviceObjectiveAssignmentErrorCodeElement != null) {
                    String serviceObjectiveAssignmentErrorCodeInstance;
                    serviceObjectiveAssignmentErrorCodeInstance = serviceObjectiveAssignmentErrorCodeElement
                            .getTextContent();
                    serviceResourceInstance.setServiceObjectiveAssignmentErrorCode(
                            serviceObjectiveAssignmentErrorCodeInstance);
                }

                Element serviceObjectiveAssignmentErrorDescriptionElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "ServiceObjectiveAssignmentErrorDescription");
                if (serviceObjectiveAssignmentErrorDescriptionElement != null) {
                    String serviceObjectiveAssignmentErrorDescriptionInstance;
                    serviceObjectiveAssignmentErrorDescriptionInstance = serviceObjectiveAssignmentErrorDescriptionElement
                            .getTextContent();
                    serviceResourceInstance.setServiceObjectiveAssignmentErrorDescription(
                            serviceObjectiveAssignmentErrorDescriptionInstance);
                }

                Element serviceObjectiveAssignmentStateElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "ServiceObjectiveAssignmentState");
                if (serviceObjectiveAssignmentStateElement != null) {
                    String serviceObjectiveAssignmentStateInstance;
                    serviceObjectiveAssignmentStateInstance = serviceObjectiveAssignmentStateElement
                            .getTextContent();
                    serviceResourceInstance
                            .setServiceObjectiveAssignmentState(serviceObjectiveAssignmentStateInstance);
                }

                Element serviceObjectiveAssignmentStateDescriptionElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "ServiceObjectiveAssignmentStateDescription");
                if (serviceObjectiveAssignmentStateDescriptionElement != null) {
                    String serviceObjectiveAssignmentStateDescriptionInstance;
                    serviceObjectiveAssignmentStateDescriptionInstance = serviceObjectiveAssignmentStateDescriptionElement
                            .getTextContent();
                    serviceResourceInstance.setServiceObjectiveAssignmentStateDescription(
                            serviceObjectiveAssignmentStateDescriptionInstance);
                }

                Element serviceObjectiveAssignmentSuccessDateElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "ServiceObjectiveAssignmentSuccessDate");
                if (serviceObjectiveAssignmentSuccessDateElement != null) {
                    String serviceObjectiveAssignmentSuccessDateInstance;
                    serviceObjectiveAssignmentSuccessDateInstance = serviceObjectiveAssignmentSuccessDateElement
                            .getTextContent();
                    serviceResourceInstance.setServiceObjectiveAssignmentSuccessDate(
                            serviceObjectiveAssignmentSuccessDateInstance);
                }

                Element serviceObjectiveIdElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveId");
                if (serviceObjectiveIdElement2 != null) {
                    String serviceObjectiveIdInstance;
                    serviceObjectiveIdInstance = serviceObjectiveIdElement2.getTextContent();
                    serviceResourceInstance.setServiceObjectiveId(serviceObjectiveIdInstance);
                }

                Element assignedServiceObjectiveIdElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "AssignedServiceObjectiveId");
                if (assignedServiceObjectiveIdElement != null) {
                    String assignedServiceObjectiveIdInstance;
                    assignedServiceObjectiveIdInstance = assignedServiceObjectiveIdElement.getTextContent();
                    serviceResourceInstance.setAssignedServiceObjectiveId(assignedServiceObjectiveIdInstance);
                }

                Element recoveryPeriodStartDateElement = XmlUtility.getElementByTagNameNS(
                        serviceResourceElement2, "http://schemas.microsoft.com/windowsazure",
                        "RecoveryPeriodStartDate");
                if (recoveryPeriodStartDateElement != null
                        && recoveryPeriodStartDateElement.getTextContent() != null
                        && !recoveryPeriodStartDateElement.getTextContent().isEmpty()) {
                    Calendar recoveryPeriodStartDateInstance;
                    recoveryPeriodStartDateInstance = DatatypeConverter
                            .parseDateTime(recoveryPeriodStartDateElement.getTextContent());
                    serviceResourceInstance.setRecoveryPeriodStartDate(recoveryPeriodStartDateInstance);
                }

                Element nameElement2 = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "Name");
                if (nameElement2 != null) {
                    String nameInstance;
                    nameInstance = nameElement2.getTextContent();
                    serviceResourceInstance.setName(nameInstance);
                }

                Element typeElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "Type");
                if (typeElement != null) {
                    String typeInstance;
                    typeInstance = typeElement.getTextContent();
                    serviceResourceInstance.setType(typeInstance);
                }

                Element stateElement = XmlUtility.getElementByTagNameNS(serviceResourceElement2,
                        "http://schemas.microsoft.com/windowsazure", "State");
                if (stateElement != null) {
                    String stateInstance;
                    stateInstance = stateElement.getTextContent();
                    serviceResourceInstance.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();
        }
    }
}