Example usage for javax.xml.bind DatatypeConverter parseInt

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

Introduction

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

Prototype

public static int parseInt(String lexicalXSDInt) 

Source Link

Document

Convert the string argument into an int value.

Usage

From source file:com.microsoft.windowsazure.management.sql.DatabaseOperationsImpl.java

/**
* Updates the properties of an Azure SQL Database.
*
* @param serverName Required. The name of the Azure SQL Database Server
* where the database is hosted.//from   w w w . j av a2 s  . com
* @param databaseName Required. The name of the Azure SQL Database to be
* updated.
* @param parameters Required. The parameters for the Update Database
* operation.
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return Contains the response from a request to Update Database.
*/
@Override
public DatabaseUpdateResponse update(String serverName, String databaseName,
        DatabaseUpdateParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (serverName == null) {
        throw new NullPointerException("serverName");
    }
    if (databaseName == null) {
        throw new NullPointerException("databaseName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getEdition() == null) {
        throw new NullPointerException("parameters.Edition");
    }

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

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/sqlservers/servers/";
    url = url + URLEncoder.encode(serverName, "UTF-8");
    url = url + "/databases/";
    url = url + URLEncoder.encode(databaseName, "UTF-8");
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

From source file:com.microsoft.azure.management.network.ApplicationGatewayOperationsImpl.java

/**
* The delete applicationgateway operation deletes the specified
* applicationgateway./*w  ww  .j av  a2 s.  c  om*/
*
* @param resourceGroupName Required. The name of the resource group.
* @param applicationGatewayName Required. The name of the
* applicationgateway.
* @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 If the resource provide needs to return an error to any
* operation, it should return the appropriate HTTP error code and a
* message body as can be seen below.The message should be localized per
* the Accept-Language header specified in the original request such thatit
* could be directly be exposed to users
*/
@Override
public UpdateOperationResponse beginDeleting(String resourceGroupName, String applicationGatewayName)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (applicationGatewayName == null) {
        throw new NullPointerException("applicationGatewayName");
    }

    // 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("applicationGatewayName", applicationGatewayName);
        CloudTracing.enter(invocationId, this, "beginDeletingAsync", 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.Network";
    url = url + "/applicationGateways/";
    url = url + URLEncoder.encode(applicationGatewayName, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-05-01-preview");
    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
    CustomHttpDelete httpRequest = new CustomHttpDelete(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 && statusCode != HttpStatus.SC_ACCEPTED
                && statusCode != HttpStatus.SC_NO_CONTENT) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        UpdateOperationResponse result = null;
        // Deserialize Response
        result = new UpdateOperationResponse();
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Azure-AsyncOperation").length > 0) {
            result.setAzureAsyncOperation(httpResponse.getFirstHeader("Azure-AsyncOperation").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue()));
        }
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (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.RouteOperationsImpl.java

/**
* Get the specified route table for this subscription.
*
* @param routeTableName Required. The name of the route table in this
* subscription to retrieve./*from  ww w.  j ava 2  s  .c  o  m*/
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @return A standard service response including an HTTP status code and
* request ID.
*/
@Override
public GetRouteTableResponse getRouteTable(String routeTableName)
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate
    if (routeTableName == null) {
        throw new NullPointerException("routeTableName");
    }

    // 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("routeTableName", routeTableName);
        CloudTracing.enter(invocationId, this, "getRouteTableAsync", 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/routetables/";
    url = url + URLEncoder.encode(routeTableName, "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("Content-Type", "application/xml");
    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
        GetRouteTableResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new GetRouteTableResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element routeTableElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "RouteTable");
            if (routeTableElement != null) {
                RouteTable routeTableInstance = new RouteTable();
                result.setRouteTable(routeTableInstance);

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

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

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

                Element routeTableStateElement = XmlUtility.getElementByTagNameNS(routeTableElement,
                        "http://schemas.microsoft.com/windowsazure", "RouteTableState");
                if (routeTableStateElement != null && routeTableStateElement.getTextContent() != null
                        && !routeTableStateElement.getTextContent().isEmpty()) {
                    RouteTableState routeTableStateInstance;
                    routeTableStateInstance = RouteTableState.valueOf(routeTableStateElement.getTextContent());
                    routeTableInstance.setRouteTableState(routeTableStateInstance);
                }

                Element routeListSequenceElement = XmlUtility.getElementByTagNameNS(routeTableElement,
                        "http://schemas.microsoft.com/windowsazure", "RouteList");
                if (routeListSequenceElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(routeListSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "Route")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element routeListElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(routeListSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "Route")
                                .get(i1));
                        Route routeInstance = new Route();
                        routeTableInstance.getRouteList().add(routeInstance);

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

                        Element addressPrefixElement = XmlUtility.getElementByTagNameNS(routeListElement,
                                "http://schemas.microsoft.com/windowsazure", "AddressPrefix");
                        if (addressPrefixElement != null) {
                            String addressPrefixInstance;
                            addressPrefixInstance = addressPrefixElement.getTextContent();
                            routeInstance.setAddressPrefix(addressPrefixInstance);
                        }

                        Element nextHopTypeElement = XmlUtility.getElementByTagNameNS(routeListElement,
                                "http://schemas.microsoft.com/windowsazure", "NextHopType");
                        if (nextHopTypeElement != null) {
                            NextHop nextHopTypeInstance = new NextHop();
                            routeInstance.setNextHop(nextHopTypeInstance);

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

                            Element ipAddressElement = XmlUtility.getElementByTagNameNS(nextHopTypeElement,
                                    "http://schemas.microsoft.com/windowsazure", "IpAddress");
                            if (ipAddressElement != null) {
                                String ipAddressInstance;
                                ipAddressInstance = ipAddressElement.getTextContent();
                                nextHopTypeInstance.setIpAddress(ipAddressInstance);
                            }
                        }

                        Element metricElement = XmlUtility.getElementByTagNameNS(routeListElement,
                                "http://schemas.microsoft.com/windowsazure", "Metric");
                        if (metricElement != null) {
                            int metricInstance;
                            metricInstance = DatatypeConverter.parseInt(metricElement.getTextContent());
                            routeInstance.setMetric(metricInstance);
                        }

                        Element routeStateElement = XmlUtility.getElementByTagNameNS(routeListElement,
                                "http://schemas.microsoft.com/windowsazure", "RouteState");
                        if (routeStateElement != null && routeStateElement.getTextContent() != null
                                && !routeStateElement.getTextContent().isEmpty()) {
                            RouteState routeStateInstance;
                            routeStateInstance = RouteState.valueOf(routeStateElement.getTextContent());
                            routeInstance.setState(routeStateInstance);
                        }
                    }
                }
            }

        }
        result.setStatusCode(statusCode);

        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.servicebus.TopicOperationsImpl.java

/**
* Enumerates the topics in the service namespace. An empty feed is returned
* if no topic exists in the service namespace.  (see
* http://msdn.microsoft.com/en-us/library/windowsazure/hh780744.aspx for
* more information)/*www .j  a  v  a 2 s  .com*/
*
* @param namespaceName Required. The namespace 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 A response to a request for a list of topics.
*/
@Override
public ServiceBusTopicsResponse list(String namespaceName)
        throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException {
    // Validate
    if (namespaceName == null) {
        throw new NullPointerException("namespaceName");
    }

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

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/servicebus/namespaces/";
    url = url + URLEncoder.encode(namespaceName, "UTF-8");
    url = url + "/topics/";
    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/xml; charset=utf-8");
    httpRequest.setHeader("x-ms-version", "2013-08-01");

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

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

            Element feedElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://www.w3.org/2005/Atom",
                    "feed");
            if (feedElement != null) {
                if (feedElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(feedElement, "http://www.w3.org/2005/Atom", "entry")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element entriesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(feedElement, "http://www.w3.org/2005/Atom", "entry")
                                .get(i1));
                        ServiceBusTopic entryInstance = new ServiceBusTopic();
                        result.getTopics().add(entryInstance);

                        Element titleElement = XmlUtility.getElementByTagNameNS(entriesElement,
                                "http://www.w3.org/2005/Atom", "title");
                        if (titleElement != null) {
                            String titleInstance;
                            titleInstance = titleElement.getTextContent();
                            entryInstance.setName(titleInstance);
                        }

                        Element contentElement = XmlUtility.getElementByTagNameNS(entriesElement,
                                "http://www.w3.org/2005/Atom", "content");
                        if (contentElement != null) {
                            Element topicDescriptionElement = XmlUtility.getElementByTagNameNS(contentElement,
                                    "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                    "TopicDescription");
                            if (topicDescriptionElement != null) {
                                Element defaultMessageTimeToLiveElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "DefaultMessageTimeToLive");
                                if (defaultMessageTimeToLiveElement != null) {
                                    String defaultMessageTimeToLiveInstance;
                                    defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement
                                            .getTextContent();
                                    entryInstance.setDefaultMessageTimeToLive(defaultMessageTimeToLiveInstance);
                                }

                                Element maxSizeInMegabytesElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "MaxSizeInMegabytes");
                                if (maxSizeInMegabytesElement != null) {
                                    int maxSizeInMegabytesInstance;
                                    maxSizeInMegabytesInstance = DatatypeConverter
                                            .parseInt(maxSizeInMegabytesElement.getTextContent());
                                    entryInstance.setMaxSizeInMegabytes(maxSizeInMegabytesInstance);
                                }

                                Element requiresDuplicateDetectionElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "RequiresDuplicateDetection");
                                if (requiresDuplicateDetectionElement != null) {
                                    boolean requiresDuplicateDetectionInstance;
                                    requiresDuplicateDetectionInstance = DatatypeConverter.parseBoolean(
                                            requiresDuplicateDetectionElement.getTextContent().toLowerCase());
                                    entryInstance
                                            .setRequiresDuplicateDetection(requiresDuplicateDetectionInstance);
                                }

                                Element duplicateDetectionHistoryTimeWindowElement = XmlUtility
                                        .getElementByTagNameNS(topicDescriptionElement,
                                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                                "DuplicateDetectionHistoryTimeWindow");
                                if (duplicateDetectionHistoryTimeWindowElement != null) {
                                    String duplicateDetectionHistoryTimeWindowInstance;
                                    duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement
                                            .getTextContent();
                                    entryInstance.setDuplicateDetectionHistoryTimeWindow(
                                            duplicateDetectionHistoryTimeWindowInstance);
                                }

                                Element enableBatchedOperationsElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "EnableBatchedOperations");
                                if (enableBatchedOperationsElement != null) {
                                    boolean enableBatchedOperationsInstance;
                                    enableBatchedOperationsInstance = DatatypeConverter.parseBoolean(
                                            enableBatchedOperationsElement.getTextContent().toLowerCase());
                                    entryInstance.setEnableBatchedOperations(enableBatchedOperationsInstance);
                                }

                                Element sizeInBytesElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "SizeInBytes");
                                if (sizeInBytesElement != null) {
                                    int sizeInBytesInstance;
                                    sizeInBytesInstance = DatatypeConverter
                                            .parseInt(sizeInBytesElement.getTextContent());
                                    entryInstance.setSizeInBytes(sizeInBytesInstance);
                                }

                                Element filteringMessagesBeforePublishingElement = XmlUtility
                                        .getElementByTagNameNS(topicDescriptionElement,
                                                "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                                "FilteringMessagesBeforePublishing");
                                if (filteringMessagesBeforePublishingElement != null) {
                                    boolean filteringMessagesBeforePublishingInstance;
                                    filteringMessagesBeforePublishingInstance = DatatypeConverter
                                            .parseBoolean(filteringMessagesBeforePublishingElement
                                                    .getTextContent().toLowerCase());
                                    entryInstance.setFilteringMessagesBeforePublishing(
                                            filteringMessagesBeforePublishingInstance);
                                }

                                Element isAnonymousAccessibleElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "IsAnonymousAccessible");
                                if (isAnonymousAccessibleElement != null) {
                                    boolean isAnonymousAccessibleInstance;
                                    isAnonymousAccessibleInstance = DatatypeConverter.parseBoolean(
                                            isAnonymousAccessibleElement.getTextContent().toLowerCase());
                                    entryInstance.setIsAnonymousAccessible(isAnonymousAccessibleInstance);
                                }

                                Element authorizationRulesSequenceElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "AuthorizationRules");
                                if (authorizationRulesSequenceElement != null) {
                                    for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(authorizationRulesSequenceElement,
                                                    "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                                    "AuthorizationRule")
                                            .size(); i2 = i2 + 1) {
                                        org.w3c.dom.Element authorizationRulesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(authorizationRulesSequenceElement,
                                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                                        "AuthorizationRule")
                                                .get(i2));
                                        ServiceBusSharedAccessAuthorizationRule authorizationRuleInstance = new ServiceBusSharedAccessAuthorizationRule();
                                        entryInstance.getAuthorizationRules().add(authorizationRuleInstance);

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

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

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

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

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

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

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

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

                                Element statusElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "Status");
                                if (statusElement != null) {
                                    String statusInstance;
                                    statusInstance = statusElement.getTextContent();
                                    entryInstance.setStatus(statusInstance);
                                }

                                Element createdAtElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "CreatedAt");
                                if (createdAtElement != null) {
                                    Calendar createdAtInstance;
                                    createdAtInstance = DatatypeConverter
                                            .parseDateTime(createdAtElement.getTextContent());
                                    entryInstance.setCreatedAt(createdAtInstance);
                                }

                                Element updatedAtElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "UpdatedAt");
                                if (updatedAtElement != null) {
                                    Calendar updatedAtInstance;
                                    updatedAtInstance = DatatypeConverter
                                            .parseDateTime(updatedAtElement.getTextContent());
                                    entryInstance.setUpdatedAt(updatedAtInstance);
                                }

                                Element accessedAtElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "AccessedAt");
                                if (accessedAtElement != null) {
                                    Calendar accessedAtInstance;
                                    accessedAtInstance = DatatypeConverter
                                            .parseDateTime(accessedAtElement.getTextContent());
                                    entryInstance.setAccessedAt(accessedAtInstance);
                                }

                                Element supportOrderingElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "SupportOrdering");
                                if (supportOrderingElement != null) {
                                    boolean supportOrderingInstance;
                                    supportOrderingInstance = DatatypeConverter.parseBoolean(
                                            supportOrderingElement.getTextContent().toLowerCase());
                                    entryInstance.setSupportOrdering(supportOrderingInstance);
                                }

                                Element countDetailsElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "CountDetails");
                                if (countDetailsElement != null) {
                                    CountDetails countDetailsInstance = new CountDetails();
                                    entryInstance.setCountDetails(countDetailsInstance);
                                }

                                Element subscriptionCountElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "SubscriptionCount");
                                if (subscriptionCountElement != null) {
                                    int subscriptionCountInstance;
                                    subscriptionCountInstance = DatatypeConverter
                                            .parseInt(subscriptionCountElement.getTextContent());
                                    entryInstance.setSubscriptionCount(subscriptionCountInstance);
                                }

                                Element autoDeleteOnIdleElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "AutoDeleteOnIdle");
                                if (autoDeleteOnIdleElement != null) {
                                    String autoDeleteOnIdleInstance;
                                    autoDeleteOnIdleInstance = autoDeleteOnIdleElement.getTextContent();
                                    entryInstance.setAutoDeleteOnIdle(autoDeleteOnIdleInstance);
                                }

                                Element entityAvailabilityStatusElement = XmlUtility.getElementByTagNameNS(
                                        topicDescriptionElement,
                                        "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect",
                                        "EntityAvailabilityStatus");
                                if (entityAvailabilityStatusElement != null) {
                                    String entityAvailabilityStatusInstance;
                                    entityAvailabilityStatusInstance = entityAvailabilityStatusElement
                                            .getTextContent();
                                    entryInstance.setEntityAvailabilityStatus(entityAvailabilityStatusInstance);
                                }
                            }
                        }
                    }
                }
            }

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

/**
* The Put VirtualNetworkGatewayConnectionSharedKey operation sets the
* virtual network gateway connection shared key for passed virtual network
* gateway connection in the specified resource group through Network
* resource provider.//from  ww  w.  j  a v a2  s . c o  m
*
* @param resourceGroupName Required. The name of the resource group.
* @param virtualNetworkGatewayConnectionName Required. The virtual network
* gateway connection name.
* @param parameters Required. Parameters supplied to the Begin Set Virtual
* Network Gateway conection Shared key operation throughNetwork resource
* provider.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return Response for PutVirtualNetworkGatewayConnectionSharedKey Api
* servive call
*/
@Override
public ConnectionSharedKeyPutResponse beginSetSharedKey(String resourceGroupName,
        String virtualNetworkGatewayConnectionName, ConnectionSharedKey parameters)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (virtualNetworkGatewayConnectionName == null) {
        throw new NullPointerException("virtualNetworkGatewayConnectionName");
    }
    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("resourceGroupName", resourceGroupName);
        tracingParameters.put("virtualNetworkGatewayConnectionName", virtualNetworkGatewayConnectionName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginSetSharedKeyAsync", 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.Network";
    url = url + "/connections/";
    url = url + URLEncoder.encode(virtualNetworkGatewayConnectionName, "UTF-8");
    url = url + "/sharedkey";
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-05-01-preview");
    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
    HttpPut httpRequest = new HttpPut(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json");

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

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

    ObjectNode propertiesValue = objectMapper.createObjectNode();
    ((ObjectNode) connectionSharedKeyJsonFormatValue).put("properties", propertiesValue);

    if (parameters.getValue() != null) {
        ((ObjectNode) propertiesValue).put("value", parameters.getValue());
    }

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

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

        // Create Result
        ConnectionSharedKeyPutResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new ConnectionSharedKeyPutResponse();
            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) {
                ConnectionSharedKey connectionSharedKeyInstance = new ConnectionSharedKey();
                result.setConnectionSharedKey(connectionSharedKeyInstance);

                JsonNode propertiesValue2 = responseDoc.get("properties");
                if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) {
                    JsonNode valueValue = propertiesValue2.get("value");
                    if (valueValue != null && valueValue instanceof NullNode == false) {
                        String valueInstance;
                        valueInstance = valueValue.getTextValue();
                        connectionSharedKeyInstance.setValue(valueInstance);
                    }
                }

                JsonNode errorValue = responseDoc.get("error");
                if (errorValue != null && errorValue instanceof NullNode == false) {
                    Error errorInstance = new Error();
                    result.setError(errorInstance);

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

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

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

                    JsonNode detailsArray = errorValue.get("details");
                    if (detailsArray != null && detailsArray instanceof NullNode == false) {
                        for (JsonNode detailsValue : ((ArrayNode) detailsArray)) {
                            ErrorDetails errorDetailsInstance = new ErrorDetails();
                            errorInstance.getDetails().add(errorDetailsInstance);

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

                            JsonNode targetValue2 = detailsValue.get("target");
                            if (targetValue2 != null && targetValue2 instanceof NullNode == false) {
                                String targetInstance2;
                                targetInstance2 = targetValue2.getTextValue();
                                errorDetailsInstance.setTarget(targetInstance2);
                            }

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

                    JsonNode innerErrorValue = errorValue.get("innerError");
                    if (innerErrorValue != null && innerErrorValue instanceof NullNode == false) {
                        String innerErrorInstance;
                        innerErrorInstance = innerErrorValue.getTextValue();
                        errorInstance.setInnerError(innerErrorInstance);
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Azure-AsyncOperation").length > 0) {
            result.setAzureAsyncOperation(httpResponse.getFirstHeader("Azure-AsyncOperation").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue()));
        }
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (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.notificationhubs.NamespaceOperationsImpl.java

/**
* The Get namespace Delete Operation Status operation returns the status of
* the delete operation. After calling the operation, you can call Get
* namespace Delete Operation Status to determine whether the operation has
* succeeded, failed, or is still in progress. This method differs from
* GetLongRunningOperationStatus in providing NotificationHub service
* resource description./* w  ww.j  av  a  2 s  . c o m*/
*
* @param operationStatusLink Required. Location value returned by the Begin
* operation.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws URISyntaxException Thrown if there was an error parsing a URI in
* the response.
* @return The response of the CreateOrUpdate Api Management service long
* running operation.
*/
@Override
public NamespaceLongRunningResponse getDeleteNamespaceOperationStatus(String operationStatusLink)
        throws IOException, ServiceException, URISyntaxException {
    // Validate
    if (operationStatusLink == null) {
        throw new NullPointerException("operationStatusLink");
    }

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

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

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

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

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

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

            if (responseDoc != null && responseDoc instanceof NullNode == false) {
                NamespaceResource valueInstance = new NamespaceResource();
                result.setValue(valueInstance);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

From source file:com.microsoft.azure.management.network.ApplicationGatewayOperationsImpl.java

/**
* The Start ApplicationGateway operation starts application gatewayin the
* specified resource group through Network resource provider.
*
* @param resourceGroupName Required. The name of the resource group.
* @param applicationGatewayName Required. The name of the application
* gateway./*from  w  ww.  j  ava 2 s.  c  o m*/
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return Response for PutVirtualNetworkGateway Api servive call
*/
@Override
public VirtualNetworkGatewayPutResponse beginStart(String resourceGroupName, String applicationGatewayName)
        throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (applicationGatewayName == null) {
        throw new NullPointerException("applicationGatewayName");
    }

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

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

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json");

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

        // Create Result
        VirtualNetworkGatewayPutResponse result = null;
        // Deserialize Response
        result = new VirtualNetworkGatewayPutResponse();
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Azure-AsyncOperation").length > 0) {
            result.setAzureAsyncOperation(httpResponse.getFirstHeader("Azure-AsyncOperation").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue()));
        }
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (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

/**
* Creates an association to a hybrid connection for a web site.
*
* @param webSpaceName Required. The name of the web space.
* @param siteName Required. The name of the web site.
* @param parameters Required. Parameters supplied to the Create Hybrid
* Connection operation.//from ww w .j av a2 s. c o m
* @throws ParserConfigurationException Thrown if there was an error
* configuring the parser for the response body.
* @throws SAXException Thrown if there was an error parsing the response
* body.
* @throws TransformerException Thrown if there was an error creating the
* DOM transformer.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return The Create Hybrid Connection operation response.
*/
@Override
public HybridConnectionCreateResponse createHybridConnection(String webSpaceName, String siteName,
        HybridConnectionCreateParameters parameters)
        throws ParserConfigurationException, SAXException, TransformerException, IOException, ServiceException {
    // Validate
    if (webSpaceName == null) {
        throw new NullPointerException("webSpaceName");
    }
    if (siteName == null) {
        throw new NullPointerException("siteName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getBiztalkUri() == null) {
        throw new NullPointerException("parameters.BiztalkUri");
    }
    if (parameters.getEntityConnectionString() == null) {
        throw new NullPointerException("parameters.EntityConnectionString");
    }
    if (parameters.getEntityName() == null) {
        throw new NullPointerException("parameters.EntityName");
    }
    if (parameters.getHostname() == null) {
        throw new NullPointerException("parameters.Hostname");
    }
    if (parameters.getResourceConnectionString() == null) {
        throw new NullPointerException("parameters.ResourceConnectionString");
    }
    if (parameters.getResourceType() == null) {
        throw new NullPointerException("parameters.ResourceType");
    }

    // 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("siteName", siteName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "createHybridConnectionAsync", 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(siteName, "UTF-8");
    url = url + "/hybridconnection";
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

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

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/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 relayServiceConnectionEntityElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "RelayServiceConnectionEntity");
    requestDoc.appendChild(relayServiceConnectionEntityElement);

    Element biztalkUriElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "BiztalkUri");
    biztalkUriElement.appendChild(requestDoc.createTextNode(parameters.getBiztalkUri()));
    relayServiceConnectionEntityElement.appendChild(biztalkUriElement);

    Element entityConnectionStringElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "EntityConnectionString");
    entityConnectionStringElement
            .appendChild(requestDoc.createTextNode(parameters.getEntityConnectionString()));
    relayServiceConnectionEntityElement.appendChild(entityConnectionStringElement);

    Element entityNameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "EntityName");
    entityNameElement.appendChild(requestDoc.createTextNode(parameters.getEntityName()));
    relayServiceConnectionEntityElement.appendChild(entityNameElement);

    Element hostnameElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "Hostname");
    hostnameElement.appendChild(requestDoc.createTextNode(parameters.getHostname()));
    relayServiceConnectionEntityElement.appendChild(hostnameElement);

    Element portElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Port");
    portElement.appendChild(requestDoc.createTextNode(Integer.toString(parameters.getPort())));
    relayServiceConnectionEntityElement.appendChild(portElement);

    Element resourceConnectionStringElement = requestDoc
            .createElementNS("http://schemas.microsoft.com/windowsazure", "ResourceConnectionString");
    resourceConnectionStringElement
            .appendChild(requestDoc.createTextNode(parameters.getResourceConnectionString()));
    relayServiceConnectionEntityElement.appendChild(resourceConnectionStringElement);

    Element resourceTypeElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure",
            "ResourceType");
    resourceTypeElement.appendChild(requestDoc.createTextNode(parameters.getResourceType()));
    relayServiceConnectionEntityElement.appendChild(resourceTypeElement);

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

            Element relayServiceConnectionEntityElement2 = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "RelayServiceConnectionEntity");
            if (relayServiceConnectionEntityElement2 != null) {
                HybridConnection hybridConnectionInstance = new HybridConnection();
                result.setHybridConnection(hybridConnectionInstance);

                Element entityNameElement2 = XmlUtility.getElementByTagNameNS(
                        relayServiceConnectionEntityElement2, "http://schemas.microsoft.com/windowsazure",
                        "EntityName");
                if (entityNameElement2 != null) {
                    String entityNameInstance;
                    entityNameInstance = entityNameElement2.getTextContent();
                    hybridConnectionInstance.setEntityName(entityNameInstance);
                }

                Element entityConnectionStringElement2 = XmlUtility.getElementByTagNameNS(
                        relayServiceConnectionEntityElement2, "http://schemas.microsoft.com/windowsazure",
                        "EntityConnectionString");
                if (entityConnectionStringElement2 != null) {
                    String entityConnectionStringInstance;
                    entityConnectionStringInstance = entityConnectionStringElement2.getTextContent();
                    hybridConnectionInstance.setEntityConnectionString(entityConnectionStringInstance);
                }

                Element resourceTypeElement2 = XmlUtility.getElementByTagNameNS(
                        relayServiceConnectionEntityElement2, "http://schemas.microsoft.com/windowsazure",
                        "ResourceType");
                if (resourceTypeElement2 != null) {
                    String resourceTypeInstance;
                    resourceTypeInstance = resourceTypeElement2.getTextContent();
                    hybridConnectionInstance.setResourceType(resourceTypeInstance);
                }

                Element resourceConnectionStringElement2 = XmlUtility.getElementByTagNameNS(
                        relayServiceConnectionEntityElement2, "http://schemas.microsoft.com/windowsazure",
                        "ResourceConnectionString");
                if (resourceConnectionStringElement2 != null) {
                    String resourceConnectionStringInstance;
                    resourceConnectionStringInstance = resourceConnectionStringElement2.getTextContent();
                    hybridConnectionInstance.setResourceConnectionString(resourceConnectionStringInstance);
                }

                Element hostnameElement2 = XmlUtility.getElementByTagNameNS(
                        relayServiceConnectionEntityElement2, "http://schemas.microsoft.com/windowsazure",
                        "Hostname");
                if (hostnameElement2 != null) {
                    String hostnameInstance;
                    hostnameInstance = hostnameElement2.getTextContent();
                    hybridConnectionInstance.setHostname(hostnameInstance);
                }

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

                Element biztalkUriElement2 = XmlUtility.getElementByTagNameNS(
                        relayServiceConnectionEntityElement2, "http://schemas.microsoft.com/windowsazure",
                        "BiztalkUri");
                if (biztalkUriElement2 != null) {
                    String biztalkUriInstance;
                    biztalkUriInstance = biztalkUriElement2.getTextContent();
                    hybridConnectionInstance.setBiztalkUri(biztalkUriInstance);
                }
            }

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

/**
* The Put LoadBalancer operation creates/updates a LoadBalancer
*
* @param resourceGroupName Required. The name of the resource group.
* @param loadBalancerName Required. The name of the loadBalancer.
* @param parameters Required. Parameters supplied to the create/delete
* LoadBalancer operation//from   w  ww  .  j ava  2 s  .co  m
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @return Response of a PUT Load Balancer operation
*/
@Override
public LoadBalancerPutResponse beginCreateOrUpdating(String resourceGroupName, String loadBalancerName,
        LoadBalancer parameters) throws IOException, ServiceException {
    // Validate
    if (resourceGroupName == null) {
        throw new NullPointerException("resourceGroupName");
    }
    if (loadBalancerName == null) {
        throw new NullPointerException("loadBalancerName");
    }
    if (parameters == null) {
        throw new NullPointerException("parameters");
    }
    if (parameters.getInboundNatPools() != null) {
        for (InboundNatPool inboundNatPoolsParameterItem : parameters.getInboundNatPools()) {
            if (inboundNatPoolsParameterItem.getProtocol() == null) {
                throw new NullPointerException("parameters.InboundNatPools.Protocol");
            }
        }
    }
    if (parameters.getInboundNatRules() != null) {
        for (InboundNatRule inboundNatRulesParameterItem : parameters.getInboundNatRules()) {
            if (inboundNatRulesParameterItem.getProtocol() == null) {
                throw new NullPointerException("parameters.InboundNatRules.Protocol");
            }
        }
    }
    if (parameters.getLoadBalancingRules() != null) {
        for (LoadBalancingRule loadBalancingRulesParameterItem : parameters.getLoadBalancingRules()) {
            if (loadBalancingRulesParameterItem.getBackendAddressPool() == null) {
                throw new NullPointerException("parameters.LoadBalancingRules.BackendAddressPool");
            }
            if (loadBalancingRulesParameterItem.getProtocol() == null) {
                throw new NullPointerException("parameters.LoadBalancingRules.Protocol");
            }
        }
    }
    if (parameters.getLocation() == null) {
        throw new NullPointerException("parameters.Location");
    }
    if (parameters.getOutboundNatRules() != null) {
        for (OutboundNatRule outboundNatRulesParameterItem : parameters.getOutboundNatRules()) {
            if (outboundNatRulesParameterItem.getBackendAddressPool() == null) {
                throw new NullPointerException("parameters.OutboundNatRules.BackendAddressPool");
            }
        }
    }
    if (parameters.getProbes() != null) {
        for (Probe probesParameterItem : parameters.getProbes()) {
            if (probesParameterItem.getProtocol() == null) {
                throw new NullPointerException("parameters.Probes.Protocol");
            }
        }
    }

    // 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("loadBalancerName", loadBalancerName);
        tracingParameters.put("parameters", parameters);
        CloudTracing.enter(invocationId, this, "beginCreateOrUpdatingAsync", 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.Network";
    url = url + "/loadBalancers/";
    url = url + URLEncoder.encode(loadBalancerName, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("api-version=" + "2015-05-01-preview");
    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
    HttpPut httpRequest = new HttpPut(url);

    // Set Headers
    httpRequest.setHeader("Content-Type", "application/json");

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

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

    ObjectNode propertiesValue = objectMapper.createObjectNode();
    ((ObjectNode) loadBalancerJsonFormatValue).put("properties", propertiesValue);

    if (parameters.getFrontendIpConfigurations() != null) {
        if (parameters.getFrontendIpConfigurations() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getFrontendIpConfigurations()).isInitialized()) {
            ArrayNode frontendIPConfigurationsArray = objectMapper.createArrayNode();
            for (FrontendIpConfiguration frontendIPConfigurationsItem : parameters
                    .getFrontendIpConfigurations()) {
                ObjectNode frontendIpConfigurationJsonFormatValue = objectMapper.createObjectNode();
                frontendIPConfigurationsArray.add(frontendIpConfigurationJsonFormatValue);

                ObjectNode propertiesValue2 = objectMapper.createObjectNode();
                ((ObjectNode) frontendIpConfigurationJsonFormatValue).put("properties", propertiesValue2);

                if (frontendIPConfigurationsItem.getPrivateIpAddress() != null) {
                    ((ObjectNode) propertiesValue2).put("privateIPAddress",
                            frontendIPConfigurationsItem.getPrivateIpAddress());
                }

                if (frontendIPConfigurationsItem.getPrivateIpAllocationMethod() != null) {
                    ((ObjectNode) propertiesValue2).put("privateIPAllocationMethod",
                            frontendIPConfigurationsItem.getPrivateIpAllocationMethod());
                }

                if (frontendIPConfigurationsItem.getSubnet() != null) {
                    ObjectNode subnetValue = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue2).put("subnet", subnetValue);

                    if (frontendIPConfigurationsItem.getSubnet().getId() != null) {
                        ((ObjectNode) subnetValue).put("id", frontendIPConfigurationsItem.getSubnet().getId());
                    }
                }

                if (frontendIPConfigurationsItem.getPublicIpAddress() != null) {
                    ObjectNode publicIPAddressValue = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue2).put("publicIPAddress", publicIPAddressValue);

                    if (frontendIPConfigurationsItem.getPublicIpAddress().getId() != null) {
                        ((ObjectNode) publicIPAddressValue).put("id",
                                frontendIPConfigurationsItem.getPublicIpAddress().getId());
                    }
                }

                if (frontendIPConfigurationsItem.getInboundNatRules() != null) {
                    if (frontendIPConfigurationsItem.getInboundNatRules() instanceof LazyCollection == false
                            || ((LazyCollection) frontendIPConfigurationsItem.getInboundNatRules())
                                    .isInitialized()) {
                        ArrayNode inboundNatRulesArray = objectMapper.createArrayNode();
                        for (ResourceId inboundNatRulesItem : frontendIPConfigurationsItem
                                .getInboundNatRules()) {
                            ObjectNode resourceIdValue = objectMapper.createObjectNode();
                            inboundNatRulesArray.add(resourceIdValue);

                            if (inboundNatRulesItem.getId() != null) {
                                ((ObjectNode) resourceIdValue).put("id", inboundNatRulesItem.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue2).put("inboundNatRules", inboundNatRulesArray);
                    }
                }

                if (frontendIPConfigurationsItem.getInboundNatPools() != null) {
                    if (frontendIPConfigurationsItem.getInboundNatPools() instanceof LazyCollection == false
                            || ((LazyCollection) frontendIPConfigurationsItem.getInboundNatPools())
                                    .isInitialized()) {
                        ArrayNode inboundNatPoolsArray = objectMapper.createArrayNode();
                        for (ResourceId inboundNatPoolsItem : frontendIPConfigurationsItem
                                .getInboundNatPools()) {
                            ObjectNode resourceIdValue2 = objectMapper.createObjectNode();
                            inboundNatPoolsArray.add(resourceIdValue2);

                            if (inboundNatPoolsItem.getId() != null) {
                                ((ObjectNode) resourceIdValue2).put("id", inboundNatPoolsItem.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue2).put("inboundNatPools", inboundNatPoolsArray);
                    }
                }

                if (frontendIPConfigurationsItem.getOutboundNatRules() != null) {
                    if (frontendIPConfigurationsItem.getOutboundNatRules() instanceof LazyCollection == false
                            || ((LazyCollection) frontendIPConfigurationsItem.getOutboundNatRules())
                                    .isInitialized()) {
                        ArrayNode outboundNatRulesArray = objectMapper.createArrayNode();
                        for (ResourceId outboundNatRulesItem : frontendIPConfigurationsItem
                                .getOutboundNatRules()) {
                            ObjectNode resourceIdValue3 = objectMapper.createObjectNode();
                            outboundNatRulesArray.add(resourceIdValue3);

                            if (outboundNatRulesItem.getId() != null) {
                                ((ObjectNode) resourceIdValue3).put("id", outboundNatRulesItem.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue2).put("outboundNatRules", outboundNatRulesArray);
                    }
                }

                if (frontendIPConfigurationsItem.getLoadBalancingRules() != null) {
                    if (frontendIPConfigurationsItem.getLoadBalancingRules() instanceof LazyCollection == false
                            || ((LazyCollection) frontendIPConfigurationsItem.getLoadBalancingRules())
                                    .isInitialized()) {
                        ArrayNode loadBalancingRulesArray = objectMapper.createArrayNode();
                        for (ResourceId loadBalancingRulesItem : frontendIPConfigurationsItem
                                .getLoadBalancingRules()) {
                            ObjectNode resourceIdValue4 = objectMapper.createObjectNode();
                            loadBalancingRulesArray.add(resourceIdValue4);

                            if (loadBalancingRulesItem.getId() != null) {
                                ((ObjectNode) resourceIdValue4).put("id", loadBalancingRulesItem.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue2).put("loadBalancingRules", loadBalancingRulesArray);
                    }
                }

                if (frontendIPConfigurationsItem.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue2).put("provisioningState",
                            frontendIPConfigurationsItem.getProvisioningState());
                }

                if (frontendIPConfigurationsItem.getName() != null) {
                    ((ObjectNode) frontendIpConfigurationJsonFormatValue).put("name",
                            frontendIPConfigurationsItem.getName());
                }

                if (frontendIPConfigurationsItem.getEtag() != null) {
                    ((ObjectNode) frontendIpConfigurationJsonFormatValue).put("etag",
                            frontendIPConfigurationsItem.getEtag());
                }

                if (frontendIPConfigurationsItem.getId() != null) {
                    ((ObjectNode) frontendIpConfigurationJsonFormatValue).put("id",
                            frontendIPConfigurationsItem.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("frontendIPConfigurations", frontendIPConfigurationsArray);
        }
    }

    if (parameters.getBackendAddressPools() != null) {
        if (parameters.getBackendAddressPools() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getBackendAddressPools()).isInitialized()) {
            ArrayNode backendAddressPoolsArray = objectMapper.createArrayNode();
            for (BackendAddressPool backendAddressPoolsItem : parameters.getBackendAddressPools()) {
                ObjectNode backendAddressPoolJsonFormatValue = objectMapper.createObjectNode();
                backendAddressPoolsArray.add(backendAddressPoolJsonFormatValue);

                ObjectNode propertiesValue3 = objectMapper.createObjectNode();
                ((ObjectNode) backendAddressPoolJsonFormatValue).put("properties", propertiesValue3);

                if (backendAddressPoolsItem.getBackendIpConfigurations() != null) {
                    if (backendAddressPoolsItem.getBackendIpConfigurations() instanceof LazyCollection == false
                            || ((LazyCollection) backendAddressPoolsItem.getBackendIpConfigurations())
                                    .isInitialized()) {
                        ArrayNode backendIPConfigurationsArray = objectMapper.createArrayNode();
                        for (ResourceId backendIPConfigurationsItem : backendAddressPoolsItem
                                .getBackendIpConfigurations()) {
                            ObjectNode resourceIdValue5 = objectMapper.createObjectNode();
                            backendIPConfigurationsArray.add(resourceIdValue5);

                            if (backendIPConfigurationsItem.getId() != null) {
                                ((ObjectNode) resourceIdValue5).put("id", backendIPConfigurationsItem.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue3).put("backendIPConfigurations",
                                backendIPConfigurationsArray);
                    }
                }

                if (backendAddressPoolsItem.getLoadBalancingRules() != null) {
                    if (backendAddressPoolsItem.getLoadBalancingRules() instanceof LazyCollection == false
                            || ((LazyCollection) backendAddressPoolsItem.getLoadBalancingRules())
                                    .isInitialized()) {
                        ArrayNode loadBalancingRulesArray2 = objectMapper.createArrayNode();
                        for (ResourceId loadBalancingRulesItem2 : backendAddressPoolsItem
                                .getLoadBalancingRules()) {
                            ObjectNode resourceIdValue6 = objectMapper.createObjectNode();
                            loadBalancingRulesArray2.add(resourceIdValue6);

                            if (loadBalancingRulesItem2.getId() != null) {
                                ((ObjectNode) resourceIdValue6).put("id", loadBalancingRulesItem2.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue3).put("loadBalancingRules", loadBalancingRulesArray2);
                    }
                }

                if (backendAddressPoolsItem.getOutboundNatRule() != null) {
                    ObjectNode outboundNatRuleValue = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue3).put("outboundNatRule", outboundNatRuleValue);

                    if (backendAddressPoolsItem.getOutboundNatRule().getId() != null) {
                        ((ObjectNode) outboundNatRuleValue).put("id",
                                backendAddressPoolsItem.getOutboundNatRule().getId());
                    }
                }

                if (backendAddressPoolsItem.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue3).put("provisioningState",
                            backendAddressPoolsItem.getProvisioningState());
                }

                if (backendAddressPoolsItem.getName() != null) {
                    ((ObjectNode) backendAddressPoolJsonFormatValue).put("name",
                            backendAddressPoolsItem.getName());
                }

                if (backendAddressPoolsItem.getEtag() != null) {
                    ((ObjectNode) backendAddressPoolJsonFormatValue).put("etag",
                            backendAddressPoolsItem.getEtag());
                }

                if (backendAddressPoolsItem.getId() != null) {
                    ((ObjectNode) backendAddressPoolJsonFormatValue).put("id", backendAddressPoolsItem.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("backendAddressPools", backendAddressPoolsArray);
        }
    }

    if (parameters.getLoadBalancingRules() != null) {
        if (parameters.getLoadBalancingRules() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getLoadBalancingRules()).isInitialized()) {
            ArrayNode loadBalancingRulesArray3 = objectMapper.createArrayNode();
            for (LoadBalancingRule loadBalancingRulesItem3 : parameters.getLoadBalancingRules()) {
                ObjectNode loadBalancingRuleJsonFormatValue = objectMapper.createObjectNode();
                loadBalancingRulesArray3.add(loadBalancingRuleJsonFormatValue);

                ObjectNode propertiesValue4 = objectMapper.createObjectNode();
                ((ObjectNode) loadBalancingRuleJsonFormatValue).put("properties", propertiesValue4);

                if (loadBalancingRulesItem3.getFrontendIPConfiguration() != null) {
                    ObjectNode frontendIPConfigurationValue = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue4).put("frontendIPConfiguration",
                            frontendIPConfigurationValue);

                    if (loadBalancingRulesItem3.getFrontendIPConfiguration().getId() != null) {
                        ((ObjectNode) frontendIPConfigurationValue).put("id",
                                loadBalancingRulesItem3.getFrontendIPConfiguration().getId());
                    }
                }

                ObjectNode backendAddressPoolValue = objectMapper.createObjectNode();
                ((ObjectNode) propertiesValue4).put("backendAddressPool", backendAddressPoolValue);

                if (loadBalancingRulesItem3.getBackendAddressPool().getId() != null) {
                    ((ObjectNode) backendAddressPoolValue).put("id",
                            loadBalancingRulesItem3.getBackendAddressPool().getId());
                }

                if (loadBalancingRulesItem3.getProbe() != null) {
                    ObjectNode probeValue = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue4).put("probe", probeValue);

                    if (loadBalancingRulesItem3.getProbe().getId() != null) {
                        ((ObjectNode) probeValue).put("id", loadBalancingRulesItem3.getProbe().getId());
                    }
                }

                ((ObjectNode) propertiesValue4).put("protocol", loadBalancingRulesItem3.getProtocol());

                if (loadBalancingRulesItem3.getLoadDistribution() != null) {
                    ((ObjectNode) propertiesValue4).put("loadDistribution",
                            loadBalancingRulesItem3.getLoadDistribution());
                }

                ((ObjectNode) propertiesValue4).put("frontendPort", loadBalancingRulesItem3.getFrontendPort());

                ((ObjectNode) propertiesValue4).put("backendPort", loadBalancingRulesItem3.getBackendPort());

                if (loadBalancingRulesItem3.getIdleTimeoutInMinutes() != null) {
                    ((ObjectNode) propertiesValue4).put("idleTimeoutInMinutes",
                            loadBalancingRulesItem3.getIdleTimeoutInMinutes());
                }

                ((ObjectNode) propertiesValue4).put("enableFloatingIP",
                        loadBalancingRulesItem3.isEnableFloatingIP());

                if (loadBalancingRulesItem3.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue4).put("provisioningState",
                            loadBalancingRulesItem3.getProvisioningState());
                }

                if (loadBalancingRulesItem3.getName() != null) {
                    ((ObjectNode) loadBalancingRuleJsonFormatValue).put("name",
                            loadBalancingRulesItem3.getName());
                }

                if (loadBalancingRulesItem3.getEtag() != null) {
                    ((ObjectNode) loadBalancingRuleJsonFormatValue).put("etag",
                            loadBalancingRulesItem3.getEtag());
                }

                if (loadBalancingRulesItem3.getId() != null) {
                    ((ObjectNode) loadBalancingRuleJsonFormatValue).put("id", loadBalancingRulesItem3.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("loadBalancingRules", loadBalancingRulesArray3);
        }
    }

    if (parameters.getProbes() != null) {
        if (parameters.getProbes() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getProbes()).isInitialized()) {
            ArrayNode probesArray = objectMapper.createArrayNode();
            for (Probe probesItem : parameters.getProbes()) {
                ObjectNode probeJsonFormatValue = objectMapper.createObjectNode();
                probesArray.add(probeJsonFormatValue);

                ObjectNode propertiesValue5 = objectMapper.createObjectNode();
                ((ObjectNode) probeJsonFormatValue).put("properties", propertiesValue5);

                if (probesItem.getLoadBalancingRules() != null) {
                    if (probesItem.getLoadBalancingRules() instanceof LazyCollection == false
                            || ((LazyCollection) probesItem.getLoadBalancingRules()).isInitialized()) {
                        ArrayNode loadBalancingRulesArray4 = objectMapper.createArrayNode();
                        for (ResourceId loadBalancingRulesItem4 : probesItem.getLoadBalancingRules()) {
                            ObjectNode resourceIdValue7 = objectMapper.createObjectNode();
                            loadBalancingRulesArray4.add(resourceIdValue7);

                            if (loadBalancingRulesItem4.getId() != null) {
                                ((ObjectNode) resourceIdValue7).put("id", loadBalancingRulesItem4.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue5).put("loadBalancingRules", loadBalancingRulesArray4);
                    }
                }

                ((ObjectNode) propertiesValue5).put("protocol", probesItem.getProtocol());

                ((ObjectNode) propertiesValue5).put("port", probesItem.getPort());

                ((ObjectNode) propertiesValue5).put("intervalInSeconds", probesItem.getIntervalInSeconds());

                ((ObjectNode) propertiesValue5).put("numberOfProbes", probesItem.getNumberOfProbes());

                if (probesItem.getRequestPath() != null) {
                    ((ObjectNode) propertiesValue5).put("requestPath", probesItem.getRequestPath());
                }

                if (probesItem.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue5).put("provisioningState", probesItem.getProvisioningState());
                }

                if (probesItem.getName() != null) {
                    ((ObjectNode) probeJsonFormatValue).put("name", probesItem.getName());
                }

                if (probesItem.getEtag() != null) {
                    ((ObjectNode) probeJsonFormatValue).put("etag", probesItem.getEtag());
                }

                if (probesItem.getId() != null) {
                    ((ObjectNode) probeJsonFormatValue).put("id", probesItem.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("probes", probesArray);
        }
    }

    if (parameters.getInboundNatRules() != null) {
        if (parameters.getInboundNatRules() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getInboundNatRules()).isInitialized()) {
            ArrayNode inboundNatRulesArray2 = objectMapper.createArrayNode();
            for (InboundNatRule inboundNatRulesItem2 : parameters.getInboundNatRules()) {
                ObjectNode inboundNatRuleJsonFormatValue = objectMapper.createObjectNode();
                inboundNatRulesArray2.add(inboundNatRuleJsonFormatValue);

                ObjectNode propertiesValue6 = objectMapper.createObjectNode();
                ((ObjectNode) inboundNatRuleJsonFormatValue).put("properties", propertiesValue6);

                if (inboundNatRulesItem2.getFrontendIPConfiguration() != null) {
                    ObjectNode frontendIPConfigurationValue2 = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue6).put("frontendIPConfiguration",
                            frontendIPConfigurationValue2);

                    if (inboundNatRulesItem2.getFrontendIPConfiguration().getId() != null) {
                        ((ObjectNode) frontendIPConfigurationValue2).put("id",
                                inboundNatRulesItem2.getFrontendIPConfiguration().getId());
                    }
                }

                if (inboundNatRulesItem2.getBackendIPConfiguration() != null) {
                    ObjectNode backendIPConfigurationValue = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue6).put("backendIPConfiguration", backendIPConfigurationValue);

                    if (inboundNatRulesItem2.getBackendIPConfiguration().getId() != null) {
                        ((ObjectNode) backendIPConfigurationValue).put("id",
                                inboundNatRulesItem2.getBackendIPConfiguration().getId());
                    }
                }

                ((ObjectNode) propertiesValue6).put("protocol", inboundNatRulesItem2.getProtocol());

                ((ObjectNode) propertiesValue6).put("frontendPort", inboundNatRulesItem2.getFrontendPort());

                ((ObjectNode) propertiesValue6).put("backendPort", inboundNatRulesItem2.getBackendPort());

                if (inboundNatRulesItem2.getIdleTimeoutInMinutes() != null) {
                    ((ObjectNode) propertiesValue6).put("idleTimeoutInMinutes",
                            inboundNatRulesItem2.getIdleTimeoutInMinutes());
                }

                ((ObjectNode) propertiesValue6).put("enableFloatingIP",
                        inboundNatRulesItem2.isEnableFloatingIP());

                if (inboundNatRulesItem2.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue6).put("provisioningState",
                            inboundNatRulesItem2.getProvisioningState());
                }

                if (inboundNatRulesItem2.getName() != null) {
                    ((ObjectNode) inboundNatRuleJsonFormatValue).put("name", inboundNatRulesItem2.getName());
                }

                if (inboundNatRulesItem2.getEtag() != null) {
                    ((ObjectNode) inboundNatRuleJsonFormatValue).put("etag", inboundNatRulesItem2.getEtag());
                }

                if (inboundNatRulesItem2.getId() != null) {
                    ((ObjectNode) inboundNatRuleJsonFormatValue).put("id", inboundNatRulesItem2.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("inboundNatRules", inboundNatRulesArray2);
        }
    }

    if (parameters.getInboundNatPools() != null) {
        if (parameters.getInboundNatPools() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getInboundNatPools()).isInitialized()) {
            ArrayNode inboundNatPoolsArray2 = objectMapper.createArrayNode();
            for (InboundNatPool inboundNatPoolsItem2 : parameters.getInboundNatPools()) {
                ObjectNode inboundNatPoolJsonFormatValue = objectMapper.createObjectNode();
                inboundNatPoolsArray2.add(inboundNatPoolJsonFormatValue);

                ObjectNode propertiesValue7 = objectMapper.createObjectNode();
                ((ObjectNode) inboundNatPoolJsonFormatValue).put("properties", propertiesValue7);

                if (inboundNatPoolsItem2.getFrontendIPConfiguration() != null) {
                    ObjectNode frontendIPConfigurationValue3 = objectMapper.createObjectNode();
                    ((ObjectNode) propertiesValue7).put("frontendIPConfiguration",
                            frontendIPConfigurationValue3);

                    if (inboundNatPoolsItem2.getFrontendIPConfiguration().getId() != null) {
                        ((ObjectNode) frontendIPConfigurationValue3).put("id",
                                inboundNatPoolsItem2.getFrontendIPConfiguration().getId());
                    }
                }

                ((ObjectNode) propertiesValue7).put("protocol", inboundNatPoolsItem2.getProtocol());

                ((ObjectNode) propertiesValue7).put("frontendPortRangeStart",
                        inboundNatPoolsItem2.getFrontendPortRangeStart());

                ((ObjectNode) propertiesValue7).put("frontendPortRangeEnd",
                        inboundNatPoolsItem2.getFrontendPortRangeEnd());

                ((ObjectNode) propertiesValue7).put("backendPort", inboundNatPoolsItem2.getBackendPort());

                if (inboundNatPoolsItem2.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue7).put("provisioningState",
                            inboundNatPoolsItem2.getProvisioningState());
                }

                if (inboundNatPoolsItem2.getName() != null) {
                    ((ObjectNode) inboundNatPoolJsonFormatValue).put("name", inboundNatPoolsItem2.getName());
                }

                if (inboundNatPoolsItem2.getEtag() != null) {
                    ((ObjectNode) inboundNatPoolJsonFormatValue).put("etag", inboundNatPoolsItem2.getEtag());
                }

                if (inboundNatPoolsItem2.getId() != null) {
                    ((ObjectNode) inboundNatPoolJsonFormatValue).put("id", inboundNatPoolsItem2.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("inboundNatPools", inboundNatPoolsArray2);
        }
    }

    if (parameters.getOutboundNatRules() != null) {
        if (parameters.getOutboundNatRules() instanceof LazyCollection == false
                || ((LazyCollection) parameters.getOutboundNatRules()).isInitialized()) {
            ArrayNode outboundNatRulesArray2 = objectMapper.createArrayNode();
            for (OutboundNatRule outboundNatRulesItem2 : parameters.getOutboundNatRules()) {
                ObjectNode outboundNatRuleJsonFormatValue = objectMapper.createObjectNode();
                outboundNatRulesArray2.add(outboundNatRuleJsonFormatValue);

                ObjectNode propertiesValue8 = objectMapper.createObjectNode();
                ((ObjectNode) outboundNatRuleJsonFormatValue).put("properties", propertiesValue8);

                ((ObjectNode) propertiesValue8).put("allocatedOutboundPorts",
                        outboundNatRulesItem2.getAllocatedOutboundPorts());

                if (outboundNatRulesItem2.getFrontendIpConfigurations() != null) {
                    if (outboundNatRulesItem2.getFrontendIpConfigurations() instanceof LazyCollection == false
                            || ((LazyCollection) outboundNatRulesItem2.getFrontendIpConfigurations())
                                    .isInitialized()) {
                        ArrayNode frontendIPConfigurationsArray2 = objectMapper.createArrayNode();
                        for (ResourceId frontendIPConfigurationsItem2 : outboundNatRulesItem2
                                .getFrontendIpConfigurations()) {
                            ObjectNode resourceIdValue8 = objectMapper.createObjectNode();
                            frontendIPConfigurationsArray2.add(resourceIdValue8);

                            if (frontendIPConfigurationsItem2.getId() != null) {
                                ((ObjectNode) resourceIdValue8).put("id",
                                        frontendIPConfigurationsItem2.getId());
                            }
                        }
                        ((ObjectNode) propertiesValue8).put("frontendIPConfigurations",
                                frontendIPConfigurationsArray2);
                    }
                }

                ObjectNode backendAddressPoolValue2 = objectMapper.createObjectNode();
                ((ObjectNode) propertiesValue8).put("backendAddressPool", backendAddressPoolValue2);

                if (outboundNatRulesItem2.getBackendAddressPool().getId() != null) {
                    ((ObjectNode) backendAddressPoolValue2).put("id",
                            outboundNatRulesItem2.getBackendAddressPool().getId());
                }

                if (outboundNatRulesItem2.getProvisioningState() != null) {
                    ((ObjectNode) propertiesValue8).put("provisioningState",
                            outboundNatRulesItem2.getProvisioningState());
                }

                if (outboundNatRulesItem2.getName() != null) {
                    ((ObjectNode) outboundNatRuleJsonFormatValue).put("name", outboundNatRulesItem2.getName());
                }

                if (outboundNatRulesItem2.getEtag() != null) {
                    ((ObjectNode) outboundNatRuleJsonFormatValue).put("etag", outboundNatRulesItem2.getEtag());
                }

                if (outboundNatRulesItem2.getId() != null) {
                    ((ObjectNode) outboundNatRuleJsonFormatValue).put("id", outboundNatRulesItem2.getId());
                }
            }
            ((ObjectNode) propertiesValue).put("outboundNatRules", outboundNatRulesArray2);
        }
    }

    if (parameters.getResourceGuid() != null) {
        ((ObjectNode) propertiesValue).put("resourceGuid", parameters.getResourceGuid());
    }

    if (parameters.getProvisioningState() != null) {
        ((ObjectNode) propertiesValue).put("provisioningState", parameters.getProvisioningState());
    }

    if (parameters.getEtag() != null) {
        ((ObjectNode) loadBalancerJsonFormatValue).put("etag", parameters.getEtag());
    }

    if (parameters.getId() != null) {
        ((ObjectNode) loadBalancerJsonFormatValue).put("id", parameters.getId());
    }

    if (parameters.getName() != null) {
        ((ObjectNode) loadBalancerJsonFormatValue).put("name", parameters.getName());
    }

    if (parameters.getType() != null) {
        ((ObjectNode) loadBalancerJsonFormatValue).put("type", parameters.getType());
    }

    ((ObjectNode) loadBalancerJsonFormatValue).put("location", parameters.getLocation());

    if (parameters.getTags() != null) {
        ObjectNode tagsDictionary = objectMapper.createObjectNode();
        for (Map.Entry<String, String> entry : parameters.getTags().entrySet()) {
            String tagsKey = entry.getKey();
            String tagsValue = entry.getValue();
            ((ObjectNode) tagsDictionary).put(tagsKey, tagsValue);
        }
        ((ObjectNode) loadBalancerJsonFormatValue).put("tags", tagsDictionary);
    }

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

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

        // Create Result
        LoadBalancerPutResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new LoadBalancerPutResponse();
            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) {
                LoadBalancer loadBalancerInstance = new LoadBalancer();
                result.setLoadBalancer(loadBalancerInstance);

                JsonNode propertiesValue9 = responseDoc.get("properties");
                if (propertiesValue9 != null && propertiesValue9 instanceof NullNode == false) {
                    JsonNode frontendIPConfigurationsArray3 = propertiesValue9.get("frontendIPConfigurations");
                    if (frontendIPConfigurationsArray3 != null
                            && frontendIPConfigurationsArray3 instanceof NullNode == false) {
                        for (JsonNode frontendIPConfigurationsValue : ((ArrayNode) frontendIPConfigurationsArray3)) {
                            FrontendIpConfiguration frontendIpConfigurationJsonFormatInstance = new FrontendIpConfiguration();
                            loadBalancerInstance.getFrontendIpConfigurations()
                                    .add(frontendIpConfigurationJsonFormatInstance);

                            JsonNode propertiesValue10 = frontendIPConfigurationsValue.get("properties");
                            if (propertiesValue10 != null && propertiesValue10 instanceof NullNode == false) {
                                JsonNode privateIPAddressValue = propertiesValue10.get("privateIPAddress");
                                if (privateIPAddressValue != null
                                        && privateIPAddressValue instanceof NullNode == false) {
                                    String privateIPAddressInstance;
                                    privateIPAddressInstance = privateIPAddressValue.getTextValue();
                                    frontendIpConfigurationJsonFormatInstance
                                            .setPrivateIpAddress(privateIPAddressInstance);
                                }

                                JsonNode privateIPAllocationMethodValue = propertiesValue10
                                        .get("privateIPAllocationMethod");
                                if (privateIPAllocationMethodValue != null
                                        && privateIPAllocationMethodValue instanceof NullNode == false) {
                                    String privateIPAllocationMethodInstance;
                                    privateIPAllocationMethodInstance = privateIPAllocationMethodValue
                                            .getTextValue();
                                    frontendIpConfigurationJsonFormatInstance
                                            .setPrivateIpAllocationMethod(privateIPAllocationMethodInstance);
                                }

                                JsonNode subnetValue2 = propertiesValue10.get("subnet");
                                if (subnetValue2 != null && subnetValue2 instanceof NullNode == false) {
                                    ResourceId subnetInstance = new ResourceId();
                                    frontendIpConfigurationJsonFormatInstance.setSubnet(subnetInstance);

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

                                JsonNode publicIPAddressValue2 = propertiesValue10.get("publicIPAddress");
                                if (publicIPAddressValue2 != null
                                        && publicIPAddressValue2 instanceof NullNode == false) {
                                    ResourceId publicIPAddressInstance = new ResourceId();
                                    frontendIpConfigurationJsonFormatInstance
                                            .setPublicIpAddress(publicIPAddressInstance);

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

                                JsonNode inboundNatRulesArray3 = propertiesValue10.get("inboundNatRules");
                                if (inboundNatRulesArray3 != null
                                        && inboundNatRulesArray3 instanceof NullNode == false) {
                                    for (JsonNode inboundNatRulesValue : ((ArrayNode) inboundNatRulesArray3)) {
                                        ResourceId resourceIdInstance = new ResourceId();
                                        frontendIpConfigurationJsonFormatInstance.getInboundNatRules()
                                                .add(resourceIdInstance);

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

                                JsonNode inboundNatPoolsArray3 = propertiesValue10.get("inboundNatPools");
                                if (inboundNatPoolsArray3 != null
                                        && inboundNatPoolsArray3 instanceof NullNode == false) {
                                    for (JsonNode inboundNatPoolsValue : ((ArrayNode) inboundNatPoolsArray3)) {
                                        ResourceId resourceIdInstance2 = new ResourceId();
                                        frontendIpConfigurationJsonFormatInstance.getInboundNatPools()
                                                .add(resourceIdInstance2);

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

                                JsonNode outboundNatRulesArray3 = propertiesValue10.get("outboundNatRules");
                                if (outboundNatRulesArray3 != null
                                        && outboundNatRulesArray3 instanceof NullNode == false) {
                                    for (JsonNode outboundNatRulesValue : ((ArrayNode) outboundNatRulesArray3)) {
                                        ResourceId resourceIdInstance3 = new ResourceId();
                                        frontendIpConfigurationJsonFormatInstance.getOutboundNatRules()
                                                .add(resourceIdInstance3);

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

                                JsonNode loadBalancingRulesArray5 = propertiesValue10.get("loadBalancingRules");
                                if (loadBalancingRulesArray5 != null
                                        && loadBalancingRulesArray5 instanceof NullNode == false) {
                                    for (JsonNode loadBalancingRulesValue : ((ArrayNode) loadBalancingRulesArray5)) {
                                        ResourceId resourceIdInstance4 = new ResourceId();
                                        frontendIpConfigurationJsonFormatInstance.getLoadBalancingRules()
                                                .add(resourceIdInstance4);

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

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

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

                            JsonNode etagValue = frontendIPConfigurationsValue.get("etag");
                            if (etagValue != null && etagValue instanceof NullNode == false) {
                                String etagInstance;
                                etagInstance = etagValue.getTextValue();
                                frontendIpConfigurationJsonFormatInstance.setEtag(etagInstance);
                            }

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

                    JsonNode backendAddressPoolsArray2 = propertiesValue9.get("backendAddressPools");
                    if (backendAddressPoolsArray2 != null
                            && backendAddressPoolsArray2 instanceof NullNode == false) {
                        for (JsonNode backendAddressPoolsValue : ((ArrayNode) backendAddressPoolsArray2)) {
                            BackendAddressPool backendAddressPoolJsonFormatInstance = new BackendAddressPool();
                            loadBalancerInstance.getBackendAddressPools()
                                    .add(backendAddressPoolJsonFormatInstance);

                            JsonNode propertiesValue11 = backendAddressPoolsValue.get("properties");
                            if (propertiesValue11 != null && propertiesValue11 instanceof NullNode == false) {
                                JsonNode backendIPConfigurationsArray2 = propertiesValue11
                                        .get("backendIPConfigurations");
                                if (backendIPConfigurationsArray2 != null
                                        && backendIPConfigurationsArray2 instanceof NullNode == false) {
                                    for (JsonNode backendIPConfigurationsValue : ((ArrayNode) backendIPConfigurationsArray2)) {
                                        ResourceId resourceIdInstance5 = new ResourceId();
                                        backendAddressPoolJsonFormatInstance.getBackendIpConfigurations()
                                                .add(resourceIdInstance5);

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

                                JsonNode loadBalancingRulesArray6 = propertiesValue11.get("loadBalancingRules");
                                if (loadBalancingRulesArray6 != null
                                        && loadBalancingRulesArray6 instanceof NullNode == false) {
                                    for (JsonNode loadBalancingRulesValue2 : ((ArrayNode) loadBalancingRulesArray6)) {
                                        ResourceId resourceIdInstance6 = new ResourceId();
                                        backendAddressPoolJsonFormatInstance.getLoadBalancingRules()
                                                .add(resourceIdInstance6);

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

                                JsonNode outboundNatRuleValue2 = propertiesValue11.get("outboundNatRule");
                                if (outboundNatRuleValue2 != null
                                        && outboundNatRuleValue2 instanceof NullNode == false) {
                                    ResourceId outboundNatRuleInstance = new ResourceId();
                                    backendAddressPoolJsonFormatInstance
                                            .setOutboundNatRule(outboundNatRuleInstance);

                                    JsonNode idValue10 = outboundNatRuleValue2.get("id");
                                    if (idValue10 != null && idValue10 instanceof NullNode == false) {
                                        String idInstance10;
                                        idInstance10 = idValue10.getTextValue();
                                        outboundNatRuleInstance.setId(idInstance10);
                                    }
                                }

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

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

                            JsonNode etagValue2 = backendAddressPoolsValue.get("etag");
                            if (etagValue2 != null && etagValue2 instanceof NullNode == false) {
                                String etagInstance2;
                                etagInstance2 = etagValue2.getTextValue();
                                backendAddressPoolJsonFormatInstance.setEtag(etagInstance2);
                            }

                            JsonNode idValue11 = backendAddressPoolsValue.get("id");
                            if (idValue11 != null && idValue11 instanceof NullNode == false) {
                                String idInstance11;
                                idInstance11 = idValue11.getTextValue();
                                backendAddressPoolJsonFormatInstance.setId(idInstance11);
                            }
                        }
                    }

                    JsonNode loadBalancingRulesArray7 = propertiesValue9.get("loadBalancingRules");
                    if (loadBalancingRulesArray7 != null
                            && loadBalancingRulesArray7 instanceof NullNode == false) {
                        for (JsonNode loadBalancingRulesValue3 : ((ArrayNode) loadBalancingRulesArray7)) {
                            LoadBalancingRule loadBalancingRuleJsonFormatInstance = new LoadBalancingRule();
                            loadBalancerInstance.getLoadBalancingRules()
                                    .add(loadBalancingRuleJsonFormatInstance);

                            JsonNode propertiesValue12 = loadBalancingRulesValue3.get("properties");
                            if (propertiesValue12 != null && propertiesValue12 instanceof NullNode == false) {
                                JsonNode frontendIPConfigurationValue4 = propertiesValue12
                                        .get("frontendIPConfiguration");
                                if (frontendIPConfigurationValue4 != null
                                        && frontendIPConfigurationValue4 instanceof NullNode == false) {
                                    ResourceId frontendIPConfigurationInstance = new ResourceId();
                                    loadBalancingRuleJsonFormatInstance
                                            .setFrontendIPConfiguration(frontendIPConfigurationInstance);

                                    JsonNode idValue12 = frontendIPConfigurationValue4.get("id");
                                    if (idValue12 != null && idValue12 instanceof NullNode == false) {
                                        String idInstance12;
                                        idInstance12 = idValue12.getTextValue();
                                        frontendIPConfigurationInstance.setId(idInstance12);
                                    }
                                }

                                JsonNode backendAddressPoolValue3 = propertiesValue12.get("backendAddressPool");
                                if (backendAddressPoolValue3 != null
                                        && backendAddressPoolValue3 instanceof NullNode == false) {
                                    ResourceId backendAddressPoolInstance = new ResourceId();
                                    loadBalancingRuleJsonFormatInstance
                                            .setBackendAddressPool(backendAddressPoolInstance);

                                    JsonNode idValue13 = backendAddressPoolValue3.get("id");
                                    if (idValue13 != null && idValue13 instanceof NullNode == false) {
                                        String idInstance13;
                                        idInstance13 = idValue13.getTextValue();
                                        backendAddressPoolInstance.setId(idInstance13);
                                    }
                                }

                                JsonNode probeValue2 = propertiesValue12.get("probe");
                                if (probeValue2 != null && probeValue2 instanceof NullNode == false) {
                                    ResourceId probeInstance = new ResourceId();
                                    loadBalancingRuleJsonFormatInstance.setProbe(probeInstance);

                                    JsonNode idValue14 = probeValue2.get("id");
                                    if (idValue14 != null && idValue14 instanceof NullNode == false) {
                                        String idInstance14;
                                        idInstance14 = idValue14.getTextValue();
                                        probeInstance.setId(idInstance14);
                                    }
                                }

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

                                JsonNode loadDistributionValue = propertiesValue12.get("loadDistribution");
                                if (loadDistributionValue != null
                                        && loadDistributionValue instanceof NullNode == false) {
                                    String loadDistributionInstance;
                                    loadDistributionInstance = loadDistributionValue.getTextValue();
                                    loadBalancingRuleJsonFormatInstance
                                            .setLoadDistribution(loadDistributionInstance);
                                }

                                JsonNode frontendPortValue = propertiesValue12.get("frontendPort");
                                if (frontendPortValue != null
                                        && frontendPortValue instanceof NullNode == false) {
                                    int frontendPortInstance;
                                    frontendPortInstance = frontendPortValue.getIntValue();
                                    loadBalancingRuleJsonFormatInstance.setFrontendPort(frontendPortInstance);
                                }

                                JsonNode backendPortValue = propertiesValue12.get("backendPort");
                                if (backendPortValue != null && backendPortValue instanceof NullNode == false) {
                                    int backendPortInstance;
                                    backendPortInstance = backendPortValue.getIntValue();
                                    loadBalancingRuleJsonFormatInstance.setBackendPort(backendPortInstance);
                                }

                                JsonNode idleTimeoutInMinutesValue = propertiesValue12
                                        .get("idleTimeoutInMinutes");
                                if (idleTimeoutInMinutesValue != null
                                        && idleTimeoutInMinutesValue instanceof NullNode == false) {
                                    int idleTimeoutInMinutesInstance;
                                    idleTimeoutInMinutesInstance = idleTimeoutInMinutesValue.getIntValue();
                                    loadBalancingRuleJsonFormatInstance
                                            .setIdleTimeoutInMinutes(idleTimeoutInMinutesInstance);
                                }

                                JsonNode enableFloatingIPValue = propertiesValue12.get("enableFloatingIP");
                                if (enableFloatingIPValue != null
                                        && enableFloatingIPValue instanceof NullNode == false) {
                                    boolean enableFloatingIPInstance;
                                    enableFloatingIPInstance = enableFloatingIPValue.getBooleanValue();
                                    loadBalancingRuleJsonFormatInstance
                                            .setEnableFloatingIP(enableFloatingIPInstance);
                                }

                                JsonNode provisioningStateValue3 = propertiesValue12.get("provisioningState");
                                if (provisioningStateValue3 != null
                                        && provisioningStateValue3 instanceof NullNode == false) {
                                    String provisioningStateInstance3;
                                    provisioningStateInstance3 = provisioningStateValue3.getTextValue();
                                    loadBalancingRuleJsonFormatInstance
                                            .setProvisioningState(provisioningStateInstance3);
                                }
                            }

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

                            JsonNode etagValue3 = loadBalancingRulesValue3.get("etag");
                            if (etagValue3 != null && etagValue3 instanceof NullNode == false) {
                                String etagInstance3;
                                etagInstance3 = etagValue3.getTextValue();
                                loadBalancingRuleJsonFormatInstance.setEtag(etagInstance3);
                            }

                            JsonNode idValue15 = loadBalancingRulesValue3.get("id");
                            if (idValue15 != null && idValue15 instanceof NullNode == false) {
                                String idInstance15;
                                idInstance15 = idValue15.getTextValue();
                                loadBalancingRuleJsonFormatInstance.setId(idInstance15);
                            }
                        }
                    }

                    JsonNode probesArray2 = propertiesValue9.get("probes");
                    if (probesArray2 != null && probesArray2 instanceof NullNode == false) {
                        for (JsonNode probesValue : ((ArrayNode) probesArray2)) {
                            Probe probeJsonFormatInstance = new Probe();
                            loadBalancerInstance.getProbes().add(probeJsonFormatInstance);

                            JsonNode propertiesValue13 = probesValue.get("properties");
                            if (propertiesValue13 != null && propertiesValue13 instanceof NullNode == false) {
                                JsonNode loadBalancingRulesArray8 = propertiesValue13.get("loadBalancingRules");
                                if (loadBalancingRulesArray8 != null
                                        && loadBalancingRulesArray8 instanceof NullNode == false) {
                                    for (JsonNode loadBalancingRulesValue4 : ((ArrayNode) loadBalancingRulesArray8)) {
                                        ResourceId resourceIdInstance7 = new ResourceId();
                                        probeJsonFormatInstance.getLoadBalancingRules()
                                                .add(resourceIdInstance7);

                                        JsonNode idValue16 = loadBalancingRulesValue4.get("id");
                                        if (idValue16 != null && idValue16 instanceof NullNode == false) {
                                            String idInstance16;
                                            idInstance16 = idValue16.getTextValue();
                                            resourceIdInstance7.setId(idInstance16);
                                        }
                                    }
                                }

                                JsonNode protocolValue2 = propertiesValue13.get("protocol");
                                if (protocolValue2 != null && protocolValue2 instanceof NullNode == false) {
                                    String protocolInstance2;
                                    protocolInstance2 = protocolValue2.getTextValue();
                                    probeJsonFormatInstance.setProtocol(protocolInstance2);
                                }

                                JsonNode portValue = propertiesValue13.get("port");
                                if (portValue != null && portValue instanceof NullNode == false) {
                                    int portInstance;
                                    portInstance = portValue.getIntValue();
                                    probeJsonFormatInstance.setPort(portInstance);
                                }

                                JsonNode intervalInSecondsValue = propertiesValue13.get("intervalInSeconds");
                                if (intervalInSecondsValue != null
                                        && intervalInSecondsValue instanceof NullNode == false) {
                                    int intervalInSecondsInstance;
                                    intervalInSecondsInstance = intervalInSecondsValue.getIntValue();
                                    probeJsonFormatInstance.setIntervalInSeconds(intervalInSecondsInstance);
                                }

                                JsonNode numberOfProbesValue = propertiesValue13.get("numberOfProbes");
                                if (numberOfProbesValue != null
                                        && numberOfProbesValue instanceof NullNode == false) {
                                    int numberOfProbesInstance;
                                    numberOfProbesInstance = numberOfProbesValue.getIntValue();
                                    probeJsonFormatInstance.setNumberOfProbes(numberOfProbesInstance);
                                }

                                JsonNode requestPathValue = propertiesValue13.get("requestPath");
                                if (requestPathValue != null && requestPathValue instanceof NullNode == false) {
                                    String requestPathInstance;
                                    requestPathInstance = requestPathValue.getTextValue();
                                    probeJsonFormatInstance.setRequestPath(requestPathInstance);
                                }

                                JsonNode provisioningStateValue4 = propertiesValue13.get("provisioningState");
                                if (provisioningStateValue4 != null
                                        && provisioningStateValue4 instanceof NullNode == false) {
                                    String provisioningStateInstance4;
                                    provisioningStateInstance4 = provisioningStateValue4.getTextValue();
                                    probeJsonFormatInstance.setProvisioningState(provisioningStateInstance4);
                                }
                            }

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

                            JsonNode etagValue4 = probesValue.get("etag");
                            if (etagValue4 != null && etagValue4 instanceof NullNode == false) {
                                String etagInstance4;
                                etagInstance4 = etagValue4.getTextValue();
                                probeJsonFormatInstance.setEtag(etagInstance4);
                            }

                            JsonNode idValue17 = probesValue.get("id");
                            if (idValue17 != null && idValue17 instanceof NullNode == false) {
                                String idInstance17;
                                idInstance17 = idValue17.getTextValue();
                                probeJsonFormatInstance.setId(idInstance17);
                            }
                        }
                    }

                    JsonNode inboundNatRulesArray4 = propertiesValue9.get("inboundNatRules");
                    if (inboundNatRulesArray4 != null && inboundNatRulesArray4 instanceof NullNode == false) {
                        for (JsonNode inboundNatRulesValue2 : ((ArrayNode) inboundNatRulesArray4)) {
                            InboundNatRule inboundNatRuleJsonFormatInstance = new InboundNatRule();
                            loadBalancerInstance.getInboundNatRules().add(inboundNatRuleJsonFormatInstance);

                            JsonNode propertiesValue14 = inboundNatRulesValue2.get("properties");
                            if (propertiesValue14 != null && propertiesValue14 instanceof NullNode == false) {
                                JsonNode frontendIPConfigurationValue5 = propertiesValue14
                                        .get("frontendIPConfiguration");
                                if (frontendIPConfigurationValue5 != null
                                        && frontendIPConfigurationValue5 instanceof NullNode == false) {
                                    ResourceId frontendIPConfigurationInstance2 = new ResourceId();
                                    inboundNatRuleJsonFormatInstance
                                            .setFrontendIPConfiguration(frontendIPConfigurationInstance2);

                                    JsonNode idValue18 = frontendIPConfigurationValue5.get("id");
                                    if (idValue18 != null && idValue18 instanceof NullNode == false) {
                                        String idInstance18;
                                        idInstance18 = idValue18.getTextValue();
                                        frontendIPConfigurationInstance2.setId(idInstance18);
                                    }
                                }

                                JsonNode backendIPConfigurationValue2 = propertiesValue14
                                        .get("backendIPConfiguration");
                                if (backendIPConfigurationValue2 != null
                                        && backendIPConfigurationValue2 instanceof NullNode == false) {
                                    ResourceId backendIPConfigurationInstance = new ResourceId();
                                    inboundNatRuleJsonFormatInstance
                                            .setBackendIPConfiguration(backendIPConfigurationInstance);

                                    JsonNode idValue19 = backendIPConfigurationValue2.get("id");
                                    if (idValue19 != null && idValue19 instanceof NullNode == false) {
                                        String idInstance19;
                                        idInstance19 = idValue19.getTextValue();
                                        backendIPConfigurationInstance.setId(idInstance19);
                                    }
                                }

                                JsonNode protocolValue3 = propertiesValue14.get("protocol");
                                if (protocolValue3 != null && protocolValue3 instanceof NullNode == false) {
                                    String protocolInstance3;
                                    protocolInstance3 = protocolValue3.getTextValue();
                                    inboundNatRuleJsonFormatInstance.setProtocol(protocolInstance3);
                                }

                                JsonNode frontendPortValue2 = propertiesValue14.get("frontendPort");
                                if (frontendPortValue2 != null
                                        && frontendPortValue2 instanceof NullNode == false) {
                                    int frontendPortInstance2;
                                    frontendPortInstance2 = frontendPortValue2.getIntValue();
                                    inboundNatRuleJsonFormatInstance.setFrontendPort(frontendPortInstance2);
                                }

                                JsonNode backendPortValue2 = propertiesValue14.get("backendPort");
                                if (backendPortValue2 != null
                                        && backendPortValue2 instanceof NullNode == false) {
                                    int backendPortInstance2;
                                    backendPortInstance2 = backendPortValue2.getIntValue();
                                    inboundNatRuleJsonFormatInstance.setBackendPort(backendPortInstance2);
                                }

                                JsonNode idleTimeoutInMinutesValue2 = propertiesValue14
                                        .get("idleTimeoutInMinutes");
                                if (idleTimeoutInMinutesValue2 != null
                                        && idleTimeoutInMinutesValue2 instanceof NullNode == false) {
                                    int idleTimeoutInMinutesInstance2;
                                    idleTimeoutInMinutesInstance2 = idleTimeoutInMinutesValue2.getIntValue();
                                    inboundNatRuleJsonFormatInstance
                                            .setIdleTimeoutInMinutes(idleTimeoutInMinutesInstance2);
                                }

                                JsonNode enableFloatingIPValue2 = propertiesValue14.get("enableFloatingIP");
                                if (enableFloatingIPValue2 != null
                                        && enableFloatingIPValue2 instanceof NullNode == false) {
                                    boolean enableFloatingIPInstance2;
                                    enableFloatingIPInstance2 = enableFloatingIPValue2.getBooleanValue();
                                    inboundNatRuleJsonFormatInstance
                                            .setEnableFloatingIP(enableFloatingIPInstance2);
                                }

                                JsonNode provisioningStateValue5 = propertiesValue14.get("provisioningState");
                                if (provisioningStateValue5 != null
                                        && provisioningStateValue5 instanceof NullNode == false) {
                                    String provisioningStateInstance5;
                                    provisioningStateInstance5 = provisioningStateValue5.getTextValue();
                                    inboundNatRuleJsonFormatInstance
                                            .setProvisioningState(provisioningStateInstance5);
                                }
                            }

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

                            JsonNode etagValue5 = inboundNatRulesValue2.get("etag");
                            if (etagValue5 != null && etagValue5 instanceof NullNode == false) {
                                String etagInstance5;
                                etagInstance5 = etagValue5.getTextValue();
                                inboundNatRuleJsonFormatInstance.setEtag(etagInstance5);
                            }

                            JsonNode idValue20 = inboundNatRulesValue2.get("id");
                            if (idValue20 != null && idValue20 instanceof NullNode == false) {
                                String idInstance20;
                                idInstance20 = idValue20.getTextValue();
                                inboundNatRuleJsonFormatInstance.setId(idInstance20);
                            }
                        }
                    }

                    JsonNode inboundNatPoolsArray4 = propertiesValue9.get("inboundNatPools");
                    if (inboundNatPoolsArray4 != null && inboundNatPoolsArray4 instanceof NullNode == false) {
                        for (JsonNode inboundNatPoolsValue2 : ((ArrayNode) inboundNatPoolsArray4)) {
                            InboundNatPool inboundNatPoolJsonFormatInstance = new InboundNatPool();
                            loadBalancerInstance.getInboundNatPools().add(inboundNatPoolJsonFormatInstance);

                            JsonNode propertiesValue15 = inboundNatPoolsValue2.get("properties");
                            if (propertiesValue15 != null && propertiesValue15 instanceof NullNode == false) {
                                JsonNode frontendIPConfigurationValue6 = propertiesValue15
                                        .get("frontendIPConfiguration");
                                if (frontendIPConfigurationValue6 != null
                                        && frontendIPConfigurationValue6 instanceof NullNode == false) {
                                    ResourceId frontendIPConfigurationInstance3 = new ResourceId();
                                    inboundNatPoolJsonFormatInstance
                                            .setFrontendIPConfiguration(frontendIPConfigurationInstance3);

                                    JsonNode idValue21 = frontendIPConfigurationValue6.get("id");
                                    if (idValue21 != null && idValue21 instanceof NullNode == false) {
                                        String idInstance21;
                                        idInstance21 = idValue21.getTextValue();
                                        frontendIPConfigurationInstance3.setId(idInstance21);
                                    }
                                }

                                JsonNode protocolValue4 = propertiesValue15.get("protocol");
                                if (protocolValue4 != null && protocolValue4 instanceof NullNode == false) {
                                    String protocolInstance4;
                                    protocolInstance4 = protocolValue4.getTextValue();
                                    inboundNatPoolJsonFormatInstance.setProtocol(protocolInstance4);
                                }

                                JsonNode frontendPortRangeStartValue = propertiesValue15
                                        .get("frontendPortRangeStart");
                                if (frontendPortRangeStartValue != null
                                        && frontendPortRangeStartValue instanceof NullNode == false) {
                                    int frontendPortRangeStartInstance;
                                    frontendPortRangeStartInstance = frontendPortRangeStartValue.getIntValue();
                                    inboundNatPoolJsonFormatInstance
                                            .setFrontendPortRangeStart(frontendPortRangeStartInstance);
                                }

                                JsonNode frontendPortRangeEndValue = propertiesValue15
                                        .get("frontendPortRangeEnd");
                                if (frontendPortRangeEndValue != null
                                        && frontendPortRangeEndValue instanceof NullNode == false) {
                                    int frontendPortRangeEndInstance;
                                    frontendPortRangeEndInstance = frontendPortRangeEndValue.getIntValue();
                                    inboundNatPoolJsonFormatInstance
                                            .setFrontendPortRangeEnd(frontendPortRangeEndInstance);
                                }

                                JsonNode backendPortValue3 = propertiesValue15.get("backendPort");
                                if (backendPortValue3 != null
                                        && backendPortValue3 instanceof NullNode == false) {
                                    int backendPortInstance3;
                                    backendPortInstance3 = backendPortValue3.getIntValue();
                                    inboundNatPoolJsonFormatInstance.setBackendPort(backendPortInstance3);
                                }

                                JsonNode provisioningStateValue6 = propertiesValue15.get("provisioningState");
                                if (provisioningStateValue6 != null
                                        && provisioningStateValue6 instanceof NullNode == false) {
                                    String provisioningStateInstance6;
                                    provisioningStateInstance6 = provisioningStateValue6.getTextValue();
                                    inboundNatPoolJsonFormatInstance
                                            .setProvisioningState(provisioningStateInstance6);
                                }
                            }

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

                            JsonNode etagValue6 = inboundNatPoolsValue2.get("etag");
                            if (etagValue6 != null && etagValue6 instanceof NullNode == false) {
                                String etagInstance6;
                                etagInstance6 = etagValue6.getTextValue();
                                inboundNatPoolJsonFormatInstance.setEtag(etagInstance6);
                            }

                            JsonNode idValue22 = inboundNatPoolsValue2.get("id");
                            if (idValue22 != null && idValue22 instanceof NullNode == false) {
                                String idInstance22;
                                idInstance22 = idValue22.getTextValue();
                                inboundNatPoolJsonFormatInstance.setId(idInstance22);
                            }
                        }
                    }

                    JsonNode outboundNatRulesArray4 = propertiesValue9.get("outboundNatRules");
                    if (outboundNatRulesArray4 != null && outboundNatRulesArray4 instanceof NullNode == false) {
                        for (JsonNode outboundNatRulesValue2 : ((ArrayNode) outboundNatRulesArray4)) {
                            OutboundNatRule outboundNatRuleJsonFormatInstance = new OutboundNatRule();
                            loadBalancerInstance.getOutboundNatRules().add(outboundNatRuleJsonFormatInstance);

                            JsonNode propertiesValue16 = outboundNatRulesValue2.get("properties");
                            if (propertiesValue16 != null && propertiesValue16 instanceof NullNode == false) {
                                JsonNode allocatedOutboundPortsValue = propertiesValue16
                                        .get("allocatedOutboundPorts");
                                if (allocatedOutboundPortsValue != null
                                        && allocatedOutboundPortsValue instanceof NullNode == false) {
                                    int allocatedOutboundPortsInstance;
                                    allocatedOutboundPortsInstance = allocatedOutboundPortsValue.getIntValue();
                                    outboundNatRuleJsonFormatInstance
                                            .setAllocatedOutboundPorts(allocatedOutboundPortsInstance);
                                }

                                JsonNode frontendIPConfigurationsArray4 = propertiesValue16
                                        .get("frontendIPConfigurations");
                                if (frontendIPConfigurationsArray4 != null
                                        && frontendIPConfigurationsArray4 instanceof NullNode == false) {
                                    for (JsonNode frontendIPConfigurationsValue2 : ((ArrayNode) frontendIPConfigurationsArray4)) {
                                        ResourceId resourceIdInstance8 = new ResourceId();
                                        outboundNatRuleJsonFormatInstance.getFrontendIpConfigurations()
                                                .add(resourceIdInstance8);

                                        JsonNode idValue23 = frontendIPConfigurationsValue2.get("id");
                                        if (idValue23 != null && idValue23 instanceof NullNode == false) {
                                            String idInstance23;
                                            idInstance23 = idValue23.getTextValue();
                                            resourceIdInstance8.setId(idInstance23);
                                        }
                                    }
                                }

                                JsonNode backendAddressPoolValue4 = propertiesValue16.get("backendAddressPool");
                                if (backendAddressPoolValue4 != null
                                        && backendAddressPoolValue4 instanceof NullNode == false) {
                                    ResourceId backendAddressPoolInstance2 = new ResourceId();
                                    outboundNatRuleJsonFormatInstance
                                            .setBackendAddressPool(backendAddressPoolInstance2);

                                    JsonNode idValue24 = backendAddressPoolValue4.get("id");
                                    if (idValue24 != null && idValue24 instanceof NullNode == false) {
                                        String idInstance24;
                                        idInstance24 = idValue24.getTextValue();
                                        backendAddressPoolInstance2.setId(idInstance24);
                                    }
                                }

                                JsonNode provisioningStateValue7 = propertiesValue16.get("provisioningState");
                                if (provisioningStateValue7 != null
                                        && provisioningStateValue7 instanceof NullNode == false) {
                                    String provisioningStateInstance7;
                                    provisioningStateInstance7 = provisioningStateValue7.getTextValue();
                                    outboundNatRuleJsonFormatInstance
                                            .setProvisioningState(provisioningStateInstance7);
                                }
                            }

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

                            JsonNode etagValue7 = outboundNatRulesValue2.get("etag");
                            if (etagValue7 != null && etagValue7 instanceof NullNode == false) {
                                String etagInstance7;
                                etagInstance7 = etagValue7.getTextValue();
                                outboundNatRuleJsonFormatInstance.setEtag(etagInstance7);
                            }

                            JsonNode idValue25 = outboundNatRulesValue2.get("id");
                            if (idValue25 != null && idValue25 instanceof NullNode == false) {
                                String idInstance25;
                                idInstance25 = idValue25.getTextValue();
                                outboundNatRuleJsonFormatInstance.setId(idInstance25);
                            }
                        }
                    }

                    JsonNode resourceGuidValue = propertiesValue9.get("resourceGuid");
                    if (resourceGuidValue != null && resourceGuidValue instanceof NullNode == false) {
                        String resourceGuidInstance;
                        resourceGuidInstance = resourceGuidValue.getTextValue();
                        loadBalancerInstance.setResourceGuid(resourceGuidInstance);
                    }

                    JsonNode provisioningStateValue8 = propertiesValue9.get("provisioningState");
                    if (provisioningStateValue8 != null
                            && provisioningStateValue8 instanceof NullNode == false) {
                        String provisioningStateInstance8;
                        provisioningStateInstance8 = provisioningStateValue8.getTextValue();
                        loadBalancerInstance.setProvisioningState(provisioningStateInstance8);
                    }
                }

                JsonNode etagValue8 = responseDoc.get("etag");
                if (etagValue8 != null && etagValue8 instanceof NullNode == false) {
                    String etagInstance8;
                    etagInstance8 = etagValue8.getTextValue();
                    loadBalancerInstance.setEtag(etagInstance8);
                }

                JsonNode idValue26 = responseDoc.get("id");
                if (idValue26 != null && idValue26 instanceof NullNode == false) {
                    String idInstance26;
                    idInstance26 = idValue26.getTextValue();
                    loadBalancerInstance.setId(idInstance26);
                }

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

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

                JsonNode locationValue = responseDoc.get("location");
                if (locationValue != null && locationValue instanceof NullNode == false) {
                    String locationInstance;
                    locationInstance = locationValue.getTextValue();
                    loadBalancerInstance.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 tagsKey2 = property.getKey();
                        String tagsValue2 = property.getValue().getTextValue();
                        loadBalancerInstance.getTags().put(tagsKey2, tagsValue2);
                    }
                }

                JsonNode errorValue = responseDoc.get("error");
                if (errorValue != null && errorValue instanceof NullNode == false) {
                    Error errorInstance = new Error();
                    result.setError(errorInstance);

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

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

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

                    JsonNode detailsArray = errorValue.get("details");
                    if (detailsArray != null && detailsArray instanceof NullNode == false) {
                        for (JsonNode detailsValue : ((ArrayNode) detailsArray)) {
                            ErrorDetails errorDetailsInstance = new ErrorDetails();
                            errorInstance.getDetails().add(errorDetailsInstance);

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

                            JsonNode targetValue2 = detailsValue.get("target");
                            if (targetValue2 != null && targetValue2 instanceof NullNode == false) {
                                String targetInstance2;
                                targetInstance2 = targetValue2.getTextValue();
                                errorDetailsInstance.setTarget(targetInstance2);
                            }

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

                    JsonNode innerErrorValue = errorValue.get("innerError");
                    if (innerErrorValue != null && innerErrorValue instanceof NullNode == false) {
                        String innerErrorInstance;
                        innerErrorInstance = innerErrorValue.getTextValue();
                        errorInstance.setInnerError(innerErrorInstance);
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("Azure-AsyncOperation").length > 0) {
            result.setAzureAsyncOperation(httpResponse.getFirstHeader("Azure-AsyncOperation").getValue());
        }
        if (httpResponse.getHeaders("Retry-After").length > 0) {
            result.setRetryAfter(
                    DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").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 Get Detailed Hosted Service Properties operation retrieves system
* properties for the specified cloud service. These properties include the
* service name and service type; the name of the affinity group to which
* the service belongs, or its location if it is not part of an affinity
* group; and information on the deployments of the service.  (see
* http://msdn.microsoft.com/en-us/library/windowsazure/ee460806.aspx for
* more information)//from  w w w. j  a  v a2 s.c  o m
*
* @param serviceName Required. The name of the cloud service.
* @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 detailed Get Hosted Service operation response.
*/
@Override
public HostedServiceGetDetailedResponse getDetailed(String serviceName)
        throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException {
    // Validate
    if (serviceName == null) {
        throw new NullPointerException("serviceName");
    }

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

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

            Element hostedServiceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "HostedService");
            if (hostedServiceElement != null) {
                Element deploymentsSequenceElement = XmlUtility.getElementByTagNameNS(hostedServiceElement,
                        "http://schemas.microsoft.com/windowsazure", "Deployments");
                if (deploymentsSequenceElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(deploymentsSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "Deployment")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element deploymentsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(deploymentsSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "Deployment")
                                .get(i1));
                        HostedServiceGetDetailedResponse.Deployment deploymentInstance = new HostedServiceGetDetailedResponse.Deployment();
                        result.getDeployments().add(deploymentInstance);

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

                        Element deploymentSlotElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "DeploymentSlot");
                        if (deploymentSlotElement != null && deploymentSlotElement.getTextContent() != null
                                && !deploymentSlotElement.getTextContent().isEmpty()) {
                            DeploymentSlot deploymentSlotInstance;
                            deploymentSlotInstance = DeploymentSlot
                                    .valueOf(deploymentSlotElement.getTextContent());
                            deploymentInstance.setDeploymentSlot(deploymentSlotInstance);
                        }

                        Element privateIDElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "PrivateID");
                        if (privateIDElement != null) {
                            String privateIDInstance;
                            privateIDInstance = privateIDElement.getTextContent();
                            deploymentInstance.setPrivateId(privateIDInstance);
                        }

                        Element statusElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "Status");
                        if (statusElement != null && statusElement.getTextContent() != null
                                && !statusElement.getTextContent().isEmpty()) {
                            DeploymentStatus statusInstance;
                            statusInstance = DeploymentStatus.valueOf(statusElement.getTextContent());
                            deploymentInstance.setStatus(statusInstance);
                        }

                        Element labelElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "Label");
                        if (labelElement != null) {
                            String labelInstance;
                            labelInstance = labelElement.getTextContent() != null
                                    ? new String(Base64.decode(labelElement.getTextContent()))
                                    : null;
                            deploymentInstance.setLabel(labelInstance);
                        }

                        Element urlElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "Url");
                        if (urlElement != null) {
                            URI urlInstance;
                            urlInstance = new URI(urlElement.getTextContent());
                            deploymentInstance.setUri(urlInstance);
                        }

                        Element configurationElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "Configuration");
                        if (configurationElement != null) {
                            String configurationInstance;
                            configurationInstance = configurationElement.getTextContent() != null
                                    ? new String(Base64.decode(configurationElement.getTextContent()))
                                    : null;
                            deploymentInstance.setConfiguration(configurationInstance);
                        }

                        Element roleInstanceListSequenceElement = XmlUtility.getElementByTagNameNS(
                                deploymentsElement, "http://schemas.microsoft.com/windowsazure",
                                "RoleInstanceList");
                        if (roleInstanceListSequenceElement != null) {
                            for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(roleInstanceListSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "RoleInstance")
                                    .size(); i2 = i2 + 1) {
                                org.w3c.dom.Element roleInstanceListElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(roleInstanceListSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "RoleInstance")
                                        .get(i2));
                                RoleInstance roleInstanceInstance = new RoleInstance();
                                deploymentInstance.getRoleInstances().add(roleInstanceInstance);

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

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

                                Element instanceStatusElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceStatus");
                                if (instanceStatusElement != null) {
                                    String instanceStatusInstance;
                                    instanceStatusInstance = instanceStatusElement.getTextContent();
                                    roleInstanceInstance.setInstanceStatus(instanceStatusInstance);
                                }

                                Element instanceUpgradeDomainElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceUpgradeDomain");
                                if (instanceUpgradeDomainElement != null
                                        && instanceUpgradeDomainElement.getTextContent() != null
                                        && !instanceUpgradeDomainElement.getTextContent().isEmpty()) {
                                    int instanceUpgradeDomainInstance;
                                    instanceUpgradeDomainInstance = DatatypeConverter
                                            .parseInt(instanceUpgradeDomainElement.getTextContent());
                                    roleInstanceInstance
                                            .setInstanceUpgradeDomain(instanceUpgradeDomainInstance);
                                }

                                Element instanceFaultDomainElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceFaultDomain");
                                if (instanceFaultDomainElement != null
                                        && instanceFaultDomainElement.getTextContent() != null
                                        && !instanceFaultDomainElement.getTextContent().isEmpty()) {
                                    int instanceFaultDomainInstance;
                                    instanceFaultDomainInstance = DatatypeConverter
                                            .parseInt(instanceFaultDomainElement.getTextContent());
                                    roleInstanceInstance.setInstanceFaultDomain(instanceFaultDomainInstance);
                                }

                                Element instanceSizeElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceSize");
                                if (instanceSizeElement != null) {
                                    String instanceSizeInstance;
                                    instanceSizeInstance = instanceSizeElement.getTextContent();
                                    roleInstanceInstance.setInstanceSize(instanceSizeInstance);
                                }

                                Element instanceStateDetailsElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceStateDetails");
                                if (instanceStateDetailsElement != null) {
                                    String instanceStateDetailsInstance;
                                    instanceStateDetailsInstance = instanceStateDetailsElement.getTextContent();
                                    roleInstanceInstance.setInstanceStateDetails(instanceStateDetailsInstance);
                                }

                                Element instanceErrorCodeElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceErrorCode");
                                if (instanceErrorCodeElement != null) {
                                    String instanceErrorCodeInstance;
                                    instanceErrorCodeInstance = instanceErrorCodeElement.getTextContent();
                                    roleInstanceInstance.setInstanceErrorCode(instanceErrorCodeInstance);
                                }

                                Element ipAddressElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "IpAddress");
                                if (ipAddressElement != null) {
                                    InetAddress ipAddressInstance;
                                    ipAddressInstance = InetAddress
                                            .getByName(ipAddressElement.getTextContent());
                                    roleInstanceInstance.setIPAddress(ipAddressInstance);
                                }

                                Element instanceEndpointsSequenceElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "InstanceEndpoints");
                                if (instanceEndpointsSequenceElement != null) {
                                    for (int i3 = 0; i3 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(instanceEndpointsSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "InstanceEndpoint")
                                            .size(); i3 = i3 + 1) {
                                        org.w3c.dom.Element instanceEndpointsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(instanceEndpointsSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "InstanceEndpoint")
                                                .get(i3));
                                        InstanceEndpoint instanceEndpointInstance = new InstanceEndpoint();
                                        roleInstanceInstance.getInstanceEndpoints()
                                                .add(instanceEndpointInstance);

                                        Element localPortElement = XmlUtility.getElementByTagNameNS(
                                                instanceEndpointsElement,
                                                "http://schemas.microsoft.com/windowsazure", "LocalPort");
                                        if (localPortElement != null
                                                && localPortElement.getTextContent() != null
                                                && !localPortElement.getTextContent().isEmpty()) {
                                            int localPortInstance;
                                            localPortInstance = DatatypeConverter
                                                    .parseInt(localPortElement.getTextContent());
                                            instanceEndpointInstance.setLocalPort(localPortInstance);
                                        }

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

                                        Element publicPortElement = XmlUtility.getElementByTagNameNS(
                                                instanceEndpointsElement,
                                                "http://schemas.microsoft.com/windowsazure", "PublicPort");
                                        if (publicPortElement != null) {
                                            int publicPortInstance;
                                            publicPortInstance = DatatypeConverter
                                                    .parseInt(publicPortElement.getTextContent());
                                            instanceEndpointInstance.setPort(publicPortInstance);
                                        }

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

                                        Element vipElement = XmlUtility.getElementByTagNameNS(
                                                instanceEndpointsElement,
                                                "http://schemas.microsoft.com/windowsazure", "Vip");
                                        if (vipElement != null) {
                                            InetAddress vipInstance;
                                            vipInstance = InetAddress.getByName(vipElement.getTextContent());
                                            instanceEndpointInstance.setVirtualIPAddress(vipInstance);
                                        }

                                        Element idleTimeoutInMinutesElement = XmlUtility.getElementByTagNameNS(
                                                instanceEndpointsElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "IdleTimeoutInMinutes");
                                        if (idleTimeoutInMinutesElement != null
                                                && idleTimeoutInMinutesElement.getTextContent() != null
                                                && !idleTimeoutInMinutesElement.getTextContent().isEmpty()) {
                                            int idleTimeoutInMinutesInstance;
                                            idleTimeoutInMinutesInstance = DatatypeConverter
                                                    .parseInt(idleTimeoutInMinutesElement.getTextContent());
                                            instanceEndpointInstance
                                                    .setIdleTimeoutInMinutes(idleTimeoutInMinutesInstance);
                                        }
                                    }
                                }

                                Element guestAgentStatusElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "GuestAgentStatus");
                                if (guestAgentStatusElement != null) {
                                    GuestAgentStatus guestAgentStatusInstance = new GuestAgentStatus();
                                    roleInstanceInstance.setGuestAgentStatus(guestAgentStatusInstance);

                                    Element protocolVersionElement = XmlUtility.getElementByTagNameNS(
                                            guestAgentStatusElement,
                                            "http://schemas.microsoft.com/windowsazure", "ProtocolVersion");
                                    if (protocolVersionElement != null) {
                                        String protocolVersionInstance;
                                        protocolVersionInstance = protocolVersionElement.getTextContent();
                                        guestAgentStatusInstance.setProtocolVersion(protocolVersionInstance);
                                    }

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

                                    Element guestAgentVersionElement = XmlUtility.getElementByTagNameNS(
                                            guestAgentStatusElement,
                                            "http://schemas.microsoft.com/windowsazure", "GuestAgentVersion");
                                    if (guestAgentVersionElement != null) {
                                        String guestAgentVersionInstance;
                                        guestAgentVersionInstance = guestAgentVersionElement.getTextContent();
                                        guestAgentStatusInstance
                                                .setGuestAgentVersion(guestAgentVersionInstance);
                                    }

                                    Element statusElement2 = XmlUtility.getElementByTagNameNS(
                                            guestAgentStatusElement,
                                            "http://schemas.microsoft.com/windowsazure", "Status");
                                    if (statusElement2 != null) {
                                        String statusInstance2;
                                        statusInstance2 = statusElement2.getTextContent();
                                        guestAgentStatusInstance.setStatus(statusInstance2);
                                    }

                                    Element codeElement = XmlUtility.getElementByTagNameNS(
                                            guestAgentStatusElement,
                                            "http://schemas.microsoft.com/windowsazure", "Code");
                                    if (codeElement != null && codeElement.getTextContent() != null
                                            && !codeElement.getTextContent().isEmpty()) {
                                        int codeInstance;
                                        codeInstance = DatatypeConverter.parseInt(codeElement.getTextContent());
                                        guestAgentStatusInstance.setCode(codeInstance);
                                    }

                                    Element messageElement = XmlUtility.getElementByTagNameNS(
                                            guestAgentStatusElement,
                                            "http://schemas.microsoft.com/windowsazure", "Message");
                                    if (messageElement != null) {
                                        GuestAgentMessage messageInstance = new GuestAgentMessage();
                                        guestAgentStatusInstance.setMessage(messageInstance);

                                        Element messageResourceIdElement = XmlUtility.getElementByTagNameNS(
                                                messageElement, "http://schemas.microsoft.com/windowsazure",
                                                "MessageResourceId");
                                        if (messageResourceIdElement != null) {
                                            String messageResourceIdInstance;
                                            messageResourceIdInstance = messageResourceIdElement
                                                    .getTextContent();
                                            messageInstance.setMessageResourceId(messageResourceIdInstance);
                                        }

                                        Element paramListSequenceElement = XmlUtility.getElementByTagNameNS(
                                                messageElement, "http://schemas.microsoft.com/windowsazure",
                                                "ParamList");
                                        if (paramListSequenceElement != null) {
                                            for (int i4 = 0; i4 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(paramListSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Param")
                                                    .size(); i4 = i4 + 1) {
                                                org.w3c.dom.Element paramListElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(paramListSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "Param")
                                                        .get(i4));
                                                messageInstance.getParamList()
                                                        .add(paramListElement.getTextContent());
                                            }
                                        }
                                    }

                                    Element formattedMessageElement = XmlUtility.getElementByTagNameNS(
                                            guestAgentStatusElement,
                                            "http://schemas.microsoft.com/windowsazure", "FormattedMessage");
                                    if (formattedMessageElement != null) {
                                        GuestAgentFormattedMessage formattedMessageInstance = new GuestAgentFormattedMessage();
                                        guestAgentStatusInstance.setFormattedMessage(formattedMessageInstance);

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

                                        Element messageElement2 = XmlUtility.getElementByTagNameNS(
                                                formattedMessageElement,
                                                "http://schemas.microsoft.com/windowsazure", "Message");
                                        if (messageElement2 != null) {
                                            String messageInstance2;
                                            messageInstance2 = messageElement2.getTextContent();
                                            formattedMessageInstance.setMessage(messageInstance2);
                                        }
                                    }
                                }

                                Element resourceExtensionStatusListSequenceElement = XmlUtility
                                        .getElementByTagNameNS(roleInstanceListElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "ResourceExtensionStatusList");
                                if (resourceExtensionStatusListSequenceElement != null) {
                                    for (int i5 = 0; i5 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(resourceExtensionStatusListSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "ResourceExtensionStatus")
                                            .size(); i5 = i5 + 1) {
                                        org.w3c.dom.Element resourceExtensionStatusListElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(
                                                        resourceExtensionStatusListSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "ResourceExtensionStatus")
                                                .get(i5));
                                        ResourceExtensionStatus resourceExtensionStatusInstance = new ResourceExtensionStatus();
                                        roleInstanceInstance.getResourceExtensionStatusList()
                                                .add(resourceExtensionStatusInstance);

                                        Element handlerNameElement = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionStatusListElement,
                                                "http://schemas.microsoft.com/windowsazure", "HandlerName");
                                        if (handlerNameElement != null) {
                                            String handlerNameInstance;
                                            handlerNameInstance = handlerNameElement.getTextContent();
                                            resourceExtensionStatusInstance.setHandlerName(handlerNameInstance);
                                        }

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

                                        Element statusElement3 = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionStatusListElement,
                                                "http://schemas.microsoft.com/windowsazure", "Status");
                                        if (statusElement3 != null) {
                                            String statusInstance3;
                                            statusInstance3 = statusElement3.getTextContent();
                                            resourceExtensionStatusInstance.setStatus(statusInstance3);
                                        }

                                        Element codeElement2 = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionStatusListElement,
                                                "http://schemas.microsoft.com/windowsazure", "Code");
                                        if (codeElement2 != null && codeElement2.getTextContent() != null
                                                && !codeElement2.getTextContent().isEmpty()) {
                                            int codeInstance2;
                                            codeInstance2 = DatatypeConverter
                                                    .parseInt(codeElement2.getTextContent());
                                            resourceExtensionStatusInstance.setCode(codeInstance2);
                                        }

                                        Element messageElement3 = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionStatusListElement,
                                                "http://schemas.microsoft.com/windowsazure", "Message");
                                        if (messageElement3 != null) {
                                            GuestAgentMessage messageInstance3 = new GuestAgentMessage();
                                            resourceExtensionStatusInstance.setMessage(messageInstance3);

                                            Element messageResourceIdElement2 = XmlUtility
                                                    .getElementByTagNameNS(messageElement3,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "MessageResourceId");
                                            if (messageResourceIdElement2 != null) {
                                                String messageResourceIdInstance2;
                                                messageResourceIdInstance2 = messageResourceIdElement2
                                                        .getTextContent();
                                                messageInstance3
                                                        .setMessageResourceId(messageResourceIdInstance2);
                                            }

                                            Element paramListSequenceElement2 = XmlUtility
                                                    .getElementByTagNameNS(messageElement3,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "ParamList");
                                            if (paramListSequenceElement2 != null) {
                                                for (int i6 = 0; i6 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(paramListSequenceElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "Param")
                                                        .size(); i6 = i6 + 1) {
                                                    org.w3c.dom.Element paramListElement2 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(paramListSequenceElement2,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Param")
                                                            .get(i6));
                                                    messageInstance3.getParamList()
                                                            .add(paramListElement2.getTextContent());
                                                }
                                            }
                                        }

                                        Element formattedMessageElement2 = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionStatusListElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "FormattedMessage");
                                        if (formattedMessageElement2 != null) {
                                            GuestAgentFormattedMessage formattedMessageInstance2 = new GuestAgentFormattedMessage();
                                            resourceExtensionStatusInstance
                                                    .setFormattedMessage(formattedMessageInstance2);

                                            Element languageElement2 = XmlUtility.getElementByTagNameNS(
                                                    formattedMessageElement2,
                                                    "http://schemas.microsoft.com/windowsazure", "Language");
                                            if (languageElement2 != null) {
                                                String languageInstance2;
                                                languageInstance2 = languageElement2.getTextContent();
                                                formattedMessageInstance2.setLanguage(languageInstance2);
                                            }

                                            Element messageElement4 = XmlUtility.getElementByTagNameNS(
                                                    formattedMessageElement2,
                                                    "http://schemas.microsoft.com/windowsazure", "Message");
                                            if (messageElement4 != null) {
                                                String messageInstance4;
                                                messageInstance4 = messageElement4.getTextContent();
                                                formattedMessageInstance2.setMessage(messageInstance4);
                                            }
                                        }

                                        Element extensionSettingStatusElement = XmlUtility
                                                .getElementByTagNameNS(resourceExtensionStatusListElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "ExtensionSettingStatus");
                                        if (extensionSettingStatusElement != null) {
                                            ResourceExtensionConfigurationStatus extensionSettingStatusInstance = new ResourceExtensionConfigurationStatus();
                                            resourceExtensionStatusInstance
                                                    .setExtensionSettingStatus(extensionSettingStatusInstance);

                                            Element timestampElement2 = XmlUtility.getElementByTagNameNS(
                                                    extensionSettingStatusElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Timestamp");
                                            if (timestampElement2 != null
                                                    && timestampElement2.getTextContent() != null
                                                    && !timestampElement2.getTextContent().isEmpty()) {
                                                Calendar timestampInstance2;
                                                timestampInstance2 = DatatypeConverter
                                                        .parseDateTime(timestampElement2.getTextContent());
                                                extensionSettingStatusInstance.setTimestamp(timestampInstance2);
                                            }

                                            Element configurationAppliedTimeElement = XmlUtility
                                                    .getElementByTagNameNS(extensionSettingStatusElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "ConfigurationAppliedTime");
                                            if (configurationAppliedTimeElement != null
                                                    && configurationAppliedTimeElement.getTextContent() != null
                                                    && !configurationAppliedTimeElement.getTextContent()
                                                            .isEmpty()) {
                                                Calendar configurationAppliedTimeInstance;
                                                configurationAppliedTimeInstance = DatatypeConverter
                                                        .parseDateTime(configurationAppliedTimeElement
                                                                .getTextContent());
                                                extensionSettingStatusInstance.setConfigurationAppliedTime(
                                                        configurationAppliedTimeInstance);
                                            }

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

                                            Element operationElement = XmlUtility.getElementByTagNameNS(
                                                    extensionSettingStatusElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Operation");
                                            if (operationElement != null) {
                                                String operationInstance;
                                                operationInstance = operationElement.getTextContent();
                                                extensionSettingStatusInstance.setOperation(operationInstance);
                                            }

                                            Element statusElement4 = XmlUtility.getElementByTagNameNS(
                                                    extensionSettingStatusElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Status");
                                            if (statusElement4 != null) {
                                                String statusInstance4;
                                                statusInstance4 = statusElement4.getTextContent();
                                                extensionSettingStatusInstance.setStatus(statusInstance4);
                                            }

                                            Element codeElement3 = XmlUtility.getElementByTagNameNS(
                                                    extensionSettingStatusElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Code");
                                            if (codeElement3 != null && codeElement3.getTextContent() != null
                                                    && !codeElement3.getTextContent().isEmpty()) {
                                                int codeInstance3;
                                                codeInstance3 = DatatypeConverter
                                                        .parseInt(codeElement3.getTextContent());
                                                extensionSettingStatusInstance.setCode(codeInstance3);
                                            }

                                            Element messageElement5 = XmlUtility.getElementByTagNameNS(
                                                    extensionSettingStatusElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Message");
                                            if (messageElement5 != null) {
                                                GuestAgentMessage messageInstance5 = new GuestAgentMessage();
                                                extensionSettingStatusInstance.setMessage(messageInstance5);

                                                Element messageResourceIdElement3 = XmlUtility
                                                        .getElementByTagNameNS(messageElement5,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "MessageResourceId");
                                                if (messageResourceIdElement3 != null) {
                                                    String messageResourceIdInstance3;
                                                    messageResourceIdInstance3 = messageResourceIdElement3
                                                            .getTextContent();
                                                    messageInstance5
                                                            .setMessageResourceId(messageResourceIdInstance3);
                                                }

                                                Element paramListSequenceElement3 = XmlUtility
                                                        .getElementByTagNameNS(messageElement5,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "ParamList");
                                                if (paramListSequenceElement3 != null) {
                                                    for (int i7 = 0; i7 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(paramListSequenceElement3,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Param")
                                                            .size(); i7 = i7 + 1) {
                                                        org.w3c.dom.Element paramListElement3 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                                .getElementsByTagNameNS(
                                                                        paramListSequenceElement3,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "Param")
                                                                .get(i7));
                                                        messageInstance5.getParamList()
                                                                .add(paramListElement3.getTextContent());
                                                    }
                                                }
                                            }

                                            Element formattedMessageElement3 = XmlUtility.getElementByTagNameNS(
                                                    extensionSettingStatusElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "FormattedMessage");
                                            if (formattedMessageElement3 != null) {
                                                GuestAgentFormattedMessage formattedMessageInstance3 = new GuestAgentFormattedMessage();
                                                extensionSettingStatusInstance
                                                        .setFormattedMessage(formattedMessageInstance3);

                                                Element languageElement3 = XmlUtility.getElementByTagNameNS(
                                                        formattedMessageElement3,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "Language");
                                                if (languageElement3 != null) {
                                                    String languageInstance3;
                                                    languageInstance3 = languageElement3.getTextContent();
                                                    formattedMessageInstance3.setLanguage(languageInstance3);
                                                }

                                                Element messageElement6 = XmlUtility.getElementByTagNameNS(
                                                        formattedMessageElement3,
                                                        "http://schemas.microsoft.com/windowsazure", "Message");
                                                if (messageElement6 != null) {
                                                    String messageInstance6;
                                                    messageInstance6 = messageElement6.getTextContent();
                                                    formattedMessageInstance3.setMessage(messageInstance6);
                                                }
                                            }

                                            Element subStatusListSequenceElement = XmlUtility
                                                    .getElementByTagNameNS(extensionSettingStatusElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "SubStatusList");
                                            if (subStatusListSequenceElement != null) {
                                                for (int i8 = 0; i8 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(subStatusListSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "SubStatus")
                                                        .size(); i8 = i8 + 1) {
                                                    org.w3c.dom.Element subStatusListElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(
                                                                    subStatusListSequenceElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "SubStatus")
                                                            .get(i8));
                                                    ResourceExtensionSubStatus subStatusInstance = new ResourceExtensionSubStatus();
                                                    extensionSettingStatusInstance.getSubStatusList()
                                                            .add(subStatusInstance);

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

                                                    Element statusElement5 = XmlUtility.getElementByTagNameNS(
                                                            subStatusListElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Status");
                                                    if (statusElement5 != null) {
                                                        String statusInstance5;
                                                        statusInstance5 = statusElement5.getTextContent();
                                                        subStatusInstance.setStatus(statusInstance5);
                                                    }

                                                    Element codeElement4 = XmlUtility.getElementByTagNameNS(
                                                            subStatusListElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Code");
                                                    if (codeElement4 != null
                                                            && codeElement4.getTextContent() != null
                                                            && !codeElement4.getTextContent().isEmpty()) {
                                                        int codeInstance4;
                                                        codeInstance4 = DatatypeConverter
                                                                .parseInt(codeElement4.getTextContent());
                                                        subStatusInstance.setCode(codeInstance4);
                                                    }

                                                    Element messageElement7 = XmlUtility.getElementByTagNameNS(
                                                            subStatusListElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Message");
                                                    if (messageElement7 != null) {
                                                        GuestAgentMessage messageInstance7 = new GuestAgentMessage();
                                                        subStatusInstance.setMessage(messageInstance7);

                                                        Element messageResourceIdElement4 = XmlUtility
                                                                .getElementByTagNameNS(messageElement7,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "MessageResourceId");
                                                        if (messageResourceIdElement4 != null) {
                                                            String messageResourceIdInstance4;
                                                            messageResourceIdInstance4 = messageResourceIdElement4
                                                                    .getTextContent();
                                                            messageInstance7.setMessageResourceId(
                                                                    messageResourceIdInstance4);
                                                        }

                                                        Element paramListSequenceElement4 = XmlUtility
                                                                .getElementByTagNameNS(messageElement7,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "ParamList");
                                                        if (paramListSequenceElement4 != null) {
                                                            for (int i9 = 0; i9 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                                    .getElementsByTagNameNS(
                                                                            paramListSequenceElement4,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "Param")
                                                                    .size(); i9 = i9 + 1) {
                                                                org.w3c.dom.Element paramListElement4 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                                        .getElementsByTagNameNS(
                                                                                paramListSequenceElement4,
                                                                                "http://schemas.microsoft.com/windowsazure",
                                                                                "Param")
                                                                        .get(i9));
                                                                messageInstance7.getParamList().add(
                                                                        paramListElement4.getTextContent());
                                                            }
                                                        }
                                                    }

                                                    Element formattedMessageElement4 = XmlUtility
                                                            .getElementByTagNameNS(subStatusListElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "FormattedMessage");
                                                    if (formattedMessageElement4 != null) {
                                                        GuestAgentFormattedMessage formattedMessageInstance4 = new GuestAgentFormattedMessage();
                                                        subStatusInstance
                                                                .setFormattedMessage(formattedMessageInstance4);

                                                        Element languageElement4 = XmlUtility
                                                                .getElementByTagNameNS(formattedMessageElement4,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "Language");
                                                        if (languageElement4 != null) {
                                                            String languageInstance4;
                                                            languageInstance4 = languageElement4
                                                                    .getTextContent();
                                                            formattedMessageInstance4
                                                                    .setLanguage(languageInstance4);
                                                        }

                                                        Element messageElement8 = XmlUtility
                                                                .getElementByTagNameNS(formattedMessageElement4,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "Message");
                                                        if (messageElement8 != null) {
                                                            String messageInstance8;
                                                            messageInstance8 = messageElement8.getTextContent();
                                                            formattedMessageInstance4
                                                                    .setMessage(messageInstance8);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }

                                Element powerStateElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "PowerState");
                                if (powerStateElement != null && powerStateElement.getTextContent() != null
                                        && !powerStateElement.getTextContent().isEmpty()) {
                                    RoleInstancePowerState powerStateInstance;
                                    powerStateInstance = RoleInstancePowerState
                                            .valueOf(powerStateElement.getTextContent());
                                    roleInstanceInstance.setPowerState(powerStateInstance);
                                }

                                Element hostNameElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "HostName");
                                if (hostNameElement != null) {
                                    String hostNameInstance;
                                    hostNameInstance = hostNameElement.getTextContent();
                                    roleInstanceInstance.setHostName(hostNameInstance);
                                }

                                Element remoteAccessCertificateThumbprintElement = XmlUtility
                                        .getElementByTagNameNS(roleInstanceListElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "RemoteAccessCertificateThumbprint");
                                if (remoteAccessCertificateThumbprintElement != null) {
                                    String remoteAccessCertificateThumbprintInstance;
                                    remoteAccessCertificateThumbprintInstance = remoteAccessCertificateThumbprintElement
                                            .getTextContent();
                                    roleInstanceInstance.setRemoteAccessCertificateThumbprint(
                                            remoteAccessCertificateThumbprintInstance);
                                }

                                Element publicIPsSequenceElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "PublicIPs");
                                if (publicIPsSequenceElement != null) {
                                    for (int i10 = 0; i10 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(publicIPsSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure", "PublicIP")
                                            .size(); i10 = i10 + 1) {
                                        org.w3c.dom.Element publicIPsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(publicIPsSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure", "PublicIP")
                                                .get(i10));
                                        RoleInstance.PublicIP publicIPInstance = new RoleInstance.PublicIP();
                                        roleInstanceInstance.getPublicIPs().add(publicIPInstance);

                                        Element nameElement5 = XmlUtility.getElementByTagNameNS(
                                                publicIPsElement, "http://schemas.microsoft.com/windowsazure",
                                                "Name");
                                        if (nameElement5 != null) {
                                            String nameInstance5;
                                            nameInstance5 = nameElement5.getTextContent();
                                            publicIPInstance.setName(nameInstance5);
                                        }

                                        Element addressElement = XmlUtility.getElementByTagNameNS(
                                                publicIPsElement, "http://schemas.microsoft.com/windowsazure",
                                                "Address");
                                        if (addressElement != null) {
                                            InetAddress addressInstance;
                                            addressInstance = InetAddress
                                                    .getByName(addressElement.getTextContent());
                                            publicIPInstance.setAddress(addressInstance);
                                        }

                                        Element idleTimeoutInMinutesElement2 = XmlUtility.getElementByTagNameNS(
                                                publicIPsElement, "http://schemas.microsoft.com/windowsazure",
                                                "IdleTimeoutInMinutes");
                                        if (idleTimeoutInMinutesElement2 != null
                                                && idleTimeoutInMinutesElement2.getTextContent() != null
                                                && !idleTimeoutInMinutesElement2.getTextContent().isEmpty()) {
                                            int idleTimeoutInMinutesInstance2;
                                            idleTimeoutInMinutesInstance2 = DatatypeConverter
                                                    .parseInt(idleTimeoutInMinutesElement2.getTextContent());
                                            publicIPInstance
                                                    .setIdleTimeoutInMinutes(idleTimeoutInMinutesInstance2);
                                        }

                                        Element domainNameLabelElement = XmlUtility.getElementByTagNameNS(
                                                publicIPsElement, "http://schemas.microsoft.com/windowsazure",
                                                "DomainNameLabel");
                                        if (domainNameLabelElement != null) {
                                            String domainNameLabelInstance;
                                            domainNameLabelInstance = domainNameLabelElement.getTextContent();
                                            publicIPInstance.setDomainNameLabel(domainNameLabelInstance);
                                        }

                                        Element fqdnsSequenceElement = XmlUtility.getElementByTagNameNS(
                                                publicIPsElement, "http://schemas.microsoft.com/windowsazure",
                                                "Fqdns");
                                        if (fqdnsSequenceElement != null) {
                                            for (int i11 = 0; i11 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(fqdnsSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure", "Fqdn")
                                                    .size(); i11 = i11 + 1) {
                                                org.w3c.dom.Element fqdnsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(fqdnsSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "Fqdn")
                                                        .get(i11));
                                                publicIPInstance.getFqdns().add(fqdnsElement.getTextContent());
                                            }
                                        }
                                    }
                                }

                                Element networkInterfacesSequenceElement = XmlUtility.getElementByTagNameNS(
                                        roleInstanceListElement, "http://schemas.microsoft.com/windowsazure",
                                        "NetworkInterfaces");
                                if (networkInterfacesSequenceElement != null) {
                                    for (int i12 = 0; i12 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(networkInterfacesSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "NetworkInterface")
                                            .size(); i12 = i12 + 1) {
                                        org.w3c.dom.Element networkInterfacesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(networkInterfacesSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "NetworkInterface")
                                                .get(i12));
                                        NetworkInterfaceInstance networkInterfaceInstance = new NetworkInterfaceInstance();
                                        roleInstanceInstance.getNetworkInterfaces()
                                                .add(networkInterfaceInstance);

                                        Element nameElement6 = XmlUtility.getElementByTagNameNS(
                                                networkInterfacesElement,
                                                "http://schemas.microsoft.com/windowsazure", "Name");
                                        if (nameElement6 != null) {
                                            String nameInstance6;
                                            nameInstance6 = nameElement6.getTextContent();
                                            networkInterfaceInstance.setName(nameInstance6);
                                        }

                                        Element macAddressElement = XmlUtility.getElementByTagNameNS(
                                                networkInterfacesElement,
                                                "http://schemas.microsoft.com/windowsazure", "MacAddress");
                                        if (macAddressElement != null) {
                                            String macAddressInstance;
                                            macAddressInstance = macAddressElement.getTextContent();
                                            networkInterfaceInstance.setMacAddress(macAddressInstance);
                                        }

                                        Element iPConfigurationsSequenceElement = XmlUtility
                                                .getElementByTagNameNS(networkInterfacesElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "IPConfigurations");
                                        if (iPConfigurationsSequenceElement != null) {
                                            for (int i13 = 0; i13 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(iPConfigurationsSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "IPConfiguration")
                                                    .size(); i13 = i13 + 1) {
                                                org.w3c.dom.Element iPConfigurationsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(iPConfigurationsSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "IPConfiguration")
                                                        .get(i13));
                                                IPConfigurationInstance iPConfigurationInstance = new IPConfigurationInstance();
                                                networkInterfaceInstance.getIPConfigurations()
                                                        .add(iPConfigurationInstance);

                                                Element subnetNameElement = XmlUtility.getElementByTagNameNS(
                                                        iPConfigurationsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "SubnetName");
                                                if (subnetNameElement != null) {
                                                    String subnetNameInstance;
                                                    subnetNameInstance = subnetNameElement.getTextContent();
                                                    iPConfigurationInstance.setSubnetName(subnetNameInstance);
                                                }

                                                Element addressElement2 = XmlUtility.getElementByTagNameNS(
                                                        iPConfigurationsElement,
                                                        "http://schemas.microsoft.com/windowsazure", "Address");
                                                if (addressElement2 != null) {
                                                    String addressInstance2;
                                                    addressInstance2 = addressElement2.getTextContent();
                                                    iPConfigurationInstance.setAddress(addressInstance2);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        Element upgradeStatusElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "UpgradeStatus");
                        if (upgradeStatusElement != null) {
                            UpgradeStatus upgradeStatusInstance = new UpgradeStatus();
                            deploymentInstance.setUpgradeStatus(upgradeStatusInstance);

                            Element upgradeTypeElement = XmlUtility.getElementByTagNameNS(upgradeStatusElement,
                                    "http://schemas.microsoft.com/windowsazure", "UpgradeType");
                            if (upgradeTypeElement != null && upgradeTypeElement.getTextContent() != null
                                    && !upgradeTypeElement.getTextContent().isEmpty()) {
                                DeploymentUpgradeType upgradeTypeInstance;
                                upgradeTypeInstance = DeploymentUpgradeType
                                        .valueOf(upgradeTypeElement.getTextContent());
                                upgradeStatusInstance.setUpgradeType(upgradeTypeInstance);
                            }

                            Element currentUpgradeDomainStateElement = XmlUtility.getElementByTagNameNS(
                                    upgradeStatusElement, "http://schemas.microsoft.com/windowsazure",
                                    "CurrentUpgradeDomainState");
                            if (currentUpgradeDomainStateElement != null
                                    && currentUpgradeDomainStateElement.getTextContent() != null
                                    && !currentUpgradeDomainStateElement.getTextContent().isEmpty()) {
                                UpgradeDomainState currentUpgradeDomainStateInstance;
                                currentUpgradeDomainStateInstance = UpgradeDomainState
                                        .valueOf(currentUpgradeDomainStateElement.getTextContent());
                                upgradeStatusInstance
                                        .setCurrentUpgradeDomainState(currentUpgradeDomainStateInstance);
                            }

                            Element currentUpgradeDomainElement = XmlUtility.getElementByTagNameNS(
                                    upgradeStatusElement, "http://schemas.microsoft.com/windowsazure",
                                    "CurrentUpgradeDomain");
                            if (currentUpgradeDomainElement != null) {
                                int currentUpgradeDomainInstance;
                                currentUpgradeDomainInstance = DatatypeConverter
                                        .parseInt(currentUpgradeDomainElement.getTextContent());
                                upgradeStatusInstance.setCurrentUpgradeDomain(currentUpgradeDomainInstance);
                            }
                        }

                        Element upgradeDomainCountElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "UpgradeDomainCount");
                        if (upgradeDomainCountElement != null) {
                            int upgradeDomainCountInstance;
                            upgradeDomainCountInstance = DatatypeConverter
                                    .parseInt(upgradeDomainCountElement.getTextContent());
                            deploymentInstance.setUpgradeDomainCount(upgradeDomainCountInstance);
                        }

                        Element roleListSequenceElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "RoleList");
                        if (roleListSequenceElement != null) {
                            for (int i14 = 0; i14 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(roleListSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "Role")
                                    .size(); i14 = i14 + 1) {
                                org.w3c.dom.Element roleListElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(roleListSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "Role")
                                        .get(i14));
                                Role roleInstance = new Role();
                                deploymentInstance.getRoles().add(roleInstance);

                                Element roleNameElement2 = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "RoleName");
                                if (roleNameElement2 != null) {
                                    String roleNameInstance2;
                                    roleNameInstance2 = roleNameElement2.getTextContent();
                                    roleInstance.setRoleName(roleNameInstance2);
                                }

                                Element osVersionElement = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "OsVersion");
                                if (osVersionElement != null) {
                                    String osVersionInstance;
                                    osVersionInstance = osVersionElement.getTextContent();
                                    roleInstance.setOSVersion(osVersionInstance);
                                }

                                Element roleTypeElement = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "RoleType");
                                if (roleTypeElement != null) {
                                    String roleTypeInstance;
                                    roleTypeInstance = roleTypeElement.getTextContent();
                                    roleInstance.setRoleType(roleTypeInstance);
                                }

                                Element configurationSetsSequenceElement = XmlUtility.getElementByTagNameNS(
                                        roleListElement, "http://schemas.microsoft.com/windowsazure",
                                        "ConfigurationSets");
                                if (configurationSetsSequenceElement != null) {
                                    for (int i15 = 0; i15 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(configurationSetsSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "ConfigurationSet")
                                            .size(); i15 = i15 + 1) {
                                        org.w3c.dom.Element configurationSetsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(configurationSetsSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "ConfigurationSet")
                                                .get(i15));
                                        ConfigurationSet configurationSetInstance = new ConfigurationSet();
                                        roleInstance.getConfigurationSets().add(configurationSetInstance);

                                        Element configurationSetTypeElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "ConfigurationSetType");
                                        if (configurationSetTypeElement != null) {
                                            String configurationSetTypeInstance;
                                            configurationSetTypeInstance = configurationSetTypeElement
                                                    .getTextContent();
                                            configurationSetInstance
                                                    .setConfigurationSetType(configurationSetTypeInstance);
                                        }

                                        Element inputEndpointsSequenceElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "InputEndpoints");
                                        if (inputEndpointsSequenceElement != null) {
                                            for (int i16 = 0; i16 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(inputEndpointsSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "InputEndpoint")
                                                    .size(); i16 = i16 + 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(i16));
                                                InputEndpoint inputEndpointInstance = new InputEndpoint();
                                                configurationSetInstance.getInputEndpoints()
                                                        .add(inputEndpointInstance);

                                                Element loadBalancedEndpointSetNameElement = XmlUtility
                                                        .getElementByTagNameNS(inputEndpointsElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "LoadBalancedEndpointSetName");
                                                if (loadBalancedEndpointSetNameElement != null) {
                                                    String loadBalancedEndpointSetNameInstance;
                                                    loadBalancedEndpointSetNameInstance = loadBalancedEndpointSetNameElement
                                                            .getTextContent();
                                                    inputEndpointInstance.setLoadBalancedEndpointSetName(
                                                            loadBalancedEndpointSetNameInstance);
                                                }

                                                Element localPortElement2 = XmlUtility.getElementByTagNameNS(
                                                        inputEndpointsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "LocalPort");
                                                if (localPortElement2 != null
                                                        && localPortElement2.getTextContent() != null
                                                        && !localPortElement2.getTextContent().isEmpty()) {
                                                    int localPortInstance2;
                                                    localPortInstance2 = DatatypeConverter
                                                            .parseInt(localPortElement2.getTextContent());
                                                    inputEndpointInstance.setLocalPort(localPortInstance2);
                                                }

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

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

                                                Element loadBalancerProbeElement = XmlUtility
                                                        .getElementByTagNameNS(inputEndpointsElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "LoadBalancerProbe");
                                                if (loadBalancerProbeElement != null) {
                                                    LoadBalancerProbe loadBalancerProbeInstance = new LoadBalancerProbe();
                                                    inputEndpointInstance
                                                            .setLoadBalancerProbe(loadBalancerProbeInstance);

                                                    Element pathElement = XmlUtility.getElementByTagNameNS(
                                                            loadBalancerProbeElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Path");
                                                    if (pathElement != null) {
                                                        String pathInstance;
                                                        pathInstance = pathElement.getTextContent();
                                                        loadBalancerProbeInstance.setPath(pathInstance);
                                                    }

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

                                                    Element protocolElement2 = XmlUtility.getElementByTagNameNS(
                                                            loadBalancerProbeElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Protocol");
                                                    if (protocolElement2 != null
                                                            && protocolElement2.getTextContent() != null
                                                            && !protocolElement2.getTextContent().isEmpty()) {
                                                        LoadBalancerProbeTransportProtocol protocolInstance2;
                                                        protocolInstance2 = com.microsoft.windowsazure.management.compute.ComputeManagementClientImpl
                                                                .parseLoadBalancerProbeTransportProtocol(
                                                                        protocolElement2.getTextContent());
                                                        loadBalancerProbeInstance
                                                                .setProtocol(protocolInstance2);
                                                    }

                                                    Element intervalInSecondsElement = XmlUtility
                                                            .getElementByTagNameNS(loadBalancerProbeElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "IntervalInSeconds");
                                                    if (intervalInSecondsElement != null
                                                            && intervalInSecondsElement.getTextContent() != null
                                                            && !intervalInSecondsElement.getTextContent()
                                                                    .isEmpty()) {
                                                        int intervalInSecondsInstance;
                                                        intervalInSecondsInstance = DatatypeConverter.parseInt(
                                                                intervalInSecondsElement.getTextContent());
                                                        loadBalancerProbeInstance.setIntervalInSeconds(
                                                                intervalInSecondsInstance);
                                                    }

                                                    Element timeoutInSecondsElement = XmlUtility
                                                            .getElementByTagNameNS(loadBalancerProbeElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "TimeoutInSeconds");
                                                    if (timeoutInSecondsElement != null
                                                            && timeoutInSecondsElement.getTextContent() != null
                                                            && !timeoutInSecondsElement.getTextContent()
                                                                    .isEmpty()) {
                                                        int timeoutInSecondsInstance;
                                                        timeoutInSecondsInstance = DatatypeConverter.parseInt(
                                                                timeoutInSecondsElement.getTextContent());
                                                        loadBalancerProbeInstance
                                                                .setTimeoutInSeconds(timeoutInSecondsInstance);
                                                    }
                                                }

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

                                                Element vipElement2 = XmlUtility.getElementByTagNameNS(
                                                        inputEndpointsElement,
                                                        "http://schemas.microsoft.com/windowsazure", "Vip");
                                                if (vipElement2 != null) {
                                                    InetAddress vipInstance2;
                                                    vipInstance2 = InetAddress
                                                            .getByName(vipElement2.getTextContent());
                                                    inputEndpointInstance.setVirtualIPAddress(vipInstance2);
                                                }

                                                Element enableDirectServerReturnElement = XmlUtility
                                                        .getElementByTagNameNS(inputEndpointsElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "EnableDirectServerReturn");
                                                if (enableDirectServerReturnElement != null
                                                        && enableDirectServerReturnElement
                                                                .getTextContent() != null
                                                        && !enableDirectServerReturnElement.getTextContent()
                                                                .isEmpty()) {
                                                    boolean enableDirectServerReturnInstance;
                                                    enableDirectServerReturnInstance = DatatypeConverter
                                                            .parseBoolean(enableDirectServerReturnElement
                                                                    .getTextContent().toLowerCase());
                                                    inputEndpointInstance.setEnableDirectServerReturn(
                                                            enableDirectServerReturnInstance);
                                                }

                                                Element loadBalancerNameElement = XmlUtility
                                                        .getElementByTagNameNS(inputEndpointsElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "LoadBalancerName");
                                                if (loadBalancerNameElement != null) {
                                                    String loadBalancerNameInstance;
                                                    loadBalancerNameInstance = loadBalancerNameElement
                                                            .getTextContent();
                                                    inputEndpointInstance
                                                            .setLoadBalancerName(loadBalancerNameInstance);
                                                }

                                                Element endpointAclElement = XmlUtility.getElementByTagNameNS(
                                                        inputEndpointsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "EndpointAcl");
                                                if (endpointAclElement != null) {
                                                    EndpointAcl endpointAclInstance = new EndpointAcl();
                                                    inputEndpointInstance.setEndpointAcl(endpointAclInstance);

                                                    Element rulesSequenceElement = XmlUtility
                                                            .getElementByTagNameNS(endpointAclElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Rules");
                                                    if (rulesSequenceElement != null) {
                                                        for (int i17 = 0; i17 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                                .getElementsByTagNameNS(rulesSequenceElement,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "Rule")
                                                                .size(); i17 = i17 + 1) {
                                                            org.w3c.dom.Element rulesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                                    .getElementsByTagNameNS(
                                                                            rulesSequenceElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "Rule")
                                                                    .get(i17));
                                                            AccessControlListRule ruleInstance = new AccessControlListRule();
                                                            endpointAclInstance.getRules().add(ruleInstance);

                                                            Element orderElement = XmlUtility
                                                                    .getElementByTagNameNS(rulesElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "Order");
                                                            if (orderElement != null
                                                                    && orderElement.getTextContent() != null
                                                                    && !orderElement.getTextContent()
                                                                            .isEmpty()) {
                                                                int orderInstance;
                                                                orderInstance = DatatypeConverter.parseInt(
                                                                        orderElement.getTextContent());
                                                                ruleInstance.setOrder(orderInstance);
                                                            }

                                                            Element actionElement = XmlUtility
                                                                    .getElementByTagNameNS(rulesElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "Action");
                                                            if (actionElement != null) {
                                                                String actionInstance;
                                                                actionInstance = actionElement.getTextContent();
                                                                ruleInstance.setAction(actionInstance);
                                                            }

                                                            Element remoteSubnetElement = XmlUtility
                                                                    .getElementByTagNameNS(rulesElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "RemoteSubnet");
                                                            if (remoteSubnetElement != null) {
                                                                String remoteSubnetInstance;
                                                                remoteSubnetInstance = remoteSubnetElement
                                                                        .getTextContent();
                                                                ruleInstance
                                                                        .setRemoteSubnet(remoteSubnetInstance);
                                                            }

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

                                                Element idleTimeoutInMinutesElement3 = XmlUtility
                                                        .getElementByTagNameNS(inputEndpointsElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "IdleTimeoutInMinutes");
                                                if (idleTimeoutInMinutesElement3 != null
                                                        && idleTimeoutInMinutesElement3.getTextContent() != null
                                                        && !idleTimeoutInMinutesElement3.getTextContent()
                                                                .isEmpty()) {
                                                    int idleTimeoutInMinutesInstance3;
                                                    idleTimeoutInMinutesInstance3 = DatatypeConverter.parseInt(
                                                            idleTimeoutInMinutesElement3.getTextContent());
                                                    inputEndpointInstance.setIdleTimeoutInMinutes(
                                                            idleTimeoutInMinutesInstance3);
                                                }

                                                Element loadBalancerDistributionElement = XmlUtility
                                                        .getElementByTagNameNS(inputEndpointsElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "LoadBalancerDistribution");
                                                if (loadBalancerDistributionElement != null) {
                                                    String loadBalancerDistributionInstance;
                                                    loadBalancerDistributionInstance = loadBalancerDistributionElement
                                                            .getTextContent();
                                                    inputEndpointInstance.setLoadBalancerDistribution(
                                                            loadBalancerDistributionInstance);
                                                }

                                                Element virtualIPNameElement = XmlUtility.getElementByTagNameNS(
                                                        inputEndpointsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "VirtualIPName");
                                                if (virtualIPNameElement != null) {
                                                    String virtualIPNameInstance;
                                                    virtualIPNameInstance = virtualIPNameElement
                                                            .getTextContent();
                                                    inputEndpointInstance
                                                            .setVirtualIPName(virtualIPNameInstance);
                                                }
                                            }
                                        }

                                        Element subnetNamesSequenceElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "SubnetNames");
                                        if (subnetNamesSequenceElement != null) {
                                            for (int i18 = 0; i18 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(subnetNamesSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "SubnetName")
                                                    .size(); i18 = i18 + 1) {
                                                org.w3c.dom.Element subnetNamesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(subnetNamesSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "SubnetName")
                                                        .get(i18));
                                                configurationSetInstance.getSubnetNames()
                                                        .add(subnetNamesElement.getTextContent());
                                            }
                                        }

                                        Element staticVirtualNetworkIPAddressElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "StaticVirtualNetworkIPAddress");
                                        if (staticVirtualNetworkIPAddressElement != null) {
                                            String staticVirtualNetworkIPAddressInstance;
                                            staticVirtualNetworkIPAddressInstance = staticVirtualNetworkIPAddressElement
                                                    .getTextContent();
                                            configurationSetInstance.setStaticVirtualNetworkIPAddress(
                                                    staticVirtualNetworkIPAddressInstance);
                                        }

                                        Element publicIPsSequenceElement2 = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "PublicIPs");
                                        if (publicIPsSequenceElement2 != null) {
                                            for (int i19 = 0; i19 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(publicIPsSequenceElement2,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "PublicIP")
                                                    .size(); i19 = i19 + 1) {
                                                org.w3c.dom.Element publicIPsElement2 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(publicIPsSequenceElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "PublicIP")
                                                        .get(i19));
                                                ConfigurationSet.PublicIP publicIPInstance2 = new ConfigurationSet.PublicIP();
                                                configurationSetInstance.getPublicIPs().add(publicIPInstance2);

                                                Element nameElement8 = XmlUtility.getElementByTagNameNS(
                                                        publicIPsElement2,
                                                        "http://schemas.microsoft.com/windowsazure", "Name");
                                                if (nameElement8 != null) {
                                                    String nameInstance8;
                                                    nameInstance8 = nameElement8.getTextContent();
                                                    publicIPInstance2.setName(nameInstance8);
                                                }

                                                Element idleTimeoutInMinutesElement4 = XmlUtility
                                                        .getElementByTagNameNS(publicIPsElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "IdleTimeoutInMinutes");
                                                if (idleTimeoutInMinutesElement4 != null
                                                        && idleTimeoutInMinutesElement4.getTextContent() != null
                                                        && !idleTimeoutInMinutesElement4.getTextContent()
                                                                .isEmpty()) {
                                                    int idleTimeoutInMinutesInstance4;
                                                    idleTimeoutInMinutesInstance4 = DatatypeConverter.parseInt(
                                                            idleTimeoutInMinutesElement4.getTextContent());
                                                    publicIPInstance2.setIdleTimeoutInMinutes(
                                                            idleTimeoutInMinutesInstance4);
                                                }

                                                Element domainNameLabelElement2 = XmlUtility
                                                        .getElementByTagNameNS(publicIPsElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "DomainNameLabel");
                                                if (domainNameLabelElement2 != null) {
                                                    String domainNameLabelInstance2;
                                                    domainNameLabelInstance2 = domainNameLabelElement2
                                                            .getTextContent();
                                                    publicIPInstance2
                                                            .setDomainNameLabel(domainNameLabelInstance2);
                                                }
                                            }
                                        }

                                        Element networkInterfacesSequenceElement2 = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "NetworkInterfaces");
                                        if (networkInterfacesSequenceElement2 != null) {
                                            for (int i20 = 0; i20 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(networkInterfacesSequenceElement2,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "NetworkInterface")
                                                    .size(); i20 = i20 + 1) {
                                                org.w3c.dom.Element networkInterfacesElement2 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(
                                                                networkInterfacesSequenceElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "NetworkInterface")
                                                        .get(i20));
                                                NetworkInterface networkInterfaceInstance2 = new NetworkInterface();
                                                configurationSetInstance.getNetworkInterfaces()
                                                        .add(networkInterfaceInstance2);

                                                Element nameElement9 = XmlUtility.getElementByTagNameNS(
                                                        networkInterfacesElement2,
                                                        "http://schemas.microsoft.com/windowsazure", "Name");
                                                if (nameElement9 != null) {
                                                    String nameInstance9;
                                                    nameInstance9 = nameElement9.getTextContent();
                                                    networkInterfaceInstance2.setName(nameInstance9);
                                                }

                                                Element iPConfigurationsSequenceElement2 = XmlUtility
                                                        .getElementByTagNameNS(networkInterfacesElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "IPConfigurations");
                                                if (iPConfigurationsSequenceElement2 != null) {
                                                    for (int i21 = 0; i21 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(
                                                                    iPConfigurationsSequenceElement2,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "IPConfiguration")
                                                            .size(); i21 = i21 + 1) {
                                                        org.w3c.dom.Element iPConfigurationsElement2 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                                .getElementsByTagNameNS(
                                                                        iPConfigurationsSequenceElement2,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "IPConfiguration")
                                                                .get(i21));
                                                        IPConfiguration iPConfigurationInstance2 = new IPConfiguration();
                                                        networkInterfaceInstance2.getIPConfigurations()
                                                                .add(iPConfigurationInstance2);

                                                        Element subnetNameElement2 = XmlUtility
                                                                .getElementByTagNameNS(iPConfigurationsElement2,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "SubnetName");
                                                        if (subnetNameElement2 != null) {
                                                            String subnetNameInstance2;
                                                            subnetNameInstance2 = subnetNameElement2
                                                                    .getTextContent();
                                                            iPConfigurationInstance2
                                                                    .setSubnetName(subnetNameInstance2);
                                                        }

                                                        Element staticVirtualNetworkIPAddressElement2 = XmlUtility
                                                                .getElementByTagNameNS(iPConfigurationsElement2,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "StaticVirtualNetworkIPAddress");
                                                        if (staticVirtualNetworkIPAddressElement2 != null) {
                                                            String staticVirtualNetworkIPAddressInstance2;
                                                            staticVirtualNetworkIPAddressInstance2 = staticVirtualNetworkIPAddressElement2
                                                                    .getTextContent();
                                                            iPConfigurationInstance2
                                                                    .setStaticVirtualNetworkIPAddress(
                                                                            staticVirtualNetworkIPAddressInstance2);
                                                        }
                                                    }
                                                }

                                                Element networkSecurityGroupElement = XmlUtility
                                                        .getElementByTagNameNS(networkInterfacesElement2,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "NetworkSecurityGroup");
                                                if (networkSecurityGroupElement != null) {
                                                    String networkSecurityGroupInstance;
                                                    networkSecurityGroupInstance = networkSecurityGroupElement
                                                            .getTextContent();
                                                    networkInterfaceInstance2.setNetworkSecurityGroup(
                                                            networkSecurityGroupInstance);
                                                }

                                                Element iPForwardingElement = XmlUtility.getElementByTagNameNS(
                                                        networkInterfacesElement2,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "IPForwarding");
                                                if (iPForwardingElement != null) {
                                                    String iPForwardingInstance;
                                                    iPForwardingInstance = iPForwardingElement.getTextContent();
                                                    networkInterfaceInstance2
                                                            .setIPForwarding(iPForwardingInstance);
                                                }
                                            }
                                        }

                                        Element networkSecurityGroupElement2 = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "NetworkSecurityGroup");
                                        if (networkSecurityGroupElement2 != null) {
                                            String networkSecurityGroupInstance2;
                                            networkSecurityGroupInstance2 = networkSecurityGroupElement2
                                                    .getTextContent();
                                            configurationSetInstance
                                                    .setNetworkSecurityGroup(networkSecurityGroupInstance2);
                                        }

                                        Element iPForwardingElement2 = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "IPForwarding");
                                        if (iPForwardingElement2 != null) {
                                            String iPForwardingInstance2;
                                            iPForwardingInstance2 = iPForwardingElement2.getTextContent();
                                            configurationSetInstance.setIPForwarding(iPForwardingInstance2);
                                        }

                                        Element computerNameElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "ComputerName");
                                        if (computerNameElement != null) {
                                            String computerNameInstance;
                                            computerNameInstance = computerNameElement.getTextContent();
                                            configurationSetInstance.setComputerName(computerNameInstance);
                                        }

                                        Element adminPasswordElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "AdminPassword");
                                        if (adminPasswordElement != null) {
                                            String adminPasswordInstance;
                                            adminPasswordInstance = adminPasswordElement.getTextContent();
                                            configurationSetInstance.setAdminPassword(adminPasswordInstance);
                                        }

                                        Element resetPasswordOnFirstLogonElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "ResetPasswordOnFirstLogon");
                                        if (resetPasswordOnFirstLogonElement != null
                                                && resetPasswordOnFirstLogonElement.getTextContent() != null
                                                && !resetPasswordOnFirstLogonElement.getTextContent()
                                                        .isEmpty()) {
                                            boolean resetPasswordOnFirstLogonInstance;
                                            resetPasswordOnFirstLogonInstance = DatatypeConverter
                                                    .parseBoolean(resetPasswordOnFirstLogonElement
                                                            .getTextContent().toLowerCase());
                                            configurationSetInstance.setResetPasswordOnFirstLogon(
                                                    resetPasswordOnFirstLogonInstance);
                                        }

                                        Element enableAutomaticUpdatesElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "EnableAutomaticUpdates");
                                        if (enableAutomaticUpdatesElement != null
                                                && enableAutomaticUpdatesElement.getTextContent() != null
                                                && !enableAutomaticUpdatesElement.getTextContent().isEmpty()) {
                                            boolean enableAutomaticUpdatesInstance;
                                            enableAutomaticUpdatesInstance = DatatypeConverter
                                                    .parseBoolean(enableAutomaticUpdatesElement.getTextContent()
                                                            .toLowerCase());
                                            configurationSetInstance
                                                    .setEnableAutomaticUpdates(enableAutomaticUpdatesInstance);
                                        }

                                        Element timeZoneElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "TimeZone");
                                        if (timeZoneElement != null) {
                                            String timeZoneInstance;
                                            timeZoneInstance = timeZoneElement.getTextContent();
                                            configurationSetInstance.setTimeZone(timeZoneInstance);
                                        }

                                        Element domainJoinElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "DomainJoin");
                                        if (domainJoinElement != null) {
                                            DomainJoinSettings domainJoinInstance = new DomainJoinSettings();
                                            configurationSetInstance.setDomainJoin(domainJoinInstance);

                                            Element credentialsElement = XmlUtility.getElementByTagNameNS(
                                                    domainJoinElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Credentials");
                                            if (credentialsElement != null) {
                                                DomainJoinCredentials credentialsInstance = new DomainJoinCredentials();
                                                domainJoinInstance.setCredentials(credentialsInstance);

                                                Element domainElement = XmlUtility.getElementByTagNameNS(
                                                        credentialsElement,
                                                        "http://schemas.microsoft.com/windowsazure", "Domain");
                                                if (domainElement != null) {
                                                    String domainInstance;
                                                    domainInstance = domainElement.getTextContent();
                                                    credentialsInstance.setDomain(domainInstance);
                                                }

                                                Element usernameElement = XmlUtility.getElementByTagNameNS(
                                                        credentialsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "Username");
                                                if (usernameElement != null) {
                                                    String usernameInstance;
                                                    usernameInstance = usernameElement.getTextContent();
                                                    credentialsInstance.setUserName(usernameInstance);
                                                }

                                                Element passwordElement = XmlUtility.getElementByTagNameNS(
                                                        credentialsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "Password");
                                                if (passwordElement != null) {
                                                    String passwordInstance;
                                                    passwordInstance = passwordElement.getTextContent();
                                                    credentialsInstance.setPassword(passwordInstance);
                                                }
                                            }

                                            Element joinDomainElement = XmlUtility.getElementByTagNameNS(
                                                    domainJoinElement,
                                                    "http://schemas.microsoft.com/windowsazure", "JoinDomain");
                                            if (joinDomainElement != null) {
                                                String joinDomainInstance;
                                                joinDomainInstance = joinDomainElement.getTextContent();
                                                domainJoinInstance.setDomainToJoin(joinDomainInstance);
                                            }

                                            Element machineObjectOUElement = XmlUtility.getElementByTagNameNS(
                                                    domainJoinElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "MachineObjectOU");
                                            if (machineObjectOUElement != null) {
                                                String machineObjectOUInstance;
                                                machineObjectOUInstance = machineObjectOUElement
                                                        .getTextContent();
                                                domainJoinInstance
                                                        .setLdapMachineObjectOU(machineObjectOUInstance);
                                            }

                                            Element provisioningElement = XmlUtility.getElementByTagNameNS(
                                                    domainJoinElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "Provisioning");
                                            if (provisioningElement != null) {
                                                DomainJoinProvisioning provisioningInstance = new DomainJoinProvisioning();
                                                domainJoinInstance.setProvisioning(provisioningInstance);

                                                Element accountDataElement = XmlUtility.getElementByTagNameNS(
                                                        provisioningElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "AccountData");
                                                if (accountDataElement != null) {
                                                    String accountDataInstance;
                                                    accountDataInstance = accountDataElement.getTextContent();
                                                    provisioningInstance.setAccountData(accountDataInstance);
                                                }
                                            }
                                        }

                                        Element storedCertificateSettingsSequenceElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "StoredCertificateSettings");
                                        if (storedCertificateSettingsSequenceElement != null) {
                                            for (int i22 = 0; i22 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(
                                                            storedCertificateSettingsSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "CertificateSetting")
                                                    .size(); i22 = i22 + 1) {
                                                org.w3c.dom.Element storedCertificateSettingsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(
                                                                storedCertificateSettingsSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "CertificateSetting")
                                                        .get(i22));
                                                StoredCertificateSettings certificateSettingInstance = new StoredCertificateSettings();
                                                configurationSetInstance.getStoredCertificateSettings()
                                                        .add(certificateSettingInstance);

                                                Element storeLocationElement = XmlUtility.getElementByTagNameNS(
                                                        storedCertificateSettingsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "StoreLocation");
                                                if (storeLocationElement != null) {
                                                }

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

                                                Element thumbprintElement = XmlUtility.getElementByTagNameNS(
                                                        storedCertificateSettingsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "Thumbprint");
                                                if (thumbprintElement != null) {
                                                    String thumbprintInstance;
                                                    thumbprintInstance = thumbprintElement.getTextContent();
                                                    certificateSettingInstance
                                                            .setThumbprint(thumbprintInstance);
                                                }
                                            }
                                        }

                                        Element winRMElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "WinRM");
                                        if (winRMElement != null) {
                                            WindowsRemoteManagementSettings winRMInstance = new WindowsRemoteManagementSettings();
                                            configurationSetInstance.setWindowsRemoteManagement(winRMInstance);

                                            Element listenersSequenceElement = XmlUtility.getElementByTagNameNS(
                                                    winRMElement, "http://schemas.microsoft.com/windowsazure",
                                                    "Listeners");
                                            if (listenersSequenceElement != null) {
                                                for (int i23 = 0; i23 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(listenersSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "Listener")
                                                        .size(); i23 = i23 + 1) {
                                                    org.w3c.dom.Element listenersElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(listenersSequenceElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Listener")
                                                            .get(i23));
                                                    WindowsRemoteManagementListener listenerInstance = new WindowsRemoteManagementListener();
                                                    winRMInstance.getListeners().add(listenerInstance);

                                                    Element protocolElement4 = XmlUtility.getElementByTagNameNS(
                                                            listenersElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Protocol");
                                                    if (protocolElement4 != null
                                                            && protocolElement4.getTextContent() != null
                                                            && !protocolElement4.getTextContent().isEmpty()) {
                                                        VirtualMachineWindowsRemoteManagementListenerType protocolInstance4;
                                                        protocolInstance4 = VirtualMachineWindowsRemoteManagementListenerType
                                                                .valueOf(protocolElement4.getTextContent());
                                                        listenerInstance.setListenerType(protocolInstance4);
                                                    }

                                                    Element certificateThumbprintElement = XmlUtility
                                                            .getElementByTagNameNS(listenersElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "CertificateThumbprint");
                                                    if (certificateThumbprintElement != null) {
                                                        String certificateThumbprintInstance;
                                                        certificateThumbprintInstance = certificateThumbprintElement
                                                                .getTextContent();
                                                        listenerInstance.setCertificateThumbprint(
                                                                certificateThumbprintInstance);
                                                    }
                                                }
                                            }
                                        }

                                        Element adminUsernameElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "AdminUsername");
                                        if (adminUsernameElement != null) {
                                            String adminUsernameInstance;
                                            adminUsernameInstance = adminUsernameElement.getTextContent();
                                            configurationSetInstance.setAdminUserName(adminUsernameInstance);
                                        }

                                        Element additionalUnattendContentElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "AdditionalUnattendContent");
                                        if (additionalUnattendContentElement != null) {
                                            AdditionalUnattendContentSettings additionalUnattendContentInstance = new AdditionalUnattendContentSettings();
                                            configurationSetInstance.setAdditionalUnattendContent(
                                                    additionalUnattendContentInstance);

                                            Element passesSequenceElement = XmlUtility.getElementByTagNameNS(
                                                    additionalUnattendContentElement,
                                                    "http://schemas.microsoft.com/windowsazure", "Passes");
                                            if (passesSequenceElement != null) {
                                                for (int i24 = 0; i24 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(passesSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "UnattendPass")
                                                        .size(); i24 = i24 + 1) {
                                                    org.w3c.dom.Element passesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(passesSequenceElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "UnattendPass")
                                                            .get(i24));
                                                    UnattendPassSettings unattendPassInstance = new UnattendPassSettings();
                                                    additionalUnattendContentInstance.getUnattendPasses()
                                                            .add(unattendPassInstance);

                                                    Element passNameElement = XmlUtility.getElementByTagNameNS(
                                                            passesElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "PassName");
                                                    if (passNameElement != null) {
                                                        String passNameInstance;
                                                        passNameInstance = passNameElement.getTextContent();
                                                        unattendPassInstance.setPassName(passNameInstance);
                                                    }

                                                    Element componentsSequenceElement = XmlUtility
                                                            .getElementByTagNameNS(passesElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Components");
                                                    if (componentsSequenceElement != null) {
                                                        for (int i25 = 0; i25 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                                .getElementsByTagNameNS(
                                                                        componentsSequenceElement,
                                                                        "http://schemas.microsoft.com/windowsazure",
                                                                        "UnattendComponent")
                                                                .size(); i25 = i25 + 1) {
                                                            org.w3c.dom.Element componentsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                                    .getElementsByTagNameNS(
                                                                            componentsSequenceElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "UnattendComponent")
                                                                    .get(i25));
                                                            UnattendComponent unattendComponentInstance = new UnattendComponent();
                                                            unattendPassInstance.getUnattendComponents()
                                                                    .add(unattendComponentInstance);

                                                            Element componentNameElement = XmlUtility
                                                                    .getElementByTagNameNS(componentsElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "ComponentName");
                                                            if (componentNameElement != null) {
                                                                String componentNameInstance;
                                                                componentNameInstance = componentNameElement
                                                                        .getTextContent();
                                                                unattendComponentInstance.setComponentName(
                                                                        componentNameInstance);
                                                            }

                                                            Element componentSettingsSequenceElement = XmlUtility
                                                                    .getElementByTagNameNS(componentsElement,
                                                                            "http://schemas.microsoft.com/windowsazure",
                                                                            "ComponentSettings");
                                                            if (componentSettingsSequenceElement != null) {
                                                                for (int i26 = 0; i26 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                                        .getElementsByTagNameNS(
                                                                                componentSettingsSequenceElement,
                                                                                "http://schemas.microsoft.com/windowsazure",
                                                                                "ComponentSetting")
                                                                        .size(); i26 = i26 + 1) {
                                                                    org.w3c.dom.Element componentSettingsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                                            .getElementsByTagNameNS(
                                                                                    componentSettingsSequenceElement,
                                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                                    "ComponentSetting")
                                                                            .get(i26));
                                                                    ComponentSetting componentSettingInstance = new ComponentSetting();
                                                                    unattendComponentInstance
                                                                            .getUnattendComponentSettings()
                                                                            .add(componentSettingInstance);

                                                                    Element settingNameElement = XmlUtility
                                                                            .getElementByTagNameNS(
                                                                                    componentSettingsElement,
                                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                                    "SettingName");
                                                                    if (settingNameElement != null) {
                                                                        String settingNameInstance;
                                                                        settingNameInstance = settingNameElement
                                                                                .getTextContent();
                                                                        componentSettingInstance.setSettingName(
                                                                                settingNameInstance);
                                                                    }

                                                                    Element contentElement = XmlUtility
                                                                            .getElementByTagNameNS(
                                                                                    componentSettingsElement,
                                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                                    "Content");
                                                                    if (contentElement != null) {
                                                                        String contentInstance;
                                                                        contentInstance = contentElement
                                                                                .getTextContent() != null
                                                                                        ? new String(Base64
                                                                                                .decode(contentElement
                                                                                                        .getTextContent()))
                                                                                        : null;
                                                                        componentSettingInstance
                                                                                .setContent(contentInstance);
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        Element hostNameElement2 = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "HostName");
                                        if (hostNameElement2 != null) {
                                            String hostNameInstance2;
                                            hostNameInstance2 = hostNameElement2.getTextContent();
                                            configurationSetInstance.setHostName(hostNameInstance2);
                                        }

                                        Element userNameElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "UserName");
                                        if (userNameElement != null) {
                                            String userNameInstance;
                                            userNameInstance = userNameElement.getTextContent();
                                            configurationSetInstance.setUserName(userNameInstance);
                                        }

                                        Element userPasswordElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "UserPassword");
                                        if (userPasswordElement != null) {
                                            String userPasswordInstance;
                                            userPasswordInstance = userPasswordElement.getTextContent();
                                            configurationSetInstance.setUserPassword(userPasswordInstance);
                                        }

                                        Element disableSshPasswordAuthenticationElement = XmlUtility
                                                .getElementByTagNameNS(configurationSetsElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "DisableSshPasswordAuthentication");
                                        if (disableSshPasswordAuthenticationElement != null
                                                && disableSshPasswordAuthenticationElement
                                                        .getTextContent() != null
                                                && !disableSshPasswordAuthenticationElement.getTextContent()
                                                        .isEmpty()) {
                                            boolean disableSshPasswordAuthenticationInstance;
                                            disableSshPasswordAuthenticationInstance = DatatypeConverter
                                                    .parseBoolean(disableSshPasswordAuthenticationElement
                                                            .getTextContent().toLowerCase());
                                            configurationSetInstance.setDisableSshPasswordAuthentication(
                                                    disableSshPasswordAuthenticationInstance);
                                        }

                                        Element sSHElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "SSH");
                                        if (sSHElement != null) {
                                            SshSettings sSHInstance = new SshSettings();
                                            configurationSetInstance.setSshSettings(sSHInstance);

                                            Element publicKeysSequenceElement = XmlUtility
                                                    .getElementByTagNameNS(sSHElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "PublicKeys");
                                            if (publicKeysSequenceElement != null) {
                                                for (int i27 = 0; i27 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(publicKeysSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "PublicKey")
                                                        .size(); i27 = i27 + 1) {
                                                    org.w3c.dom.Element publicKeysElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(publicKeysSequenceElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "PublicKey")
                                                            .get(i27));
                                                    SshSettingPublicKey publicKeyInstance = new SshSettingPublicKey();
                                                    sSHInstance.getPublicKeys().add(publicKeyInstance);

                                                    Element fingerprintElement = XmlUtility
                                                            .getElementByTagNameNS(publicKeysElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Fingerprint");
                                                    if (fingerprintElement != null) {
                                                        String fingerprintInstance;
                                                        fingerprintInstance = fingerprintElement
                                                                .getTextContent();
                                                        publicKeyInstance.setFingerprint(fingerprintInstance);
                                                    }

                                                    Element pathElement2 = XmlUtility.getElementByTagNameNS(
                                                            publicKeysElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Path");
                                                    if (pathElement2 != null) {
                                                        String pathInstance2;
                                                        pathInstance2 = pathElement2.getTextContent();
                                                        publicKeyInstance.setPath(pathInstance2);
                                                    }
                                                }
                                            }

                                            Element keyPairsSequenceElement = XmlUtility.getElementByTagNameNS(
                                                    sSHElement, "http://schemas.microsoft.com/windowsazure",
                                                    "KeyPairs");
                                            if (keyPairsSequenceElement != null) {
                                                for (int i28 = 0; i28 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(keyPairsSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "KeyPair")
                                                        .size(); i28 = i28 + 1) {
                                                    org.w3c.dom.Element keyPairsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                            .getElementsByTagNameNS(keyPairsSequenceElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "KeyPair")
                                                            .get(i28));
                                                    SshSettingKeyPair keyPairInstance = new SshSettingKeyPair();
                                                    sSHInstance.getKeyPairs().add(keyPairInstance);

                                                    Element fingerprintElement2 = XmlUtility
                                                            .getElementByTagNameNS(keyPairsElement,
                                                                    "http://schemas.microsoft.com/windowsazure",
                                                                    "Fingerprint");
                                                    if (fingerprintElement2 != null) {
                                                        String fingerprintInstance2;
                                                        fingerprintInstance2 = fingerprintElement2
                                                                .getTextContent();
                                                        keyPairInstance.setFingerprint(fingerprintInstance2);
                                                    }

                                                    Element pathElement3 = XmlUtility.getElementByTagNameNS(
                                                            keyPairsElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "Path");
                                                    if (pathElement3 != null) {
                                                        String pathInstance3;
                                                        pathInstance3 = pathElement3.getTextContent();
                                                        keyPairInstance.setPath(pathInstance3);
                                                    }
                                                }
                                            }
                                        }

                                        Element customDataElement = XmlUtility.getElementByTagNameNS(
                                                configurationSetsElement,
                                                "http://schemas.microsoft.com/windowsazure", "CustomData");
                                        if (customDataElement != null) {
                                            String customDataInstance;
                                            customDataInstance = customDataElement.getTextContent();
                                            configurationSetInstance.setCustomData(customDataInstance);
                                        }
                                    }
                                }

                                Element resourceExtensionReferencesSequenceElement = XmlUtility
                                        .getElementByTagNameNS(roleListElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "ResourceExtensionReferences");
                                if (resourceExtensionReferencesSequenceElement != null) {
                                    for (int i29 = 0; i29 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(resourceExtensionReferencesSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "ResourceExtensionReference")
                                            .size(); i29 = i29 + 1) {
                                        org.w3c.dom.Element resourceExtensionReferencesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(
                                                        resourceExtensionReferencesSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "ResourceExtensionReference")
                                                .get(i29));
                                        ResourceExtensionReference resourceExtensionReferenceInstance = new ResourceExtensionReference();
                                        roleInstance.getResourceExtensionReferences()
                                                .add(resourceExtensionReferenceInstance);

                                        Element referenceNameElement = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionReferencesElement,
                                                "http://schemas.microsoft.com/windowsazure", "ReferenceName");
                                        if (referenceNameElement != null) {
                                            String referenceNameInstance;
                                            referenceNameInstance = referenceNameElement.getTextContent();
                                            resourceExtensionReferenceInstance
                                                    .setReferenceName(referenceNameInstance);
                                        }

                                        Element publisherElement = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionReferencesElement,
                                                "http://schemas.microsoft.com/windowsazure", "Publisher");
                                        if (publisherElement != null) {
                                            String publisherInstance;
                                            publisherInstance = publisherElement.getTextContent();
                                            resourceExtensionReferenceInstance.setPublisher(publisherInstance);
                                        }

                                        Element nameElement10 = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionReferencesElement,
                                                "http://schemas.microsoft.com/windowsazure", "Name");
                                        if (nameElement10 != null) {
                                            String nameInstance10;
                                            nameInstance10 = nameElement10.getTextContent();
                                            resourceExtensionReferenceInstance.setName(nameInstance10);
                                        }

                                        Element versionElement2 = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionReferencesElement,
                                                "http://schemas.microsoft.com/windowsazure", "Version");
                                        if (versionElement2 != null) {
                                            String versionInstance2;
                                            versionInstance2 = versionElement2.getTextContent();
                                            resourceExtensionReferenceInstance.setVersion(versionInstance2);
                                        }

                                        Element resourceExtensionParameterValuesSequenceElement = XmlUtility
                                                .getElementByTagNameNS(resourceExtensionReferencesElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "ResourceExtensionParameterValues");
                                        if (resourceExtensionParameterValuesSequenceElement != null) {
                                            for (int i30 = 0; i30 < com.microsoft.windowsazure.core.utils.XmlUtility
                                                    .getElementsByTagNameNS(
                                                            resourceExtensionParameterValuesSequenceElement,
                                                            "http://schemas.microsoft.com/windowsazure",
                                                            "ResourceExtensionParameterValue")
                                                    .size(); i30 = i30 + 1) {
                                                org.w3c.dom.Element resourceExtensionParameterValuesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                        .getElementsByTagNameNS(
                                                                resourceExtensionParameterValuesSequenceElement,
                                                                "http://schemas.microsoft.com/windowsazure",
                                                                "ResourceExtensionParameterValue")
                                                        .get(i30));
                                                ResourceExtensionParameterValue resourceExtensionParameterValueInstance = new ResourceExtensionParameterValue();
                                                resourceExtensionReferenceInstance
                                                        .getResourceExtensionParameterValues()
                                                        .add(resourceExtensionParameterValueInstance);

                                                Element keyElement = XmlUtility.getElementByTagNameNS(
                                                        resourceExtensionParameterValuesElement,
                                                        "http://schemas.microsoft.com/windowsazure", "Key");
                                                if (keyElement != null) {
                                                    String keyInstance;
                                                    keyInstance = keyElement.getTextContent();
                                                    resourceExtensionParameterValueInstance.setKey(keyInstance);
                                                }

                                                Element valueElement = XmlUtility.getElementByTagNameNS(
                                                        resourceExtensionParameterValuesElement,
                                                        "http://schemas.microsoft.com/windowsazure", "Value");
                                                if (valueElement != null) {
                                                    String valueInstance;
                                                    valueInstance = valueElement.getTextContent() != null
                                                            ? new String(Base64
                                                                    .decode(valueElement.getTextContent()))
                                                            : null;
                                                    resourceExtensionParameterValueInstance
                                                            .setValue(valueInstance);
                                                }

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

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

                                        Element forceUpdateElement = XmlUtility.getElementByTagNameNS(
                                                resourceExtensionReferencesElement,
                                                "http://schemas.microsoft.com/windowsazure", "ForceUpdate");
                                        if (forceUpdateElement != null
                                                && forceUpdateElement.getTextContent() != null
                                                && !forceUpdateElement.getTextContent().isEmpty()) {
                                            boolean forceUpdateInstance;
                                            forceUpdateInstance = DatatypeConverter.parseBoolean(
                                                    forceUpdateElement.getTextContent().toLowerCase());
                                            resourceExtensionReferenceInstance
                                                    .setForceUpdate(forceUpdateInstance);
                                        }
                                    }
                                }

                                Element vMImageNameElement = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "VMImageName");
                                if (vMImageNameElement != null) {
                                    String vMImageNameInstance;
                                    vMImageNameInstance = vMImageNameElement.getTextContent();
                                    roleInstance.setVMImageName(vMImageNameInstance);
                                }

                                Element mediaLocationElement = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "MediaLocation");
                                if (mediaLocationElement != null) {
                                    URI mediaLocationInstance;
                                    mediaLocationInstance = new URI(mediaLocationElement.getTextContent());
                                    roleInstance.setMediaLocation(mediaLocationInstance);
                                }

                                Element availabilitySetNameElement = XmlUtility.getElementByTagNameNS(
                                        roleListElement, "http://schemas.microsoft.com/windowsazure",
                                        "AvailabilitySetName");
                                if (availabilitySetNameElement != null) {
                                    String availabilitySetNameInstance;
                                    availabilitySetNameInstance = availabilitySetNameElement.getTextContent();
                                    roleInstance.setAvailabilitySetName(availabilitySetNameInstance);
                                }

                                Element dataVirtualHardDisksSequenceElement = XmlUtility.getElementByTagNameNS(
                                        roleListElement, "http://schemas.microsoft.com/windowsazure",
                                        "DataVirtualHardDisks");
                                if (dataVirtualHardDisksSequenceElement != null) {
                                    for (int i31 = 0; i31 < com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(dataVirtualHardDisksSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "DataVirtualHardDisk")
                                            .size(); i31 = i31 + 1) {
                                        org.w3c.dom.Element dataVirtualHardDisksElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                                .getElementsByTagNameNS(dataVirtualHardDisksSequenceElement,
                                                        "http://schemas.microsoft.com/windowsazure",
                                                        "DataVirtualHardDisk")
                                                .get(i31));
                                        DataVirtualHardDisk dataVirtualHardDiskInstance = new DataVirtualHardDisk();
                                        roleInstance.getDataVirtualHardDisks().add(dataVirtualHardDiskInstance);

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

                                        Element diskLabelElement = XmlUtility.getElementByTagNameNS(
                                                dataVirtualHardDisksElement,
                                                "http://schemas.microsoft.com/windowsazure", "DiskLabel");
                                        if (diskLabelElement != null) {
                                            String diskLabelInstance;
                                            diskLabelInstance = diskLabelElement.getTextContent();
                                            dataVirtualHardDiskInstance.setLabel(diskLabelInstance);
                                        }

                                        Element diskNameElement = XmlUtility.getElementByTagNameNS(
                                                dataVirtualHardDisksElement,
                                                "http://schemas.microsoft.com/windowsazure", "DiskName");
                                        if (diskNameElement != null) {
                                            String diskNameInstance;
                                            diskNameInstance = diskNameElement.getTextContent();
                                            dataVirtualHardDiskInstance.setName(diskNameInstance);
                                        }

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

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

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

                                        Element sourceMediaLinkElement = XmlUtility.getElementByTagNameNS(
                                                dataVirtualHardDisksElement,
                                                "http://schemas.microsoft.com/windowsazure", "SourceMediaLink");
                                        if (sourceMediaLinkElement != null) {
                                            URI sourceMediaLinkInstance;
                                            sourceMediaLinkInstance = new URI(
                                                    sourceMediaLinkElement.getTextContent());
                                            dataVirtualHardDiskInstance
                                                    .setSourceMediaLink(sourceMediaLinkInstance);
                                        }

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

                                Element labelElement2 = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "Label");
                                if (labelElement2 != null) {
                                    String labelInstance2;
                                    labelInstance2 = labelElement2.getTextContent();
                                    roleInstance.setLabel(labelInstance2);
                                }

                                Element oSVirtualHardDiskElement = XmlUtility.getElementByTagNameNS(
                                        roleListElement, "http://schemas.microsoft.com/windowsazure",
                                        "OSVirtualHardDisk");
                                if (oSVirtualHardDiskElement != null) {
                                    OSVirtualHardDisk oSVirtualHardDiskInstance = new OSVirtualHardDisk();
                                    roleInstance.setOSVirtualHardDisk(oSVirtualHardDiskInstance);

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

                                    Element diskLabelElement2 = XmlUtility.getElementByTagNameNS(
                                            oSVirtualHardDiskElement,
                                            "http://schemas.microsoft.com/windowsazure", "DiskLabel");
                                    if (diskLabelElement2 != null) {
                                        String diskLabelInstance2;
                                        diskLabelInstance2 = diskLabelElement2.getTextContent();
                                        oSVirtualHardDiskInstance.setLabel(diskLabelInstance2);
                                    }

                                    Element diskNameElement2 = XmlUtility.getElementByTagNameNS(
                                            oSVirtualHardDiskElement,
                                            "http://schemas.microsoft.com/windowsazure", "DiskName");
                                    if (diskNameElement2 != null) {
                                        String diskNameInstance2;
                                        diskNameInstance2 = diskNameElement2.getTextContent();
                                        oSVirtualHardDiskInstance.setName(diskNameInstance2);
                                    }

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

                                    Element sourceImageNameElement = XmlUtility.getElementByTagNameNS(
                                            oSVirtualHardDiskElement,
                                            "http://schemas.microsoft.com/windowsazure", "SourceImageName");
                                    if (sourceImageNameElement != null) {
                                        String sourceImageNameInstance;
                                        sourceImageNameInstance = sourceImageNameElement.getTextContent();
                                        oSVirtualHardDiskInstance.setSourceImageName(sourceImageNameInstance);
                                    }

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

                                    Element remoteSourceImageLinkElement = XmlUtility.getElementByTagNameNS(
                                            oSVirtualHardDiskElement,
                                            "http://schemas.microsoft.com/windowsazure",
                                            "RemoteSourceImageLink");
                                    if (remoteSourceImageLinkElement != null) {
                                        URI remoteSourceImageLinkInstance;
                                        remoteSourceImageLinkInstance = new URI(
                                                remoteSourceImageLinkElement.getTextContent());
                                        oSVirtualHardDiskInstance
                                                .setRemoteSourceImageLink(remoteSourceImageLinkInstance);
                                    }

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

                                    Element resizedSizeInGBElement = XmlUtility.getElementByTagNameNS(
                                            oSVirtualHardDiskElement,
                                            "http://schemas.microsoft.com/windowsazure", "ResizedSizeInGB");
                                    if (resizedSizeInGBElement != null
                                            && resizedSizeInGBElement.getTextContent() != null
                                            && !resizedSizeInGBElement.getTextContent().isEmpty()) {
                                        int resizedSizeInGBInstance;
                                        resizedSizeInGBInstance = DatatypeConverter
                                                .parseInt(resizedSizeInGBElement.getTextContent());
                                        oSVirtualHardDiskInstance.setResizedSizeInGB(resizedSizeInGBInstance);
                                    }
                                }

                                Element roleSizeElement = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "RoleSize");
                                if (roleSizeElement != null) {
                                    String roleSizeInstance;
                                    roleSizeInstance = roleSizeElement.getTextContent();
                                    roleInstance.setRoleSize(roleSizeInstance);
                                }

                                Element defaultWinRmCertificateThumbprintElement = XmlUtility
                                        .getElementByTagNameNS(roleListElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "DefaultWinRmCertificateThumbprint");
                                if (defaultWinRmCertificateThumbprintElement != null) {
                                    String defaultWinRmCertificateThumbprintInstance;
                                    defaultWinRmCertificateThumbprintInstance = defaultWinRmCertificateThumbprintElement
                                            .getTextContent();
                                    roleInstance.setDefaultWinRmCertificateThumbprint(
                                            defaultWinRmCertificateThumbprintInstance);
                                }

                                Element provisionGuestAgentElement = XmlUtility.getElementByTagNameNS(
                                        roleListElement, "http://schemas.microsoft.com/windowsazure",
                                        "ProvisionGuestAgent");
                                if (provisionGuestAgentElement != null
                                        && provisionGuestAgentElement.getTextContent() != null
                                        && !provisionGuestAgentElement.getTextContent().isEmpty()) {
                                    boolean provisionGuestAgentInstance;
                                    provisionGuestAgentInstance = DatatypeConverter.parseBoolean(
                                            provisionGuestAgentElement.getTextContent().toLowerCase());
                                    roleInstance.setProvisionGuestAgent(provisionGuestAgentInstance);
                                }

                                Element vMImageInputElement = XmlUtility.getElementByTagNameNS(roleListElement,
                                        "http://schemas.microsoft.com/windowsazure", "VMImageInput");
                                if (vMImageInputElement != null) {
                                    VMImageInput vMImageInputInstance = new VMImageInput();
                                    roleInstance.setVMImageInput(vMImageInputInstance);

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

                                        Element resizedSizeInGBElement2 = XmlUtility.getElementByTagNameNS(
                                                oSDiskConfigurationElement,
                                                "http://schemas.microsoft.com/windowsazure", "ResizedSizeInGB");
                                        if (resizedSizeInGBElement2 != null
                                                && resizedSizeInGBElement2.getTextContent() != null
                                                && !resizedSizeInGBElement2.getTextContent().isEmpty()) {
                                            int resizedSizeInGBInstance2;
                                            resizedSizeInGBInstance2 = DatatypeConverter
                                                    .parseInt(resizedSizeInGBElement2.getTextContent());
                                            oSDiskConfigurationInstance
                                                    .setResizedSizeInGB(resizedSizeInGBInstance2);
                                        }
                                    }

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

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

                                            Element resizedSizeInGBElement3 = XmlUtility.getElementByTagNameNS(
                                                    dataDiskConfigurationsElement,
                                                    "http://schemas.microsoft.com/windowsazure",
                                                    "ResizedSizeInGB");
                                            if (resizedSizeInGBElement3 != null
                                                    && resizedSizeInGBElement3.getTextContent() != null
                                                    && !resizedSizeInGBElement3.getTextContent().isEmpty()) {
                                                int resizedSizeInGBInstance3;
                                                resizedSizeInGBInstance3 = DatatypeConverter
                                                        .parseInt(resizedSizeInGBElement3.getTextContent());
                                                dataDiskConfigurationInstance
                                                        .setResizedSizeInGB(resizedSizeInGBInstance3);
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        Element sdkVersionElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "SdkVersion");
                        if (sdkVersionElement != null) {
                            String sdkVersionInstance;
                            sdkVersionInstance = sdkVersionElement.getTextContent();
                            deploymentInstance.setSdkVersion(sdkVersionInstance);
                        }

                        Element lockedElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "Locked");
                        if (lockedElement != null) {
                            boolean lockedInstance;
                            lockedInstance = DatatypeConverter
                                    .parseBoolean(lockedElement.getTextContent().toLowerCase());
                            deploymentInstance.setLocked(lockedInstance);
                        }

                        Element rollbackAllowedElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "RollbackAllowed");
                        if (rollbackAllowedElement != null) {
                            boolean rollbackAllowedInstance;
                            rollbackAllowedInstance = DatatypeConverter
                                    .parseBoolean(rollbackAllowedElement.getTextContent().toLowerCase());
                            deploymentInstance.setRollbackAllowed(rollbackAllowedInstance);
                        }

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

                        Element lastModifiedTimeElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "LastModifiedTime");
                        if (lastModifiedTimeElement != null) {
                            String lastModifiedTimeInstance;
                            lastModifiedTimeInstance = lastModifiedTimeElement.getTextContent();
                            deploymentInstance.setLastModifiedTime(lastModifiedTimeInstance);
                        }

                        Element virtualNetworkNameElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "VirtualNetworkName");
                        if (virtualNetworkNameElement != null) {
                            String virtualNetworkNameInstance;
                            virtualNetworkNameInstance = virtualNetworkNameElement.getTextContent();
                            deploymentInstance.setVirtualNetworkName(virtualNetworkNameInstance);
                        }

                        Element extendedPropertiesSequenceElement = XmlUtility.getElementByTagNameNS(
                                deploymentsElement, "http://schemas.microsoft.com/windowsazure",
                                "ExtendedProperties");
                        if (extendedPropertiesSequenceElement != null) {
                            for (int i33 = 0; i33 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(extendedPropertiesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "ExtendedProperty")
                                    .size(); i33 = i33 + 1) {
                                org.w3c.dom.Element extendedPropertiesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(extendedPropertiesSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "ExtendedProperty")
                                        .get(i33));
                                String extendedPropertiesKey = XmlUtility
                                        .getElementByTagNameNS(extendedPropertiesElement,
                                                "http://schemas.microsoft.com/windowsazure", "Name")
                                        .getTextContent();
                                String extendedPropertiesValue = XmlUtility
                                        .getElementByTagNameNS(extendedPropertiesElement,
                                                "http://schemas.microsoft.com/windowsazure", "Value")
                                        .getTextContent();
                                deploymentInstance.getExtendedProperties().put(extendedPropertiesKey,
                                        extendedPropertiesValue);
                            }
                        }

                        Element persistentVMDowntimeElement = XmlUtility.getElementByTagNameNS(
                                deploymentsElement, "http://schemas.microsoft.com/windowsazure",
                                "PersistentVMDowntime");
                        if (persistentVMDowntimeElement != null) {
                            PersistentVMDowntime persistentVMDowntimeInstance = new PersistentVMDowntime();
                            deploymentInstance.setPersistentVMDowntime(persistentVMDowntimeInstance);

                            Element startTimeElement = XmlUtility.getElementByTagNameNS(
                                    persistentVMDowntimeElement, "http://schemas.microsoft.com/windowsazure",
                                    "StartTime");
                            if (startTimeElement != null) {
                                Calendar startTimeInstance;
                                startTimeInstance = DatatypeConverter
                                        .parseDateTime(startTimeElement.getTextContent());
                                persistentVMDowntimeInstance.setStartTime(startTimeInstance);
                            }

                            Element endTimeElement = XmlUtility.getElementByTagNameNS(
                                    persistentVMDowntimeElement, "http://schemas.microsoft.com/windowsazure",
                                    "EndTime");
                            if (endTimeElement != null) {
                                Calendar endTimeInstance;
                                endTimeInstance = DatatypeConverter
                                        .parseDateTime(endTimeElement.getTextContent());
                                persistentVMDowntimeInstance.setEndTime(endTimeInstance);
                            }

                            Element statusElement6 = XmlUtility.getElementByTagNameNS(
                                    persistentVMDowntimeElement, "http://schemas.microsoft.com/windowsazure",
                                    "Status");
                            if (statusElement6 != null) {
                                String statusInstance6;
                                statusInstance6 = statusElement6.getTextContent();
                                persistentVMDowntimeInstance.setStatus(statusInstance6);
                            }
                        }

                        Element virtualIPsSequenceElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "VirtualIPs");
                        if (virtualIPsSequenceElement != null) {
                            for (int i34 = 0; i34 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(virtualIPsSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "VirtualIP")
                                    .size(); i34 = i34 + 1) {
                                org.w3c.dom.Element virtualIPsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(virtualIPsSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "VirtualIP")
                                        .get(i34));
                                VirtualIPAddress virtualIPInstance = new VirtualIPAddress();
                                deploymentInstance.getVirtualIPAddresses().add(virtualIPInstance);

                                Element addressElement3 = XmlUtility.getElementByTagNameNS(virtualIPsElement,
                                        "http://schemas.microsoft.com/windowsazure", "Address");
                                if (addressElement3 != null) {
                                    InetAddress addressInstance3;
                                    addressInstance3 = InetAddress.getByName(addressElement3.getTextContent());
                                    virtualIPInstance.setAddress(addressInstance3);
                                }

                                Element isDnsProgrammedElement = XmlUtility.getElementByTagNameNS(
                                        virtualIPsElement, "http://schemas.microsoft.com/windowsazure",
                                        "IsDnsProgrammed");
                                if (isDnsProgrammedElement != null
                                        && isDnsProgrammedElement.getTextContent() != null
                                        && !isDnsProgrammedElement.getTextContent().isEmpty()) {
                                    boolean isDnsProgrammedInstance;
                                    isDnsProgrammedInstance = DatatypeConverter.parseBoolean(
                                            isDnsProgrammedElement.getTextContent().toLowerCase());
                                    virtualIPInstance.setIsDnsProgrammed(isDnsProgrammedInstance);
                                }

                                Element nameElement12 = XmlUtility.getElementByTagNameNS(virtualIPsElement,
                                        "http://schemas.microsoft.com/windowsazure", "Name");
                                if (nameElement12 != null) {
                                    String nameInstance12;
                                    nameInstance12 = nameElement12.getTextContent();
                                    virtualIPInstance.setName(nameInstance12);
                                }

                                Element reservedIPNameElement = XmlUtility.getElementByTagNameNS(
                                        virtualIPsElement, "http://schemas.microsoft.com/windowsazure",
                                        "ReservedIPName");
                                if (reservedIPNameElement != null) {
                                    String reservedIPNameInstance;
                                    reservedIPNameInstance = reservedIPNameElement.getTextContent();
                                    virtualIPInstance.setReservedIPName(reservedIPNameInstance);
                                }
                            }
                        }

                        Element dnsElement = XmlUtility.getElementByTagNameNS(deploymentsElement,
                                "http://schemas.microsoft.com/windowsazure", "Dns");
                        if (dnsElement != null) {
                            DnsSettings dnsInstance = new DnsSettings();
                            deploymentInstance.setDnsSettings(dnsInstance);

                            Element dnsServersSequenceElement = XmlUtility.getElementByTagNameNS(dnsElement,
                                    "http://schemas.microsoft.com/windowsazure", "DnsServers");
                            if (dnsServersSequenceElement != null) {
                                for (int i35 = 0; i35 < com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(dnsServersSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "DnsServer")
                                        .size(); i35 = i35 + 1) {
                                    org.w3c.dom.Element dnsServersElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                            .getElementsByTagNameNS(dnsServersSequenceElement,
                                                    "http://schemas.microsoft.com/windowsazure", "DnsServer")
                                            .get(i35));
                                    DnsServer dnsServerInstance = new DnsServer();
                                    dnsInstance.getDnsServers().add(dnsServerInstance);

                                    Element nameElement13 = XmlUtility.getElementByTagNameNS(dnsServersElement,
                                            "http://schemas.microsoft.com/windowsazure", "Name");
                                    if (nameElement13 != null) {
                                        String nameInstance13;
                                        nameInstance13 = nameElement13.getTextContent();
                                        dnsServerInstance.setName(nameInstance13);
                                    }

                                    Element addressElement4 = XmlUtility.getElementByTagNameNS(
                                            dnsServersElement, "http://schemas.microsoft.com/windowsazure",
                                            "Address");
                                    if (addressElement4 != null) {
                                        InetAddress addressInstance4;
                                        addressInstance4 = InetAddress
                                                .getByName(addressElement4.getTextContent());
                                        dnsServerInstance.setAddress(addressInstance4);
                                    }
                                }
                            }
                        }
                    }
                }

                Element urlElement2 = XmlUtility.getElementByTagNameNS(hostedServiceElement,
                        "http://schemas.microsoft.com/windowsazure", "Url");
                if (urlElement2 != null) {
                    URI urlInstance2;
                    urlInstance2 = new URI(urlElement2.getTextContent());
                    result.setUri(urlInstance2);
                }

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

                Element hostedServicePropertiesElement = XmlUtility.getElementByTagNameNS(hostedServiceElement,
                        "http://schemas.microsoft.com/windowsazure", "HostedServiceProperties");
                if (hostedServicePropertiesElement != null) {
                    HostedServiceProperties hostedServicePropertiesInstance = new HostedServiceProperties();
                    result.setProperties(hostedServicePropertiesInstance);

                    Element descriptionElement2 = XmlUtility.getElementByTagNameNS(
                            hostedServicePropertiesElement, "http://schemas.microsoft.com/windowsazure",
                            "Description");
                    if (descriptionElement2 != null) {
                        String descriptionInstance2;
                        descriptionInstance2 = descriptionElement2.getTextContent();
                        hostedServicePropertiesInstance.setDescription(descriptionInstance2);
                    }

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

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

                    Element labelElement3 = XmlUtility.getElementByTagNameNS(hostedServicePropertiesElement,
                            "http://schemas.microsoft.com/windowsazure", "Label");
                    if (labelElement3 != null) {
                        String labelInstance3;
                        labelInstance3 = labelElement3.getTextContent() != null
                                ? new String(Base64.decode(labelElement3.getTextContent()))
                                : null;
                        hostedServicePropertiesInstance.setLabel(labelInstance3);
                    }

                    Element statusElement7 = XmlUtility.getElementByTagNameNS(hostedServicePropertiesElement,
                            "http://schemas.microsoft.com/windowsazure", "Status");
                    if (statusElement7 != null && statusElement7.getTextContent() != null
                            && !statusElement7.getTextContent().isEmpty()) {
                        HostedServiceStatus statusInstance7;
                        statusInstance7 = HostedServiceStatus.valueOf(statusElement7.getTextContent());
                        hostedServicePropertiesInstance.setStatus(statusInstance7);
                    }

                    Element dateCreatedElement = XmlUtility.getElementByTagNameNS(
                            hostedServicePropertiesElement, "http://schemas.microsoft.com/windowsazure",
                            "DateCreated");
                    if (dateCreatedElement != null) {
                        Calendar dateCreatedInstance;
                        dateCreatedInstance = DatatypeConverter
                                .parseDateTime(dateCreatedElement.getTextContent());
                        hostedServicePropertiesInstance.setDateCreated(dateCreatedInstance);
                    }

                    Element dateLastModifiedElement = XmlUtility.getElementByTagNameNS(
                            hostedServicePropertiesElement, "http://schemas.microsoft.com/windowsazure",
                            "DateLastModified");
                    if (dateLastModifiedElement != null) {
                        Calendar dateLastModifiedInstance;
                        dateLastModifiedInstance = DatatypeConverter
                                .parseDateTime(dateLastModifiedElement.getTextContent());
                        hostedServicePropertiesInstance.setDateLastModified(dateLastModifiedInstance);
                    }

                    Element extendedPropertiesSequenceElement2 = XmlUtility.getElementByTagNameNS(
                            hostedServicePropertiesElement, "http://schemas.microsoft.com/windowsazure",
                            "ExtendedProperties");
                    if (extendedPropertiesSequenceElement2 != null) {
                        for (int i36 = 0; i36 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(extendedPropertiesSequenceElement2,
                                        "http://schemas.microsoft.com/windowsazure", "ExtendedProperty")
                                .size(); i36 = i36 + 1) {
                            org.w3c.dom.Element extendedPropertiesElement2 = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(extendedPropertiesSequenceElement2,
                                            "http://schemas.microsoft.com/windowsazure", "ExtendedProperty")
                                    .get(i36));
                            String extendedPropertiesKey2 = XmlUtility
                                    .getElementByTagNameNS(extendedPropertiesElement2,
                                            "http://schemas.microsoft.com/windowsazure", "Name")
                                    .getTextContent();
                            String extendedPropertiesValue2 = XmlUtility
                                    .getElementByTagNameNS(extendedPropertiesElement2,
                                            "http://schemas.microsoft.com/windowsazure", "Value")
                                    .getTextContent();
                            hostedServicePropertiesInstance.getExtendedProperties().put(extendedPropertiesKey2,
                                    extendedPropertiesValue2);
                        }
                    }

                    Element reverseDnsFqdnElement = XmlUtility.getElementByTagNameNS(
                            hostedServicePropertiesElement, "http://schemas.microsoft.com/windowsazure",
                            "ReverseDnsFqdn");
                    if (reverseDnsFqdnElement != null) {
                        String reverseDnsFqdnInstance;
                        reverseDnsFqdnInstance = reverseDnsFqdnElement.getTextContent();
                        hostedServicePropertiesInstance.setReverseDnsFqdn(reverseDnsFqdnInstance);
                    }
                }

                Element computeCapabilitiesElement = XmlUtility.getElementByTagNameNS(hostedServiceElement,
                        "http://schemas.microsoft.com/windowsazure", "ComputeCapabilities");
                if (computeCapabilitiesElement != null) {
                    ComputeCapabilities computeCapabilitiesInstance = new ComputeCapabilities();
                    result.setComputeCapabilities(computeCapabilitiesInstance);

                    Element virtualMachinesRoleSizesSequenceElement = XmlUtility.getElementByTagNameNS(
                            computeCapabilitiesElement, "http://schemas.microsoft.com/windowsazure",
                            "VirtualMachinesRoleSizes");
                    if (virtualMachinesRoleSizesSequenceElement != null) {
                        for (int i37 = 0; i37 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(virtualMachinesRoleSizesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                .size(); i37 = i37 + 1) {
                            org.w3c.dom.Element virtualMachinesRoleSizesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(virtualMachinesRoleSizesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                    .get(i37));
                            computeCapabilitiesInstance.getVirtualMachinesRoleSizes()
                                    .add(virtualMachinesRoleSizesElement.getTextContent());
                        }
                    }

                    Element webWorkerRoleSizesSequenceElement = XmlUtility.getElementByTagNameNS(
                            computeCapabilitiesElement, "http://schemas.microsoft.com/windowsazure",
                            "WebWorkerRoleSizes");
                    if (webWorkerRoleSizesSequenceElement != null) {
                        for (int i38 = 0; i38 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(webWorkerRoleSizesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                .size(); i38 = i38 + 1) {
                            org.w3c.dom.Element webWorkerRoleSizesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(webWorkerRoleSizesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                    .get(i38));
                            computeCapabilitiesInstance.getWebWorkerRoleSizes()
                                    .add(webWorkerRoleSizesElement.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();
        }
    }
}