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.HostedServiceOperationsImpl.java

/**
* The List Available Extensions operation lists the extensions that are
* available to add to your cloud service. In Windows Azure, a process can
* run as an extension of a cloud service. For example, Remote Desktop
* Access or the Azure Diagnostics Agent can run as extensions to the cloud
* service.  (see//from   w w w  . j a  v a2s  .c  o m
* http://msdn.microsoft.com/en-us/library/windowsazure/dn169559.aspx for
* more information)
*
* @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 Available Extensions operation response.
*/
@Override
public HostedServiceListAvailableExtensionsResponse listAvailableExtensions()
        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, "listAvailableExtensionsAsync", 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/extensions";
    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
        HostedServiceListAvailableExtensionsResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new HostedServiceListAvailableExtensionsResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element extensionImagesSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "ExtensionImages");
            if (extensionImagesSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(extensionImagesSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "ExtensionImage")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element extensionImagesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(extensionImagesSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "ExtensionImage")
                            .get(i1));
                    ExtensionImage extensionImageInstance = new ExtensionImage();
                    result.getExtensionImages().add(extensionImageInstance);

                    Element providerNameSpaceElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ProviderNameSpace");
                    if (providerNameSpaceElement != null) {
                        String providerNameSpaceInstance;
                        providerNameSpaceInstance = providerNameSpaceElement.getTextContent();
                        extensionImageInstance.setProviderNameSpace(providerNameSpaceInstance);
                    }

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

                    Element versionElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Version");
                    if (versionElement != null) {
                        String versionInstance;
                        versionInstance = versionElement.getTextContent();
                        extensionImageInstance.setVersion(versionInstance);
                    }

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

                    Element hostingResourcesElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "HostingResources");
                    if (hostingResourcesElement != null) {
                        String hostingResourcesInstance;
                        hostingResourcesInstance = hostingResourcesElement.getTextContent();
                        extensionImageInstance.setHostingResources(hostingResourcesInstance);
                    }

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

                    Element certificateElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Certificate");
                    if (certificateElement != null) {
                        ExtensionCertificateConfiguration certificateInstance = new ExtensionCertificateConfiguration();
                        extensionImageInstance.setCertificate(certificateInstance);

                        Element storeLocationElement = XmlUtility.getElementByTagNameNS(certificateElement,
                                "http://schemas.microsoft.com/windowsazure", "StoreLocation");
                        if (storeLocationElement != null) {
                            String storeLocationInstance;
                            storeLocationInstance = storeLocationElement.getTextContent();
                            certificateInstance.setStoreLocation(storeLocationInstance);
                        }

                        Element storeNameElement = XmlUtility.getElementByTagNameNS(certificateElement,
                                "http://schemas.microsoft.com/windowsazure", "StoreName");
                        if (storeNameElement != null) {
                            String storeNameInstance;
                            storeNameInstance = storeNameElement.getTextContent();
                            certificateInstance.setStoreName(storeNameInstance);
                        }

                        Element thumbprintRequiredElement = XmlUtility.getElementByTagNameNS(certificateElement,
                                "http://schemas.microsoft.com/windowsazure", "ThumbprintRequired");
                        if (thumbprintRequiredElement != null
                                && thumbprintRequiredElement.getTextContent() != null
                                && !thumbprintRequiredElement.getTextContent().isEmpty()) {
                            boolean thumbprintRequiredInstance;
                            thumbprintRequiredInstance = DatatypeConverter
                                    .parseBoolean(thumbprintRequiredElement.getTextContent().toLowerCase());
                            certificateInstance.setThumbprintRequired(thumbprintRequiredInstance);
                        }

                        Element thumbprintAlgorithmElement = XmlUtility.getElementByTagNameNS(
                                certificateElement, "http://schemas.microsoft.com/windowsazure",
                                "ThumbprintAlgorithm");
                        if (thumbprintAlgorithmElement != null) {
                            String thumbprintAlgorithmInstance;
                            thumbprintAlgorithmInstance = thumbprintAlgorithmElement.getTextContent();
                            certificateInstance.setThumbprintAlgorithm(thumbprintAlgorithmInstance);
                        }
                    }

                    Element endpointsElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Endpoints");
                    if (endpointsElement != null) {
                        ExtensionEndpointConfiguration endpointsInstance = new ExtensionEndpointConfiguration();
                        extensionImageInstance.setExtensionEndpoints(endpointsInstance);

                        Element inputEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                endpointsElement, "http://schemas.microsoft.com/windowsazure",
                                "InputEndpoints");
                        if (inputEndpointsSequenceElement != null) {
                            for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(inputEndpointsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "InputEndpoint")
                                    .size(); i2 = i2 + 1) {
                                org.w3c.dom.Element inputEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(inputEndpointsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "InputEndpoint")
                                        .get(i2));
                                ExtensionEndpointConfiguration.InputEndpoint inputEndpointInstance = new ExtensionEndpointConfiguration.InputEndpoint();
                                endpointsInstance.getInputEndpoints().add(inputEndpointInstance);

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

                                Element protocolElement = XmlUtility.getElementByTagNameNS(
                                        inputEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "Protocol");
                                if (protocolElement != null) {
                                    String protocolInstance;
                                    protocolInstance = protocolElement.getTextContent();
                                    inputEndpointInstance.setProtocol(protocolInstance);
                                }

                                Element portElement = XmlUtility.getElementByTagNameNS(inputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "Port");
                                if (portElement != null) {
                                    int portInstance;
                                    portInstance = DatatypeConverter.parseInt(portElement.getTextContent());
                                    inputEndpointInstance.setPort(portInstance);
                                }

                                Element localPortElement = XmlUtility.getElementByTagNameNS(
                                        inputEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "LocalPort");
                                if (localPortElement != null) {
                                    String localPortInstance;
                                    localPortInstance = localPortElement.getTextContent();
                                    inputEndpointInstance.setLocalPort(localPortInstance);
                                }
                            }
                        }

                        Element internalEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                endpointsElement, "http://schemas.microsoft.com/windowsazure",
                                "InternalEndpoints");
                        if (internalEndpointsSequenceElement != null) {
                            for (int i3 = 0; i3 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(internalEndpointsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "InternalEndpoint")
                                    .size(); i3 = i3 + 1) {
                                org.w3c.dom.Element internalEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(internalEndpointsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "InternalEndpoint")
                                        .get(i3));
                                ExtensionEndpointConfiguration.InternalEndpoint internalEndpointInstance = new ExtensionEndpointConfiguration.InternalEndpoint();
                                endpointsInstance.getInternalEndpoints().add(internalEndpointInstance);

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

                                Element protocolElement2 = XmlUtility.getElementByTagNameNS(
                                        internalEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "Protocol");
                                if (protocolElement2 != null) {
                                    String protocolInstance2;
                                    protocolInstance2 = protocolElement2.getTextContent();
                                    internalEndpointInstance.setProtocol(protocolInstance2);
                                }

                                Element portElement2 = XmlUtility.getElementByTagNameNS(
                                        internalEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "Port");
                                if (portElement2 != null) {
                                    int portInstance2;
                                    portInstance2 = DatatypeConverter.parseInt(portElement2.getTextContent());
                                    internalEndpointInstance.setPort(portInstance2);
                                }
                            }
                        }

                        Element instanceInputEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                endpointsElement, "http://schemas.microsoft.com/windowsazure",
                                "InstanceInputEndpoints");
                        if (instanceInputEndpointsSequenceElement != null) {
                            for (int i4 = 0; i4 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(instanceInputEndpointsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure",
                                            "InstanceInputEndpoint")
                                    .size(); i4 = i4 + 1) {
                                org.w3c.dom.Element instanceInputEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(instanceInputEndpointsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "InstanceInputEndpoint")
                                        .get(i4));
                                ExtensionEndpointConfiguration.InstanceInputEndpoint instanceInputEndpointInstance = new ExtensionEndpointConfiguration.InstanceInputEndpoint();
                                endpointsInstance.getInstanceInputEndpoints()
                                        .add(instanceInputEndpointInstance);

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

                                Element protocolElement3 = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "Protocol");
                                if (protocolElement3 != null) {
                                    String protocolInstance3;
                                    protocolInstance3 = protocolElement3.getTextContent();
                                    instanceInputEndpointInstance.setProtocol(protocolInstance3);
                                }

                                Element localPortElement2 = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "LocalPort");
                                if (localPortElement2 != null) {
                                    String localPortInstance2;
                                    localPortInstance2 = localPortElement2.getTextContent();
                                    instanceInputEndpointInstance.setLocalPort(localPortInstance2);
                                }

                                Element fixedPortMinElement = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "FixedPortMin");
                                if (fixedPortMinElement != null) {
                                    int fixedPortMinInstance;
                                    fixedPortMinInstance = DatatypeConverter
                                            .parseInt(fixedPortMinElement.getTextContent());
                                    instanceInputEndpointInstance.setFixedPortMin(fixedPortMinInstance);
                                }

                                Element fixedPortMaxElement = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "FixedPortMax");
                                if (fixedPortMaxElement != null) {
                                    int fixedPortMaxInstance;
                                    fixedPortMaxInstance = DatatypeConverter
                                            .parseInt(fixedPortMaxElement.getTextContent());
                                    instanceInputEndpointInstance.setFixedPortMax(fixedPortMaxInstance);
                                }
                            }
                        }
                    }

                    Element publicConfigurationSchemaElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "PublicConfigurationSchema");
                    if (publicConfigurationSchemaElement != null) {
                        String publicConfigurationSchemaInstance;
                        publicConfigurationSchemaInstance = publicConfigurationSchemaElement
                                .getTextContent() != null ? new String(
                                        Base64.decode(publicConfigurationSchemaElement.getTextContent()))
                                        : null;
                        extensionImageInstance.setPublicConfigurationSchema(publicConfigurationSchemaInstance);
                    }

                    Element privateConfigurationSchemaElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "PrivateConfigurationSchema");
                    if (privateConfigurationSchemaElement != null) {
                        String privateConfigurationSchemaInstance;
                        privateConfigurationSchemaInstance = privateConfigurationSchemaElement
                                .getTextContent() != null ? new String(
                                        Base64.decode(privateConfigurationSchemaElement.getTextContent()))
                                        : null;
                        extensionImageInstance
                                .setPrivateConfigurationSchema(privateConfigurationSchemaInstance);
                    }

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

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

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

                    Element localResourcesSequenceElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "LocalResources");
                    if (localResourcesSequenceElement != null) {
                        for (int i5 = 0; i5 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(localResourcesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "LocalResource")
                                .size(); i5 = i5 + 1) {
                            org.w3c.dom.Element localResourcesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(localResourcesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "LocalResource")
                                    .get(i5));
                            ExtensionLocalResourceConfiguration localResourceInstance = new ExtensionLocalResourceConfiguration();
                            extensionImageInstance.getLocalResources().add(localResourceInstance);

                            Element nameElement4 = XmlUtility.getElementByTagNameNS(localResourcesElement,
                                    "http://schemas.microsoft.com/windowsazure", "Name");
                            if (nameElement4 != null) {
                                String nameInstance4;
                                nameInstance4 = nameElement4.getTextContent();
                                localResourceInstance.setName(nameInstance4);
                            }

                            Element sizeInMBElement = XmlUtility.getElementByTagNameNS(localResourcesElement,
                                    "http://schemas.microsoft.com/windowsazure", "SizeInMB");
                            if (sizeInMBElement != null && sizeInMBElement.getTextContent() != null
                                    && !sizeInMBElement.getTextContent().isEmpty()) {
                                int sizeInMBInstance;
                                sizeInMBInstance = DatatypeConverter.parseInt(sizeInMBElement.getTextContent());
                                localResourceInstance.setSizeInMB(sizeInMBInstance);
                            }
                        }
                    }

                    Element blockRoleUponFailureElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "BlockRoleUponFailure");
                    if (blockRoleUponFailureElement != null
                            && blockRoleUponFailureElement.getTextContent() != null
                            && !blockRoleUponFailureElement.getTextContent().isEmpty()) {
                        boolean blockRoleUponFailureInstance;
                        blockRoleUponFailureInstance = DatatypeConverter
                                .parseBoolean(blockRoleUponFailureElement.getTextContent().toLowerCase());
                        extensionImageInstance.setBlockRoleUponFailure(blockRoleUponFailureInstance);
                    }

                    Element isInternalExtensionElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "IsInternalExtension");
                    if (isInternalExtensionElement != null
                            && isInternalExtensionElement.getTextContent() != null
                            && !isInternalExtensionElement.getTextContent().isEmpty()) {
                        boolean isInternalExtensionInstance;
                        isInternalExtensionInstance = DatatypeConverter
                                .parseBoolean(isInternalExtensionElement.getTextContent().toLowerCase());
                        extensionImageInstance.setIsInternalExtension(isInternalExtensionInstance);
                    }

                    Element sampleConfigElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "SampleConfig");
                    if (sampleConfigElement != null) {
                        String sampleConfigInstance;
                        sampleConfigInstance = sampleConfigElement.getTextContent() != null
                                ? new String(Base64.decode(sampleConfigElement.getTextContent()))
                                : null;
                        extensionImageInstance.setSampleConfig(sampleConfigInstance);
                    }

                    Element replicationCompletedElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "ReplicationCompleted");
                    if (replicationCompletedElement != null
                            && replicationCompletedElement.getTextContent() != null
                            && !replicationCompletedElement.getTextContent().isEmpty()) {
                        boolean replicationCompletedInstance;
                        replicationCompletedInstance = DatatypeConverter
                                .parseBoolean(replicationCompletedElement.getTextContent().toLowerCase());
                        extensionImageInstance.setReplicationCompleted(replicationCompletedInstance);
                    }

                    Element eulaElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Eula");
                    if (eulaElement != null) {
                        URI eulaInstance;
                        eulaInstance = new URI(eulaElement.getTextContent());
                        extensionImageInstance.setEula(eulaInstance);
                    }

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

                    Element homepageUriElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "HomepageUri");
                    if (homepageUriElement != null) {
                        URI homepageUriInstance;
                        homepageUriInstance = new URI(homepageUriElement.getTextContent());
                        extensionImageInstance.setHomepageUri(homepageUriInstance);
                    }

                    Element isJsonExtensionElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IsJsonExtension");
                    if (isJsonExtensionElement != null && isJsonExtensionElement.getTextContent() != null
                            && !isJsonExtensionElement.getTextContent().isEmpty()) {
                        boolean isJsonExtensionInstance;
                        isJsonExtensionInstance = DatatypeConverter
                                .parseBoolean(isJsonExtensionElement.getTextContent().toLowerCase());
                        extensionImageInstance.setIsJsonExtension(isJsonExtensionInstance);
                    }

                    Element disallowMajorVersionUpgradeElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "DisallowMajorVersionUpgrade");
                    if (disallowMajorVersionUpgradeElement != null
                            && disallowMajorVersionUpgradeElement.getTextContent() != null
                            && !disallowMajorVersionUpgradeElement.getTextContent().isEmpty()) {
                        boolean disallowMajorVersionUpgradeInstance;
                        disallowMajorVersionUpgradeInstance = DatatypeConverter.parseBoolean(
                                disallowMajorVersionUpgradeElement.getTextContent().toLowerCase());
                        extensionImageInstance
                                .setDisallowMajorVersionUpgrade(disallowMajorVersionUpgradeInstance);
                    }

                    Element supportedOSElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "SupportedOS");
                    if (supportedOSElement != null) {
                        String supportedOSInstance;
                        supportedOSInstance = supportedOSElement.getTextContent();
                        extensionImageInstance.setSupportedOS(supportedOSInstance);
                    }

                    Element companyNameElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "CompanyName");
                    if (companyNameElement != null) {
                        String companyNameInstance;
                        companyNameInstance = companyNameElement.getTextContent();
                        extensionImageInstance.setCompanyName(companyNameInstance);
                    }

                    Element regionsElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Regions");
                    if (regionsElement != null) {
                        String regionsInstance;
                        regionsInstance = regionsElement.getTextContent();
                        extensionImageInstance.setRegions(regionsInstance);
                    }
                }
            }

        }
        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.websites.WebSiteOperationsImpl.java

/**
* You can update the settings for a web site by using the HTTP PUT method
* and by specifying the settings in the request body.  (see
* http://msdn.microsoft.com/en-us/library/windowsazure/dn167005.aspx for
* more information)//from   w ww .  ja  v  a  2s .co  m
*
* @param webSpaceName Required. The name of the web space.
* @param webSiteName Required. The name of the web site.
* @param parameters Required. Parameters supplied to the Update Web Site
* 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.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return The Update Web Site operation response.
*/
@Override
public WebSiteUpdateResponse update(String webSpaceName, String webSiteName, WebSiteUpdateParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException,
        URISyntaxException {
    // Validate
    if (webSpaceName == null) {
        throw new NullPointerException("webSpaceName");
    }
    if (webSiteName == null) {
        throw new NullPointerException("webSiteName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getHostNameSslStates() != null) {
        for (WebSiteUpdateParameters.WebSiteHostNameSslState hostNameSslStatesParameterItem : parameters
                .getHostNameSslStates()) {
            if (hostNameSslStatesParameterItem.getName() == null) {
                throw new NullPointerException("parameters.HostNameSslStates.Name");
            }
            if (hostNameSslStatesParameterItem.getSslState() == null) {
                throw new NullPointerException("parameters.HostNameSslStates.SslState");
            }
        }
    }

    // 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("webSpaceName", webSpaceName);
        tracingParameters.put("webSiteName", webSiteName);
        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/WebSpaces/";
    url = url + URLEncoder.encode(webSpaceName, "UTF-8");
    url = url + "/sites/";
    url = url + URLEncoder.encode(webSiteName, "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", "2014-04-01");

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

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

    if (parameters.getHostNameSslStates() != null) {
        if (parameters.getHostNameSslStates() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getHostNameSslStates()).isInitialized()) {
            Element hostNameSslStatesSequenceElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "HostNameSslStates");
            for (WebSiteUpdateParameters.WebSiteHostNameSslState hostNameSslStatesItem : parameters
                    .getHostNameSslStates()) {
                Element webSiteHostNameSslStateElement = requestDoc.createElementNS(
                        "http://schemas.microsoft.com/windowsazure", "WebSiteHostNameSslState");
                hostNameSslStatesSequenceElement.appendChild(webSiteHostNameSslStateElement);

                Element nameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                        "Name");
                nameElement.appendChild(requestDoc.createTextNode(hostNameSslStatesItem.getName()));
                webSiteHostNameSslStateElement.appendChild(nameElement);

                Element sslStateElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/windowsazure", "SslState");
                sslStateElement
                        .appendChild(requestDoc.createTextNode(hostNameSslStatesItem.getSslState().toString()));
                webSiteHostNameSslStateElement.appendChild(sslStateElement);

                if (hostNameSslStatesItem.getThumbprint() != null) {
                    Element thumbprintElement = requestDoc
                            .createElementNS("http://schemas.microsoft.com/windowsazure", "Thumbprint");
                    thumbprintElement
                            .appendChild(requestDoc.createTextNode(hostNameSslStatesItem.getThumbprint()));
                    webSiteHostNameSslStateElement.appendChild(thumbprintElement);
                } else {
                    Element emptyElement = requestDoc
                            .createElementNS("http://schemas.microsoft.com/windowsazure", "Thumbprint");
                    Attr nilAttribute = requestDoc
                            .createAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "nil");
                    nilAttribute.setValue("true");
                    emptyElement.setAttributeNode(nilAttribute);
                    webSiteHostNameSslStateElement.appendChild(emptyElement);
                }

                Element toUpdateElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/windowsazure", "ToUpdate");
                toUpdateElement.appendChild(requestDoc.createTextNode("true"));
                webSiteHostNameSslStateElement.appendChild(toUpdateElement);
            }
            siteElement.appendChild(hostNameSslStatesSequenceElement);
        }
    }

    if (parameters.getHostNames() != null) {
        if (parameters.getHostNames() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getHostNames()).isInitialized()) {
            Element hostNamesSequenceElement = requestDoc
                    .createElementNS("http://schemas.microsoft.com/windowsazure", "HostNames");
            for (String hostNamesItem : parameters.getHostNames()) {
                Element hostNamesItemElement = requestDoc
                        .createElementNS("http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string");
                hostNamesItemElement.appendChild(requestDoc.createTextNode(hostNamesItem));
                hostNamesSequenceElement.appendChild(hostNamesItemElement);
            }
            siteElement.appendChild(hostNamesSequenceElement);
        }
    }

    if (parameters.getServerFarm() != null) {
        Element serverFarmElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
                "ServerFarm");
        serverFarmElement.appendChild(requestDoc.createTextNode(parameters.getServerFarm()));
        siteElement.appendChild(serverFarmElement);
    }

    if (parameters.getState() != null) {
        Element stateElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "State");
        stateElement.appendChild(requestDoc.createTextNode(parameters.getState()));
        siteElement.appendChild(stateElement);
    }

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

            Element siteElement2 = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "Site");
            if (siteElement2 != null) {
                WebSite webSiteInstance = new WebSite();
                result.setWebSite(webSiteInstance);

                Element adminEnabledElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "AdminEnabled");
                if (adminEnabledElement != null && adminEnabledElement.getTextContent() != null
                        && !adminEnabledElement.getTextContent().isEmpty()) {
                    boolean adminEnabledInstance;
                    adminEnabledInstance = DatatypeConverter
                            .parseBoolean(adminEnabledElement.getTextContent().toLowerCase());
                    webSiteInstance.setAdminEnabled(adminEnabledInstance);
                }

                Element availabilityStateElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "AvailabilityState");
                if (availabilityStateElement != null && availabilityStateElement.getTextContent() != null
                        && !availabilityStateElement.getTextContent().isEmpty()) {
                    WebSpaceAvailabilityState availabilityStateInstance;
                    availabilityStateInstance = WebSpaceAvailabilityState
                            .valueOf(availabilityStateElement.getTextContent());
                    webSiteInstance.setAvailabilityState(availabilityStateInstance);
                }

                Element sKUElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "SKU");
                if (sKUElement != null && sKUElement.getTextContent() != null
                        && !sKUElement.getTextContent().isEmpty()) {
                    SkuOptions sKUInstance;
                    sKUInstance = SkuOptions.valueOf(sKUElement.getTextContent());
                    webSiteInstance.setSku(sKUInstance);
                }

                Element enabledElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "Enabled");
                if (enabledElement != null && enabledElement.getTextContent() != null
                        && !enabledElement.getTextContent().isEmpty()) {
                    boolean enabledInstance;
                    enabledInstance = DatatypeConverter
                            .parseBoolean(enabledElement.getTextContent().toLowerCase());
                    webSiteInstance.setEnabled(enabledInstance);
                }

                Element enabledHostNamesSequenceElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "EnabledHostNames");
                if (enabledHostNamesSequenceElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(enabledHostNamesSequenceElement,
                                    "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element enabledHostNamesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(enabledHostNamesSequenceElement,
                                        "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string")
                                .get(i1));
                        webSiteInstance.getEnabledHostNames().add(enabledHostNamesElement.getTextContent());
                    }
                }

                Element hostNameSslStatesSequenceElement2 = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "HostNameSslStates");
                if (hostNameSslStatesSequenceElement2 != null) {
                    for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(hostNameSslStatesSequenceElement2,
                                    "http://schemas.microsoft.com/windowsazure", "HostNameSslState")
                            .size(); i2 = i2 + 1) {
                        org.w3c.dom.Element hostNameSslStatesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(hostNameSslStatesSequenceElement2,
                                        "http://schemas.microsoft.com/windowsazure", "HostNameSslState")
                                .get(i2));
                        WebSite.WebSiteHostNameSslState hostNameSslStateInstance = new WebSite.WebSiteHostNameSslState();
                        webSiteInstance.getHostNameSslStates().add(hostNameSslStateInstance);

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

                        Element sslStateElement2 = XmlUtility.getElementByTagNameNS(hostNameSslStatesElement,
                                "http://schemas.microsoft.com/windowsazure", "SslState");
                        if (sslStateElement2 != null && sslStateElement2.getTextContent() != null
                                && !sslStateElement2.getTextContent().isEmpty()) {
                            WebSiteSslState sslStateInstance;
                            sslStateInstance = WebSiteSslState.valueOf(sslStateElement2.getTextContent());
                            hostNameSslStateInstance.setSslState(sslStateInstance);
                        }

                        Element thumbprintElement2 = XmlUtility.getElementByTagNameNS(hostNameSslStatesElement,
                                "http://schemas.microsoft.com/windowsazure", "Thumbprint");
                        if (thumbprintElement2 != null) {
                            boolean isNil = false;
                            Attr nilAttribute2 = thumbprintElement2
                                    .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil");
                            if (nilAttribute2 != null) {
                                isNil = "true".equals(nilAttribute2.getValue());
                            }
                            if (isNil == false) {
                                String thumbprintInstance;
                                thumbprintInstance = thumbprintElement2.getTextContent();
                                hostNameSslStateInstance.setThumbprint(thumbprintInstance);
                            }
                        }

                        Element virtualIPElement = XmlUtility.getElementByTagNameNS(hostNameSslStatesElement,
                                "http://schemas.microsoft.com/windowsazure", "VirtualIP");
                        if (virtualIPElement != null) {
                            boolean isNil2 = false;
                            Attr nilAttribute3 = virtualIPElement
                                    .getAttributeNodeNS("http://www.w3.org/2001/XMLSchema-instance", "nil");
                            if (nilAttribute3 != null) {
                                isNil2 = "true".equals(nilAttribute3.getValue());
                            }
                            if (isNil2 == false) {
                                InetAddress virtualIPInstance;
                                virtualIPInstance = InetAddress.getByName(virtualIPElement.getTextContent());
                                hostNameSslStateInstance.setVirtualIP(virtualIPInstance);
                            }
                        }
                    }
                }

                Element hostNamesSequenceElement2 = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "HostNames");
                if (hostNamesSequenceElement2 != null) {
                    for (int i3 = 0; i3 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(hostNamesSequenceElement2,
                                    "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string")
                            .size(); i3 = i3 + 1) {
                        org.w3c.dom.Element hostNamesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(hostNamesSequenceElement2,
                                        "http://schemas.microsoft.com/2003/10/Serialization/Arrays", "string")
                                .get(i3));
                        webSiteInstance.getHostNames().add(hostNamesElement.getTextContent());
                    }
                }

                Element lastModifiedTimeUtcElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "LastModifiedTimeUtc");
                if (lastModifiedTimeUtcElement != null && lastModifiedTimeUtcElement.getTextContent() != null
                        && !lastModifiedTimeUtcElement.getTextContent().isEmpty()) {
                    Calendar lastModifiedTimeUtcInstance;
                    lastModifiedTimeUtcInstance = DatatypeConverter
                            .parseDateTime(lastModifiedTimeUtcElement.getTextContent());
                    webSiteInstance.setLastModifiedTimeUtc(lastModifiedTimeUtcInstance);
                }

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

                Element repositorySiteNameElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "RepositorySiteName");
                if (repositorySiteNameElement != null) {
                    String repositorySiteNameInstance;
                    repositorySiteNameInstance = repositorySiteNameElement.getTextContent();
                    webSiteInstance.setRepositorySiteName(repositorySiteNameInstance);
                }

                Element runtimeAvailabilityStateElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "RuntimeAvailabilityState");
                if (runtimeAvailabilityStateElement != null
                        && runtimeAvailabilityStateElement.getTextContent() != null
                        && !runtimeAvailabilityStateElement.getTextContent().isEmpty()) {
                    WebSiteRuntimeAvailabilityState runtimeAvailabilityStateInstance;
                    runtimeAvailabilityStateInstance = WebSiteRuntimeAvailabilityState
                            .valueOf(runtimeAvailabilityStateElement.getTextContent());
                    webSiteInstance.setRuntimeAvailabilityState(runtimeAvailabilityStateInstance);
                }

                Element selfLinkElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "SelfLink");
                if (selfLinkElement != null) {
                    URI selfLinkInstance;
                    selfLinkInstance = new URI(selfLinkElement.getTextContent());
                    webSiteInstance.setUri(selfLinkInstance);
                }

                Element serverFarmElement2 = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "ServerFarm");
                if (serverFarmElement2 != null) {
                    String serverFarmInstance;
                    serverFarmInstance = serverFarmElement2.getTextContent();
                    webSiteInstance.setServerFarm(serverFarmInstance);
                }

                Element sitePropertiesElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "SiteProperties");
                if (sitePropertiesElement != null) {
                    WebSite.WebSiteProperties sitePropertiesInstance = new WebSite.WebSiteProperties();
                    webSiteInstance.setSiteProperties(sitePropertiesInstance);

                    Element appSettingsSequenceElement = XmlUtility.getElementByTagNameNS(sitePropertiesElement,
                            "http://schemas.microsoft.com/windowsazure", "AppSettings");
                    if (appSettingsSequenceElement != null) {
                        for (int i4 = 0; i4 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(appSettingsSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "NameValuePair")
                                .size(); i4 = i4 + 1) {
                            org.w3c.dom.Element appSettingsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(appSettingsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "NameValuePair")
                                    .get(i4));
                            String appSettingsKey = XmlUtility
                                    .getElementByTagNameNS(appSettingsElement,
                                            "http://schemas.microsoft.com/windowsazure", "Name")
                                    .getTextContent();
                            String appSettingsValue = XmlUtility
                                    .getElementByTagNameNS(appSettingsElement,
                                            "http://schemas.microsoft.com/windowsazure", "Value")
                                    .getTextContent();
                            sitePropertiesInstance.getAppSettings().put(appSettingsKey, appSettingsValue);
                        }
                    }

                    Element metadataSequenceElement = XmlUtility.getElementByTagNameNS(sitePropertiesElement,
                            "http://schemas.microsoft.com/windowsazure", "Metadata");
                    if (metadataSequenceElement != null) {
                        for (int i5 = 0; i5 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(metadataSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "NameValuePair")
                                .size(); i5 = i5 + 1) {
                            org.w3c.dom.Element metadataElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(metadataSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "NameValuePair")
                                    .get(i5));
                            String metadataKey = XmlUtility
                                    .getElementByTagNameNS(metadataElement,
                                            "http://schemas.microsoft.com/windowsazure", "Name")
                                    .getTextContent();
                            String metadataValue = XmlUtility
                                    .getElementByTagNameNS(metadataElement,
                                            "http://schemas.microsoft.com/windowsazure", "Value")
                                    .getTextContent();
                            sitePropertiesInstance.getMetadata().put(metadataKey, metadataValue);
                        }
                    }

                    Element propertiesSequenceElement = XmlUtility.getElementByTagNameNS(sitePropertiesElement,
                            "http://schemas.microsoft.com/windowsazure", "Properties");
                    if (propertiesSequenceElement != null) {
                        for (int i6 = 0; i6 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(propertiesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "NameValuePair")
                                .size(); i6 = i6 + 1) {
                            org.w3c.dom.Element propertiesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(propertiesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "NameValuePair")
                                    .get(i6));
                            String propertiesKey = XmlUtility
                                    .getElementByTagNameNS(propertiesElement,
                                            "http://schemas.microsoft.com/windowsazure", "Name")
                                    .getTextContent();
                            String propertiesValue = XmlUtility
                                    .getElementByTagNameNS(propertiesElement,
                                            "http://schemas.microsoft.com/windowsazure", "Value")
                                    .getTextContent();
                            sitePropertiesInstance.getProperties().put(propertiesKey, propertiesValue);
                        }
                    }
                }

                Element stateElement2 = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "State");
                if (stateElement2 != null) {
                    String stateInstance;
                    stateInstance = stateElement2.getTextContent();
                    webSiteInstance.setState(stateInstance);
                }

                Element usageStateElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "UsageState");
                if (usageStateElement != null && usageStateElement.getTextContent() != null
                        && !usageStateElement.getTextContent().isEmpty()) {
                    WebSiteUsageState usageStateInstance;
                    usageStateInstance = WebSiteUsageState.valueOf(usageStateElement.getTextContent());
                    webSiteInstance.setUsageState(usageStateInstance);
                }

                Element webSpaceElement = XmlUtility.getElementByTagNameNS(siteElement2,
                        "http://schemas.microsoft.com/windowsazure", "WebSpace");
                if (webSpaceElement != null) {
                    String webSpaceInstance;
                    webSpaceInstance = webSpaceElement.getTextContent();
                    webSiteInstance.setWebSpace(webSpaceInstance);
                }
            }

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

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

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

/**
* The List Connections operation returns a list of the local network
* connections that can be accessed through the gateway.  (see
* http://msdn.microsoft.com/en-us/library/windowsazure/jj154120.aspx for
* more information)/*from   w w w.j  ava  2  s .c  o  m*/
*
* @param networkName Required. The name of the virtual network for this
* gateway.
* @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 The response to a ListConnections request to a Virtual Network
* Gateway.
*/
@Override
public GatewayListConnectionsResponse listConnections(String networkName)
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate
    if (networkName == null) {
        throw new NullPointerException("networkName");
    }

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

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/networking/";
    url = url + URLEncoder.encode(networkName, "UTF-8");
    url = url + "/gateway/connections";
    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
        GatewayListConnectionsResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new GatewayListConnectionsResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element connectionsSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "Connections");
            if (connectionsSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(connectionsSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "Connection")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element connectionsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(connectionsSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "Connection")
                            .get(i1));
                    GatewayListConnectionsResponse.GatewayConnection connectionInstance = new GatewayListConnectionsResponse.GatewayConnection();
                    result.getConnections().add(connectionInstance);

                    Element localNetworkSiteNameElement = XmlUtility.getElementByTagNameNS(connectionsElement,
                            "http://schemas.microsoft.com/windowsazure", "LocalNetworkSiteName");
                    if (localNetworkSiteNameElement != null) {
                        String localNetworkSiteNameInstance;
                        localNetworkSiteNameInstance = localNetworkSiteNameElement.getTextContent();
                        connectionInstance.setLocalNetworkSiteName(localNetworkSiteNameInstance);
                    }

                    Element connectivityStateElement = XmlUtility.getElementByTagNameNS(connectionsElement,
                            "http://schemas.microsoft.com/windowsazure", "ConnectivityState");
                    if (connectivityStateElement != null && connectivityStateElement.getTextContent() != null
                            && !connectivityStateElement.getTextContent().isEmpty()) {
                        GatewayConnectivityState connectivityStateInstance;
                        connectivityStateInstance = GatewayConnectivityState
                                .valueOf(connectivityStateElement.getTextContent());
                        connectionInstance.setConnectivityState(connectivityStateInstance);
                    }

                    Element lastEventElement = XmlUtility.getElementByTagNameNS(connectionsElement,
                            "http://schemas.microsoft.com/windowsazure", "LastEvent");
                    if (lastEventElement != null) {
                        GatewayEvent lastEventInstance = new GatewayEvent();
                        connectionInstance.setLastEvent(lastEventInstance);

                        Element timestampElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Timestamp");
                        if (timestampElement != null) {
                            Calendar timestampInstance;
                            timestampInstance = DatatypeConverter
                                    .parseDateTime(timestampElement.getTextContent());
                            lastEventInstance.setTimestamp(timestampInstance);
                        }

                        Element idElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Id");
                        if (idElement != null) {
                            String idInstance;
                            idInstance = idElement.getTextContent();
                            lastEventInstance.setId(idInstance);
                        }

                        Element messageElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Message");
                        if (messageElement != null) {
                            String messageInstance;
                            messageInstance = messageElement.getTextContent();
                            lastEventInstance.setMessage(messageInstance);
                        }

                        Element dataElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Data");
                        if (dataElement != null) {
                            String dataInstance;
                            dataInstance = dataElement.getTextContent();
                            lastEventInstance.setData(dataInstance);
                        }
                    }

                    Element ingressBytesTransferredElement = XmlUtility.getElementByTagNameNS(
                            connectionsElement, "http://schemas.microsoft.com/windowsazure",
                            "IngressBytesTransferred");
                    if (ingressBytesTransferredElement != null) {
                        long ingressBytesTransferredInstance;
                        ingressBytesTransferredInstance = DatatypeConverter
                                .parseLong(ingressBytesTransferredElement.getTextContent());
                        connectionInstance.setIngressBytesTransferred(ingressBytesTransferredInstance);
                    }

                    Element egressBytesTransferredElement = XmlUtility.getElementByTagNameNS(connectionsElement,
                            "http://schemas.microsoft.com/windowsazure", "EgressBytesTransferred");
                    if (egressBytesTransferredElement != null) {
                        long egressBytesTransferredInstance;
                        egressBytesTransferredInstance = DatatypeConverter
                                .parseLong(egressBytesTransferredElement.getTextContent());
                        connectionInstance.setEgressBytesTransferred(egressBytesTransferredInstance);
                    }

                    Element lastConnectionEstablishedElement = XmlUtility.getElementByTagNameNS(
                            connectionsElement, "http://schemas.microsoft.com/windowsazure",
                            "LastConnectionEstablished");
                    if (lastConnectionEstablishedElement != null) {
                        Calendar lastConnectionEstablishedInstance;
                        lastConnectionEstablishedInstance = DatatypeConverter
                                .parseDateTime(lastConnectionEstablishedElement.getTextContent());
                        connectionInstance.setLastConnectionEstablished(lastConnectionEstablishedInstance);
                    }

                    Element allocatedIPAddressesSequenceElement = XmlUtility.getElementByTagNameNS(
                            connectionsElement, "http://schemas.microsoft.com/windowsazure",
                            "AllocatedIPAddresses");
                    if (allocatedIPAddressesSequenceElement != null) {
                        for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(allocatedIPAddressesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "string")
                                .size(); i2 = i2 + 1) {
                            org.w3c.dom.Element allocatedIPAddressesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(allocatedIPAddressesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "string")
                                    .get(i2));
                            connectionInstance.getAllocatedIPAddresses()
                                    .add(allocatedIPAddressesElement.getTextContent());
                        }
                    }
                }
            }

        }
        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.websites.WebSiteOperationsImpl.java

/**
* Returns list of all backups which are tracked by the system.
*
* @param resourceGroupName Required. The name of the resource group.
* @param webSiteName Required. The name of the web site.
* @param slotName Optional. The name of the slot.
* @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./* ww w  . j  a  v a2 s  . co m*/
* @throws ServiceException Thrown if an unexpected response is found.
* @return List of backups for the website.
*/
@Override
public WebSiteGetBackupsResponse listBackups(String resourceGroupName, String webSiteName, String slotName)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (webSiteName == null) {
        throw new NullPointerException("webSiteName");
    }

    // 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("webSiteName", webSiteName);
        tracingParameters.put("slotName", slotName);
        CloudTracing.enter(invocationId, this, "listBackupsAsync", 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.Web";
    url = url + "/";
    url = url + "sites";
    url = url + "/";
    url = url + URLEncoder.encode(webSiteName, "UTF-8");
    if (slotName != null) {
        url = url + "/slots/" + URLEncoder.encode(slotName, "UTF-8");
    }
    url = url + "/restore";
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2014-06-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
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers
    httpRequest.setHeader("x-ms-version", "2014-06-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.createFromJson(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        WebSiteGetBackupsResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new WebSiteGetBackupsResponse();
            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) {
                BackupItemsEnvelope backupListInstance = new BackupItemsEnvelope();
                result.setBackupList(backupListInstance);

                JsonNode propertiesArray = responseDoc.get("properties");
                if (propertiesArray != null && propertiesArray instanceof NullNode == false) {
                    for (JsonNode propertiesValue : ((ArrayNode) propertiesArray)) {
                        BackupItem backupItemInstance = new BackupItem();
                        backupListInstance.getProperties().add(backupItemInstance);

                        JsonNode storageAccountUrlValue = propertiesValue.get("storageAccountUrl");
                        if (storageAccountUrlValue != null
                                && storageAccountUrlValue instanceof NullNode == false) {
                            String storageAccountUrlInstance;
                            storageAccountUrlInstance = storageAccountUrlValue.getTextValue();
                            backupItemInstance.setStorageAccountUrl(storageAccountUrlInstance);
                        }

                        JsonNode blobNameValue = propertiesValue.get("blobName");
                        if (blobNameValue != null && blobNameValue instanceof NullNode == false) {
                            String blobNameInstance;
                            blobNameInstance = blobNameValue.getTextValue();
                            backupItemInstance.setBlobName(blobNameInstance);
                        }

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

                        JsonNode statusValue = propertiesValue.get("status");
                        if (statusValue != null && statusValue instanceof NullNode == false) {
                            BackupItemStatus statusInstance;
                            statusInstance = Enum.valueOf(BackupItemStatus.class, statusValue.getTextValue());
                            backupItemInstance.setStatus(statusInstance);
                        }

                        JsonNode sizeInBytesValue = propertiesValue.get("sizeInBytes");
                        if (sizeInBytesValue != null && sizeInBytesValue instanceof NullNode == false) {
                            long sizeInBytesInstance;
                            sizeInBytesInstance = sizeInBytesValue.getLongValue();
                            backupItemInstance.setSizeInBytes(sizeInBytesInstance);
                        }

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

                        JsonNode logValue = propertiesValue.get("log");
                        if (logValue != null && logValue instanceof NullNode == false) {
                            String logInstance;
                            logInstance = logValue.getTextValue();
                            backupItemInstance.setLog(logInstance);
                        }

                        JsonNode databasesArray = propertiesValue.get("databases");
                        if (databasesArray != null && databasesArray instanceof NullNode == false) {
                            for (JsonNode databasesValue : ((ArrayNode) databasesArray)) {
                                DatabaseBackupSetting databaseBackupSettingInstance = new DatabaseBackupSetting();
                                backupItemInstance.getDatabases().add(databaseBackupSettingInstance);

                                JsonNode connectionStringValue = databasesValue.get("connectionString");
                                if (connectionStringValue != null
                                        && connectionStringValue instanceof NullNode == false) {
                                    String connectionStringInstance;
                                    connectionStringInstance = connectionStringValue.getTextValue();
                                    databaseBackupSettingInstance.setConnectionString(connectionStringInstance);
                                }

                                JsonNode connectionStringNameValue = databasesValue.get("connectionStringName");
                                if (connectionStringNameValue != null
                                        && connectionStringNameValue instanceof NullNode == false) {
                                    String connectionStringNameInstance;
                                    connectionStringNameInstance = connectionStringNameValue.getTextValue();
                                    databaseBackupSettingInstance
                                            .setConnectionStringName(connectionStringNameInstance);
                                }

                                JsonNode databaseTypeValue = databasesValue.get("databaseType");
                                if (databaseTypeValue != null
                                        && databaseTypeValue instanceof NullNode == false) {
                                    String databaseTypeInstance;
                                    databaseTypeInstance = databaseTypeValue.getTextValue();
                                    databaseBackupSettingInstance.setDatabaseType(databaseTypeInstance);
                                }

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

                        JsonNode scheduledValue = propertiesValue.get("scheduled");
                        if (scheduledValue != null && scheduledValue instanceof NullNode == false) {
                            boolean scheduledInstance;
                            scheduledInstance = scheduledValue.getBooleanValue();
                            backupItemInstance.setScheduled(scheduledInstance);
                        }

                        JsonNode lastRestoreTimeStampValue = propertiesValue.get("lastRestoreTimeStamp");
                        if (lastRestoreTimeStampValue != null
                                && lastRestoreTimeStampValue instanceof NullNode == false) {
                            Calendar lastRestoreTimeStampInstance;
                            lastRestoreTimeStampInstance = DatatypeConverter
                                    .parseDateTime(lastRestoreTimeStampValue.getTextValue());
                            backupItemInstance.setLastRestoreTimeStamp(lastRestoreTimeStampInstance);
                        }

                        JsonNode finishedTimeStampValue = propertiesValue.get("finishedTimeStamp");
                        if (finishedTimeStampValue != null
                                && finishedTimeStampValue instanceof NullNode == false) {
                            Calendar finishedTimeStampInstance;
                            finishedTimeStampInstance = DatatypeConverter
                                    .parseDateTime(finishedTimeStampValue.getTextValue());
                            backupItemInstance.setFinishedTimeStamp(finishedTimeStampInstance);
                        }

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

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

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

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

                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();
                        backupListInstance.getTags().put(tagsKey, tagsValue);
                    }
                }

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

        }
        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.RecommendedElasticPoolOperationsImpl.java

/**
* Returns information about Azure SQL Recommended Elastic Pools.
*
* @param resourceGroupName Required. The name of the Resource Group to
* which the Azure SQL Recommended Serve belongs.
* @param serverName Required. The name of the Azure SQL Database Server in
* which Azure SQL Recommended Elastic Pools are hosted.
* @param expand Required. The comma separated list of child objects that we
* want to expand on in response./*from  w  w w  . j  av  a2 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.
* @return Represents the response to a List Azure Sql Recommended Elastic
* Pool request.
*/
@Override
public RecommendedElasticPoolListResponse listExpanded(String resourceGroupName, String serverName,
        String expand) throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (serverName == null) {
        throw new NullPointerException("serverName");
    }
    if (expand == null) {
        throw new NullPointerException("expand");
    }

    // 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("expand", expand);
        CloudTracing.enter(invocationId, this, "listExpandedAsync", 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 + "/recommendedElasticPools";
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2014-04-01");
    queryParameters.add("$expand=" + URLEncoder.encode(expand, "UTF-8"));
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

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

    // Set Headers

    // 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
        RecommendedElasticPoolListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new RecommendedElasticPoolListResponse();
            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)) {
                        RecommendedElasticPool recommendedElasticPoolInstance = new RecommendedElasticPool();
                        result.getRecommendedElasticPools().add(recommendedElasticPoolInstance);

                        JsonNode propertiesValue = valueValue.get("properties");
                        if (propertiesValue != null && propertiesValue instanceof NullNode == false) {
                            RecommendedElasticPoolProperties propertiesInstance = new RecommendedElasticPoolProperties();
                            recommendedElasticPoolInstance.setProperties(propertiesInstance);

                            JsonNode databaseEditionValue = propertiesValue.get("databaseEdition");
                            if (databaseEditionValue != null
                                    && databaseEditionValue instanceof NullNode == false) {
                                String databaseEditionInstance;
                                databaseEditionInstance = databaseEditionValue.getTextValue();
                                propertiesInstance.setDatabaseEdition(databaseEditionInstance);
                            }

                            JsonNode dtuValue = propertiesValue.get("dtu");
                            if (dtuValue != null && dtuValue instanceof NullNode == false) {
                                double dtuInstance;
                                dtuInstance = dtuValue.getDoubleValue();
                                propertiesInstance.setDtu(dtuInstance);
                            }

                            JsonNode databaseDtuMinValue = propertiesValue.get("databaseDtuMin");
                            if (databaseDtuMinValue != null
                                    && databaseDtuMinValue instanceof NullNode == false) {
                                double databaseDtuMinInstance;
                                databaseDtuMinInstance = databaseDtuMinValue.getDoubleValue();
                                propertiesInstance.setDatabaseDtuMin(databaseDtuMinInstance);
                            }

                            JsonNode databaseDtuMaxValue = propertiesValue.get("databaseDtuMax");
                            if (databaseDtuMaxValue != null
                                    && databaseDtuMaxValue instanceof NullNode == false) {
                                double databaseDtuMaxInstance;
                                databaseDtuMaxInstance = databaseDtuMaxValue.getDoubleValue();
                                propertiesInstance.setDatabaseDtuMax(databaseDtuMaxInstance);
                            }

                            JsonNode storageMBValue = propertiesValue.get("storageMB");
                            if (storageMBValue != null && storageMBValue instanceof NullNode == false) {
                                double storageMBInstance;
                                storageMBInstance = storageMBValue.getDoubleValue();
                                propertiesInstance.setStorageMB(storageMBInstance);
                            }

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

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

                            JsonNode maxObservedDtuValue = propertiesValue.get("maxObservedDtu");
                            if (maxObservedDtuValue != null
                                    && maxObservedDtuValue instanceof NullNode == false) {
                                double maxObservedDtuInstance;
                                maxObservedDtuInstance = maxObservedDtuValue.getDoubleValue();
                                propertiesInstance.setMaxObservedDtu(maxObservedDtuInstance);
                            }

                            JsonNode maxObservedStorageMBValue = propertiesValue.get("maxObservedStorageMB");
                            if (maxObservedStorageMBValue != null
                                    && maxObservedStorageMBValue instanceof NullNode == false) {
                                double maxObservedStorageMBInstance;
                                maxObservedStorageMBInstance = maxObservedStorageMBValue.getDoubleValue();
                                propertiesInstance.setMaxObservedStorageMB(maxObservedStorageMBInstance);
                            }

                            JsonNode databasesArray = propertiesValue.get("databases");
                            if (databasesArray != null && databasesArray instanceof NullNode == false) {
                                for (JsonNode databasesValue : ((ArrayNode) databasesArray)) {
                                    Database databaseInstance = new Database();
                                    propertiesInstance.getDatabases().add(databaseInstance);

                                    JsonNode propertiesValue2 = databasesValue.get("properties");
                                    if (propertiesValue2 != null
                                            && propertiesValue2 instanceof NullNode == false) {
                                        DatabaseProperties propertiesInstance2 = new DatabaseProperties();
                                        databaseInstance.setProperties(propertiesInstance2);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                    JsonNode observationPeriodStartValue2 = propertiesValue3
                                                            .get("observationPeriodStart");
                                                    if (observationPeriodStartValue2 != null
                                                            && observationPeriodStartValue2 instanceof NullNode == false) {
                                                        Calendar observationPeriodStartInstance2;
                                                        observationPeriodStartInstance2 = DatatypeConverter
                                                                .parseDateTime(observationPeriodStartValue2
                                                                        .getTextValue());
                                                        propertiesInstance3.setObservationPeriodStart(
                                                                observationPeriodStartInstance2);
                                                    }

                                                    JsonNode observationPeriodEndValue2 = propertiesValue3
                                                            .get("observationPeriodEnd");
                                                    if (observationPeriodEndValue2 != null
                                                            && observationPeriodEndValue2 instanceof NullNode == false) {
                                                        Calendar observationPeriodEndInstance2;
                                                        observationPeriodEndInstance2 = DatatypeConverter
                                                                .parseDateTime(observationPeriodEndValue2
                                                                        .getTextValue());
                                                        propertiesInstance3.setObservationPeriodEnd(
                                                                observationPeriodEndInstance2);
                                                    }

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

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

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

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

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

                                                    JsonNode serviceLevelObjectiveUsageMetricsArray = propertiesValue3
                                                            .get("serviceLevelObjectiveUsageMetrics");
                                                    if (serviceLevelObjectiveUsageMetricsArray != null
                                                            && serviceLevelObjectiveUsageMetricsArray instanceof NullNode == false) {
                                                        for (JsonNode serviceLevelObjectiveUsageMetricsValue : ((ArrayNode) serviceLevelObjectiveUsageMetricsArray)) {
                                                            SloUsageMetric sloUsageMetricInstance = new SloUsageMetric();
                                                            propertiesInstance3
                                                                    .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 = propertiesValue3
                                                            .get("currentServiceLevelObjective");
                                                    if (currentServiceLevelObjectiveValue != null
                                                            && currentServiceLevelObjectiveValue instanceof NullNode == false) {
                                                        String currentServiceLevelObjectiveInstance;
                                                        currentServiceLevelObjectiveInstance = currentServiceLevelObjectiveValue
                                                                .getTextValue();
                                                        propertiesInstance3.setCurrentServiceLevelObjective(
                                                                currentServiceLevelObjectiveInstance);
                                                    }

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

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

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

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

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

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

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

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

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

                                                    JsonNode confidenceValue = propertiesValue3
                                                            .get("confidence");
                                                    if (confidenceValue != null
                                                            && confidenceValue instanceof NullNode == false) {
                                                        double confidenceInstance;
                                                        confidenceInstance = confidenceValue.getDoubleValue();
                                                        propertiesInstance3.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 = propertiesValue2.get("upgradeHint");
                                        if (upgradeHintValue != null
                                                && upgradeHintValue instanceof NullNode == false) {
                                            UpgradeHint upgradeHintInstance = new UpgradeHint();
                                            propertiesInstance2.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 = propertiesValue2.get("schemas");
                                        if (schemasArray != null && schemasArray instanceof NullNode == false) {
                                            for (JsonNode schemasValue : ((ArrayNode) schemasArray)) {
                                                Schema schemaInstance = new Schema();
                                                propertiesInstance2.getSchemas().add(schemaInstance);

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

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

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

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

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

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

                                                                            JsonNode columnTypeValue = propertiesValue6
                                                                                    .get("columnType");
                                                                            if (columnTypeValue != null
                                                                                    && columnTypeValue instanceof NullNode == false) {
                                                                                String columnTypeInstance;
                                                                                columnTypeInstance = columnTypeValue
                                                                                        .getTextValue();
                                                                                propertiesInstance6
                                                                                        .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 = propertiesValue5
                                                                        .get("recommendedIndexes");
                                                                if (recommendedIndexesArray != null
                                                                        && recommendedIndexesArray instanceof NullNode == false) {
                                                                    for (JsonNode recommendedIndexesValue : ((ArrayNode) recommendedIndexesArray)) {
                                                                        RecommendedIndex recommendedIndexInstance = new RecommendedIndex();
                                                                        propertiesInstance5
                                                                                .getRecommendedIndexes()
                                                                                .add(recommendedIndexInstance);

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

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

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

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

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

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

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

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

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

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

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

                                                                            JsonNode estimatedImpactArray = propertiesValue7
                                                                                    .get("estimatedImpact");
                                                                            if (estimatedImpactArray != null
                                                                                    && estimatedImpactArray instanceof NullNode == false) {
                                                                                for (JsonNode estimatedImpactValue : ((ArrayNode) estimatedImpactArray)) {
                                                                                    OperationImpact operationImpactInstance = new OperationImpact();
                                                                                    propertiesInstance7
                                                                                            .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 = propertiesValue7
                                                                                    .get("reportedImpact");
                                                                            if (reportedImpactArray != null
                                                                                    && reportedImpactArray instanceof NullNode == false) {
                                                                                for (JsonNode reportedImpactValue : ((ArrayNode) reportedImpactArray)) {
                                                                                    OperationImpact operationImpactInstance2 = new OperationImpact();
                                                                                    propertiesInstance7
                                                                                            .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 = propertiesValue2
                                                .get("defaultSecondaryLocation");
                                        if (defaultSecondaryLocationValue != null
                                                && defaultSecondaryLocationValue instanceof NullNode == false) {
                                            String defaultSecondaryLocationInstance;
                                            defaultSecondaryLocationInstance = defaultSecondaryLocationValue
                                                    .getTextValue();
                                            propertiesInstance2.setDefaultSecondaryLocation(
                                                    defaultSecondaryLocationInstance);
                                        }
                                    }

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

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

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

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

                                    JsonNode tagsSequenceElement8 = ((JsonNode) databasesValue.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);
                                        }
                                    }
                                }
                            }

                            JsonNode metricsArray = propertiesValue.get("metrics");
                            if (metricsArray != null && metricsArray instanceof NullNode == false) {
                                for (JsonNode metricsValue : ((ArrayNode) metricsArray)) {
                                    RecommendedElasticPoolMetric recommendedElasticPoolMetricInstance = new RecommendedElasticPoolMetric();
                                    propertiesInstance.getMetrics().add(recommendedElasticPoolMetricInstance);

                                    JsonNode dateTimeValue = metricsValue.get("dateTime");
                                    if (dateTimeValue != null && dateTimeValue instanceof NullNode == false) {
                                        Calendar dateTimeInstance;
                                        dateTimeInstance = DatatypeConverter
                                                .parseDateTime(dateTimeValue.getTextValue());
                                        recommendedElasticPoolMetricInstance.setDateTime(dateTimeInstance);
                                    }

                                    JsonNode dtuValue2 = metricsValue.get("dtu");
                                    if (dtuValue2 != null && dtuValue2 instanceof NullNode == false) {
                                        double dtuInstance2;
                                        dtuInstance2 = dtuValue2.getDoubleValue();
                                        recommendedElasticPoolMetricInstance.setDtu(dtuInstance2);
                                    }

                                    JsonNode sizeGBValue = metricsValue.get("sizeGB");
                                    if (sizeGBValue != null && sizeGBValue instanceof NullNode == false) {
                                        double sizeGBInstance;
                                        sizeGBInstance = sizeGBValue.getDoubleValue();
                                        recommendedElasticPoolMetricInstance.setSizeGB(sizeGBInstance);
                                    }
                                }
                            }
                        }

                        JsonNode idValue9 = valueValue.get("id");
                        if (idValue9 != null && idValue9 instanceof NullNode == false) {
                            String idInstance9;
                            idInstance9 = idValue9.getTextValue();
                            recommendedElasticPoolInstance.setId(idInstance9);
                        }

                        JsonNode nameValue11 = valueValue.get("name");
                        if (nameValue11 != null && nameValue11 instanceof NullNode == false) {
                            String nameInstance11;
                            nameInstance11 = nameValue11.getTextValue();
                            recommendedElasticPoolInstance.setName(nameInstance11);
                        }

                        JsonNode typeValue9 = valueValue.get("type");
                        if (typeValue9 != null && typeValue9 instanceof NullNode == false) {
                            String typeInstance9;
                            typeInstance9 = typeValue9.getTextValue();
                            recommendedElasticPoolInstance.setType(typeInstance9);
                        }

                        JsonNode locationValue9 = valueValue.get("location");
                        if (locationValue9 != null && locationValue9 instanceof NullNode == false) {
                            String locationInstance9;
                            locationInstance9 = locationValue9.getTextValue();
                            recommendedElasticPoolInstance.setLocation(locationInstance9);
                        }

                        JsonNode tagsSequenceElement9 = ((JsonNode) valueValue.get("tags"));
                        if (tagsSequenceElement9 != null && tagsSequenceElement9 instanceof NullNode == false) {
                            Iterator<Map.Entry<String, JsonNode>> itr9 = tagsSequenceElement9.getFields();
                            while (itr9.hasNext()) {
                                Map.Entry<String, JsonNode> property9 = itr9.next();
                                String tagsKey9 = property9.getKey();
                                String tagsValue9 = property9.getValue().getTextValue();
                                recommendedElasticPoolInstance.getTags().put(tagsKey9, tagsValue9);
                            }
                        }
                    }
                }
            }

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

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

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

/**
* The List Virtual network gateways operation returns a list of the virtual
* network gateways./*from   ww w.j av  a2s.  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.
* @return The response to a ListVirtualNetworkGateways request.
*/
@Override
public ListVirtualNetworkGatewaysResponse listVirtualNetworkGateways()
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // 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, "listVirtualNetworkGatewaysAsync", tracingParameters);
    }

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

    // Create HTTP transport objects
    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
        ListVirtualNetworkGatewaysResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new ListVirtualNetworkGatewaysResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element virtualNetworkGatewaysSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "VirtualNetworkGateways");
            if (virtualNetworkGatewaysSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(virtualNetworkGatewaysSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "VirtualNetworkGateway")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element virtualNetworkGatewaysElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(virtualNetworkGatewaysSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "VirtualNetworkGateway")
                            .get(i1));
                    ListVirtualNetworkGatewaysResponse.VirtualNetworkGateway virtualNetworkGatewayInstance = new ListVirtualNetworkGatewaysResponse.VirtualNetworkGateway();
                    result.getVirtualNetworkGateways().add(virtualNetworkGatewayInstance);

                    Element gatewayIdElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "GatewayId");
                    if (gatewayIdElement != null && gatewayIdElement.getTextContent() != null
                            && !gatewayIdElement.getTextContent().isEmpty()) {
                        String gatewayIdInstance;
                        gatewayIdInstance = gatewayIdElement.getTextContent();
                        virtualNetworkGatewayInstance.setGatewayId(gatewayIdInstance);
                    }

                    Element lastEventElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "LastEvent");
                    if (lastEventElement != null) {
                        GatewayEvent lastEventInstance = new GatewayEvent();
                        virtualNetworkGatewayInstance.setLastEvent(lastEventInstance);

                        Element timestampElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Timestamp");
                        if (timestampElement != null) {
                            Calendar timestampInstance;
                            timestampInstance = DatatypeConverter
                                    .parseDateTime(timestampElement.getTextContent());
                            lastEventInstance.setTimestamp(timestampInstance);
                        }

                        Element idElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Id");
                        if (idElement != null) {
                            String idInstance;
                            idInstance = idElement.getTextContent();
                            lastEventInstance.setId(idInstance);
                        }

                        Element messageElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Message");
                        if (messageElement != null) {
                            String messageInstance;
                            messageInstance = messageElement.getTextContent();
                            lastEventInstance.setMessage(messageInstance);
                        }

                        Element dataElement = XmlUtility.getElementByTagNameNS(lastEventElement,
                                "http://schemas.microsoft.com/windowsazure", "Data");
                        if (dataElement != null) {
                            String dataInstance;
                            dataInstance = dataElement.getTextContent();
                            lastEventInstance.setData(dataInstance);
                        }
                    }

                    Element gatewayNameElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "GatewayName");
                    if (gatewayNameElement != null) {
                        String gatewayNameInstance;
                        gatewayNameInstance = gatewayNameElement.getTextContent();
                        virtualNetworkGatewayInstance.setGatewayName(gatewayNameInstance);
                    }

                    Element gatewayTypeElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "GatewayType");
                    if (gatewayTypeElement != null) {
                        String gatewayTypeInstance;
                        gatewayTypeInstance = gatewayTypeElement.getTextContent();
                        virtualNetworkGatewayInstance.setGatewayType(gatewayTypeInstance);
                    }

                    Element gatewaySizeElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "GatewaySize");
                    if (gatewaySizeElement != null) {
                        String gatewaySizeInstance;
                        gatewaySizeInstance = gatewaySizeElement.getTextContent();
                        virtualNetworkGatewayInstance.setGatewaySKU(gatewaySizeInstance);
                    }

                    Element stateElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "State");
                    if (stateElement != null) {
                        String stateInstance;
                        stateInstance = stateElement.getTextContent();
                        virtualNetworkGatewayInstance.setState(stateInstance);
                    }

                    Element vIPAddressElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "VIPAddress");
                    if (vIPAddressElement != null) {
                        String vIPAddressInstance;
                        vIPAddressInstance = vIPAddressElement.getTextContent();
                        virtualNetworkGatewayInstance.setVipAddress(vIPAddressInstance);
                    }

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

                    Element vnetIdElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "VnetId");
                    if (vnetIdElement != null) {
                        String vnetIdInstance;
                        vnetIdInstance = vnetIdElement.getTextContent();
                        virtualNetworkGatewayInstance.setVnetId(vnetIdInstance);
                    }

                    Element subnetIdElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "SubnetId");
                    if (subnetIdElement != null) {
                        String subnetIdInstance;
                        subnetIdInstance = subnetIdElement.getTextContent();
                        virtualNetworkGatewayInstance.setSubnetId(subnetIdInstance);
                    }

                    Element defaultSitesElement = XmlUtility.getElementByTagNameNS(
                            virtualNetworkGatewaysElement, "http://schemas.microsoft.com/windowsazure",
                            "DefaultSites");
                    if (defaultSitesElement != null) {
                        GatewayDefaultSite defaultSitesInstance = new GatewayDefaultSite();
                        virtualNetworkGatewayInstance.setDefaultSite(defaultSitesInstance);

                        Element stringElement = XmlUtility.getElementByTagNameNS(defaultSitesElement,
                                "http://schemas.microsoft.com/windowsazure", "string");
                        if (stringElement != null) {
                            String stringInstance;
                            stringInstance = stringElement.getTextContent();
                            defaultSitesInstance.setName(stringInstance);
                        }
                    }

                    Element enableBgpElement = XmlUtility.getElementByTagNameNS(virtualNetworkGatewaysElement,
                            "http://schemas.microsoft.com/windowsazure", "EnableBgp");
                    if (enableBgpElement != null) {
                        boolean enableBgpInstance;
                        enableBgpInstance = DatatypeConverter
                                .parseBoolean(enableBgpElement.getTextContent().toLowerCase());
                        virtualNetworkGatewayInstance.setEnableBgp(enableBgpInstance);
                    }
                }
            }

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

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

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

/**
* The List Extension Versions operation lists the versions of an extension
* that are available to add to a cloud service. In Azure, a process can
* run as an extension of a cloud service. For example, Remote Desktop
* Access or the Azure Diagnostics Agent can run as extensions to the cloud
* service.  (see/* w w w  .j  a v a 2 s .c  o m*/
* http://msdn.microsoft.com/en-us/library/windowsazure/dn495437.aspx for
* more information)
*
* @param providerNamespace Required. The provider namespace.
* @param extensionType Required. The extension type name.
* @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 Available Extensions operation response.
*/
@Override
public HostedServiceListAvailableExtensionsResponse listExtensionVersions(String providerNamespace,
        String extensionType)
        throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException {
    // Validate
    if (providerNamespace == null) {
        throw new NullPointerException("providerNamespace");
    }
    if (extensionType == null) {
        throw new NullPointerException("extensionType");
    }

    // 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("providerNamespace", providerNamespace);
        tracingParameters.put("extensionType", extensionType);
        CloudTracing.enter(invocationId, this, "listExtensionVersionsAsync", 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/extensions/";
    url = url + URLEncoder.encode(providerNamespace, "UTF-8");
    url = url + "/";
    url = url + URLEncoder.encode(extensionType, "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("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
        HostedServiceListAvailableExtensionsResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new HostedServiceListAvailableExtensionsResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element extensionImagesSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "ExtensionImages");
            if (extensionImagesSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(extensionImagesSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "ExtensionImage")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element extensionImagesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(extensionImagesSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "ExtensionImage")
                            .get(i1));
                    ExtensionImage extensionImageInstance = new ExtensionImage();
                    result.getExtensionImages().add(extensionImageInstance);

                    Element providerNameSpaceElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "ProviderNameSpace");
                    if (providerNameSpaceElement != null) {
                        String providerNameSpaceInstance;
                        providerNameSpaceInstance = providerNameSpaceElement.getTextContent();
                        extensionImageInstance.setProviderNameSpace(providerNameSpaceInstance);
                    }

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

                    Element versionElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Version");
                    if (versionElement != null) {
                        String versionInstance;
                        versionInstance = versionElement.getTextContent();
                        extensionImageInstance.setVersion(versionInstance);
                    }

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

                    Element hostingResourcesElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "HostingResources");
                    if (hostingResourcesElement != null) {
                        String hostingResourcesInstance;
                        hostingResourcesInstance = hostingResourcesElement.getTextContent();
                        extensionImageInstance.setHostingResources(hostingResourcesInstance);
                    }

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

                    Element certificateElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Certificate");
                    if (certificateElement != null) {
                        ExtensionCertificateConfiguration certificateInstance = new ExtensionCertificateConfiguration();
                        extensionImageInstance.setCertificate(certificateInstance);

                        Element storeLocationElement = XmlUtility.getElementByTagNameNS(certificateElement,
                                "http://schemas.microsoft.com/windowsazure", "StoreLocation");
                        if (storeLocationElement != null) {
                            String storeLocationInstance;
                            storeLocationInstance = storeLocationElement.getTextContent();
                            certificateInstance.setStoreLocation(storeLocationInstance);
                        }

                        Element storeNameElement = XmlUtility.getElementByTagNameNS(certificateElement,
                                "http://schemas.microsoft.com/windowsazure", "StoreName");
                        if (storeNameElement != null) {
                            String storeNameInstance;
                            storeNameInstance = storeNameElement.getTextContent();
                            certificateInstance.setStoreName(storeNameInstance);
                        }

                        Element thumbprintRequiredElement = XmlUtility.getElementByTagNameNS(certificateElement,
                                "http://schemas.microsoft.com/windowsazure", "ThumbprintRequired");
                        if (thumbprintRequiredElement != null
                                && thumbprintRequiredElement.getTextContent() != null
                                && !thumbprintRequiredElement.getTextContent().isEmpty()) {
                            boolean thumbprintRequiredInstance;
                            thumbprintRequiredInstance = DatatypeConverter
                                    .parseBoolean(thumbprintRequiredElement.getTextContent().toLowerCase());
                            certificateInstance.setThumbprintRequired(thumbprintRequiredInstance);
                        }

                        Element thumbprintAlgorithmElement = XmlUtility.getElementByTagNameNS(
                                certificateElement, "http://schemas.microsoft.com/windowsazure",
                                "ThumbprintAlgorithm");
                        if (thumbprintAlgorithmElement != null) {
                            String thumbprintAlgorithmInstance;
                            thumbprintAlgorithmInstance = thumbprintAlgorithmElement.getTextContent();
                            certificateInstance.setThumbprintAlgorithm(thumbprintAlgorithmInstance);
                        }
                    }

                    Element endpointsElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Endpoints");
                    if (endpointsElement != null) {
                        ExtensionEndpointConfiguration endpointsInstance = new ExtensionEndpointConfiguration();
                        extensionImageInstance.setExtensionEndpoints(endpointsInstance);

                        Element inputEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                endpointsElement, "http://schemas.microsoft.com/windowsazure",
                                "InputEndpoints");
                        if (inputEndpointsSequenceElement != null) {
                            for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(inputEndpointsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "InputEndpoint")
                                    .size(); i2 = i2 + 1) {
                                org.w3c.dom.Element inputEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(inputEndpointsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "InputEndpoint")
                                        .get(i2));
                                ExtensionEndpointConfiguration.InputEndpoint inputEndpointInstance = new ExtensionEndpointConfiguration.InputEndpoint();
                                endpointsInstance.getInputEndpoints().add(inputEndpointInstance);

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

                                Element protocolElement = XmlUtility.getElementByTagNameNS(
                                        inputEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "Protocol");
                                if (protocolElement != null) {
                                    String protocolInstance;
                                    protocolInstance = protocolElement.getTextContent();
                                    inputEndpointInstance.setProtocol(protocolInstance);
                                }

                                Element portElement = XmlUtility.getElementByTagNameNS(inputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "Port");
                                if (portElement != null) {
                                    int portInstance;
                                    portInstance = DatatypeConverter.parseInt(portElement.getTextContent());
                                    inputEndpointInstance.setPort(portInstance);
                                }

                                Element localPortElement = XmlUtility.getElementByTagNameNS(
                                        inputEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "LocalPort");
                                if (localPortElement != null) {
                                    String localPortInstance;
                                    localPortInstance = localPortElement.getTextContent();
                                    inputEndpointInstance.setLocalPort(localPortInstance);
                                }
                            }
                        }

                        Element internalEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                endpointsElement, "http://schemas.microsoft.com/windowsazure",
                                "InternalEndpoints");
                        if (internalEndpointsSequenceElement != null) {
                            for (int i3 = 0; i3 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(internalEndpointsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "InternalEndpoint")
                                    .size(); i3 = i3 + 1) {
                                org.w3c.dom.Element internalEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(internalEndpointsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "InternalEndpoint")
                                        .get(i3));
                                ExtensionEndpointConfiguration.InternalEndpoint internalEndpointInstance = new ExtensionEndpointConfiguration.InternalEndpoint();
                                endpointsInstance.getInternalEndpoints().add(internalEndpointInstance);

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

                                Element protocolElement2 = XmlUtility.getElementByTagNameNS(
                                        internalEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "Protocol");
                                if (protocolElement2 != null) {
                                    String protocolInstance2;
                                    protocolInstance2 = protocolElement2.getTextContent();
                                    internalEndpointInstance.setProtocol(protocolInstance2);
                                }

                                Element portElement2 = XmlUtility.getElementByTagNameNS(
                                        internalEndpointsElement, "http://schemas.microsoft.com/windowsazure",
                                        "Port");
                                if (portElement2 != null) {
                                    int portInstance2;
                                    portInstance2 = DatatypeConverter.parseInt(portElement2.getTextContent());
                                    internalEndpointInstance.setPort(portInstance2);
                                }
                            }
                        }

                        Element instanceInputEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                endpointsElement, "http://schemas.microsoft.com/windowsazure",
                                "InstanceInputEndpoints");
                        if (instanceInputEndpointsSequenceElement != null) {
                            for (int i4 = 0; i4 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(instanceInputEndpointsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure",
                                            "InstanceInputEndpoint")
                                    .size(); i4 = i4 + 1) {
                                org.w3c.dom.Element instanceInputEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(instanceInputEndpointsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "InstanceInputEndpoint")
                                        .get(i4));
                                ExtensionEndpointConfiguration.InstanceInputEndpoint instanceInputEndpointInstance = new ExtensionEndpointConfiguration.InstanceInputEndpoint();
                                endpointsInstance.getInstanceInputEndpoints()
                                        .add(instanceInputEndpointInstance);

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

                                Element protocolElement3 = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "Protocol");
                                if (protocolElement3 != null) {
                                    String protocolInstance3;
                                    protocolInstance3 = protocolElement3.getTextContent();
                                    instanceInputEndpointInstance.setProtocol(protocolInstance3);
                                }

                                Element localPortElement2 = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "LocalPort");
                                if (localPortElement2 != null) {
                                    String localPortInstance2;
                                    localPortInstance2 = localPortElement2.getTextContent();
                                    instanceInputEndpointInstance.setLocalPort(localPortInstance2);
                                }

                                Element fixedPortMinElement = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "FixedPortMin");
                                if (fixedPortMinElement != null) {
                                    int fixedPortMinInstance;
                                    fixedPortMinInstance = DatatypeConverter
                                            .parseInt(fixedPortMinElement.getTextContent());
                                    instanceInputEndpointInstance.setFixedPortMin(fixedPortMinInstance);
                                }

                                Element fixedPortMaxElement = XmlUtility.getElementByTagNameNS(
                                        instanceInputEndpointsElement,
                                        "http://schemas.microsoft.com/windowsazure", "FixedPortMax");
                                if (fixedPortMaxElement != null) {
                                    int fixedPortMaxInstance;
                                    fixedPortMaxInstance = DatatypeConverter
                                            .parseInt(fixedPortMaxElement.getTextContent());
                                    instanceInputEndpointInstance.setFixedPortMax(fixedPortMaxInstance);
                                }
                            }
                        }
                    }

                    Element publicConfigurationSchemaElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "PublicConfigurationSchema");
                    if (publicConfigurationSchemaElement != null) {
                        String publicConfigurationSchemaInstance;
                        publicConfigurationSchemaInstance = publicConfigurationSchemaElement
                                .getTextContent() != null ? new String(
                                        Base64.decode(publicConfigurationSchemaElement.getTextContent()))
                                        : null;
                        extensionImageInstance.setPublicConfigurationSchema(publicConfigurationSchemaInstance);
                    }

                    Element privateConfigurationSchemaElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "PrivateConfigurationSchema");
                    if (privateConfigurationSchemaElement != null) {
                        String privateConfigurationSchemaInstance;
                        privateConfigurationSchemaInstance = privateConfigurationSchemaElement
                                .getTextContent() != null ? new String(
                                        Base64.decode(privateConfigurationSchemaElement.getTextContent()))
                                        : null;
                        extensionImageInstance
                                .setPrivateConfigurationSchema(privateConfigurationSchemaInstance);
                    }

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

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

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

                    Element localResourcesSequenceElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "LocalResources");
                    if (localResourcesSequenceElement != null) {
                        for (int i5 = 0; i5 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(localResourcesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "LocalResource")
                                .size(); i5 = i5 + 1) {
                            org.w3c.dom.Element localResourcesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(localResourcesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "LocalResource")
                                    .get(i5));
                            ExtensionLocalResourceConfiguration localResourceInstance = new ExtensionLocalResourceConfiguration();
                            extensionImageInstance.getLocalResources().add(localResourceInstance);

                            Element nameElement4 = XmlUtility.getElementByTagNameNS(localResourcesElement,
                                    "http://schemas.microsoft.com/windowsazure", "Name");
                            if (nameElement4 != null) {
                                String nameInstance4;
                                nameInstance4 = nameElement4.getTextContent();
                                localResourceInstance.setName(nameInstance4);
                            }

                            Element sizeInMBElement = XmlUtility.getElementByTagNameNS(localResourcesElement,
                                    "http://schemas.microsoft.com/windowsazure", "SizeInMB");
                            if (sizeInMBElement != null && sizeInMBElement.getTextContent() != null
                                    && !sizeInMBElement.getTextContent().isEmpty()) {
                                int sizeInMBInstance;
                                sizeInMBInstance = DatatypeConverter.parseInt(sizeInMBElement.getTextContent());
                                localResourceInstance.setSizeInMB(sizeInMBInstance);
                            }
                        }
                    }

                    Element blockRoleUponFailureElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "BlockRoleUponFailure");
                    if (blockRoleUponFailureElement != null
                            && blockRoleUponFailureElement.getTextContent() != null
                            && !blockRoleUponFailureElement.getTextContent().isEmpty()) {
                        boolean blockRoleUponFailureInstance;
                        blockRoleUponFailureInstance = DatatypeConverter
                                .parseBoolean(blockRoleUponFailureElement.getTextContent().toLowerCase());
                        extensionImageInstance.setBlockRoleUponFailure(blockRoleUponFailureInstance);
                    }

                    Element isInternalExtensionElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "IsInternalExtension");
                    if (isInternalExtensionElement != null
                            && isInternalExtensionElement.getTextContent() != null
                            && !isInternalExtensionElement.getTextContent().isEmpty()) {
                        boolean isInternalExtensionInstance;
                        isInternalExtensionInstance = DatatypeConverter
                                .parseBoolean(isInternalExtensionElement.getTextContent().toLowerCase());
                        extensionImageInstance.setIsInternalExtension(isInternalExtensionInstance);
                    }

                    Element sampleConfigElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "SampleConfig");
                    if (sampleConfigElement != null) {
                        String sampleConfigInstance;
                        sampleConfigInstance = sampleConfigElement.getTextContent() != null
                                ? new String(Base64.decode(sampleConfigElement.getTextContent()))
                                : null;
                        extensionImageInstance.setSampleConfig(sampleConfigInstance);
                    }

                    Element replicationCompletedElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "ReplicationCompleted");
                    if (replicationCompletedElement != null
                            && replicationCompletedElement.getTextContent() != null
                            && !replicationCompletedElement.getTextContent().isEmpty()) {
                        boolean replicationCompletedInstance;
                        replicationCompletedInstance = DatatypeConverter
                                .parseBoolean(replicationCompletedElement.getTextContent().toLowerCase());
                        extensionImageInstance.setReplicationCompleted(replicationCompletedInstance);
                    }

                    Element eulaElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Eula");
                    if (eulaElement != null) {
                        URI eulaInstance;
                        eulaInstance = new URI(eulaElement.getTextContent());
                        extensionImageInstance.setEula(eulaInstance);
                    }

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

                    Element homepageUriElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "HomepageUri");
                    if (homepageUriElement != null) {
                        URI homepageUriInstance;
                        homepageUriInstance = new URI(homepageUriElement.getTextContent());
                        extensionImageInstance.setHomepageUri(homepageUriInstance);
                    }

                    Element isJsonExtensionElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "IsJsonExtension");
                    if (isJsonExtensionElement != null && isJsonExtensionElement.getTextContent() != null
                            && !isJsonExtensionElement.getTextContent().isEmpty()) {
                        boolean isJsonExtensionInstance;
                        isJsonExtensionInstance = DatatypeConverter
                                .parseBoolean(isJsonExtensionElement.getTextContent().toLowerCase());
                        extensionImageInstance.setIsJsonExtension(isJsonExtensionInstance);
                    }

                    Element disallowMajorVersionUpgradeElement = XmlUtility.getElementByTagNameNS(
                            extensionImagesElement, "http://schemas.microsoft.com/windowsazure",
                            "DisallowMajorVersionUpgrade");
                    if (disallowMajorVersionUpgradeElement != null
                            && disallowMajorVersionUpgradeElement.getTextContent() != null
                            && !disallowMajorVersionUpgradeElement.getTextContent().isEmpty()) {
                        boolean disallowMajorVersionUpgradeInstance;
                        disallowMajorVersionUpgradeInstance = DatatypeConverter.parseBoolean(
                                disallowMajorVersionUpgradeElement.getTextContent().toLowerCase());
                        extensionImageInstance
                                .setDisallowMajorVersionUpgrade(disallowMajorVersionUpgradeInstance);
                    }

                    Element supportedOSElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "SupportedOS");
                    if (supportedOSElement != null) {
                        String supportedOSInstance;
                        supportedOSInstance = supportedOSElement.getTextContent();
                        extensionImageInstance.setSupportedOS(supportedOSInstance);
                    }

                    Element companyNameElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "CompanyName");
                    if (companyNameElement != null) {
                        String companyNameInstance;
                        companyNameInstance = companyNameElement.getTextContent();
                        extensionImageInstance.setCompanyName(companyNameInstance);
                    }

                    Element regionsElement = XmlUtility.getElementByTagNameNS(extensionImagesElement,
                            "http://schemas.microsoft.com/windowsazure", "Regions");
                    if (regionsElement != null) {
                        String regionsInstance;
                        regionsInstance = regionsElement.getTextContent();
                        extensionImageInstance.setRegions(regionsInstance);
                    }
                }
            }

        }
        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.compute.VirtualMachineOperationsImpl.java

/**
* The operation to list virtual machines under a resource group.
*
* @param resourceGroupName Required. The name of the resource group.
* @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./*from  www. j  av a 2  s  .  c o  m*/
* @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 Virtual Machine operation response.
*/
@Override
public VirtualMachineListResponse list(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, "listAsync", 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.Compute";
    url = url + "/";
    url = url + "virtualMachines";
    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("Content-Type", "application/json");

    // 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
        VirtualMachineListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new VirtualMachineListResponse();
            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)) {
                        VirtualMachine virtualMachineJsonInstance = new VirtualMachine();
                        result.getVirtualMachines().add(virtualMachineJsonInstance);

                        JsonNode planValue = valueValue.get("plan");
                        if (planValue != null && planValue instanceof NullNode == false) {
                            Plan planInstance = new Plan();
                            virtualMachineJsonInstance.setPlan(planInstance);

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

                            JsonNode publisherValue = planValue.get("publisher");
                            if (publisherValue != null && publisherValue instanceof NullNode == false) {
                                String publisherInstance;
                                publisherInstance = publisherValue.getTextValue();
                                planInstance.setPublisher(publisherInstance);
                            }

                            JsonNode productValue = planValue.get("product");
                            if (productValue != null && productValue instanceof NullNode == false) {
                                String productInstance;
                                productInstance = productValue.getTextValue();
                                planInstance.setProduct(productInstance);
                            }

                            JsonNode promotionCodeValue = planValue.get("promotionCode");
                            if (promotionCodeValue != null && promotionCodeValue instanceof NullNode == false) {
                                String promotionCodeInstance;
                                promotionCodeInstance = promotionCodeValue.getTextValue();
                                planInstance.setPromotionCode(promotionCodeInstance);
                            }
                        }

                        JsonNode propertiesValue = valueValue.get("properties");
                        if (propertiesValue != null && propertiesValue instanceof NullNode == false) {
                            JsonNode hardwareProfileValue = propertiesValue.get("hardwareProfile");
                            if (hardwareProfileValue != null
                                    && hardwareProfileValue instanceof NullNode == false) {
                                HardwareProfile hardwareProfileInstance = new HardwareProfile();
                                virtualMachineJsonInstance.setHardwareProfile(hardwareProfileInstance);

                                JsonNode vmSizeValue = hardwareProfileValue.get("vmSize");
                                if (vmSizeValue != null && vmSizeValue instanceof NullNode == false) {
                                    String vmSizeInstance;
                                    vmSizeInstance = vmSizeValue.getTextValue();
                                    hardwareProfileInstance.setVirtualMachineSize(vmSizeInstance);
                                }
                            }

                            JsonNode storageProfileValue = propertiesValue.get("storageProfile");
                            if (storageProfileValue != null
                                    && storageProfileValue instanceof NullNode == false) {
                                StorageProfile storageProfileInstance = new StorageProfile();
                                virtualMachineJsonInstance.setStorageProfile(storageProfileInstance);

                                JsonNode imageReferenceValue = storageProfileValue.get("imageReference");
                                if (imageReferenceValue != null
                                        && imageReferenceValue instanceof NullNode == false) {
                                    ImageReference imageReferenceInstance = new ImageReference();
                                    storageProfileInstance.setImageReference(imageReferenceInstance);

                                    JsonNode publisherValue2 = imageReferenceValue.get("publisher");
                                    if (publisherValue2 != null
                                            && publisherValue2 instanceof NullNode == false) {
                                        String publisherInstance2;
                                        publisherInstance2 = publisherValue2.getTextValue();
                                        imageReferenceInstance.setPublisher(publisherInstance2);
                                    }

                                    JsonNode offerValue = imageReferenceValue.get("offer");
                                    if (offerValue != null && offerValue instanceof NullNode == false) {
                                        String offerInstance;
                                        offerInstance = offerValue.getTextValue();
                                        imageReferenceInstance.setOffer(offerInstance);
                                    }

                                    JsonNode skuValue = imageReferenceValue.get("sku");
                                    if (skuValue != null && skuValue instanceof NullNode == false) {
                                        String skuInstance;
                                        skuInstance = skuValue.getTextValue();
                                        imageReferenceInstance.setSku(skuInstance);
                                    }

                                    JsonNode versionValue = imageReferenceValue.get("version");
                                    if (versionValue != null && versionValue instanceof NullNode == false) {
                                        String versionInstance;
                                        versionInstance = versionValue.getTextValue();
                                        imageReferenceInstance.setVersion(versionInstance);
                                    }
                                }

                                JsonNode osDiskValue = storageProfileValue.get("osDisk");
                                if (osDiskValue != null && osDiskValue instanceof NullNode == false) {
                                    OSDisk osDiskInstance = new OSDisk();
                                    storageProfileInstance.setOSDisk(osDiskInstance);

                                    JsonNode osTypeValue = osDiskValue.get("osType");
                                    if (osTypeValue != null && osTypeValue instanceof NullNode == false) {
                                        String osTypeInstance;
                                        osTypeInstance = osTypeValue.getTextValue();
                                        osDiskInstance.setOperatingSystemType(osTypeInstance);
                                    }

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

                                    JsonNode vhdValue = osDiskValue.get("vhd");
                                    if (vhdValue != null && vhdValue instanceof NullNode == false) {
                                        VirtualHardDisk vhdInstance = new VirtualHardDisk();
                                        osDiskInstance.setVirtualHardDisk(vhdInstance);

                                        JsonNode uriValue = vhdValue.get("uri");
                                        if (uriValue != null && uriValue instanceof NullNode == false) {
                                            String uriInstance;
                                            uriInstance = uriValue.getTextValue();
                                            vhdInstance.setUri(uriInstance);
                                        }
                                    }

                                    JsonNode imageValue = osDiskValue.get("image");
                                    if (imageValue != null && imageValue instanceof NullNode == false) {
                                        VirtualHardDisk imageInstance = new VirtualHardDisk();
                                        osDiskInstance.setSourceImage(imageInstance);

                                        JsonNode uriValue2 = imageValue.get("uri");
                                        if (uriValue2 != null && uriValue2 instanceof NullNode == false) {
                                            String uriInstance2;
                                            uriInstance2 = uriValue2.getTextValue();
                                            imageInstance.setUri(uriInstance2);
                                        }
                                    }

                                    JsonNode cachingValue = osDiskValue.get("caching");
                                    if (cachingValue != null && cachingValue instanceof NullNode == false) {
                                        String cachingInstance;
                                        cachingInstance = cachingValue.getTextValue();
                                        osDiskInstance.setCaching(cachingInstance);
                                    }

                                    JsonNode createOptionValue = osDiskValue.get("createOption");
                                    if (createOptionValue != null
                                            && createOptionValue instanceof NullNode == false) {
                                        String createOptionInstance;
                                        createOptionInstance = createOptionValue.getTextValue();
                                        osDiskInstance.setCreateOption(createOptionInstance);
                                    }

                                    JsonNode diskSizeGBValue = osDiskValue.get("diskSizeGB");
                                    if (diskSizeGBValue != null
                                            && diskSizeGBValue instanceof NullNode == false) {
                                        int diskSizeGBInstance;
                                        diskSizeGBInstance = diskSizeGBValue.getIntValue();
                                        osDiskInstance.setDiskSizeGB(diskSizeGBInstance);
                                    }
                                }

                                JsonNode dataDisksArray = storageProfileValue.get("dataDisks");
                                if (dataDisksArray != null && dataDisksArray instanceof NullNode == false) {
                                    for (JsonNode dataDisksValue : ((ArrayNode) dataDisksArray)) {
                                        DataDisk dataDiskInstance = new DataDisk();
                                        storageProfileInstance.getDataDisks().add(dataDiskInstance);

                                        JsonNode lunValue = dataDisksValue.get("lun");
                                        if (lunValue != null && lunValue instanceof NullNode == false) {
                                            int lunInstance;
                                            lunInstance = lunValue.getIntValue();
                                            dataDiskInstance.setLun(lunInstance);
                                        }

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

                                        JsonNode vhdValue2 = dataDisksValue.get("vhd");
                                        if (vhdValue2 != null && vhdValue2 instanceof NullNode == false) {
                                            VirtualHardDisk vhdInstance2 = new VirtualHardDisk();
                                            dataDiskInstance.setVirtualHardDisk(vhdInstance2);

                                            JsonNode uriValue3 = vhdValue2.get("uri");
                                            if (uriValue3 != null && uriValue3 instanceof NullNode == false) {
                                                String uriInstance3;
                                                uriInstance3 = uriValue3.getTextValue();
                                                vhdInstance2.setUri(uriInstance3);
                                            }
                                        }

                                        JsonNode imageValue2 = dataDisksValue.get("image");
                                        if (imageValue2 != null && imageValue2 instanceof NullNode == false) {
                                            VirtualHardDisk imageInstance2 = new VirtualHardDisk();
                                            dataDiskInstance.setSourceImage(imageInstance2);

                                            JsonNode uriValue4 = imageValue2.get("uri");
                                            if (uriValue4 != null && uriValue4 instanceof NullNode == false) {
                                                String uriInstance4;
                                                uriInstance4 = uriValue4.getTextValue();
                                                imageInstance2.setUri(uriInstance4);
                                            }
                                        }

                                        JsonNode cachingValue2 = dataDisksValue.get("caching");
                                        if (cachingValue2 != null
                                                && cachingValue2 instanceof NullNode == false) {
                                            String cachingInstance2;
                                            cachingInstance2 = cachingValue2.getTextValue();
                                            dataDiskInstance.setCaching(cachingInstance2);
                                        }

                                        JsonNode createOptionValue2 = dataDisksValue.get("createOption");
                                        if (createOptionValue2 != null
                                                && createOptionValue2 instanceof NullNode == false) {
                                            String createOptionInstance2;
                                            createOptionInstance2 = createOptionValue2.getTextValue();
                                            dataDiskInstance.setCreateOption(createOptionInstance2);
                                        }

                                        JsonNode diskSizeGBValue2 = dataDisksValue.get("diskSizeGB");
                                        if (diskSizeGBValue2 != null
                                                && diskSizeGBValue2 instanceof NullNode == false) {
                                            int diskSizeGBInstance2;
                                            diskSizeGBInstance2 = diskSizeGBValue2.getIntValue();
                                            dataDiskInstance.setDiskSizeGB(diskSizeGBInstance2);
                                        }
                                    }
                                }
                            }

                            JsonNode osProfileValue = propertiesValue.get("osProfile");
                            if (osProfileValue != null && osProfileValue instanceof NullNode == false) {
                                OSProfile osProfileInstance = new OSProfile();
                                virtualMachineJsonInstance.setOSProfile(osProfileInstance);

                                JsonNode computerNameValue = osProfileValue.get("computerName");
                                if (computerNameValue != null
                                        && computerNameValue instanceof NullNode == false) {
                                    String computerNameInstance;
                                    computerNameInstance = computerNameValue.getTextValue();
                                    osProfileInstance.setComputerName(computerNameInstance);
                                }

                                JsonNode adminUsernameValue = osProfileValue.get("adminUsername");
                                if (adminUsernameValue != null
                                        && adminUsernameValue instanceof NullNode == false) {
                                    String adminUsernameInstance;
                                    adminUsernameInstance = adminUsernameValue.getTextValue();
                                    osProfileInstance.setAdminUsername(adminUsernameInstance);
                                }

                                JsonNode adminPasswordValue = osProfileValue.get("adminPassword");
                                if (adminPasswordValue != null
                                        && adminPasswordValue instanceof NullNode == false) {
                                    String adminPasswordInstance;
                                    adminPasswordInstance = adminPasswordValue.getTextValue();
                                    osProfileInstance.setAdminPassword(adminPasswordInstance);
                                }

                                JsonNode customDataValue = osProfileValue.get("customData");
                                if (customDataValue != null && customDataValue instanceof NullNode == false) {
                                    String customDataInstance;
                                    customDataInstance = customDataValue.getTextValue();
                                    osProfileInstance.setCustomData(customDataInstance);
                                }

                                JsonNode windowsConfigurationValue = osProfileValue.get("windowsConfiguration");
                                if (windowsConfigurationValue != null
                                        && windowsConfigurationValue instanceof NullNode == false) {
                                    WindowsConfiguration windowsConfigurationInstance = new WindowsConfiguration();
                                    osProfileInstance.setWindowsConfiguration(windowsConfigurationInstance);

                                    JsonNode provisionVMAgentValue = windowsConfigurationValue
                                            .get("provisionVMAgent");
                                    if (provisionVMAgentValue != null
                                            && provisionVMAgentValue instanceof NullNode == false) {
                                        boolean provisionVMAgentInstance;
                                        provisionVMAgentInstance = provisionVMAgentValue.getBooleanValue();
                                        windowsConfigurationInstance
                                                .setProvisionVMAgent(provisionVMAgentInstance);
                                    }

                                    JsonNode enableAutomaticUpdatesValue = windowsConfigurationValue
                                            .get("enableAutomaticUpdates");
                                    if (enableAutomaticUpdatesValue != null
                                            && enableAutomaticUpdatesValue instanceof NullNode == false) {
                                        boolean enableAutomaticUpdatesInstance;
                                        enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue
                                                .getBooleanValue();
                                        windowsConfigurationInstance
                                                .setEnableAutomaticUpdates(enableAutomaticUpdatesInstance);
                                    }

                                    JsonNode timeZoneValue = windowsConfigurationValue.get("timeZone");
                                    if (timeZoneValue != null && timeZoneValue instanceof NullNode == false) {
                                        String timeZoneInstance;
                                        timeZoneInstance = timeZoneValue.getTextValue();
                                        windowsConfigurationInstance.setTimeZone(timeZoneInstance);
                                    }

                                    JsonNode additionalUnattendContentArray = windowsConfigurationValue
                                            .get("additionalUnattendContent");
                                    if (additionalUnattendContentArray != null
                                            && additionalUnattendContentArray instanceof NullNode == false) {
                                        for (JsonNode additionalUnattendContentValue : ((ArrayNode) additionalUnattendContentArray)) {
                                            AdditionalUnattendContent additionalUnattendContentInstance = new AdditionalUnattendContent();
                                            windowsConfigurationInstance.getAdditionalUnattendContents()
                                                    .add(additionalUnattendContentInstance);

                                            JsonNode passNameValue = additionalUnattendContentValue
                                                    .get("passName");
                                            if (passNameValue != null
                                                    && passNameValue instanceof NullNode == false) {
                                                String passNameInstance;
                                                passNameInstance = passNameValue.getTextValue();
                                                additionalUnattendContentInstance.setPassName(passNameInstance);
                                            }

                                            JsonNode componentNameValue = additionalUnattendContentValue
                                                    .get("componentName");
                                            if (componentNameValue != null
                                                    && componentNameValue instanceof NullNode == false) {
                                                String componentNameInstance;
                                                componentNameInstance = componentNameValue.getTextValue();
                                                additionalUnattendContentInstance
                                                        .setComponentName(componentNameInstance);
                                            }

                                            JsonNode settingNameValue = additionalUnattendContentValue
                                                    .get("settingName");
                                            if (settingNameValue != null
                                                    && settingNameValue instanceof NullNode == false) {
                                                String settingNameInstance;
                                                settingNameInstance = settingNameValue.getTextValue();
                                                additionalUnattendContentInstance
                                                        .setSettingName(settingNameInstance);
                                            }

                                            JsonNode contentValue = additionalUnattendContentValue
                                                    .get("content");
                                            if (contentValue != null
                                                    && contentValue instanceof NullNode == false) {
                                                String contentInstance;
                                                contentInstance = contentValue.getTextValue();
                                                additionalUnattendContentInstance.setContent(contentInstance);
                                            }
                                        }
                                    }

                                    JsonNode winRMValue = windowsConfigurationValue.get("winRM");
                                    if (winRMValue != null && winRMValue instanceof NullNode == false) {
                                        WinRMConfiguration winRMInstance = new WinRMConfiguration();
                                        windowsConfigurationInstance.setWinRMConfiguration(winRMInstance);

                                        JsonNode listenersArray = winRMValue.get("listeners");
                                        if (listenersArray != null
                                                && listenersArray instanceof NullNode == false) {
                                            for (JsonNode listenersValue : ((ArrayNode) listenersArray)) {
                                                WinRMListener winRMListenerInstance = new WinRMListener();
                                                winRMInstance.getListeners().add(winRMListenerInstance);

                                                JsonNode protocolValue = listenersValue.get("protocol");
                                                if (protocolValue != null
                                                        && protocolValue instanceof NullNode == false) {
                                                    String protocolInstance;
                                                    protocolInstance = protocolValue.getTextValue();
                                                    winRMListenerInstance.setProtocol(protocolInstance);
                                                }

                                                JsonNode certificateUrlValue = listenersValue
                                                        .get("certificateUrl");
                                                if (certificateUrlValue != null
                                                        && certificateUrlValue instanceof NullNode == false) {
                                                    URI certificateUrlInstance;
                                                    certificateUrlInstance = new URI(
                                                            certificateUrlValue.getTextValue());
                                                    winRMListenerInstance
                                                            .setCertificateUrl(certificateUrlInstance);
                                                }
                                            }
                                        }
                                    }
                                }

                                JsonNode linuxConfigurationValue = osProfileValue.get("linuxConfiguration");
                                if (linuxConfigurationValue != null
                                        && linuxConfigurationValue instanceof NullNode == false) {
                                    LinuxConfiguration linuxConfigurationInstance = new LinuxConfiguration();
                                    osProfileInstance.setLinuxConfiguration(linuxConfigurationInstance);

                                    JsonNode disablePasswordAuthenticationValue = linuxConfigurationValue
                                            .get("disablePasswordAuthentication");
                                    if (disablePasswordAuthenticationValue != null
                                            && disablePasswordAuthenticationValue instanceof NullNode == false) {
                                        boolean disablePasswordAuthenticationInstance;
                                        disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue
                                                .getBooleanValue();
                                        linuxConfigurationInstance.setDisablePasswordAuthentication(
                                                disablePasswordAuthenticationInstance);
                                    }

                                    JsonNode sshValue = linuxConfigurationValue.get("ssh");
                                    if (sshValue != null && sshValue instanceof NullNode == false) {
                                        SshConfiguration sshInstance = new SshConfiguration();
                                        linuxConfigurationInstance.setSshConfiguration(sshInstance);

                                        JsonNode publicKeysArray = sshValue.get("publicKeys");
                                        if (publicKeysArray != null
                                                && publicKeysArray instanceof NullNode == false) {
                                            for (JsonNode publicKeysValue : ((ArrayNode) publicKeysArray)) {
                                                SshPublicKey sshPublicKeyInstance = new SshPublicKey();
                                                sshInstance.getPublicKeys().add(sshPublicKeyInstance);

                                                JsonNode pathValue = publicKeysValue.get("path");
                                                if (pathValue != null
                                                        && pathValue instanceof NullNode == false) {
                                                    String pathInstance;
                                                    pathInstance = pathValue.getTextValue();
                                                    sshPublicKeyInstance.setPath(pathInstance);
                                                }

                                                JsonNode keyDataValue = publicKeysValue.get("keyData");
                                                if (keyDataValue != null
                                                        && keyDataValue instanceof NullNode == false) {
                                                    String keyDataInstance;
                                                    keyDataInstance = keyDataValue.getTextValue();
                                                    sshPublicKeyInstance.setKeyData(keyDataInstance);
                                                }
                                            }
                                        }
                                    }
                                }

                                JsonNode secretsArray = osProfileValue.get("secrets");
                                if (secretsArray != null && secretsArray instanceof NullNode == false) {
                                    for (JsonNode secretsValue : ((ArrayNode) secretsArray)) {
                                        VaultSecretGroup vaultSecretGroupInstance = new VaultSecretGroup();
                                        osProfileInstance.getSecrets().add(vaultSecretGroupInstance);

                                        JsonNode sourceVaultValue = secretsValue.get("sourceVault");
                                        if (sourceVaultValue != null
                                                && sourceVaultValue instanceof NullNode == false) {
                                            SourceVaultReference sourceVaultInstance = new SourceVaultReference();
                                            vaultSecretGroupInstance.setSourceVault(sourceVaultInstance);

                                            JsonNode idValue = sourceVaultValue.get("id");
                                            if (idValue != null && idValue instanceof NullNode == false) {
                                                String idInstance;
                                                idInstance = idValue.getTextValue();
                                                sourceVaultInstance.setReferenceUri(idInstance);
                                            }
                                        }

                                        JsonNode vaultCertificatesArray = secretsValue.get("vaultCertificates");
                                        if (vaultCertificatesArray != null
                                                && vaultCertificatesArray instanceof NullNode == false) {
                                            for (JsonNode vaultCertificatesValue : ((ArrayNode) vaultCertificatesArray)) {
                                                VaultCertificate vaultCertificateInstance = new VaultCertificate();
                                                vaultSecretGroupInstance.getVaultCertificates()
                                                        .add(vaultCertificateInstance);

                                                JsonNode certificateUrlValue2 = vaultCertificatesValue
                                                        .get("certificateUrl");
                                                if (certificateUrlValue2 != null
                                                        && certificateUrlValue2 instanceof NullNode == false) {
                                                    String certificateUrlInstance2;
                                                    certificateUrlInstance2 = certificateUrlValue2
                                                            .getTextValue();
                                                    vaultCertificateInstance
                                                            .setCertificateUrl(certificateUrlInstance2);
                                                }

                                                JsonNode certificateStoreValue = vaultCertificatesValue
                                                        .get("certificateStore");
                                                if (certificateStoreValue != null
                                                        && certificateStoreValue instanceof NullNode == false) {
                                                    String certificateStoreInstance;
                                                    certificateStoreInstance = certificateStoreValue
                                                            .getTextValue();
                                                    vaultCertificateInstance
                                                            .setCertificateStore(certificateStoreInstance);
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            JsonNode networkProfileValue = propertiesValue.get("networkProfile");
                            if (networkProfileValue != null
                                    && networkProfileValue instanceof NullNode == false) {
                                NetworkProfile networkProfileInstance = new NetworkProfile();
                                virtualMachineJsonInstance.setNetworkProfile(networkProfileInstance);

                                JsonNode networkInterfacesArray = networkProfileValue.get("networkInterfaces");
                                if (networkInterfacesArray != null
                                        && networkInterfacesArray instanceof NullNode == false) {
                                    for (JsonNode networkInterfacesValue : ((ArrayNode) networkInterfacesArray)) {
                                        NetworkInterfaceReference networkInterfaceReferenceJsonInstance = new NetworkInterfaceReference();
                                        networkProfileInstance.getNetworkInterfaces()
                                                .add(networkInterfaceReferenceJsonInstance);

                                        JsonNode propertiesValue2 = networkInterfacesValue.get("properties");
                                        if (propertiesValue2 != null
                                                && propertiesValue2 instanceof NullNode == false) {
                                            JsonNode primaryValue = propertiesValue2.get("primary");
                                            if (primaryValue != null
                                                    && primaryValue instanceof NullNode == false) {
                                                boolean primaryInstance;
                                                primaryInstance = primaryValue.getBooleanValue();
                                                networkInterfaceReferenceJsonInstance
                                                        .setPrimary(primaryInstance);
                                            }
                                        }

                                        JsonNode idValue2 = networkInterfacesValue.get("id");
                                        if (idValue2 != null && idValue2 instanceof NullNode == false) {
                                            String idInstance2;
                                            idInstance2 = idValue2.getTextValue();
                                            networkInterfaceReferenceJsonInstance.setReferenceUri(idInstance2);
                                        }
                                    }
                                }
                            }

                            JsonNode diagnosticsProfileValue = propertiesValue.get("diagnosticsProfile");
                            if (diagnosticsProfileValue != null
                                    && diagnosticsProfileValue instanceof NullNode == false) {
                                DiagnosticsProfile diagnosticsProfileInstance = new DiagnosticsProfile();
                                virtualMachineJsonInstance.setDiagnosticsProfile(diagnosticsProfileInstance);

                                JsonNode bootDiagnosticsValue = diagnosticsProfileValue.get("bootDiagnostics");
                                if (bootDiagnosticsValue != null
                                        && bootDiagnosticsValue instanceof NullNode == false) {
                                    BootDiagnostics bootDiagnosticsInstance = new BootDiagnostics();
                                    diagnosticsProfileInstance.setBootDiagnostics(bootDiagnosticsInstance);

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

                                    JsonNode storageUriValue = bootDiagnosticsValue.get("storageUri");
                                    if (storageUriValue != null
                                            && storageUriValue instanceof NullNode == false) {
                                        URI storageUriInstance;
                                        storageUriInstance = new URI(storageUriValue.getTextValue());
                                        bootDiagnosticsInstance.setStorageUri(storageUriInstance);
                                    }
                                }
                            }

                            JsonNode availabilitySetValue = propertiesValue.get("availabilitySet");
                            if (availabilitySetValue != null
                                    && availabilitySetValue instanceof NullNode == false) {
                                AvailabilitySetReference availabilitySetInstance = new AvailabilitySetReference();
                                virtualMachineJsonInstance.setAvailabilitySetReference(availabilitySetInstance);

                                JsonNode idValue3 = availabilitySetValue.get("id");
                                if (idValue3 != null && idValue3 instanceof NullNode == false) {
                                    String idInstance3;
                                    idInstance3 = idValue3.getTextValue();
                                    availabilitySetInstance.setReferenceUri(idInstance3);
                                }
                            }

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

                            JsonNode instanceViewValue = propertiesValue.get("instanceView");
                            if (instanceViewValue != null && instanceViewValue instanceof NullNode == false) {
                                VirtualMachineInstanceView instanceViewInstance = new VirtualMachineInstanceView();
                                virtualMachineJsonInstance.setInstanceView(instanceViewInstance);

                                JsonNode platformUpdateDomainValue = instanceViewValue
                                        .get("platformUpdateDomain");
                                if (platformUpdateDomainValue != null
                                        && platformUpdateDomainValue instanceof NullNode == false) {
                                    int platformUpdateDomainInstance;
                                    platformUpdateDomainInstance = platformUpdateDomainValue.getIntValue();
                                    instanceViewInstance.setPlatformUpdateDomain(platformUpdateDomainInstance);
                                }

                                JsonNode platformFaultDomainValue = instanceViewValue
                                        .get("platformFaultDomain");
                                if (platformFaultDomainValue != null
                                        && platformFaultDomainValue instanceof NullNode == false) {
                                    int platformFaultDomainInstance;
                                    platformFaultDomainInstance = platformFaultDomainValue.getIntValue();
                                    instanceViewInstance.setPlatformFaultDomain(platformFaultDomainInstance);
                                }

                                JsonNode rdpThumbPrintValue = instanceViewValue.get("rdpThumbPrint");
                                if (rdpThumbPrintValue != null
                                        && rdpThumbPrintValue instanceof NullNode == false) {
                                    String rdpThumbPrintInstance;
                                    rdpThumbPrintInstance = rdpThumbPrintValue.getTextValue();
                                    instanceViewInstance.setRemoteDesktopThumbprint(rdpThumbPrintInstance);
                                }

                                JsonNode vmAgentValue = instanceViewValue.get("vmAgent");
                                if (vmAgentValue != null && vmAgentValue instanceof NullNode == false) {
                                    VirtualMachineAgentInstanceView vmAgentInstance = new VirtualMachineAgentInstanceView();
                                    instanceViewInstance.setVMAgent(vmAgentInstance);

                                    JsonNode vmAgentVersionValue = vmAgentValue.get("vmAgentVersion");
                                    if (vmAgentVersionValue != null
                                            && vmAgentVersionValue instanceof NullNode == false) {
                                        String vmAgentVersionInstance;
                                        vmAgentVersionInstance = vmAgentVersionValue.getTextValue();
                                        vmAgentInstance.setVMAgentVersion(vmAgentVersionInstance);
                                    }

                                    JsonNode extensionHandlersArray = vmAgentValue.get("extensionHandlers");
                                    if (extensionHandlersArray != null
                                            && extensionHandlersArray instanceof NullNode == false) {
                                        for (JsonNode extensionHandlersValue : ((ArrayNode) extensionHandlersArray)) {
                                            VirtualMachineExtensionHandlerInstanceView virtualMachineExtensionHandlerInstanceViewInstance = new VirtualMachineExtensionHandlerInstanceView();
                                            vmAgentInstance.getExtensionHandlers()
                                                    .add(virtualMachineExtensionHandlerInstanceViewInstance);

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

                                            JsonNode typeHandlerVersionValue = extensionHandlersValue
                                                    .get("typeHandlerVersion");
                                            if (typeHandlerVersionValue != null
                                                    && typeHandlerVersionValue instanceof NullNode == false) {
                                                String typeHandlerVersionInstance;
                                                typeHandlerVersionInstance = typeHandlerVersionValue
                                                        .getTextValue();
                                                virtualMachineExtensionHandlerInstanceViewInstance
                                                        .setTypeHandlerVersion(typeHandlerVersionInstance);
                                            }

                                            JsonNode statusValue = extensionHandlersValue.get("status");
                                            if (statusValue != null
                                                    && statusValue instanceof NullNode == false) {
                                                InstanceViewStatus statusInstance = new InstanceViewStatus();
                                                virtualMachineExtensionHandlerInstanceViewInstance
                                                        .setStatus(statusInstance);

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

                                                JsonNode levelValue = statusValue.get("level");
                                                if (levelValue != null
                                                        && levelValue instanceof NullNode == false) {
                                                    String levelInstance;
                                                    levelInstance = levelValue.getTextValue();
                                                    statusInstance.setLevel(levelInstance);
                                                }

                                                JsonNode displayStatusValue = statusValue.get("displayStatus");
                                                if (displayStatusValue != null
                                                        && displayStatusValue instanceof NullNode == false) {
                                                    String displayStatusInstance;
                                                    displayStatusInstance = displayStatusValue.getTextValue();
                                                    statusInstance.setDisplayStatus(displayStatusInstance);
                                                }

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

                                                JsonNode timeValue = statusValue.get("time");
                                                if (timeValue != null
                                                        && timeValue instanceof NullNode == false) {
                                                    Calendar timeInstance;
                                                    timeInstance = DatatypeConverter
                                                            .parseDateTime(timeValue.getTextValue());
                                                    statusInstance.setTime(timeInstance);
                                                }
                                            }
                                        }
                                    }

                                    JsonNode statusesArray = vmAgentValue.get("statuses");
                                    if (statusesArray != null && statusesArray instanceof NullNode == false) {
                                        for (JsonNode statusesValue : ((ArrayNode) statusesArray)) {
                                            InstanceViewStatus instanceViewStatusInstance = new InstanceViewStatus();
                                            vmAgentInstance.getStatuses().add(instanceViewStatusInstance);

                                            JsonNode codeValue2 = statusesValue.get("code");
                                            if (codeValue2 != null && codeValue2 instanceof NullNode == false) {
                                                String codeInstance2;
                                                codeInstance2 = codeValue2.getTextValue();
                                                instanceViewStatusInstance.setCode(codeInstance2);
                                            }

                                            JsonNode levelValue2 = statusesValue.get("level");
                                            if (levelValue2 != null
                                                    && levelValue2 instanceof NullNode == false) {
                                                String levelInstance2;
                                                levelInstance2 = levelValue2.getTextValue();
                                                instanceViewStatusInstance.setLevel(levelInstance2);
                                            }

                                            JsonNode displayStatusValue2 = statusesValue.get("displayStatus");
                                            if (displayStatusValue2 != null
                                                    && displayStatusValue2 instanceof NullNode == false) {
                                                String displayStatusInstance2;
                                                displayStatusInstance2 = displayStatusValue2.getTextValue();
                                                instanceViewStatusInstance
                                                        .setDisplayStatus(displayStatusInstance2);
                                            }

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

                                            JsonNode timeValue2 = statusesValue.get("time");
                                            if (timeValue2 != null && timeValue2 instanceof NullNode == false) {
                                                Calendar timeInstance2;
                                                timeInstance2 = DatatypeConverter
                                                        .parseDateTime(timeValue2.getTextValue());
                                                instanceViewStatusInstance.setTime(timeInstance2);
                                            }
                                        }
                                    }
                                }

                                JsonNode disksArray = instanceViewValue.get("disks");
                                if (disksArray != null && disksArray instanceof NullNode == false) {
                                    for (JsonNode disksValue : ((ArrayNode) disksArray)) {
                                        DiskInstanceView diskInstanceViewInstance = new DiskInstanceView();
                                        instanceViewInstance.getDisks().add(diskInstanceViewInstance);

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

                                        JsonNode statusesArray2 = disksValue.get("statuses");
                                        if (statusesArray2 != null
                                                && statusesArray2 instanceof NullNode == false) {
                                            for (JsonNode statusesValue2 : ((ArrayNode) statusesArray2)) {
                                                InstanceViewStatus instanceViewStatusInstance2 = new InstanceViewStatus();
                                                diskInstanceViewInstance.getStatuses()
                                                        .add(instanceViewStatusInstance2);

                                                JsonNode codeValue3 = statusesValue2.get("code");
                                                if (codeValue3 != null
                                                        && codeValue3 instanceof NullNode == false) {
                                                    String codeInstance3;
                                                    codeInstance3 = codeValue3.getTextValue();
                                                    instanceViewStatusInstance2.setCode(codeInstance3);
                                                }

                                                JsonNode levelValue3 = statusesValue2.get("level");
                                                if (levelValue3 != null
                                                        && levelValue3 instanceof NullNode == false) {
                                                    String levelInstance3;
                                                    levelInstance3 = levelValue3.getTextValue();
                                                    instanceViewStatusInstance2.setLevel(levelInstance3);
                                                }

                                                JsonNode displayStatusValue3 = statusesValue2
                                                        .get("displayStatus");
                                                if (displayStatusValue3 != null
                                                        && displayStatusValue3 instanceof NullNode == false) {
                                                    String displayStatusInstance3;
                                                    displayStatusInstance3 = displayStatusValue3.getTextValue();
                                                    instanceViewStatusInstance2
                                                            .setDisplayStatus(displayStatusInstance3);
                                                }

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

                                                JsonNode timeValue3 = statusesValue2.get("time");
                                                if (timeValue3 != null
                                                        && timeValue3 instanceof NullNode == false) {
                                                    Calendar timeInstance3;
                                                    timeInstance3 = DatatypeConverter
                                                            .parseDateTime(timeValue3.getTextValue());
                                                    instanceViewStatusInstance2.setTime(timeInstance3);
                                                }
                                            }
                                        }
                                    }
                                }

                                JsonNode extensionsArray = instanceViewValue.get("extensions");
                                if (extensionsArray != null && extensionsArray instanceof NullNode == false) {
                                    for (JsonNode extensionsValue : ((ArrayNode) extensionsArray)) {
                                        VirtualMachineExtensionInstanceView virtualMachineExtensionInstanceViewInstance = new VirtualMachineExtensionInstanceView();
                                        instanceViewInstance.getExtensions()
                                                .add(virtualMachineExtensionInstanceViewInstance);

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

                                        JsonNode typeValue2 = extensionsValue.get("type");
                                        if (typeValue2 != null && typeValue2 instanceof NullNode == false) {
                                            String typeInstance2;
                                            typeInstance2 = typeValue2.getTextValue();
                                            virtualMachineExtensionInstanceViewInstance
                                                    .setExtensionType(typeInstance2);
                                        }

                                        JsonNode typeHandlerVersionValue2 = extensionsValue
                                                .get("typeHandlerVersion");
                                        if (typeHandlerVersionValue2 != null
                                                && typeHandlerVersionValue2 instanceof NullNode == false) {
                                            String typeHandlerVersionInstance2;
                                            typeHandlerVersionInstance2 = typeHandlerVersionValue2
                                                    .getTextValue();
                                            virtualMachineExtensionInstanceViewInstance
                                                    .setTypeHandlerVersion(typeHandlerVersionInstance2);
                                        }

                                        JsonNode substatusesArray = extensionsValue.get("substatuses");
                                        if (substatusesArray != null
                                                && substatusesArray instanceof NullNode == false) {
                                            for (JsonNode substatusesValue : ((ArrayNode) substatusesArray)) {
                                                InstanceViewStatus instanceViewStatusInstance3 = new InstanceViewStatus();
                                                virtualMachineExtensionInstanceViewInstance.getSubStatuses()
                                                        .add(instanceViewStatusInstance3);

                                                JsonNode codeValue4 = substatusesValue.get("code");
                                                if (codeValue4 != null
                                                        && codeValue4 instanceof NullNode == false) {
                                                    String codeInstance4;
                                                    codeInstance4 = codeValue4.getTextValue();
                                                    instanceViewStatusInstance3.setCode(codeInstance4);
                                                }

                                                JsonNode levelValue4 = substatusesValue.get("level");
                                                if (levelValue4 != null
                                                        && levelValue4 instanceof NullNode == false) {
                                                    String levelInstance4;
                                                    levelInstance4 = levelValue4.getTextValue();
                                                    instanceViewStatusInstance3.setLevel(levelInstance4);
                                                }

                                                JsonNode displayStatusValue4 = substatusesValue
                                                        .get("displayStatus");
                                                if (displayStatusValue4 != null
                                                        && displayStatusValue4 instanceof NullNode == false) {
                                                    String displayStatusInstance4;
                                                    displayStatusInstance4 = displayStatusValue4.getTextValue();
                                                    instanceViewStatusInstance3
                                                            .setDisplayStatus(displayStatusInstance4);
                                                }

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

                                                JsonNode timeValue4 = substatusesValue.get("time");
                                                if (timeValue4 != null
                                                        && timeValue4 instanceof NullNode == false) {
                                                    Calendar timeInstance4;
                                                    timeInstance4 = DatatypeConverter
                                                            .parseDateTime(timeValue4.getTextValue());
                                                    instanceViewStatusInstance3.setTime(timeInstance4);
                                                }
                                            }
                                        }

                                        JsonNode statusesArray3 = extensionsValue.get("statuses");
                                        if (statusesArray3 != null
                                                && statusesArray3 instanceof NullNode == false) {
                                            for (JsonNode statusesValue3 : ((ArrayNode) statusesArray3)) {
                                                InstanceViewStatus instanceViewStatusInstance4 = new InstanceViewStatus();
                                                virtualMachineExtensionInstanceViewInstance.getStatuses()
                                                        .add(instanceViewStatusInstance4);

                                                JsonNode codeValue5 = statusesValue3.get("code");
                                                if (codeValue5 != null
                                                        && codeValue5 instanceof NullNode == false) {
                                                    String codeInstance5;
                                                    codeInstance5 = codeValue5.getTextValue();
                                                    instanceViewStatusInstance4.setCode(codeInstance5);
                                                }

                                                JsonNode levelValue5 = statusesValue3.get("level");
                                                if (levelValue5 != null
                                                        && levelValue5 instanceof NullNode == false) {
                                                    String levelInstance5;
                                                    levelInstance5 = levelValue5.getTextValue();
                                                    instanceViewStatusInstance4.setLevel(levelInstance5);
                                                }

                                                JsonNode displayStatusValue5 = statusesValue3
                                                        .get("displayStatus");
                                                if (displayStatusValue5 != null
                                                        && displayStatusValue5 instanceof NullNode == false) {
                                                    String displayStatusInstance5;
                                                    displayStatusInstance5 = displayStatusValue5.getTextValue();
                                                    instanceViewStatusInstance4
                                                            .setDisplayStatus(displayStatusInstance5);
                                                }

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

                                                JsonNode timeValue5 = statusesValue3.get("time");
                                                if (timeValue5 != null
                                                        && timeValue5 instanceof NullNode == false) {
                                                    Calendar timeInstance5;
                                                    timeInstance5 = DatatypeConverter
                                                            .parseDateTime(timeValue5.getTextValue());
                                                    instanceViewStatusInstance4.setTime(timeInstance5);
                                                }
                                            }
                                        }
                                    }
                                }

                                JsonNode bootDiagnosticsValue2 = instanceViewValue.get("bootDiagnostics");
                                if (bootDiagnosticsValue2 != null
                                        && bootDiagnosticsValue2 instanceof NullNode == false) {
                                    BootDiagnosticsInstanceView bootDiagnosticsInstance2 = new BootDiagnosticsInstanceView();
                                    instanceViewInstance.setBootDiagnostics(bootDiagnosticsInstance2);

                                    JsonNode consoleScreenshotBlobUriValue = bootDiagnosticsValue2
                                            .get("consoleScreenshotBlobUri");
                                    if (consoleScreenshotBlobUriValue != null
                                            && consoleScreenshotBlobUriValue instanceof NullNode == false) {
                                        URI consoleScreenshotBlobUriInstance;
                                        consoleScreenshotBlobUriInstance = new URI(
                                                consoleScreenshotBlobUriValue.getTextValue());
                                        bootDiagnosticsInstance2
                                                .setConsoleScreenshotBlobUri(consoleScreenshotBlobUriInstance);
                                    }

                                    JsonNode serialConsoleLogBlobUriValue = bootDiagnosticsValue2
                                            .get("serialConsoleLogBlobUri");
                                    if (serialConsoleLogBlobUriValue != null
                                            && serialConsoleLogBlobUriValue instanceof NullNode == false) {
                                        URI serialConsoleLogBlobUriInstance;
                                        serialConsoleLogBlobUriInstance = new URI(
                                                serialConsoleLogBlobUriValue.getTextValue());
                                        bootDiagnosticsInstance2
                                                .setSerialConsoleLogBlobUri(serialConsoleLogBlobUriInstance);
                                    }
                                }

                                JsonNode statusesArray4 = instanceViewValue.get("statuses");
                                if (statusesArray4 != null && statusesArray4 instanceof NullNode == false) {
                                    for (JsonNode statusesValue4 : ((ArrayNode) statusesArray4)) {
                                        InstanceViewStatus instanceViewStatusInstance5 = new InstanceViewStatus();
                                        instanceViewInstance.getStatuses().add(instanceViewStatusInstance5);

                                        JsonNode codeValue6 = statusesValue4.get("code");
                                        if (codeValue6 != null && codeValue6 instanceof NullNode == false) {
                                            String codeInstance6;
                                            codeInstance6 = codeValue6.getTextValue();
                                            instanceViewStatusInstance5.setCode(codeInstance6);
                                        }

                                        JsonNode levelValue6 = statusesValue4.get("level");
                                        if (levelValue6 != null && levelValue6 instanceof NullNode == false) {
                                            String levelInstance6;
                                            levelInstance6 = levelValue6.getTextValue();
                                            instanceViewStatusInstance5.setLevel(levelInstance6);
                                        }

                                        JsonNode displayStatusValue6 = statusesValue4.get("displayStatus");
                                        if (displayStatusValue6 != null
                                                && displayStatusValue6 instanceof NullNode == false) {
                                            String displayStatusInstance6;
                                            displayStatusInstance6 = displayStatusValue6.getTextValue();
                                            instanceViewStatusInstance5
                                                    .setDisplayStatus(displayStatusInstance6);
                                        }

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

                                        JsonNode timeValue6 = statusesValue4.get("time");
                                        if (timeValue6 != null && timeValue6 instanceof NullNode == false) {
                                            Calendar timeInstance6;
                                            timeInstance6 = DatatypeConverter
                                                    .parseDateTime(timeValue6.getTextValue());
                                            instanceViewStatusInstance5.setTime(timeInstance6);
                                        }
                                    }
                                }
                            }
                        }

                        JsonNode resourcesArray = valueValue.get("resources");
                        if (resourcesArray != null && resourcesArray instanceof NullNode == false) {
                            virtualMachineJsonInstance.setExtensions(new ArrayList<VirtualMachineExtension>());
                            for (JsonNode resourcesValue : ((ArrayNode) resourcesArray)) {
                                VirtualMachineExtension virtualMachineExtensionJsonInstance = new VirtualMachineExtension();
                                virtualMachineJsonInstance.getExtensions()
                                        .add(virtualMachineExtensionJsonInstance);

                                JsonNode propertiesValue3 = resourcesValue.get("properties");
                                if (propertiesValue3 != null && propertiesValue3 instanceof NullNode == false) {
                                    JsonNode publisherValue3 = propertiesValue3.get("publisher");
                                    if (publisherValue3 != null
                                            && publisherValue3 instanceof NullNode == false) {
                                        String publisherInstance3;
                                        publisherInstance3 = publisherValue3.getTextValue();
                                        virtualMachineExtensionJsonInstance.setPublisher(publisherInstance3);
                                    }

                                    JsonNode typeValue3 = propertiesValue3.get("type");
                                    if (typeValue3 != null && typeValue3 instanceof NullNode == false) {
                                        String typeInstance3;
                                        typeInstance3 = typeValue3.getTextValue();
                                        virtualMachineExtensionJsonInstance.setExtensionType(typeInstance3);
                                    }

                                    JsonNode typeHandlerVersionValue3 = propertiesValue3
                                            .get("typeHandlerVersion");
                                    if (typeHandlerVersionValue3 != null
                                            && typeHandlerVersionValue3 instanceof NullNode == false) {
                                        String typeHandlerVersionInstance3;
                                        typeHandlerVersionInstance3 = typeHandlerVersionValue3.getTextValue();
                                        virtualMachineExtensionJsonInstance
                                                .setTypeHandlerVersion(typeHandlerVersionInstance3);
                                    }

                                    JsonNode autoUpgradeMinorVersionValue = propertiesValue3
                                            .get("autoUpgradeMinorVersion");
                                    if (autoUpgradeMinorVersionValue != null
                                            && autoUpgradeMinorVersionValue instanceof NullNode == false) {
                                        boolean autoUpgradeMinorVersionInstance;
                                        autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue
                                                .getBooleanValue();
                                        virtualMachineExtensionJsonInstance
                                                .setAutoUpgradeMinorVersion(autoUpgradeMinorVersionInstance);
                                    }

                                    JsonNode settingsValue = propertiesValue3.get("settings");
                                    if (settingsValue != null && settingsValue instanceof NullNode == false) {
                                        String settingsInstance;
                                        settingsInstance = settingsValue.getTextValue();
                                        virtualMachineExtensionJsonInstance.setSettings(settingsInstance);
                                    }

                                    JsonNode protectedSettingsValue = propertiesValue3.get("protectedSettings");
                                    if (protectedSettingsValue != null
                                            && protectedSettingsValue instanceof NullNode == false) {
                                        String protectedSettingsInstance;
                                        protectedSettingsInstance = protectedSettingsValue.getTextValue();
                                        virtualMachineExtensionJsonInstance
                                                .setProtectedSettings(protectedSettingsInstance);
                                    }

                                    JsonNode provisioningStateValue2 = propertiesValue3
                                            .get("provisioningState");
                                    if (provisioningStateValue2 != null
                                            && provisioningStateValue2 instanceof NullNode == false) {
                                        String provisioningStateInstance2;
                                        provisioningStateInstance2 = provisioningStateValue2.getTextValue();
                                        virtualMachineExtensionJsonInstance
                                                .setProvisioningState(provisioningStateInstance2);
                                    }

                                    JsonNode instanceViewValue2 = propertiesValue3.get("instanceView");
                                    if (instanceViewValue2 != null
                                            && instanceViewValue2 instanceof NullNode == false) {
                                        VirtualMachineExtensionInstanceView instanceViewInstance2 = new VirtualMachineExtensionInstanceView();
                                        virtualMachineExtensionJsonInstance
                                                .setInstanceView(instanceViewInstance2);

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

                                        JsonNode typeValue4 = instanceViewValue2.get("type");
                                        if (typeValue4 != null && typeValue4 instanceof NullNode == false) {
                                            String typeInstance4;
                                            typeInstance4 = typeValue4.getTextValue();
                                            instanceViewInstance2.setExtensionType(typeInstance4);
                                        }

                                        JsonNode typeHandlerVersionValue4 = instanceViewValue2
                                                .get("typeHandlerVersion");
                                        if (typeHandlerVersionValue4 != null
                                                && typeHandlerVersionValue4 instanceof NullNode == false) {
                                            String typeHandlerVersionInstance4;
                                            typeHandlerVersionInstance4 = typeHandlerVersionValue4
                                                    .getTextValue();
                                            instanceViewInstance2
                                                    .setTypeHandlerVersion(typeHandlerVersionInstance4);
                                        }

                                        JsonNode substatusesArray2 = instanceViewValue2.get("substatuses");
                                        if (substatusesArray2 != null
                                                && substatusesArray2 instanceof NullNode == false) {
                                            for (JsonNode substatusesValue2 : ((ArrayNode) substatusesArray2)) {
                                                InstanceViewStatus instanceViewStatusInstance6 = new InstanceViewStatus();
                                                instanceViewInstance2.getSubStatuses()
                                                        .add(instanceViewStatusInstance6);

                                                JsonNode codeValue7 = substatusesValue2.get("code");
                                                if (codeValue7 != null
                                                        && codeValue7 instanceof NullNode == false) {
                                                    String codeInstance7;
                                                    codeInstance7 = codeValue7.getTextValue();
                                                    instanceViewStatusInstance6.setCode(codeInstance7);
                                                }

                                                JsonNode levelValue7 = substatusesValue2.get("level");
                                                if (levelValue7 != null
                                                        && levelValue7 instanceof NullNode == false) {
                                                    String levelInstance7;
                                                    levelInstance7 = levelValue7.getTextValue();
                                                    instanceViewStatusInstance6.setLevel(levelInstance7);
                                                }

                                                JsonNode displayStatusValue7 = substatusesValue2
                                                        .get("displayStatus");
                                                if (displayStatusValue7 != null
                                                        && displayStatusValue7 instanceof NullNode == false) {
                                                    String displayStatusInstance7;
                                                    displayStatusInstance7 = displayStatusValue7.getTextValue();
                                                    instanceViewStatusInstance6
                                                            .setDisplayStatus(displayStatusInstance7);
                                                }

                                                JsonNode messageValue7 = substatusesValue2.get("message");
                                                if (messageValue7 != null
                                                        && messageValue7 instanceof NullNode == false) {
                                                    String messageInstance7;
                                                    messageInstance7 = messageValue7.getTextValue();
                                                    instanceViewStatusInstance6.setMessage(messageInstance7);
                                                }

                                                JsonNode timeValue7 = substatusesValue2.get("time");
                                                if (timeValue7 != null
                                                        && timeValue7 instanceof NullNode == false) {
                                                    Calendar timeInstance7;
                                                    timeInstance7 = DatatypeConverter
                                                            .parseDateTime(timeValue7.getTextValue());
                                                    instanceViewStatusInstance6.setTime(timeInstance7);
                                                }
                                            }
                                        }

                                        JsonNode statusesArray5 = instanceViewValue2.get("statuses");
                                        if (statusesArray5 != null
                                                && statusesArray5 instanceof NullNode == false) {
                                            for (JsonNode statusesValue5 : ((ArrayNode) statusesArray5)) {
                                                InstanceViewStatus instanceViewStatusInstance7 = new InstanceViewStatus();
                                                instanceViewInstance2.getStatuses()
                                                        .add(instanceViewStatusInstance7);

                                                JsonNode codeValue8 = statusesValue5.get("code");
                                                if (codeValue8 != null
                                                        && codeValue8 instanceof NullNode == false) {
                                                    String codeInstance8;
                                                    codeInstance8 = codeValue8.getTextValue();
                                                    instanceViewStatusInstance7.setCode(codeInstance8);
                                                }

                                                JsonNode levelValue8 = statusesValue5.get("level");
                                                if (levelValue8 != null
                                                        && levelValue8 instanceof NullNode == false) {
                                                    String levelInstance8;
                                                    levelInstance8 = levelValue8.getTextValue();
                                                    instanceViewStatusInstance7.setLevel(levelInstance8);
                                                }

                                                JsonNode displayStatusValue8 = statusesValue5
                                                        .get("displayStatus");
                                                if (displayStatusValue8 != null
                                                        && displayStatusValue8 instanceof NullNode == false) {
                                                    String displayStatusInstance8;
                                                    displayStatusInstance8 = displayStatusValue8.getTextValue();
                                                    instanceViewStatusInstance7
                                                            .setDisplayStatus(displayStatusInstance8);
                                                }

                                                JsonNode messageValue8 = statusesValue5.get("message");
                                                if (messageValue8 != null
                                                        && messageValue8 instanceof NullNode == false) {
                                                    String messageInstance8;
                                                    messageInstance8 = messageValue8.getTextValue();
                                                    instanceViewStatusInstance7.setMessage(messageInstance8);
                                                }

                                                JsonNode timeValue8 = statusesValue5.get("time");
                                                if (timeValue8 != null
                                                        && timeValue8 instanceof NullNode == false) {
                                                    Calendar timeInstance8;
                                                    timeInstance8 = DatatypeConverter
                                                            .parseDateTime(timeValue8.getTextValue());
                                                    instanceViewStatusInstance7.setTime(timeInstance8);
                                                }
                                            }
                                        }
                                    }
                                }

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

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

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

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

                                JsonNode tagsSequenceElement = ((JsonNode) resourcesValue.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();
                                        virtualMachineExtensionJsonInstance.getTags().put(tagsKey, tagsValue);
                                    }
                                }
                            }
                        }

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

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

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

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

                        JsonNode tagsSequenceElement2 = ((JsonNode) valueValue.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();
                                virtualMachineJsonInstance.getTags().put(tagsKey2, tagsValue2);
                            }
                        }
                    }
                }

                JsonNode nextLinkValue = responseDoc.get("nextLink");
                if (nextLinkValue != null && nextLinkValue instanceof NullNode == false) {
                    String nextLinkInstance;
                    nextLinkInstance = nextLinkValue.getTextValue();
                    result.setNextLink(nextLinkInstance);
                }
            }

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

/**
* Returns information about Azure SQL Databases.
*
* @param resourceGroupName Required. The name of the Resource Group to
* which the server belongs./*from  w w  w  . j ava 2 s . co m*/
* @param serverName Required. The name of the Azure SQL Database Server in
* which the Azure SQL Databases are hosted.
* @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 Represents the response to a List Azure Sql Database request.
*/
@Override
public DatabaseListResponse list(String resourceGroupName, String serverName)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (serverName == null) {
        throw new NullPointerException("serverName");
    }

    // 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);
        CloudTracing.enter(invocationId, this, "listAsync", 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";
    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
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers

    // 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
        DatabaseListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new DatabaseListResponse();
            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)) {
                        Database databaseInstance = new Database();
                        result.getDatabases().add(databaseInstance);

                        JsonNode propertiesValue = valueValue.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 = valueValue.get("id");
                        if (idValue8 != null && idValue8 instanceof NullNode == false) {
                            String idInstance8;
                            idInstance8 = idValue8.getTextValue();
                            databaseInstance.setId(idInstance8);
                        }

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

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

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

                        JsonNode tagsSequenceElement8 = ((JsonNode) valueValue.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("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

/**
* Get the execution history of a Job./*from  w  w  w.j a va 2s  .  co  m*/
*
* @param jobId Required. Id of the job to get the history of.
* @param parameters Required. Parameters supplied to the Get Job History
* 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.
* @return The Get Job History operation response.
*/
@Override
public JobGetHistoryResponse getHistory(String jobId, JobGetHistoryParameters parameters)
        throws IOException, ServiceException {
    // Validate
    if (jobId == null) {
        throw new NullPointerException("jobId");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }

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

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

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

    // Set Headers
    httpRequest.setHeader("x-ms-version", "2013-03-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.createFromJson(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        JobGetHistoryResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new JobGetHistoryResponse();
            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 jobHistoryArray = responseDoc;
                if (jobHistoryArray != null && jobHistoryArray instanceof NullNode == false) {
                    for (JsonNode jobHistoryValue : ((ArrayNode) jobHistoryArray)) {
                        JobGetHistoryResponse.JobHistoryEntry jobHistoryEntryInstance = new JobGetHistoryResponse.JobHistoryEntry();
                        result.getJobHistory().add(jobHistoryEntryInstance);

                        JsonNode jobIdValue = jobHistoryValue.get("jobId");
                        if (jobIdValue != null && jobIdValue instanceof NullNode == false) {
                            String jobIdInstance;
                            jobIdInstance = jobIdValue.getTextValue();
                            jobHistoryEntryInstance.setId(jobIdInstance);
                        }

                        JsonNode timestampValue = jobHistoryValue.get("timestamp");
                        if (timestampValue != null && timestampValue instanceof NullNode == false) {
                            Calendar timestampInstance;
                            timestampInstance = DatatypeConverter.parseDateTime(timestampValue.getTextValue());
                            jobHistoryEntryInstance.setTimestamp(timestampInstance);
                        }

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

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

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

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

                        JsonNode statusValue = jobHistoryValue.get("status");
                        if (statusValue != null && statusValue instanceof NullNode == false) {
                            JobHistoryStatus statusInstance;
                            statusInstance = SchedulerClientImpl
                                    .parseJobHistoryStatus(statusValue.getTextValue());
                            jobHistoryEntryInstance.setStatus(statusInstance);
                        }

                        JsonNode actionNameValue = jobHistoryValue.get("actionName");
                        if (actionNameValue != null && actionNameValue instanceof NullNode == false) {
                            JobHistoryActionName actionNameInstance;
                            actionNameInstance = SchedulerClientImpl
                                    .parseJobHistoryActionName(actionNameValue.getTextValue());
                            jobHistoryEntryInstance.setActionName(actionNameInstance);
                        }

                        JsonNode repeatCountValue = jobHistoryValue.get("repeatCount");
                        if (repeatCountValue != null && repeatCountValue instanceof NullNode == false) {
                            int repeatCountInstance;
                            repeatCountInstance = repeatCountValue.getIntValue();
                            jobHistoryEntryInstance.setRepeatCount(repeatCountInstance);
                        }

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

        }
        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();
        }
    }
}