List of usage examples for javax.xml.bind DatatypeConverter parseInt
public static int parseInt(String lexicalXSDInt)
Convert the string argument into an int value.
From source file:com.microsoft.windowsazure.management.sql.DatabaseOperationsImpl.java
/** * Returns a collection of Azure SQL Databases. * * @param serverName Required. The name of the Azure SQL Database Server * from which to retrieve the database.//from www . j a v a2 s .co m * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws 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 Contains a collection of databases for a given Azure SQL Database * Server. */ @Override public DatabaseListResponse list(String serverName) throws IOException, ServiceException, ParserConfigurationException, SAXException { // Validate if (serverName == null) { throw new NullPointerException("serverName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("serverName", serverName); 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/sqlservers/servers/"; url = url + URLEncoder.encode(serverName, "UTF-8"); url = url + "/databases"; ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("contentview=generic"); 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", "2012-03-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result DatabaseListResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new DatabaseListResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element serviceResourcesSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "ServiceResources"); if (serviceResourcesSequenceElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(serviceResourcesSequenceElement, "http://schemas.microsoft.com/windowsazure", "ServiceResource") .size(); i1 = i1 + 1) { org.w3c.dom.Element serviceResourcesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(serviceResourcesSequenceElement, "http://schemas.microsoft.com/windowsazure", "ServiceResource") .get(i1)); Database serviceResourceInstance = new Database(); result.getDatabases().add(serviceResourceInstance); Element idElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "Id"); if (idElement != null) { int idInstance; idInstance = DatatypeConverter.parseInt(idElement.getTextContent()); serviceResourceInstance.setId(idInstance); } Element editionElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "Edition"); if (editionElement != null) { String editionInstance; editionInstance = editionElement.getTextContent(); serviceResourceInstance.setEdition(editionInstance); } Element maxSizeGBElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "MaxSizeGB"); if (maxSizeGBElement != null) { int maxSizeGBInstance; maxSizeGBInstance = DatatypeConverter.parseInt(maxSizeGBElement.getTextContent()); serviceResourceInstance.setMaximumDatabaseSizeInGB(maxSizeGBInstance); } Element maxSizeBytesElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "MaxSizeBytes"); if (maxSizeBytesElement != null) { long maxSizeBytesInstance; maxSizeBytesInstance = DatatypeConverter .parseLong(maxSizeBytesElement.getTextContent()); serviceResourceInstance.setMaximumDatabaseSizeInBytes(maxSizeBytesInstance); } Element collationNameElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "CollationName"); if (collationNameElement != null) { String collationNameInstance; collationNameInstance = collationNameElement.getTextContent(); serviceResourceInstance.setCollationName(collationNameInstance); } Element creationDateElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "CreationDate"); if (creationDateElement != null) { Calendar creationDateInstance; creationDateInstance = DatatypeConverter .parseDateTime(creationDateElement.getTextContent()); serviceResourceInstance.setCreationDate(creationDateInstance); } Element isFederationRootElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "IsFederationRoot"); if (isFederationRootElement != null) { boolean isFederationRootInstance; isFederationRootInstance = DatatypeConverter .parseBoolean(isFederationRootElement.getTextContent().toLowerCase()); serviceResourceInstance.setIsFederationRoot(isFederationRootInstance); } Element isSystemObjectElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "IsSystemObject"); if (isSystemObjectElement != null) { boolean isSystemObjectInstance; isSystemObjectInstance = DatatypeConverter .parseBoolean(isSystemObjectElement.getTextContent().toLowerCase()); serviceResourceInstance.setIsSystemObject(isSystemObjectInstance); } Element sizeMBElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "SizeMB"); if (sizeMBElement != null) { String sizeMBInstance; sizeMBInstance = sizeMBElement.getTextContent(); serviceResourceInstance.setSizeMB(sizeMBInstance); } Element serviceObjectiveAssignmentErrorCodeElement = XmlUtility.getElementByTagNameNS( serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveAssignmentErrorCode"); if (serviceObjectiveAssignmentErrorCodeElement != null) { String serviceObjectiveAssignmentErrorCodeInstance; serviceObjectiveAssignmentErrorCodeInstance = serviceObjectiveAssignmentErrorCodeElement .getTextContent(); serviceResourceInstance.setServiceObjectiveAssignmentErrorCode( serviceObjectiveAssignmentErrorCodeInstance); } Element serviceObjectiveAssignmentErrorDescriptionElement = XmlUtility .getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveAssignmentErrorDescription"); if (serviceObjectiveAssignmentErrorDescriptionElement != null) { String serviceObjectiveAssignmentErrorDescriptionInstance; serviceObjectiveAssignmentErrorDescriptionInstance = serviceObjectiveAssignmentErrorDescriptionElement .getTextContent(); serviceResourceInstance.setServiceObjectiveAssignmentErrorDescription( serviceObjectiveAssignmentErrorDescriptionInstance); } Element serviceObjectiveAssignmentStateElement = XmlUtility.getElementByTagNameNS( serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveAssignmentState"); if (serviceObjectiveAssignmentStateElement != null) { String serviceObjectiveAssignmentStateInstance; serviceObjectiveAssignmentStateInstance = serviceObjectiveAssignmentStateElement .getTextContent(); serviceResourceInstance .setServiceObjectiveAssignmentState(serviceObjectiveAssignmentStateInstance); } Element serviceObjectiveAssignmentStateDescriptionElement = XmlUtility .getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveAssignmentStateDescription"); if (serviceObjectiveAssignmentStateDescriptionElement != null) { String serviceObjectiveAssignmentStateDescriptionInstance; serviceObjectiveAssignmentStateDescriptionInstance = serviceObjectiveAssignmentStateDescriptionElement .getTextContent(); serviceResourceInstance.setServiceObjectiveAssignmentStateDescription( serviceObjectiveAssignmentStateDescriptionInstance); } Element serviceObjectiveAssignmentSuccessDateElement = XmlUtility.getElementByTagNameNS( serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveAssignmentSuccessDate"); if (serviceObjectiveAssignmentSuccessDateElement != null) { String serviceObjectiveAssignmentSuccessDateInstance; serviceObjectiveAssignmentSuccessDateInstance = serviceObjectiveAssignmentSuccessDateElement .getTextContent(); serviceResourceInstance.setServiceObjectiveAssignmentSuccessDate( serviceObjectiveAssignmentSuccessDateInstance); } Element serviceObjectiveIdElement = XmlUtility.getElementByTagNameNS( serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "ServiceObjectiveId"); if (serviceObjectiveIdElement != null) { String serviceObjectiveIdInstance; serviceObjectiveIdInstance = serviceObjectiveIdElement.getTextContent(); serviceResourceInstance.setServiceObjectiveId(serviceObjectiveIdInstance); } Element assignedServiceObjectiveIdElement = XmlUtility.getElementByTagNameNS( serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "AssignedServiceObjectiveId"); if (assignedServiceObjectiveIdElement != null) { String assignedServiceObjectiveIdInstance; assignedServiceObjectiveIdInstance = assignedServiceObjectiveIdElement.getTextContent(); serviceResourceInstance .setAssignedServiceObjectiveId(assignedServiceObjectiveIdInstance); } Element recoveryPeriodStartDateElement = XmlUtility.getElementByTagNameNS( serviceResourcesElement, "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 nameElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement != null) { String nameInstance; nameInstance = nameElement.getTextContent(); serviceResourceInstance.setName(nameInstance); } Element typeElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "http://schemas.microsoft.com/windowsazure", "Type"); if (typeElement != null) { String typeInstance; typeInstance = typeElement.getTextContent(); serviceResourceInstance.setType(typeInstance); } Element stateElement = XmlUtility.getElementByTagNameNS(serviceResourcesElement, "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.VirtualNetworkGatewayConnectionOperationsImpl.java
/** * The Delete VirtualNetworkGatewayConnection operation deletes the specifed * virtual network Gateway connection through Network resource provider. * * @param resourceGroupName Required. The name of the resource group. * @param virtualNetworkGatewayConnectionName Required. The name of the * virtual network gateway connection.//from w w w. ja va2s. 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 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 virtualNetworkGatewayConnectionName) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (virtualNetworkGatewayConnectionName == null) { throw new NullPointerException("virtualNetworkGatewayConnectionName"); } // 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); 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 + "/connections/"; url = url + URLEncoder.encode(virtualNetworkGatewayConnectionName, "UTF-8"); url = url + "/"; 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.compute.VirtualMachineDiskOperationsImpl.java
/** * The Get Disk operation retrieves a disk from the user image repository. * The disk can be an operating system disk or a data disk. (see * http://msdn.microsoft.com/en-us/library/windowsazure/jj157178.aspx for * more information)/* w w w .j a v a 2 s .co m*/ * * @param name Required. The name of the disk. * @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 virtual machine disk associated with your subscription. */ @Override public VirtualMachineDiskGetResponse getDisk(String name) throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException { // Validate if (name == null) { throw new NullPointerException("name"); } // 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("name", name); CloudTracing.enter(invocationId, this, "getDiskAsync", 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/disks/"; url = url + URLEncoder.encode(name, "UTF-8"); String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("x-ms-version", "2015-04-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result VirtualMachineDiskGetResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new VirtualMachineDiskGetResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element diskElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "Disk"); if (diskElement != null) { Element affinityGroupElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "AffinityGroup"); if (affinityGroupElement != null) { String affinityGroupInstance; affinityGroupInstance = affinityGroupElement.getTextContent(); result.setAffinityGroup(affinityGroupInstance); } Element locationElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "Location"); if (locationElement != null) { String locationInstance; locationInstance = locationElement.getTextContent(); result.setLocation(locationInstance); } Element labelElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "Label"); if (labelElement != null) { String labelInstance; labelInstance = labelElement.getTextContent(); result.setLabel(labelInstance); } Element logicalDiskSizeInGBElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "LogicalDiskSizeInGB"); if (logicalDiskSizeInGBElement != null) { int logicalDiskSizeInGBInstance; logicalDiskSizeInGBInstance = DatatypeConverter .parseInt(logicalDiskSizeInGBElement.getTextContent()); result.setLogicalSizeInGB(logicalDiskSizeInGBInstance); } Element mediaLinkElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "MediaLink"); if (mediaLinkElement != null) { URI mediaLinkInstance; mediaLinkInstance = new URI(mediaLinkElement.getTextContent()); result.setMediaLinkUri(mediaLinkInstance); } Element nameElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement != null) { String nameInstance; nameInstance = nameElement.getTextContent(); result.setName(nameInstance); } Element osElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "OS"); if (osElement != null) { String osInstance; osInstance = osElement.getTextContent(); result.setOperatingSystemType(osInstance); } Element sourceImageNameElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "SourceImageName"); if (sourceImageNameElement != null) { String sourceImageNameInstance; sourceImageNameInstance = sourceImageNameElement.getTextContent(); result.setSourceImageName(sourceImageNameInstance); } Element attachedToElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "AttachedTo"); if (attachedToElement != null) { VirtualMachineDiskGetResponse.VirtualMachineDiskUsageDetails attachedToInstance = new VirtualMachineDiskGetResponse.VirtualMachineDiskUsageDetails(); result.setUsageDetails(attachedToInstance); Element hostedServiceNameElement = XmlUtility.getElementByTagNameNS(attachedToElement, "http://schemas.microsoft.com/windowsazure", "HostedServiceName"); if (hostedServiceNameElement != null) { String hostedServiceNameInstance; hostedServiceNameInstance = hostedServiceNameElement.getTextContent(); attachedToInstance.setHostedServiceName(hostedServiceNameInstance); } Element deploymentNameElement = XmlUtility.getElementByTagNameNS(attachedToElement, "http://schemas.microsoft.com/windowsazure", "DeploymentName"); if (deploymentNameElement != null) { String deploymentNameInstance; deploymentNameInstance = deploymentNameElement.getTextContent(); attachedToInstance.setDeploymentName(deploymentNameInstance); } Element roleNameElement = XmlUtility.getElementByTagNameNS(attachedToElement, "http://schemas.microsoft.com/windowsazure", "RoleName"); if (roleNameElement != null) { String roleNameInstance; roleNameInstance = roleNameElement.getTextContent(); attachedToInstance.setRoleName(roleNameInstance); } } Element isCorruptedElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "IsCorrupted"); if (isCorruptedElement != null && isCorruptedElement.getTextContent() != null && !isCorruptedElement.getTextContent().isEmpty()) { boolean isCorruptedInstance; isCorruptedInstance = DatatypeConverter .parseBoolean(isCorruptedElement.getTextContent().toLowerCase()); result.setIsCorrupted(isCorruptedInstance); } Element isPremiumElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "IsPremium"); if (isPremiumElement != null && isPremiumElement.getTextContent() != null && !isPremiumElement.getTextContent().isEmpty()) { boolean isPremiumInstance; isPremiumInstance = DatatypeConverter .parseBoolean(isPremiumElement.getTextContent().toLowerCase()); result.setIsPremium(isPremiumInstance); } Element iOTypeElement = XmlUtility.getElementByTagNameNS(diskElement, "http://schemas.microsoft.com/windowsazure", "IOType"); if (iOTypeElement != null) { String iOTypeInstance; iOTypeInstance = iOTypeElement.getTextContent(); result.setIOType(iOTypeInstance); } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.sql.DatabaseActivationOperationsImpl.java
/** * Start an Azure SQL Data Warehouse database pause operation.To determine * the status of the operation call GetDatabaseActivationOperationStatus. * * @param resourceGroupName Required. The name of the Resource Group to * which the Azure SQL Server belongs.// w w w. ja v a2 s .com * @param serverName Required. The name of the Azure SQL Server on which the * data warehouse database is hosted. * @param databaseName Required. The name of the Azure SQL Data Warehouse * database to pause. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Response for long running Azure Sql Database operations. */ @Override public DatabaseCreateOrUpdateResponse beginPause(String resourceGroupName, String serverName, String databaseName) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (serverName == null) { throw new NullPointerException("serverName"); } if (databaseName == null) { throw new NullPointerException("databaseName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("resourceGroupName", resourceGroupName); tracingParameters.put("serverName", serverName); tracingParameters.put("databaseName", databaseName); CloudTracing.enter(invocationId, this, "beginPauseAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourceGroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/"; url = url + "Microsoft.Sql"; url = url + "/servers/"; url = url + URLEncoder.encode(serverName, "UTF-8"); url = url + "/databases/"; url = url + URLEncoder.encode(databaseName, "UTF-8"); url = url + "/pause"; ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2014-04-01"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpPost httpRequest = new HttpPost(url); // Set Headers httpRequest.setHeader("Content-Type", "application/json; charset=utf-8"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_ACCEPTED) { ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result DatabaseCreateOrUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new DatabaseCreateOrUpdateResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; String responseDocContent = IOUtils.toString(responseContent); if (responseDocContent == null == false && responseDocContent.length() > 0) { responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { ErrorResponse errorInstance = new ErrorResponse(); result.setError(errorInstance); JsonNode codeValue = responseDoc.get("code"); if (codeValue != null && codeValue instanceof NullNode == false) { String codeInstance; codeInstance = codeValue.getTextValue(); errorInstance.setCode(codeInstance); } JsonNode messageValue = responseDoc.get("message"); if (messageValue != null && messageValue instanceof NullNode == false) { String messageInstance; messageInstance = messageValue.getTextValue(); errorInstance.setMessage(messageInstance); } JsonNode targetValue = responseDoc.get("target"); if (targetValue != null && targetValue instanceof NullNode == false) { String targetInstance; targetInstance = targetValue.getTextValue(); errorInstance.setTarget(targetInstance); } Database databaseInstance = new Database(); result.setDatabase(databaseInstance); JsonNode propertiesValue = responseDoc.get("properties"); if (propertiesValue != null && propertiesValue instanceof NullNode == false) { DatabaseProperties propertiesInstance = new DatabaseProperties(); databaseInstance.setProperties(propertiesInstance); JsonNode collationValue = propertiesValue.get("collation"); if (collationValue != null && collationValue instanceof NullNode == false) { String collationInstance; collationInstance = collationValue.getTextValue(); propertiesInstance.setCollation(collationInstance); } JsonNode creationDateValue = propertiesValue.get("creationDate"); if (creationDateValue != null && creationDateValue instanceof NullNode == false) { Calendar creationDateInstance; creationDateInstance = DatatypeConverter .parseDateTime(creationDateValue.getTextValue()); propertiesInstance.setCreationDate(creationDateInstance); } JsonNode currentServiceObjectiveIdValue = propertiesValue.get("currentServiceObjectiveId"); if (currentServiceObjectiveIdValue != null && currentServiceObjectiveIdValue instanceof NullNode == false) { String currentServiceObjectiveIdInstance; currentServiceObjectiveIdInstance = currentServiceObjectiveIdValue.getTextValue(); propertiesInstance.setCurrentServiceObjectiveId(currentServiceObjectiveIdInstance); } JsonNode databaseIdValue = propertiesValue.get("databaseId"); if (databaseIdValue != null && databaseIdValue instanceof NullNode == false) { String databaseIdInstance; databaseIdInstance = databaseIdValue.getTextValue(); propertiesInstance.setDatabaseId(databaseIdInstance); } JsonNode earliestRestoreDateValue = propertiesValue.get("earliestRestoreDate"); if (earliestRestoreDateValue != null && earliestRestoreDateValue instanceof NullNode == false) { Calendar earliestRestoreDateInstance; earliestRestoreDateInstance = DatatypeConverter .parseDateTime(earliestRestoreDateValue.getTextValue()); propertiesInstance.setEarliestRestoreDate(earliestRestoreDateInstance); } JsonNode editionValue = propertiesValue.get("edition"); if (editionValue != null && editionValue instanceof NullNode == false) { String editionInstance; editionInstance = editionValue.getTextValue(); propertiesInstance.setEdition(editionInstance); } JsonNode maxSizeBytesValue = propertiesValue.get("maxSizeBytes"); if (maxSizeBytesValue != null && maxSizeBytesValue instanceof NullNode == false) { long maxSizeBytesInstance; maxSizeBytesInstance = maxSizeBytesValue.getLongValue(); propertiesInstance.setMaxSizeBytes(maxSizeBytesInstance); } JsonNode requestedServiceObjectiveIdValue = propertiesValue .get("requestedServiceObjectiveId"); if (requestedServiceObjectiveIdValue != null && requestedServiceObjectiveIdValue instanceof NullNode == false) { String requestedServiceObjectiveIdInstance; requestedServiceObjectiveIdInstance = requestedServiceObjectiveIdValue.getTextValue(); propertiesInstance.setRequestedServiceObjectiveId(requestedServiceObjectiveIdInstance); } JsonNode requestedServiceObjectiveNameValue = propertiesValue .get("requestedServiceObjectiveName"); if (requestedServiceObjectiveNameValue != null && requestedServiceObjectiveNameValue instanceof NullNode == false) { String requestedServiceObjectiveNameInstance; requestedServiceObjectiveNameInstance = requestedServiceObjectiveNameValue .getTextValue(); propertiesInstance .setRequestedServiceObjectiveName(requestedServiceObjectiveNameInstance); } JsonNode serviceLevelObjectiveValue = propertiesValue.get("serviceLevelObjective"); if (serviceLevelObjectiveValue != null && serviceLevelObjectiveValue instanceof NullNode == false) { String serviceLevelObjectiveInstance; serviceLevelObjectiveInstance = serviceLevelObjectiveValue.getTextValue(); propertiesInstance.setServiceObjective(serviceLevelObjectiveInstance); } JsonNode statusValue = propertiesValue.get("status"); if (statusValue != null && statusValue instanceof NullNode == false) { String statusInstance; statusInstance = statusValue.getTextValue(); propertiesInstance.setStatus(statusInstance); } JsonNode elasticPoolNameValue = propertiesValue.get("elasticPoolName"); if (elasticPoolNameValue != null && elasticPoolNameValue instanceof NullNode == false) { String elasticPoolNameInstance; elasticPoolNameInstance = elasticPoolNameValue.getTextValue(); propertiesInstance.setElasticPoolName(elasticPoolNameInstance); } JsonNode serviceTierAdvisorsArray = propertiesValue.get("serviceTierAdvisors"); if (serviceTierAdvisorsArray != null && serviceTierAdvisorsArray instanceof NullNode == false) { for (JsonNode serviceTierAdvisorsValue : ((ArrayNode) serviceTierAdvisorsArray)) { ServiceTierAdvisor serviceTierAdvisorInstance = new ServiceTierAdvisor(); propertiesInstance.getServiceTierAdvisors().add(serviceTierAdvisorInstance); JsonNode propertiesValue2 = serviceTierAdvisorsValue.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { ServiceTierAdvisorProperties propertiesInstance2 = new ServiceTierAdvisorProperties(); serviceTierAdvisorInstance.setProperties(propertiesInstance2); JsonNode observationPeriodStartValue = propertiesValue2 .get("observationPeriodStart"); if (observationPeriodStartValue != null && observationPeriodStartValue instanceof NullNode == false) { Calendar observationPeriodStartInstance; observationPeriodStartInstance = DatatypeConverter .parseDateTime(observationPeriodStartValue.getTextValue()); propertiesInstance2 .setObservationPeriodStart(observationPeriodStartInstance); } JsonNode observationPeriodEndValue = propertiesValue2 .get("observationPeriodEnd"); if (observationPeriodEndValue != null && observationPeriodEndValue instanceof NullNode == false) { Calendar observationPeriodEndInstance; observationPeriodEndInstance = DatatypeConverter .parseDateTime(observationPeriodEndValue.getTextValue()); propertiesInstance2.setObservationPeriodEnd(observationPeriodEndInstance); } JsonNode activeTimeRatioValue = propertiesValue2.get("activeTimeRatio"); if (activeTimeRatioValue != null && activeTimeRatioValue instanceof NullNode == false) { double activeTimeRatioInstance; activeTimeRatioInstance = activeTimeRatioValue.getDoubleValue(); propertiesInstance2.setActiveTimeRatio(activeTimeRatioInstance); } JsonNode minDtuValue = propertiesValue2.get("minDtu"); if (minDtuValue != null && minDtuValue instanceof NullNode == false) { double minDtuInstance; minDtuInstance = minDtuValue.getDoubleValue(); propertiesInstance2.setMinDtu(minDtuInstance); } JsonNode avgDtuValue = propertiesValue2.get("avgDtu"); if (avgDtuValue != null && avgDtuValue instanceof NullNode == false) { double avgDtuInstance; avgDtuInstance = avgDtuValue.getDoubleValue(); propertiesInstance2.setAvgDtu(avgDtuInstance); } JsonNode maxDtuValue = propertiesValue2.get("maxDtu"); if (maxDtuValue != null && maxDtuValue instanceof NullNode == false) { double maxDtuInstance; maxDtuInstance = maxDtuValue.getDoubleValue(); propertiesInstance2.setMaxDtu(maxDtuInstance); } JsonNode maxSizeInGBValue = propertiesValue2.get("maxSizeInGB"); if (maxSizeInGBValue != null && maxSizeInGBValue instanceof NullNode == false) { double maxSizeInGBInstance; maxSizeInGBInstance = maxSizeInGBValue.getDoubleValue(); propertiesInstance2.setMaxSizeInGB(maxSizeInGBInstance); } JsonNode serviceLevelObjectiveUsageMetricsArray = propertiesValue2 .get("serviceLevelObjectiveUsageMetrics"); if (serviceLevelObjectiveUsageMetricsArray != null && serviceLevelObjectiveUsageMetricsArray instanceof NullNode == false) { for (JsonNode serviceLevelObjectiveUsageMetricsValue : ((ArrayNode) serviceLevelObjectiveUsageMetricsArray)) { SloUsageMetric sloUsageMetricInstance = new SloUsageMetric(); propertiesInstance2.getServiceLevelObjectiveUsageMetrics() .add(sloUsageMetricInstance); JsonNode serviceLevelObjectiveValue2 = serviceLevelObjectiveUsageMetricsValue .get("serviceLevelObjective"); if (serviceLevelObjectiveValue2 != null && serviceLevelObjectiveValue2 instanceof NullNode == false) { String serviceLevelObjectiveInstance2; serviceLevelObjectiveInstance2 = serviceLevelObjectiveValue2 .getTextValue(); sloUsageMetricInstance .setServiceLevelObjective(serviceLevelObjectiveInstance2); } JsonNode serviceLevelObjectiveIdValue = serviceLevelObjectiveUsageMetricsValue .get("serviceLevelObjectiveId"); if (serviceLevelObjectiveIdValue != null && serviceLevelObjectiveIdValue instanceof NullNode == false) { String serviceLevelObjectiveIdInstance; serviceLevelObjectiveIdInstance = serviceLevelObjectiveIdValue .getTextValue(); sloUsageMetricInstance.setServiceLevelObjectiveId( serviceLevelObjectiveIdInstance); } JsonNode inRangeTimeRatioValue = serviceLevelObjectiveUsageMetricsValue .get("inRangeTimeRatio"); if (inRangeTimeRatioValue != null && inRangeTimeRatioValue instanceof NullNode == false) { double inRangeTimeRatioInstance; inRangeTimeRatioInstance = inRangeTimeRatioValue.getDoubleValue(); sloUsageMetricInstance .setInRangeTimeRatio(inRangeTimeRatioInstance); } JsonNode idValue = serviceLevelObjectiveUsageMetricsValue.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); sloUsageMetricInstance.setId(idInstance); } JsonNode nameValue = serviceLevelObjectiveUsageMetricsValue.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); sloUsageMetricInstance.setName(nameInstance); } JsonNode typeValue = serviceLevelObjectiveUsageMetricsValue.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); sloUsageMetricInstance.setType(typeInstance); } JsonNode locationValue = serviceLevelObjectiveUsageMetricsValue .get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); sloUsageMetricInstance.setLocation(locationInstance); } JsonNode tagsSequenceElement = ((JsonNode) serviceLevelObjectiveUsageMetricsValue .get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement .getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey = property.getKey(); String tagsValue = property.getValue().getTextValue(); sloUsageMetricInstance.getTags().put(tagsKey, tagsValue); } } } } JsonNode currentServiceLevelObjectiveValue = propertiesValue2 .get("currentServiceLevelObjective"); if (currentServiceLevelObjectiveValue != null && currentServiceLevelObjectiveValue instanceof NullNode == false) { String currentServiceLevelObjectiveInstance; currentServiceLevelObjectiveInstance = currentServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setCurrentServiceLevelObjective( currentServiceLevelObjectiveInstance); } JsonNode currentServiceLevelObjectiveIdValue = propertiesValue2 .get("currentServiceLevelObjectiveId"); if (currentServiceLevelObjectiveIdValue != null && currentServiceLevelObjectiveIdValue instanceof NullNode == false) { String currentServiceLevelObjectiveIdInstance; currentServiceLevelObjectiveIdInstance = currentServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2.setCurrentServiceLevelObjectiveId( currentServiceLevelObjectiveIdInstance); } JsonNode usageBasedRecommendationServiceLevelObjectiveValue = propertiesValue2 .get("usageBasedRecommendationServiceLevelObjective"); if (usageBasedRecommendationServiceLevelObjectiveValue != null && usageBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String usageBasedRecommendationServiceLevelObjectiveInstance; usageBasedRecommendationServiceLevelObjectiveInstance = usageBasedRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setUsageBasedRecommendationServiceLevelObjective( usageBasedRecommendationServiceLevelObjectiveInstance); } JsonNode usageBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue2 .get("usageBasedRecommendationServiceLevelObjectiveId"); if (usageBasedRecommendationServiceLevelObjectiveIdValue != null && usageBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String usageBasedRecommendationServiceLevelObjectiveIdInstance; usageBasedRecommendationServiceLevelObjectiveIdInstance = usageBasedRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2.setUsageBasedRecommendationServiceLevelObjectiveId( usageBasedRecommendationServiceLevelObjectiveIdInstance); } JsonNode databaseSizeBasedRecommendationServiceLevelObjectiveValue = propertiesValue2 .get("databaseSizeBasedRecommendationServiceLevelObjective"); if (databaseSizeBasedRecommendationServiceLevelObjectiveValue != null && databaseSizeBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String databaseSizeBasedRecommendationServiceLevelObjectiveInstance; databaseSizeBasedRecommendationServiceLevelObjectiveInstance = databaseSizeBasedRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setDatabaseSizeBasedRecommendationServiceLevelObjective( databaseSizeBasedRecommendationServiceLevelObjectiveInstance); } JsonNode databaseSizeBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue2 .get("databaseSizeBasedRecommendationServiceLevelObjectiveId"); if (databaseSizeBasedRecommendationServiceLevelObjectiveIdValue != null && databaseSizeBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance; databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance = databaseSizeBasedRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2 .setDatabaseSizeBasedRecommendationServiceLevelObjectiveId( databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance); } JsonNode disasterPlanBasedRecommendationServiceLevelObjectiveValue = propertiesValue2 .get("disasterPlanBasedRecommendationServiceLevelObjective"); if (disasterPlanBasedRecommendationServiceLevelObjectiveValue != null && disasterPlanBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String disasterPlanBasedRecommendationServiceLevelObjectiveInstance; disasterPlanBasedRecommendationServiceLevelObjectiveInstance = disasterPlanBasedRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setDisasterPlanBasedRecommendationServiceLevelObjective( disasterPlanBasedRecommendationServiceLevelObjectiveInstance); } JsonNode disasterPlanBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue2 .get("disasterPlanBasedRecommendationServiceLevelObjectiveId"); if (disasterPlanBasedRecommendationServiceLevelObjectiveIdValue != null && disasterPlanBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance; disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance = disasterPlanBasedRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2 .setDisasterPlanBasedRecommendationServiceLevelObjectiveId( disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance); } JsonNode overallRecommendationServiceLevelObjectiveValue = propertiesValue2 .get("overallRecommendationServiceLevelObjective"); if (overallRecommendationServiceLevelObjectiveValue != null && overallRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String overallRecommendationServiceLevelObjectiveInstance; overallRecommendationServiceLevelObjectiveInstance = overallRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setOverallRecommendationServiceLevelObjective( overallRecommendationServiceLevelObjectiveInstance); } JsonNode overallRecommendationServiceLevelObjectiveIdValue = propertiesValue2 .get("overallRecommendationServiceLevelObjectiveId"); if (overallRecommendationServiceLevelObjectiveIdValue != null && overallRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String overallRecommendationServiceLevelObjectiveIdInstance; overallRecommendationServiceLevelObjectiveIdInstance = overallRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2.setOverallRecommendationServiceLevelObjectiveId( overallRecommendationServiceLevelObjectiveIdInstance); } JsonNode confidenceValue = propertiesValue2.get("confidence"); if (confidenceValue != null && confidenceValue instanceof NullNode == false) { double confidenceInstance; confidenceInstance = confidenceValue.getDoubleValue(); propertiesInstance2.setConfidence(confidenceInstance); } } JsonNode idValue2 = serviceTierAdvisorsValue.get("id"); if (idValue2 != null && idValue2 instanceof NullNode == false) { String idInstance2; idInstance2 = idValue2.getTextValue(); serviceTierAdvisorInstance.setId(idInstance2); } JsonNode nameValue2 = serviceTierAdvisorsValue.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); serviceTierAdvisorInstance.setName(nameInstance2); } JsonNode typeValue2 = serviceTierAdvisorsValue.get("type"); if (typeValue2 != null && typeValue2 instanceof NullNode == false) { String typeInstance2; typeInstance2 = typeValue2.getTextValue(); serviceTierAdvisorInstance.setType(typeInstance2); } JsonNode locationValue2 = serviceTierAdvisorsValue.get("location"); if (locationValue2 != null && locationValue2 instanceof NullNode == false) { String locationInstance2; locationInstance2 = locationValue2.getTextValue(); serviceTierAdvisorInstance.setLocation(locationInstance2); } JsonNode tagsSequenceElement2 = ((JsonNode) serviceTierAdvisorsValue.get("tags")); if (tagsSequenceElement2 != null && tagsSequenceElement2 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr2 = tagsSequenceElement2.getFields(); while (itr2.hasNext()) { Map.Entry<String, JsonNode> property2 = itr2.next(); String tagsKey2 = property2.getKey(); String tagsValue2 = property2.getValue().getTextValue(); serviceTierAdvisorInstance.getTags().put(tagsKey2, tagsValue2); } } } } JsonNode upgradeHintValue = propertiesValue.get("upgradeHint"); if (upgradeHintValue != null && upgradeHintValue instanceof NullNode == false) { UpgradeHint upgradeHintInstance = new UpgradeHint(); propertiesInstance.setUpgradeHint(upgradeHintInstance); JsonNode targetServiceLevelObjectiveValue = upgradeHintValue .get("targetServiceLevelObjective"); if (targetServiceLevelObjectiveValue != null && targetServiceLevelObjectiveValue instanceof NullNode == false) { String targetServiceLevelObjectiveInstance; targetServiceLevelObjectiveInstance = targetServiceLevelObjectiveValue .getTextValue(); upgradeHintInstance .setTargetServiceLevelObjective(targetServiceLevelObjectiveInstance); } JsonNode targetServiceLevelObjectiveIdValue = upgradeHintValue .get("targetServiceLevelObjectiveId"); if (targetServiceLevelObjectiveIdValue != null && targetServiceLevelObjectiveIdValue instanceof NullNode == false) { String targetServiceLevelObjectiveIdInstance; targetServiceLevelObjectiveIdInstance = targetServiceLevelObjectiveIdValue .getTextValue(); upgradeHintInstance .setTargetServiceLevelObjectiveId(targetServiceLevelObjectiveIdInstance); } JsonNode idValue3 = upgradeHintValue.get("id"); if (idValue3 != null && idValue3 instanceof NullNode == false) { String idInstance3; idInstance3 = idValue3.getTextValue(); upgradeHintInstance.setId(idInstance3); } JsonNode nameValue3 = upgradeHintValue.get("name"); if (nameValue3 != null && nameValue3 instanceof NullNode == false) { String nameInstance3; nameInstance3 = nameValue3.getTextValue(); upgradeHintInstance.setName(nameInstance3); } JsonNode typeValue3 = upgradeHintValue.get("type"); if (typeValue3 != null && typeValue3 instanceof NullNode == false) { String typeInstance3; typeInstance3 = typeValue3.getTextValue(); upgradeHintInstance.setType(typeInstance3); } JsonNode locationValue3 = upgradeHintValue.get("location"); if (locationValue3 != null && locationValue3 instanceof NullNode == false) { String locationInstance3; locationInstance3 = locationValue3.getTextValue(); upgradeHintInstance.setLocation(locationInstance3); } JsonNode tagsSequenceElement3 = ((JsonNode) upgradeHintValue.get("tags")); if (tagsSequenceElement3 != null && tagsSequenceElement3 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr3 = tagsSequenceElement3.getFields(); while (itr3.hasNext()) { Map.Entry<String, JsonNode> property3 = itr3.next(); String tagsKey3 = property3.getKey(); String tagsValue3 = property3.getValue().getTextValue(); upgradeHintInstance.getTags().put(tagsKey3, tagsValue3); } } } JsonNode schemasArray = propertiesValue.get("schemas"); if (schemasArray != null && schemasArray instanceof NullNode == false) { for (JsonNode schemasValue : ((ArrayNode) schemasArray)) { Schema schemaInstance = new Schema(); propertiesInstance.getSchemas().add(schemaInstance); JsonNode propertiesValue3 = schemasValue.get("properties"); if (propertiesValue3 != null && propertiesValue3 instanceof NullNode == false) { SchemaProperties propertiesInstance3 = new SchemaProperties(); schemaInstance.setProperties(propertiesInstance3); JsonNode tablesArray = propertiesValue3.get("tables"); if (tablesArray != null && tablesArray instanceof NullNode == false) { for (JsonNode tablesValue : ((ArrayNode) tablesArray)) { Table tableInstance = new Table(); propertiesInstance3.getTables().add(tableInstance); JsonNode propertiesValue4 = tablesValue.get("properties"); if (propertiesValue4 != null && propertiesValue4 instanceof NullNode == false) { TableProperties propertiesInstance4 = new TableProperties(); tableInstance.setProperties(propertiesInstance4); JsonNode tableTypeValue = propertiesValue4.get("tableType"); if (tableTypeValue != null && tableTypeValue instanceof NullNode == false) { String tableTypeInstance; tableTypeInstance = tableTypeValue.getTextValue(); propertiesInstance4.setTableType(tableTypeInstance); } JsonNode columnsArray = propertiesValue4.get("columns"); if (columnsArray != null && columnsArray instanceof NullNode == false) { for (JsonNode columnsValue : ((ArrayNode) columnsArray)) { Column columnInstance = new Column(); propertiesInstance4.getColumns().add(columnInstance); JsonNode propertiesValue5 = columnsValue.get("properties"); if (propertiesValue5 != null && propertiesValue5 instanceof NullNode == false) { ColumnProperties propertiesInstance5 = new ColumnProperties(); columnInstance.setProperties(propertiesInstance5); JsonNode columnTypeValue = propertiesValue5 .get("columnType"); if (columnTypeValue != null && columnTypeValue instanceof NullNode == false) { String columnTypeInstance; columnTypeInstance = columnTypeValue.getTextValue(); propertiesInstance5 .setColumnType(columnTypeInstance); } } JsonNode idValue4 = columnsValue.get("id"); if (idValue4 != null && idValue4 instanceof NullNode == false) { String idInstance4; idInstance4 = idValue4.getTextValue(); columnInstance.setId(idInstance4); } JsonNode nameValue4 = columnsValue.get("name"); if (nameValue4 != null && nameValue4 instanceof NullNode == false) { String nameInstance4; nameInstance4 = nameValue4.getTextValue(); columnInstance.setName(nameInstance4); } JsonNode typeValue4 = columnsValue.get("type"); if (typeValue4 != null && typeValue4 instanceof NullNode == false) { String typeInstance4; typeInstance4 = typeValue4.getTextValue(); columnInstance.setType(typeInstance4); } JsonNode locationValue4 = columnsValue.get("location"); if (locationValue4 != null && locationValue4 instanceof NullNode == false) { String locationInstance4; locationInstance4 = locationValue4.getTextValue(); columnInstance.setLocation(locationInstance4); } JsonNode tagsSequenceElement4 = ((JsonNode) columnsValue .get("tags")); if (tagsSequenceElement4 != null && tagsSequenceElement4 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr4 = tagsSequenceElement4 .getFields(); while (itr4.hasNext()) { Map.Entry<String, JsonNode> property4 = itr4.next(); String tagsKey4 = property4.getKey(); String tagsValue4 = property4.getValue() .getTextValue(); columnInstance.getTags().put(tagsKey4, tagsValue4); } } } } JsonNode recommendedIndexesArray = propertiesValue4 .get("recommendedIndexes"); if (recommendedIndexesArray != null && recommendedIndexesArray instanceof NullNode == false) { for (JsonNode recommendedIndexesValue : ((ArrayNode) recommendedIndexesArray)) { RecommendedIndex recommendedIndexInstance = new RecommendedIndex(); propertiesInstance4.getRecommendedIndexes() .add(recommendedIndexInstance); JsonNode propertiesValue6 = recommendedIndexesValue .get("properties"); if (propertiesValue6 != null && propertiesValue6 instanceof NullNode == false) { RecommendedIndexProperties propertiesInstance6 = new RecommendedIndexProperties(); recommendedIndexInstance .setProperties(propertiesInstance6); JsonNode actionValue = propertiesValue6.get("action"); if (actionValue != null && actionValue instanceof NullNode == false) { String actionInstance; actionInstance = actionValue.getTextValue(); propertiesInstance6.setAction(actionInstance); } JsonNode stateValue = propertiesValue6.get("state"); if (stateValue != null && stateValue instanceof NullNode == false) { String stateInstance; stateInstance = stateValue.getTextValue(); propertiesInstance6.setState(stateInstance); } JsonNode createdValue = propertiesValue6.get("created"); if (createdValue != null && createdValue instanceof NullNode == false) { Calendar createdInstance; createdInstance = DatatypeConverter .parseDateTime(createdValue.getTextValue()); propertiesInstance6.setCreated(createdInstance); } JsonNode lastModifiedValue = propertiesValue6 .get("lastModified"); if (lastModifiedValue != null && lastModifiedValue instanceof NullNode == false) { Calendar lastModifiedInstance; lastModifiedInstance = DatatypeConverter .parseDateTime( lastModifiedValue.getTextValue()); propertiesInstance6 .setLastModified(lastModifiedInstance); } JsonNode indexTypeValue = propertiesValue6 .get("indexType"); if (indexTypeValue != null && indexTypeValue instanceof NullNode == false) { String indexTypeInstance; indexTypeInstance = indexTypeValue.getTextValue(); propertiesInstance6.setIndexType(indexTypeInstance); } JsonNode schemaValue = propertiesValue6.get("schema"); if (schemaValue != null && schemaValue instanceof NullNode == false) { String schemaInstance2; schemaInstance2 = schemaValue.getTextValue(); propertiesInstance6.setSchema(schemaInstance2); } JsonNode tableValue = propertiesValue6.get("table"); if (tableValue != null && tableValue instanceof NullNode == false) { String tableInstance2; tableInstance2 = tableValue.getTextValue(); propertiesInstance6.setTable(tableInstance2); } JsonNode columnsArray2 = propertiesValue6 .get("columns"); if (columnsArray2 != null && columnsArray2 instanceof NullNode == false) { for (JsonNode columnsValue2 : ((ArrayNode) columnsArray2)) { propertiesInstance6.getColumns() .add(columnsValue2.getTextValue()); } } JsonNode includedColumnsArray = propertiesValue6 .get("includedColumns"); if (includedColumnsArray != null && includedColumnsArray instanceof NullNode == false) { for (JsonNode includedColumnsValue : ((ArrayNode) includedColumnsArray)) { propertiesInstance6.getIncludedColumns().add( includedColumnsValue.getTextValue()); } } JsonNode indexScriptValue = propertiesValue6 .get("indexScript"); if (indexScriptValue != null && indexScriptValue instanceof NullNode == false) { String indexScriptInstance; indexScriptInstance = indexScriptValue .getTextValue(); propertiesInstance6 .setIndexScript(indexScriptInstance); } JsonNode estimatedImpactArray = propertiesValue6 .get("estimatedImpact"); if (estimatedImpactArray != null && estimatedImpactArray instanceof NullNode == false) { for (JsonNode estimatedImpactValue : ((ArrayNode) estimatedImpactArray)) { OperationImpact operationImpactInstance = new OperationImpact(); propertiesInstance6.getEstimatedImpact() .add(operationImpactInstance); JsonNode nameValue5 = estimatedImpactValue .get("name"); if (nameValue5 != null && nameValue5 instanceof NullNode == false) { String nameInstance5; nameInstance5 = nameValue5.getTextValue(); operationImpactInstance .setName(nameInstance5); } JsonNode unitValue = estimatedImpactValue .get("unit"); if (unitValue != null && unitValue instanceof NullNode == false) { String unitInstance; unitInstance = unitValue.getTextValue(); operationImpactInstance .setUnit(unitInstance); } JsonNode changeValueAbsoluteValue = estimatedImpactValue .get("changeValueAbsolute"); if (changeValueAbsoluteValue != null && changeValueAbsoluteValue instanceof NullNode == false) { double changeValueAbsoluteInstance; changeValueAbsoluteInstance = changeValueAbsoluteValue .getDoubleValue(); operationImpactInstance .setChangeValueAbsolute( changeValueAbsoluteInstance); } JsonNode changeValueRelativeValue = estimatedImpactValue .get("changeValueRelative"); if (changeValueRelativeValue != null && changeValueRelativeValue instanceof NullNode == false) { double changeValueRelativeInstance; changeValueRelativeInstance = changeValueRelativeValue .getDoubleValue(); operationImpactInstance .setChangeValueRelative( changeValueRelativeInstance); } } } JsonNode reportedImpactArray = propertiesValue6 .get("reportedImpact"); if (reportedImpactArray != null && reportedImpactArray instanceof NullNode == false) { for (JsonNode reportedImpactValue : ((ArrayNode) reportedImpactArray)) { OperationImpact operationImpactInstance2 = new OperationImpact(); propertiesInstance6.getReportedImpact() .add(operationImpactInstance2); JsonNode nameValue6 = reportedImpactValue .get("name"); if (nameValue6 != null && nameValue6 instanceof NullNode == false) { String nameInstance6; nameInstance6 = nameValue6.getTextValue(); operationImpactInstance2 .setName(nameInstance6); } JsonNode unitValue2 = reportedImpactValue .get("unit"); if (unitValue2 != null && unitValue2 instanceof NullNode == false) { String unitInstance2; unitInstance2 = unitValue2.getTextValue(); operationImpactInstance2 .setUnit(unitInstance2); } JsonNode changeValueAbsoluteValue2 = reportedImpactValue .get("changeValueAbsolute"); if (changeValueAbsoluteValue2 != null && changeValueAbsoluteValue2 instanceof NullNode == false) { double changeValueAbsoluteInstance2; changeValueAbsoluteInstance2 = changeValueAbsoluteValue2 .getDoubleValue(); operationImpactInstance2 .setChangeValueAbsolute( changeValueAbsoluteInstance2); } JsonNode changeValueRelativeValue2 = reportedImpactValue .get("changeValueRelative"); if (changeValueRelativeValue2 != null && changeValueRelativeValue2 instanceof NullNode == false) { double changeValueRelativeInstance2; changeValueRelativeInstance2 = changeValueRelativeValue2 .getDoubleValue(); operationImpactInstance2 .setChangeValueRelative( changeValueRelativeInstance2); } } } } JsonNode idValue5 = recommendedIndexesValue.get("id"); if (idValue5 != null && idValue5 instanceof NullNode == false) { String idInstance5; idInstance5 = idValue5.getTextValue(); recommendedIndexInstance.setId(idInstance5); } JsonNode nameValue7 = recommendedIndexesValue.get("name"); if (nameValue7 != null && nameValue7 instanceof NullNode == false) { String nameInstance7; nameInstance7 = nameValue7.getTextValue(); recommendedIndexInstance.setName(nameInstance7); } JsonNode typeValue5 = recommendedIndexesValue.get("type"); if (typeValue5 != null && typeValue5 instanceof NullNode == false) { String typeInstance5; typeInstance5 = typeValue5.getTextValue(); recommendedIndexInstance.setType(typeInstance5); } JsonNode locationValue5 = recommendedIndexesValue .get("location"); if (locationValue5 != null && locationValue5 instanceof NullNode == false) { String locationInstance5; locationInstance5 = locationValue5.getTextValue(); recommendedIndexInstance.setLocation(locationInstance5); } JsonNode tagsSequenceElement5 = ((JsonNode) recommendedIndexesValue .get("tags")); if (tagsSequenceElement5 != null && tagsSequenceElement5 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr5 = tagsSequenceElement5 .getFields(); while (itr5.hasNext()) { Map.Entry<String, JsonNode> property5 = itr5.next(); String tagsKey5 = property5.getKey(); String tagsValue5 = property5.getValue() .getTextValue(); recommendedIndexInstance.getTags().put(tagsKey5, tagsValue5); } } } } } JsonNode idValue6 = tablesValue.get("id"); if (idValue6 != null && idValue6 instanceof NullNode == false) { String idInstance6; idInstance6 = idValue6.getTextValue(); tableInstance.setId(idInstance6); } JsonNode nameValue8 = tablesValue.get("name"); if (nameValue8 != null && nameValue8 instanceof NullNode == false) { String nameInstance8; nameInstance8 = nameValue8.getTextValue(); tableInstance.setName(nameInstance8); } JsonNode typeValue6 = tablesValue.get("type"); if (typeValue6 != null && typeValue6 instanceof NullNode == false) { String typeInstance6; typeInstance6 = typeValue6.getTextValue(); tableInstance.setType(typeInstance6); } JsonNode locationValue6 = tablesValue.get("location"); if (locationValue6 != null && locationValue6 instanceof NullNode == false) { String locationInstance6; locationInstance6 = locationValue6.getTextValue(); tableInstance.setLocation(locationInstance6); } JsonNode tagsSequenceElement6 = ((JsonNode) tablesValue.get("tags")); if (tagsSequenceElement6 != null && tagsSequenceElement6 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr6 = tagsSequenceElement6 .getFields(); while (itr6.hasNext()) { Map.Entry<String, JsonNode> property6 = itr6.next(); String tagsKey6 = property6.getKey(); String tagsValue6 = property6.getValue().getTextValue(); tableInstance.getTags().put(tagsKey6, tagsValue6); } } } } } JsonNode idValue7 = schemasValue.get("id"); if (idValue7 != null && idValue7 instanceof NullNode == false) { String idInstance7; idInstance7 = idValue7.getTextValue(); schemaInstance.setId(idInstance7); } JsonNode nameValue9 = schemasValue.get("name"); if (nameValue9 != null && nameValue9 instanceof NullNode == false) { String nameInstance9; nameInstance9 = nameValue9.getTextValue(); schemaInstance.setName(nameInstance9); } JsonNode typeValue7 = schemasValue.get("type"); if (typeValue7 != null && typeValue7 instanceof NullNode == false) { String typeInstance7; typeInstance7 = typeValue7.getTextValue(); schemaInstance.setType(typeInstance7); } JsonNode locationValue7 = schemasValue.get("location"); if (locationValue7 != null && locationValue7 instanceof NullNode == false) { String locationInstance7; locationInstance7 = locationValue7.getTextValue(); schemaInstance.setLocation(locationInstance7); } JsonNode tagsSequenceElement7 = ((JsonNode) schemasValue.get("tags")); if (tagsSequenceElement7 != null && tagsSequenceElement7 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr7 = tagsSequenceElement7.getFields(); while (itr7.hasNext()) { Map.Entry<String, JsonNode> property7 = itr7.next(); String tagsKey7 = property7.getKey(); String tagsValue7 = property7.getValue().getTextValue(); schemaInstance.getTags().put(tagsKey7, tagsValue7); } } } } JsonNode defaultSecondaryLocationValue = propertiesValue.get("defaultSecondaryLocation"); if (defaultSecondaryLocationValue != null && defaultSecondaryLocationValue instanceof NullNode == false) { String defaultSecondaryLocationInstance; defaultSecondaryLocationInstance = defaultSecondaryLocationValue.getTextValue(); propertiesInstance.setDefaultSecondaryLocation(defaultSecondaryLocationInstance); } } JsonNode idValue8 = responseDoc.get("id"); if (idValue8 != null && idValue8 instanceof NullNode == false) { String idInstance8; idInstance8 = idValue8.getTextValue(); databaseInstance.setId(idInstance8); } JsonNode nameValue10 = responseDoc.get("name"); if (nameValue10 != null && nameValue10 instanceof NullNode == false) { String nameInstance10; nameInstance10 = nameValue10.getTextValue(); databaseInstance.setName(nameInstance10); } JsonNode typeValue8 = responseDoc.get("type"); if (typeValue8 != null && typeValue8 instanceof NullNode == false) { String typeInstance8; typeInstance8 = typeValue8.getTextValue(); databaseInstance.setType(typeInstance8); } JsonNode locationValue8 = responseDoc.get("location"); if (locationValue8 != null && locationValue8 instanceof NullNode == false) { String locationInstance8; locationInstance8 = locationValue8.getTextValue(); databaseInstance.setLocation(locationInstance8); } JsonNode tagsSequenceElement8 = ((JsonNode) responseDoc.get("tags")); if (tagsSequenceElement8 != null && tagsSequenceElement8 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr8 = tagsSequenceElement8.getFields(); while (itr8.hasNext()) { Map.Entry<String, JsonNode> property8 = itr8.next(); String tagsKey8 = property8.getKey(); String tagsValue8 = property8.getValue().getTextValue(); databaseInstance.getTags().put(tagsKey8, tagsValue8); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("Location").length > 0) { result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue()); } if (httpResponse.getHeaders("Retry-After").length > 0) { result.setRetryAfter( DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue())); } if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (statusCode == HttpStatus.SC_OK) { result.setStatus(OperationStatus.Succeeded); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.network.VirtualNetworkGatewayConnectionOperationsImpl.java
/** * The VirtualNetworkGatewayConnectionResetSharedKey operation resets 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 ava 2 s . co m*/ * * @param resourceGroupName Required. The name of the resource group. * @param virtualNetworkGatewayConnectionName Required. The virtual network * gateway connection reset shared key Name. * @param parameters Required. Parameters supplied to the Begin Reset * Virtual Network Gateway connection shared key operation through Network * 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 PutVirtualNetworkGatewayConnectionResetSharedKey Api * servive call */ @Override public ConnectionResetSharedKeyPutResponse beginResetSharedKey(String resourceGroupName, String virtualNetworkGatewayConnectionName, ConnectionResetSharedKey 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, "beginResetSharedKeyAsync", 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/reset"; 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"); // Serialize Request String requestContent = null; JsonNode requestDoc = null; ObjectMapper objectMapper = new ObjectMapper(); ObjectNode connectionResetSharedKeyJsonFormatValue = objectMapper.createObjectNode(); requestDoc = connectionResetSharedKeyJsonFormatValue; ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) connectionResetSharedKeyJsonFormatValue).put("properties", propertiesValue); ((ObjectNode) propertiesValue).put("keyLength", parameters.getKeyLength()); 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_ACCEPTED) { ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result ConnectionResetSharedKeyPutResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_ACCEPTED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ConnectionResetSharedKeyPutResponse(); 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) { ConnectionResetSharedKey connectionResetSharedKeyInstance = new ConnectionResetSharedKey(); result.setConnectionResetSharedKey(connectionResetSharedKeyInstance); JsonNode propertiesValue2 = responseDoc.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { JsonNode keyLengthValue = propertiesValue2.get("keyLength"); if (keyLengthValue != null && keyLengthValue instanceof NullNode == false) { long keyLengthInstance; keyLengthInstance = keyLengthValue.getLongValue(); connectionResetSharedKeyInstance.setKeyLength(keyLengthInstance); } } 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.windowsazure.management.compute.VirtualMachineVMImageOperationsImpl.java
/** * The List Virtual Machine Images operation retrieves a list of the virtual * machine images.// w w w . j a va 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. * @throws ParserConfigurationException Thrown if there was a serious * configuration error with the document parser. * @throws SAXException Thrown if there was an error parsing the XML * response. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The List VM Images operation response. */ @Override public VirtualMachineVMImageListResponse list() throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException { // Validate // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); CloudTracing.enter(invocationId, this, "listAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/services/vmimages"; String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("x-ms-version", "2015-04-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result VirtualMachineVMImageListResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new VirtualMachineVMImageListResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element vMImagesSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "VMImages"); if (vMImagesSequenceElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(vMImagesSequenceElement, "http://schemas.microsoft.com/windowsazure", "VMImage") .size(); i1 = i1 + 1) { org.w3c.dom.Element vMImagesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(vMImagesSequenceElement, "http://schemas.microsoft.com/windowsazure", "VMImage") .get(i1)); VirtualMachineVMImageListResponse.VirtualMachineVMImage vMImageInstance = new VirtualMachineVMImageListResponse.VirtualMachineVMImage(); result.getVMImages().add(vMImageInstance); Element nameElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement != null) { String nameInstance; nameInstance = nameElement.getTextContent(); vMImageInstance.setName(nameInstance); } Element labelElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Label"); if (labelElement != null) { String labelInstance; labelInstance = labelElement.getTextContent(); vMImageInstance.setLabel(labelInstance); } Element categoryElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Category"); if (categoryElement != null) { String categoryInstance; categoryInstance = categoryElement.getTextContent(); vMImageInstance.setCategory(categoryInstance); } Element descriptionElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Description"); if (descriptionElement != null) { String descriptionInstance; descriptionInstance = descriptionElement.getTextContent(); vMImageInstance.setDescription(descriptionInstance); } Element oSDiskConfigurationElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "OSDiskConfiguration"); if (oSDiskConfigurationElement != null) { VirtualMachineVMImageListResponse.OSDiskConfiguration oSDiskConfigurationInstance = new VirtualMachineVMImageListResponse.OSDiskConfiguration(); vMImageInstance.setOSDiskConfiguration(oSDiskConfigurationInstance); Element nameElement2 = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement2 != null) { String nameInstance2; nameInstance2 = nameElement2.getTextContent(); oSDiskConfigurationInstance.setName(nameInstance2); } Element hostCachingElement = XmlUtility.getElementByTagNameNS( oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "HostCaching"); if (hostCachingElement != null) { String hostCachingInstance; hostCachingInstance = hostCachingElement.getTextContent(); oSDiskConfigurationInstance.setHostCaching(hostCachingInstance); } Element oSStateElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "OSState"); if (oSStateElement != null) { String oSStateInstance; oSStateInstance = oSStateElement.getTextContent(); oSDiskConfigurationInstance.setOSState(oSStateInstance); } Element osElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "OS"); if (osElement != null) { String osInstance; osInstance = osElement.getTextContent(); oSDiskConfigurationInstance.setOperatingSystem(osInstance); } Element mediaLinkElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "MediaLink"); if (mediaLinkElement != null) { URI mediaLinkInstance; mediaLinkInstance = new URI(mediaLinkElement.getTextContent()); oSDiskConfigurationInstance.setMediaLink(mediaLinkInstance); } Element logicalDiskSizeInGBElement = XmlUtility.getElementByTagNameNS( oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "LogicalDiskSizeInGB"); if (logicalDiskSizeInGBElement != null) { int logicalDiskSizeInGBInstance; logicalDiskSizeInGBInstance = DatatypeConverter .parseInt(logicalDiskSizeInGBElement.getTextContent()); oSDiskConfigurationInstance.setLogicalDiskSizeInGB(logicalDiskSizeInGBInstance); } Element iOTypeElement = XmlUtility.getElementByTagNameNS(oSDiskConfigurationElement, "http://schemas.microsoft.com/windowsazure", "IOType"); if (iOTypeElement != null) { String iOTypeInstance; iOTypeInstance = iOTypeElement.getTextContent(); oSDiskConfigurationInstance.setIOType(iOTypeInstance); } } Element dataDiskConfigurationsSequenceElement = XmlUtility.getElementByTagNameNS( vMImagesElement, "http://schemas.microsoft.com/windowsazure", "DataDiskConfigurations"); if (dataDiskConfigurationsSequenceElement != null) { for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(dataDiskConfigurationsSequenceElement, "http://schemas.microsoft.com/windowsazure", "DataDiskConfiguration") .size(); i2 = i2 + 1) { org.w3c.dom.Element dataDiskConfigurationsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(dataDiskConfigurationsSequenceElement, "http://schemas.microsoft.com/windowsazure", "DataDiskConfiguration") .get(i2)); VirtualMachineVMImageListResponse.DataDiskConfiguration dataDiskConfigurationInstance = new VirtualMachineVMImageListResponse.DataDiskConfiguration(); vMImageInstance.getDataDiskConfigurations().add(dataDiskConfigurationInstance); Element nameElement3 = XmlUtility.getElementByTagNameNS( dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement3 != null) { String nameInstance3; nameInstance3 = nameElement3.getTextContent(); dataDiskConfigurationInstance.setName(nameInstance3); } Element hostCachingElement2 = XmlUtility.getElementByTagNameNS( dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure", "HostCaching"); if (hostCachingElement2 != null) { String hostCachingInstance2; hostCachingInstance2 = hostCachingElement2.getTextContent(); dataDiskConfigurationInstance.setHostCaching(hostCachingInstance2); } Element lunElement = XmlUtility.getElementByTagNameNS(dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure", "Lun"); if (lunElement != null && lunElement.getTextContent() != null && !lunElement.getTextContent().isEmpty()) { int lunInstance; lunInstance = DatatypeConverter.parseInt(lunElement.getTextContent()); dataDiskConfigurationInstance.setLogicalUnitNumber(lunInstance); } Element mediaLinkElement2 = XmlUtility.getElementByTagNameNS( dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure", "MediaLink"); if (mediaLinkElement2 != null) { URI mediaLinkInstance2; mediaLinkInstance2 = new URI(mediaLinkElement2.getTextContent()); dataDiskConfigurationInstance.setMediaLink(mediaLinkInstance2); } Element logicalDiskSizeInGBElement2 = XmlUtility.getElementByTagNameNS( dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure", "LogicalDiskSizeInGB"); if (logicalDiskSizeInGBElement2 != null) { int logicalDiskSizeInGBInstance2; logicalDiskSizeInGBInstance2 = DatatypeConverter .parseInt(logicalDiskSizeInGBElement2.getTextContent()); dataDiskConfigurationInstance .setLogicalDiskSizeInGB(logicalDiskSizeInGBInstance2); } Element iOTypeElement2 = XmlUtility.getElementByTagNameNS( dataDiskConfigurationsElement, "http://schemas.microsoft.com/windowsazure", "IOType"); if (iOTypeElement2 != null) { String iOTypeInstance2; iOTypeInstance2 = iOTypeElement2.getTextContent(); dataDiskConfigurationInstance.setIOType(iOTypeInstance2); } } } Element serviceNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "ServiceName"); if (serviceNameElement != null) { String serviceNameInstance; serviceNameInstance = serviceNameElement.getTextContent(); vMImageInstance.setServiceName(serviceNameInstance); } Element deploymentNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "DeploymentName"); if (deploymentNameElement != null) { String deploymentNameInstance; deploymentNameInstance = deploymentNameElement.getTextContent(); vMImageInstance.setDeploymentName(deploymentNameInstance); } Element roleNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "RoleName"); if (roleNameElement != null) { String roleNameInstance; roleNameInstance = roleNameElement.getTextContent(); vMImageInstance.setRoleName(roleNameInstance); } Element affinityGroupElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "AffinityGroup"); if (affinityGroupElement != null) { String affinityGroupInstance; affinityGroupInstance = affinityGroupElement.getTextContent(); vMImageInstance.setAffinityGroup(affinityGroupInstance); } Element locationElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Location"); if (locationElement != null) { String locationInstance; locationInstance = locationElement.getTextContent(); vMImageInstance.setLocation(locationInstance); } Element createdTimeElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "CreatedTime"); if (createdTimeElement != null && createdTimeElement.getTextContent() != null && !createdTimeElement.getTextContent().isEmpty()) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter .parseDateTime(createdTimeElement.getTextContent()); vMImageInstance.setCreatedTime(createdTimeInstance); } Element modifiedTimeElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "ModifiedTime"); if (modifiedTimeElement != null && modifiedTimeElement.getTextContent() != null && !modifiedTimeElement.getTextContent().isEmpty()) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeElement.getTextContent()); vMImageInstance.setModifiedTime(modifiedTimeInstance); } Element languageElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Language"); if (languageElement != null) { String languageInstance; languageInstance = languageElement.getTextContent(); vMImageInstance.setLanguage(languageInstance); } Element imageFamilyElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "ImageFamily"); if (imageFamilyElement != null) { String imageFamilyInstance; imageFamilyInstance = imageFamilyElement.getTextContent(); vMImageInstance.setImageFamily(imageFamilyInstance); } Element recommendedVMSizeElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "RecommendedVMSize"); if (recommendedVMSizeElement != null) { String recommendedVMSizeInstance; recommendedVMSizeInstance = recommendedVMSizeElement.getTextContent(); vMImageInstance.setRecommendedVMSize(recommendedVMSizeInstance); } Element isPremiumElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "IsPremium"); if (isPremiumElement != null && isPremiumElement.getTextContent() != null && !isPremiumElement.getTextContent().isEmpty()) { boolean isPremiumInstance; isPremiumInstance = DatatypeConverter .parseBoolean(isPremiumElement.getTextContent().toLowerCase()); vMImageInstance.setIsPremium(isPremiumInstance); } Element eulaElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "Eula"); if (eulaElement != null) { String eulaInstance; eulaInstance = eulaElement.getTextContent(); vMImageInstance.setEula(eulaInstance); } Element iconUriElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "IconUri"); if (iconUriElement != null) { String iconUriInstance; iconUriInstance = iconUriElement.getTextContent(); vMImageInstance.setIconUri(iconUriInstance); } Element smallIconUriElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "SmallIconUri"); if (smallIconUriElement != null) { String smallIconUriInstance; smallIconUriInstance = smallIconUriElement.getTextContent(); vMImageInstance.setSmallIconUri(smallIconUriInstance); } Element privacyUriElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "PrivacyUri"); if (privacyUriElement != null) { URI privacyUriInstance; privacyUriInstance = new URI(privacyUriElement.getTextContent()); vMImageInstance.setPrivacyUri(privacyUriInstance); } Element publisherNameElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "PublisherName"); if (publisherNameElement != null) { String publisherNameInstance; publisherNameInstance = publisherNameElement.getTextContent(); vMImageInstance.setPublisherName(publisherNameInstance); } Element publishedDateElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "PublishedDate"); if (publishedDateElement != null && publishedDateElement.getTextContent() != null && !publishedDateElement.getTextContent().isEmpty()) { Calendar publishedDateInstance; publishedDateInstance = DatatypeConverter .parseDateTime(publishedDateElement.getTextContent()); vMImageInstance.setPublishedDate(publishedDateInstance); } Element showInGuiElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "ShowInGui"); if (showInGuiElement != null && showInGuiElement.getTextContent() != null && !showInGuiElement.getTextContent().isEmpty()) { boolean showInGuiInstance; showInGuiInstance = DatatypeConverter .parseBoolean(showInGuiElement.getTextContent().toLowerCase()); vMImageInstance.setShowInGui(showInGuiInstance); } Element pricingDetailLinkElement = XmlUtility.getElementByTagNameNS(vMImagesElement, "http://schemas.microsoft.com/windowsazure", "PricingDetailLink"); if (pricingDetailLinkElement != null) { URI pricingDetailLinkInstance; pricingDetailLinkInstance = new URI(pricingDetailLinkElement.getTextContent()); vMImageInstance.setPricingDetailLink(pricingDetailLinkInstance); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.network.ApplicationGatewayOperationsImpl.java
/** * The Put ApplicationGateway operation creates/updates a ApplicationGateway * * @param resourceGroupName Required. The name of the resource group. * @param applicationGatewayName Required. The name of the * ApplicationGateway.//from w w w . java 2 s .c om * @param parameters Required. Parameters supplied to the create/delete * ApplicationGateway operation * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Response of Put ApplicationGateway operation */ @Override public ApplicationGatewayPutResponse beginCreateOrUpdating(String resourceGroupName, String applicationGatewayName, ApplicationGateway parameters) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (applicationGatewayName == null) { throw new NullPointerException("applicationGatewayName"); } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getLocation() == null) { throw new NullPointerException("parameters.Location"); } // 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); 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 + "/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 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 applicationGatewayJsonFormatValue = objectMapper.createObjectNode(); requestDoc = applicationGatewayJsonFormatValue; ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayJsonFormatValue).put("properties", propertiesValue); if (parameters.getSku() != null) { ObjectNode skuValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("sku", skuValue); if (parameters.getSku().getName() != null) { ((ObjectNode) skuValue).put("name", parameters.getSku().getName()); } if (parameters.getSku().getTier() != null) { ((ObjectNode) skuValue).put("tier", parameters.getSku().getTier()); } ((ObjectNode) skuValue).put("capacity", parameters.getSku().getCapacity()); } if (parameters.getOperationalState() != null) { ((ObjectNode) propertiesValue).put("operationalState", parameters.getOperationalState()); } if (parameters.getGatewayIPConfigurations() != null) { if (parameters.getGatewayIPConfigurations() instanceof LazyCollection == false || ((LazyCollection) parameters.getGatewayIPConfigurations()).isInitialized()) { ArrayNode gatewayIPConfigurationsArray = objectMapper.createArrayNode(); for (ApplicationGatewayIPConfiguration gatewayIPConfigurationsItem : parameters .getGatewayIPConfigurations()) { ObjectNode applicationGatewayIPConfigurationJsonFormatValue = objectMapper.createObjectNode(); gatewayIPConfigurationsArray.add(applicationGatewayIPConfigurationJsonFormatValue); ObjectNode propertiesValue2 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayIPConfigurationJsonFormatValue).put("properties", propertiesValue2); if (gatewayIPConfigurationsItem.getSubnet() != null) { ObjectNode subnetValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue2).put("subnet", subnetValue); if (gatewayIPConfigurationsItem.getSubnet().getId() != null) { ((ObjectNode) subnetValue).put("id", gatewayIPConfigurationsItem.getSubnet().getId()); } } if (gatewayIPConfigurationsItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue2).put("provisioningState", gatewayIPConfigurationsItem.getProvisioningState()); } if (gatewayIPConfigurationsItem.getName() != null) { ((ObjectNode) applicationGatewayIPConfigurationJsonFormatValue).put("name", gatewayIPConfigurationsItem.getName()); } if (gatewayIPConfigurationsItem.getEtag() != null) { ((ObjectNode) applicationGatewayIPConfigurationJsonFormatValue).put("etag", gatewayIPConfigurationsItem.getEtag()); } if (gatewayIPConfigurationsItem.getId() != null) { ((ObjectNode) applicationGatewayIPConfigurationJsonFormatValue).put("id", gatewayIPConfigurationsItem.getId()); } } ((ObjectNode) propertiesValue).put("gatewayIPConfigurations", gatewayIPConfigurationsArray); } } if (parameters.getSslCertificates() != null) { if (parameters.getSslCertificates() instanceof LazyCollection == false || ((LazyCollection) parameters.getSslCertificates()).isInitialized()) { ArrayNode sslCertificatesArray = objectMapper.createArrayNode(); for (ApplicationGatewaySslCertificate sslCertificatesItem : parameters.getSslCertificates()) { ObjectNode applicationGatewaySslCertificateJsonFormatValue = objectMapper.createObjectNode(); sslCertificatesArray.add(applicationGatewaySslCertificateJsonFormatValue); ObjectNode propertiesValue3 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewaySslCertificateJsonFormatValue).put("properties", propertiesValue3); if (sslCertificatesItem.getData() != null) { ((ObjectNode) propertiesValue3).put("data", sslCertificatesItem.getData()); } if (sslCertificatesItem.getPassword() != null) { ((ObjectNode) propertiesValue3).put("password", sslCertificatesItem.getPassword()); } if (sslCertificatesItem.getPublicCertData() != null) { ((ObjectNode) propertiesValue3).put("publicCertData", sslCertificatesItem.getPublicCertData()); } if (sslCertificatesItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue3).put("provisioningState", sslCertificatesItem.getProvisioningState()); } if (sslCertificatesItem.getName() != null) { ((ObjectNode) applicationGatewaySslCertificateJsonFormatValue).put("name", sslCertificatesItem.getName()); } if (sslCertificatesItem.getEtag() != null) { ((ObjectNode) applicationGatewaySslCertificateJsonFormatValue).put("etag", sslCertificatesItem.getEtag()); } if (sslCertificatesItem.getId() != null) { ((ObjectNode) applicationGatewaySslCertificateJsonFormatValue).put("id", sslCertificatesItem.getId()); } } ((ObjectNode) propertiesValue).put("sslCertificates", sslCertificatesArray); } } if (parameters.getFrontendIPConfigurations() != null) { if (parameters.getFrontendIPConfigurations() instanceof LazyCollection == false || ((LazyCollection) parameters.getFrontendIPConfigurations()).isInitialized()) { ArrayNode frontendIPConfigurationsArray = objectMapper.createArrayNode(); for (ApplicationGatewayFrontendIPConfiguration frontendIPConfigurationsItem : parameters .getFrontendIPConfigurations()) { ObjectNode applicationGatewayFrontendIPConfigurationJsonFormatValue = objectMapper .createObjectNode(); frontendIPConfigurationsArray.add(applicationGatewayFrontendIPConfigurationJsonFormatValue); ObjectNode propertiesValue4 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayFrontendIPConfigurationJsonFormatValue).put("properties", propertiesValue4); if (frontendIPConfigurationsItem.getPrivateIPAddress() != null) { ((ObjectNode) propertiesValue4).put("privateIPAddress", frontendIPConfigurationsItem.getPrivateIPAddress()); } if (frontendIPConfigurationsItem.getPrivateIPAllocationMethod() != null) { ((ObjectNode) propertiesValue4).put("privateIPAllocationMethod", frontendIPConfigurationsItem.getPrivateIPAllocationMethod()); } if (frontendIPConfigurationsItem.getSubnet() != null) { ObjectNode subnetValue2 = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue4).put("subnet", subnetValue2); if (frontendIPConfigurationsItem.getSubnet().getId() != null) { ((ObjectNode) subnetValue2).put("id", frontendIPConfigurationsItem.getSubnet().getId()); } } if (frontendIPConfigurationsItem.getPublicIPAddress() != null) { ObjectNode publicIPAddressValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue4).put("publicIPAddress", publicIPAddressValue); if (frontendIPConfigurationsItem.getPublicIPAddress().getId() != null) { ((ObjectNode) publicIPAddressValue).put("id", frontendIPConfigurationsItem.getPublicIPAddress().getId()); } } if (frontendIPConfigurationsItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue4).put("provisioningState", frontendIPConfigurationsItem.getProvisioningState()); } if (frontendIPConfigurationsItem.getName() != null) { ((ObjectNode) applicationGatewayFrontendIPConfigurationJsonFormatValue).put("name", frontendIPConfigurationsItem.getName()); } if (frontendIPConfigurationsItem.getEtag() != null) { ((ObjectNode) applicationGatewayFrontendIPConfigurationJsonFormatValue).put("etag", frontendIPConfigurationsItem.getEtag()); } if (frontendIPConfigurationsItem.getId() != null) { ((ObjectNode) applicationGatewayFrontendIPConfigurationJsonFormatValue).put("id", frontendIPConfigurationsItem.getId()); } } ((ObjectNode) propertiesValue).put("frontendIPConfigurations", frontendIPConfigurationsArray); } } if (parameters.getFrontendPorts() != null) { if (parameters.getFrontendPorts() instanceof LazyCollection == false || ((LazyCollection) parameters.getFrontendPorts()).isInitialized()) { ArrayNode frontendPortsArray = objectMapper.createArrayNode(); for (ApplicationGatewayFrontendPort frontendPortsItem : parameters.getFrontendPorts()) { ObjectNode applicationGatewayFrontendPortJsonFormatValue = objectMapper.createObjectNode(); frontendPortsArray.add(applicationGatewayFrontendPortJsonFormatValue); ObjectNode propertiesValue5 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayFrontendPortJsonFormatValue).put("properties", propertiesValue5); ((ObjectNode) propertiesValue5).put("port", frontendPortsItem.getPort()); if (frontendPortsItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue5).put("provisioningState", frontendPortsItem.getProvisioningState()); } if (frontendPortsItem.getName() != null) { ((ObjectNode) applicationGatewayFrontendPortJsonFormatValue).put("name", frontendPortsItem.getName()); } if (frontendPortsItem.getEtag() != null) { ((ObjectNode) applicationGatewayFrontendPortJsonFormatValue).put("etag", frontendPortsItem.getEtag()); } if (frontendPortsItem.getId() != null) { ((ObjectNode) applicationGatewayFrontendPortJsonFormatValue).put("id", frontendPortsItem.getId()); } } ((ObjectNode) propertiesValue).put("frontendPorts", frontendPortsArray); } } if (parameters.getBackendAddressPools() != null) { if (parameters.getBackendAddressPools() instanceof LazyCollection == false || ((LazyCollection) parameters.getBackendAddressPools()).isInitialized()) { ArrayNode backendAddressPoolsArray = objectMapper.createArrayNode(); for (ApplicationGatewayBackendAddressPool backendAddressPoolsItem : parameters .getBackendAddressPools()) { ObjectNode applicationGatewayBackendAddressPoolJsonFormatValue = objectMapper .createObjectNode(); backendAddressPoolsArray.add(applicationGatewayBackendAddressPoolJsonFormatValue); ObjectNode propertiesValue6 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayBackendAddressPoolJsonFormatValue).put("properties", propertiesValue6); if (backendAddressPoolsItem.getBackendIPConfigurations() != null) { if (backendAddressPoolsItem.getBackendIPConfigurations() instanceof LazyCollection == false || ((LazyCollection) backendAddressPoolsItem.getBackendIPConfigurations()) .isInitialized()) { ArrayNode backendIPConfigurationsArray = objectMapper.createArrayNode(); for (ResourceId backendIPConfigurationsItem : backendAddressPoolsItem .getBackendIPConfigurations()) { ObjectNode resourceIdValue = objectMapper.createObjectNode(); backendIPConfigurationsArray.add(resourceIdValue); if (backendIPConfigurationsItem.getId() != null) { ((ObjectNode) resourceIdValue).put("id", backendIPConfigurationsItem.getId()); } } ((ObjectNode) propertiesValue6).put("backendIPConfigurations", backendIPConfigurationsArray); } } if (backendAddressPoolsItem.getBackendAddresses() != null) { if (backendAddressPoolsItem.getBackendAddresses() instanceof LazyCollection == false || ((LazyCollection) backendAddressPoolsItem.getBackendAddresses()) .isInitialized()) { ArrayNode backendAddressesArray = objectMapper.createArrayNode(); for (ApplicationGatewayBackendAddress backendAddressesItem : backendAddressPoolsItem .getBackendAddresses()) { ObjectNode applicationGatewayBackendAddressValue = objectMapper.createObjectNode(); backendAddressesArray.add(applicationGatewayBackendAddressValue); if (backendAddressesItem.getFqdn() != null) { ((ObjectNode) applicationGatewayBackendAddressValue).put("fqdn", backendAddressesItem.getFqdn()); } if (backendAddressesItem.getIpAddress() != null) { ((ObjectNode) applicationGatewayBackendAddressValue).put("ipAddress", backendAddressesItem.getIpAddress()); } } ((ObjectNode) propertiesValue6).put("backendAddresses", backendAddressesArray); } } if (backendAddressPoolsItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue6).put("provisioningState", backendAddressPoolsItem.getProvisioningState()); } if (backendAddressPoolsItem.getName() != null) { ((ObjectNode) applicationGatewayBackendAddressPoolJsonFormatValue).put("name", backendAddressPoolsItem.getName()); } if (backendAddressPoolsItem.getEtag() != null) { ((ObjectNode) applicationGatewayBackendAddressPoolJsonFormatValue).put("etag", backendAddressPoolsItem.getEtag()); } if (backendAddressPoolsItem.getId() != null) { ((ObjectNode) applicationGatewayBackendAddressPoolJsonFormatValue).put("id", backendAddressPoolsItem.getId()); } } ((ObjectNode) propertiesValue).put("backendAddressPools", backendAddressPoolsArray); } } if (parameters.getBackendHttpSettingsCollection() != null) { if (parameters.getBackendHttpSettingsCollection() instanceof LazyCollection == false || ((LazyCollection) parameters.getBackendHttpSettingsCollection()).isInitialized()) { ArrayNode backendHttpSettingsCollectionArray = objectMapper.createArrayNode(); for (ApplicationGatewayBackendHttpSettings backendHttpSettingsCollectionItem : parameters .getBackendHttpSettingsCollection()) { ObjectNode applicationGatewayBackendHttpSettingsJsonFormatValue = objectMapper .createObjectNode(); backendHttpSettingsCollectionArray.add(applicationGatewayBackendHttpSettingsJsonFormatValue); ObjectNode propertiesValue7 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayBackendHttpSettingsJsonFormatValue).put("properties", propertiesValue7); ((ObjectNode) propertiesValue7).put("port", backendHttpSettingsCollectionItem.getPort()); if (backendHttpSettingsCollectionItem.getProtocol() != null) { ((ObjectNode) propertiesValue7).put("protocol", backendHttpSettingsCollectionItem.getProtocol()); } if (backendHttpSettingsCollectionItem.getCookieBasedAffinity() != null) { ((ObjectNode) propertiesValue7).put("cookieBasedAffinity", backendHttpSettingsCollectionItem.getCookieBasedAffinity()); } if (backendHttpSettingsCollectionItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue7).put("provisioningState", backendHttpSettingsCollectionItem.getProvisioningState()); } if (backendHttpSettingsCollectionItem.getName() != null) { ((ObjectNode) applicationGatewayBackendHttpSettingsJsonFormatValue).put("name", backendHttpSettingsCollectionItem.getName()); } if (backendHttpSettingsCollectionItem.getEtag() != null) { ((ObjectNode) applicationGatewayBackendHttpSettingsJsonFormatValue).put("etag", backendHttpSettingsCollectionItem.getEtag()); } if (backendHttpSettingsCollectionItem.getId() != null) { ((ObjectNode) applicationGatewayBackendHttpSettingsJsonFormatValue).put("id", backendHttpSettingsCollectionItem.getId()); } } ((ObjectNode) propertiesValue).put("backendHttpSettingsCollection", backendHttpSettingsCollectionArray); } } if (parameters.getHttpListeners() != null) { if (parameters.getHttpListeners() instanceof LazyCollection == false || ((LazyCollection) parameters.getHttpListeners()).isInitialized()) { ArrayNode httpListenersArray = objectMapper.createArrayNode(); for (ApplicationGatewayHttpListener httpListenersItem : parameters.getHttpListeners()) { ObjectNode applicationGatewayHttpListenerJsonFormatValue = objectMapper.createObjectNode(); httpListenersArray.add(applicationGatewayHttpListenerJsonFormatValue); ObjectNode propertiesValue8 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayHttpListenerJsonFormatValue).put("properties", propertiesValue8); if (httpListenersItem.getFrontendIPConfiguration() != null) { ObjectNode frontendIPConfigurationValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue8).put("frontendIPConfiguration", frontendIPConfigurationValue); if (httpListenersItem.getFrontendIPConfiguration().getId() != null) { ((ObjectNode) frontendIPConfigurationValue).put("id", httpListenersItem.getFrontendIPConfiguration().getId()); } } if (httpListenersItem.getFrontendPort() != null) { ObjectNode frontendPortValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue8).put("frontendPort", frontendPortValue); if (httpListenersItem.getFrontendPort().getId() != null) { ((ObjectNode) frontendPortValue).put("id", httpListenersItem.getFrontendPort().getId()); } } if (httpListenersItem.getProtocol() != null) { ((ObjectNode) propertiesValue8).put("protocol", httpListenersItem.getProtocol()); } if (httpListenersItem.getSslCertificate() != null) { ObjectNode sslCertificateValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue8).put("sslCertificate", sslCertificateValue); if (httpListenersItem.getSslCertificate().getId() != null) { ((ObjectNode) sslCertificateValue).put("id", httpListenersItem.getSslCertificate().getId()); } } if (httpListenersItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue8).put("provisioningState", httpListenersItem.getProvisioningState()); } if (httpListenersItem.getName() != null) { ((ObjectNode) applicationGatewayHttpListenerJsonFormatValue).put("name", httpListenersItem.getName()); } if (httpListenersItem.getEtag() != null) { ((ObjectNode) applicationGatewayHttpListenerJsonFormatValue).put("etag", httpListenersItem.getEtag()); } if (httpListenersItem.getId() != null) { ((ObjectNode) applicationGatewayHttpListenerJsonFormatValue).put("id", httpListenersItem.getId()); } } ((ObjectNode) propertiesValue).put("httpListeners", httpListenersArray); } } if (parameters.getRequestRoutingRules() != null) { if (parameters.getRequestRoutingRules() instanceof LazyCollection == false || ((LazyCollection) parameters.getRequestRoutingRules()).isInitialized()) { ArrayNode requestRoutingRulesArray = objectMapper.createArrayNode(); for (ApplicationGatewayRequestRoutingRule requestRoutingRulesItem : parameters .getRequestRoutingRules()) { ObjectNode applicationGatewayRequestRoutingRuleJsonFormatValue = objectMapper .createObjectNode(); requestRoutingRulesArray.add(applicationGatewayRequestRoutingRuleJsonFormatValue); ObjectNode propertiesValue9 = objectMapper.createObjectNode(); ((ObjectNode) applicationGatewayRequestRoutingRuleJsonFormatValue).put("properties", propertiesValue9); if (requestRoutingRulesItem.getRuleType() != null) { ((ObjectNode) propertiesValue9).put("ruleType", requestRoutingRulesItem.getRuleType()); } if (requestRoutingRulesItem.getBackendAddressPool() != null) { ObjectNode backendAddressPoolValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue9).put("backendAddressPool", backendAddressPoolValue); if (requestRoutingRulesItem.getBackendAddressPool().getId() != null) { ((ObjectNode) backendAddressPoolValue).put("id", requestRoutingRulesItem.getBackendAddressPool().getId()); } } if (requestRoutingRulesItem.getBackendHttpSettings() != null) { ObjectNode backendHttpSettingsValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue9).put("backendHttpSettings", backendHttpSettingsValue); if (requestRoutingRulesItem.getBackendHttpSettings().getId() != null) { ((ObjectNode) backendHttpSettingsValue).put("id", requestRoutingRulesItem.getBackendHttpSettings().getId()); } } if (requestRoutingRulesItem.getHttpListener() != null) { ObjectNode httpListenerValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue9).put("httpListener", httpListenerValue); if (requestRoutingRulesItem.getHttpListener().getId() != null) { ((ObjectNode) httpListenerValue).put("id", requestRoutingRulesItem.getHttpListener().getId()); } } if (requestRoutingRulesItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue9).put("provisioningState", requestRoutingRulesItem.getProvisioningState()); } if (requestRoutingRulesItem.getName() != null) { ((ObjectNode) applicationGatewayRequestRoutingRuleJsonFormatValue).put("name", requestRoutingRulesItem.getName()); } if (requestRoutingRulesItem.getEtag() != null) { ((ObjectNode) applicationGatewayRequestRoutingRuleJsonFormatValue).put("etag", requestRoutingRulesItem.getEtag()); } if (requestRoutingRulesItem.getId() != null) { ((ObjectNode) applicationGatewayRequestRoutingRuleJsonFormatValue).put("id", requestRoutingRulesItem.getId()); } } ((ObjectNode) propertiesValue).put("requestRoutingRules", requestRoutingRulesArray); } } 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) applicationGatewayJsonFormatValue).put("etag", parameters.getEtag()); } if (parameters.getId() != null) { ((ObjectNode) applicationGatewayJsonFormatValue).put("id", parameters.getId()); } if (parameters.getName() != null) { ((ObjectNode) applicationGatewayJsonFormatValue).put("name", parameters.getName()); } if (parameters.getType() != null) { ((ObjectNode) applicationGatewayJsonFormatValue).put("type", parameters.getType()); } ((ObjectNode) applicationGatewayJsonFormatValue).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) applicationGatewayJsonFormatValue).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 ApplicationGatewayPutResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ApplicationGatewayPutResponse(); 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) { ApplicationGateway applicationGatewayInstance = new ApplicationGateway(); result.setApplicationGateway(applicationGatewayInstance); JsonNode propertiesValue10 = responseDoc.get("properties"); if (propertiesValue10 != null && propertiesValue10 instanceof NullNode == false) { JsonNode skuValue2 = propertiesValue10.get("sku"); if (skuValue2 != null && skuValue2 instanceof NullNode == false) { ApplicationGatewaySku skuInstance = new ApplicationGatewaySku(); applicationGatewayInstance.setSku(skuInstance); JsonNode nameValue = skuValue2.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); skuInstance.setName(nameInstance); } JsonNode tierValue = skuValue2.get("tier"); if (tierValue != null && tierValue instanceof NullNode == false) { String tierInstance; tierInstance = tierValue.getTextValue(); skuInstance.setTier(tierInstance); } JsonNode capacityValue = skuValue2.get("capacity"); if (capacityValue != null && capacityValue instanceof NullNode == false) { int capacityInstance; capacityInstance = capacityValue.getIntValue(); skuInstance.setCapacity(capacityInstance); } } JsonNode operationalStateValue = propertiesValue10.get("operationalState"); if (operationalStateValue != null && operationalStateValue instanceof NullNode == false) { String operationalStateInstance; operationalStateInstance = operationalStateValue.getTextValue(); applicationGatewayInstance.setOperationalState(operationalStateInstance); } JsonNode gatewayIPConfigurationsArray2 = propertiesValue10.get("gatewayIPConfigurations"); if (gatewayIPConfigurationsArray2 != null && gatewayIPConfigurationsArray2 instanceof NullNode == false) { for (JsonNode gatewayIPConfigurationsValue : ((ArrayNode) gatewayIPConfigurationsArray2)) { ApplicationGatewayIPConfiguration applicationGatewayIPConfigurationJsonFormatInstance = new ApplicationGatewayIPConfiguration(); applicationGatewayInstance.getGatewayIPConfigurations() .add(applicationGatewayIPConfigurationJsonFormatInstance); JsonNode propertiesValue11 = gatewayIPConfigurationsValue.get("properties"); if (propertiesValue11 != null && propertiesValue11 instanceof NullNode == false) { JsonNode subnetValue3 = propertiesValue11.get("subnet"); if (subnetValue3 != null && subnetValue3 instanceof NullNode == false) { ResourceId subnetInstance = new ResourceId(); applicationGatewayIPConfigurationJsonFormatInstance .setSubnet(subnetInstance); JsonNode idValue = subnetValue3.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); subnetInstance.setId(idInstance); } } JsonNode provisioningStateValue = propertiesValue11.get("provisioningState"); if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) { String provisioningStateInstance; provisioningStateInstance = provisioningStateValue.getTextValue(); applicationGatewayIPConfigurationJsonFormatInstance .setProvisioningState(provisioningStateInstance); } } JsonNode nameValue2 = gatewayIPConfigurationsValue.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); applicationGatewayIPConfigurationJsonFormatInstance.setName(nameInstance2); } JsonNode etagValue = gatewayIPConfigurationsValue.get("etag"); if (etagValue != null && etagValue instanceof NullNode == false) { String etagInstance; etagInstance = etagValue.getTextValue(); applicationGatewayIPConfigurationJsonFormatInstance.setEtag(etagInstance); } JsonNode idValue2 = gatewayIPConfigurationsValue.get("id"); if (idValue2 != null && idValue2 instanceof NullNode == false) { String idInstance2; idInstance2 = idValue2.getTextValue(); applicationGatewayIPConfigurationJsonFormatInstance.setId(idInstance2); } } } JsonNode sslCertificatesArray2 = propertiesValue10.get("sslCertificates"); if (sslCertificatesArray2 != null && sslCertificatesArray2 instanceof NullNode == false) { for (JsonNode sslCertificatesValue : ((ArrayNode) sslCertificatesArray2)) { ApplicationGatewaySslCertificate applicationGatewaySslCertificateJsonFormatInstance = new ApplicationGatewaySslCertificate(); applicationGatewayInstance.getSslCertificates() .add(applicationGatewaySslCertificateJsonFormatInstance); JsonNode propertiesValue12 = sslCertificatesValue.get("properties"); if (propertiesValue12 != null && propertiesValue12 instanceof NullNode == false) { JsonNode dataValue = propertiesValue12.get("data"); if (dataValue != null && dataValue instanceof NullNode == false) { String dataInstance; dataInstance = dataValue.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance.setData(dataInstance); } JsonNode passwordValue = propertiesValue12.get("password"); if (passwordValue != null && passwordValue instanceof NullNode == false) { String passwordInstance; passwordInstance = passwordValue.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance .setPassword(passwordInstance); } JsonNode publicCertDataValue = propertiesValue12.get("publicCertData"); if (publicCertDataValue != null && publicCertDataValue instanceof NullNode == false) { String publicCertDataInstance; publicCertDataInstance = publicCertDataValue.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance .setPublicCertData(publicCertDataInstance); } JsonNode provisioningStateValue2 = propertiesValue12.get("provisioningState"); if (provisioningStateValue2 != null && provisioningStateValue2 instanceof NullNode == false) { String provisioningStateInstance2; provisioningStateInstance2 = provisioningStateValue2.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance .setProvisioningState(provisioningStateInstance2); } } JsonNode nameValue3 = sslCertificatesValue.get("name"); if (nameValue3 != null && nameValue3 instanceof NullNode == false) { String nameInstance3; nameInstance3 = nameValue3.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance.setName(nameInstance3); } JsonNode etagValue2 = sslCertificatesValue.get("etag"); if (etagValue2 != null && etagValue2 instanceof NullNode == false) { String etagInstance2; etagInstance2 = etagValue2.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance.setEtag(etagInstance2); } JsonNode idValue3 = sslCertificatesValue.get("id"); if (idValue3 != null && idValue3 instanceof NullNode == false) { String idInstance3; idInstance3 = idValue3.getTextValue(); applicationGatewaySslCertificateJsonFormatInstance.setId(idInstance3); } } } JsonNode frontendIPConfigurationsArray2 = propertiesValue10.get("frontendIPConfigurations"); if (frontendIPConfigurationsArray2 != null && frontendIPConfigurationsArray2 instanceof NullNode == false) { for (JsonNode frontendIPConfigurationsValue : ((ArrayNode) frontendIPConfigurationsArray2)) { ApplicationGatewayFrontendIPConfiguration applicationGatewayFrontendIPConfigurationJsonFormatInstance = new ApplicationGatewayFrontendIPConfiguration(); applicationGatewayInstance.getFrontendIPConfigurations() .add(applicationGatewayFrontendIPConfigurationJsonFormatInstance); JsonNode propertiesValue13 = frontendIPConfigurationsValue.get("properties"); if (propertiesValue13 != null && propertiesValue13 instanceof NullNode == false) { JsonNode privateIPAddressValue = propertiesValue13.get("privateIPAddress"); if (privateIPAddressValue != null && privateIPAddressValue instanceof NullNode == false) { String privateIPAddressInstance; privateIPAddressInstance = privateIPAddressValue.getTextValue(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setPrivateIPAddress(privateIPAddressInstance); } JsonNode privateIPAllocationMethodValue = propertiesValue13 .get("privateIPAllocationMethod"); if (privateIPAllocationMethodValue != null && privateIPAllocationMethodValue instanceof NullNode == false) { String privateIPAllocationMethodInstance; privateIPAllocationMethodInstance = privateIPAllocationMethodValue .getTextValue(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setPrivateIPAllocationMethod(privateIPAllocationMethodInstance); } JsonNode subnetValue4 = propertiesValue13.get("subnet"); if (subnetValue4 != null && subnetValue4 instanceof NullNode == false) { ResourceId subnetInstance2 = new ResourceId(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setSubnet(subnetInstance2); JsonNode idValue4 = subnetValue4.get("id"); if (idValue4 != null && idValue4 instanceof NullNode == false) { String idInstance4; idInstance4 = idValue4.getTextValue(); subnetInstance2.setId(idInstance4); } } JsonNode publicIPAddressValue2 = propertiesValue13.get("publicIPAddress"); if (publicIPAddressValue2 != null && publicIPAddressValue2 instanceof NullNode == false) { ResourceId publicIPAddressInstance = new ResourceId(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setPublicIPAddress(publicIPAddressInstance); JsonNode idValue5 = publicIPAddressValue2.get("id"); if (idValue5 != null && idValue5 instanceof NullNode == false) { String idInstance5; idInstance5 = idValue5.getTextValue(); publicIPAddressInstance.setId(idInstance5); } } JsonNode provisioningStateValue3 = propertiesValue13.get("provisioningState"); if (provisioningStateValue3 != null && provisioningStateValue3 instanceof NullNode == false) { String provisioningStateInstance3; provisioningStateInstance3 = provisioningStateValue3.getTextValue(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setProvisioningState(provisioningStateInstance3); } } JsonNode nameValue4 = frontendIPConfigurationsValue.get("name"); if (nameValue4 != null && nameValue4 instanceof NullNode == false) { String nameInstance4; nameInstance4 = nameValue4.getTextValue(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setName(nameInstance4); } JsonNode etagValue3 = frontendIPConfigurationsValue.get("etag"); if (etagValue3 != null && etagValue3 instanceof NullNode == false) { String etagInstance3; etagInstance3 = etagValue3.getTextValue(); applicationGatewayFrontendIPConfigurationJsonFormatInstance .setEtag(etagInstance3); } JsonNode idValue6 = frontendIPConfigurationsValue.get("id"); if (idValue6 != null && idValue6 instanceof NullNode == false) { String idInstance6; idInstance6 = idValue6.getTextValue(); applicationGatewayFrontendIPConfigurationJsonFormatInstance.setId(idInstance6); } } } JsonNode frontendPortsArray2 = propertiesValue10.get("frontendPorts"); if (frontendPortsArray2 != null && frontendPortsArray2 instanceof NullNode == false) { for (JsonNode frontendPortsValue : ((ArrayNode) frontendPortsArray2)) { ApplicationGatewayFrontendPort applicationGatewayFrontendPortJsonFormatInstance = new ApplicationGatewayFrontendPort(); applicationGatewayInstance.getFrontendPorts() .add(applicationGatewayFrontendPortJsonFormatInstance); JsonNode propertiesValue14 = frontendPortsValue.get("properties"); if (propertiesValue14 != null && propertiesValue14 instanceof NullNode == false) { JsonNode portValue = propertiesValue14.get("port"); if (portValue != null && portValue instanceof NullNode == false) { int portInstance; portInstance = portValue.getIntValue(); applicationGatewayFrontendPortJsonFormatInstance.setPort(portInstance); } JsonNode provisioningStateValue4 = propertiesValue14.get("provisioningState"); if (provisioningStateValue4 != null && provisioningStateValue4 instanceof NullNode == false) { String provisioningStateInstance4; provisioningStateInstance4 = provisioningStateValue4.getTextValue(); applicationGatewayFrontendPortJsonFormatInstance .setProvisioningState(provisioningStateInstance4); } } JsonNode nameValue5 = frontendPortsValue.get("name"); if (nameValue5 != null && nameValue5 instanceof NullNode == false) { String nameInstance5; nameInstance5 = nameValue5.getTextValue(); applicationGatewayFrontendPortJsonFormatInstance.setName(nameInstance5); } JsonNode etagValue4 = frontendPortsValue.get("etag"); if (etagValue4 != null && etagValue4 instanceof NullNode == false) { String etagInstance4; etagInstance4 = etagValue4.getTextValue(); applicationGatewayFrontendPortJsonFormatInstance.setEtag(etagInstance4); } JsonNode idValue7 = frontendPortsValue.get("id"); if (idValue7 != null && idValue7 instanceof NullNode == false) { String idInstance7; idInstance7 = idValue7.getTextValue(); applicationGatewayFrontendPortJsonFormatInstance.setId(idInstance7); } } } JsonNode backendAddressPoolsArray2 = propertiesValue10.get("backendAddressPools"); if (backendAddressPoolsArray2 != null && backendAddressPoolsArray2 instanceof NullNode == false) { for (JsonNode backendAddressPoolsValue : ((ArrayNode) backendAddressPoolsArray2)) { ApplicationGatewayBackendAddressPool applicationGatewayBackendAddressPoolJsonFormatInstance = new ApplicationGatewayBackendAddressPool(); applicationGatewayInstance.getBackendAddressPools() .add(applicationGatewayBackendAddressPoolJsonFormatInstance); JsonNode propertiesValue15 = backendAddressPoolsValue.get("properties"); if (propertiesValue15 != null && propertiesValue15 instanceof NullNode == false) { JsonNode backendIPConfigurationsArray2 = propertiesValue15 .get("backendIPConfigurations"); if (backendIPConfigurationsArray2 != null && backendIPConfigurationsArray2 instanceof NullNode == false) { for (JsonNode backendIPConfigurationsValue : ((ArrayNode) backendIPConfigurationsArray2)) { ResourceId resourceIdInstance = new ResourceId(); applicationGatewayBackendAddressPoolJsonFormatInstance .getBackendIPConfigurations().add(resourceIdInstance); JsonNode idValue8 = backendIPConfigurationsValue.get("id"); if (idValue8 != null && idValue8 instanceof NullNode == false) { String idInstance8; idInstance8 = idValue8.getTextValue(); resourceIdInstance.setId(idInstance8); } } } JsonNode backendAddressesArray2 = propertiesValue15.get("backendAddresses"); if (backendAddressesArray2 != null && backendAddressesArray2 instanceof NullNode == false) { for (JsonNode backendAddressesValue : ((ArrayNode) backendAddressesArray2)) { ApplicationGatewayBackendAddress applicationGatewayBackendAddressInstance = new ApplicationGatewayBackendAddress(); applicationGatewayBackendAddressPoolJsonFormatInstance .getBackendAddresses() .add(applicationGatewayBackendAddressInstance); JsonNode fqdnValue = backendAddressesValue.get("fqdn"); if (fqdnValue != null && fqdnValue instanceof NullNode == false) { String fqdnInstance; fqdnInstance = fqdnValue.getTextValue(); applicationGatewayBackendAddressInstance.setFqdn(fqdnInstance); } JsonNode ipAddressValue = backendAddressesValue.get("ipAddress"); if (ipAddressValue != null && ipAddressValue instanceof NullNode == false) { String ipAddressInstance; ipAddressInstance = ipAddressValue.getTextValue(); applicationGatewayBackendAddressInstance .setIpAddress(ipAddressInstance); } } } JsonNode provisioningStateValue5 = propertiesValue15.get("provisioningState"); if (provisioningStateValue5 != null && provisioningStateValue5 instanceof NullNode == false) { String provisioningStateInstance5; provisioningStateInstance5 = provisioningStateValue5.getTextValue(); applicationGatewayBackendAddressPoolJsonFormatInstance .setProvisioningState(provisioningStateInstance5); } } JsonNode nameValue6 = backendAddressPoolsValue.get("name"); if (nameValue6 != null && nameValue6 instanceof NullNode == false) { String nameInstance6; nameInstance6 = nameValue6.getTextValue(); applicationGatewayBackendAddressPoolJsonFormatInstance.setName(nameInstance6); } JsonNode etagValue5 = backendAddressPoolsValue.get("etag"); if (etagValue5 != null && etagValue5 instanceof NullNode == false) { String etagInstance5; etagInstance5 = etagValue5.getTextValue(); applicationGatewayBackendAddressPoolJsonFormatInstance.setEtag(etagInstance5); } JsonNode idValue9 = backendAddressPoolsValue.get("id"); if (idValue9 != null && idValue9 instanceof NullNode == false) { String idInstance9; idInstance9 = idValue9.getTextValue(); applicationGatewayBackendAddressPoolJsonFormatInstance.setId(idInstance9); } } } JsonNode backendHttpSettingsCollectionArray2 = propertiesValue10 .get("backendHttpSettingsCollection"); if (backendHttpSettingsCollectionArray2 != null && backendHttpSettingsCollectionArray2 instanceof NullNode == false) { for (JsonNode backendHttpSettingsCollectionValue : ((ArrayNode) backendHttpSettingsCollectionArray2)) { ApplicationGatewayBackendHttpSettings applicationGatewayBackendHttpSettingsJsonFormatInstance = new ApplicationGatewayBackendHttpSettings(); applicationGatewayInstance.getBackendHttpSettingsCollection() .add(applicationGatewayBackendHttpSettingsJsonFormatInstance); JsonNode propertiesValue16 = backendHttpSettingsCollectionValue.get("properties"); if (propertiesValue16 != null && propertiesValue16 instanceof NullNode == false) { JsonNode portValue2 = propertiesValue16.get("port"); if (portValue2 != null && portValue2 instanceof NullNode == false) { int portInstance2; portInstance2 = portValue2.getIntValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance .setPort(portInstance2); } JsonNode protocolValue = propertiesValue16.get("protocol"); if (protocolValue != null && protocolValue instanceof NullNode == false) { String protocolInstance; protocolInstance = protocolValue.getTextValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance .setProtocol(protocolInstance); } JsonNode cookieBasedAffinityValue = propertiesValue16 .get("cookieBasedAffinity"); if (cookieBasedAffinityValue != null && cookieBasedAffinityValue instanceof NullNode == false) { String cookieBasedAffinityInstance; cookieBasedAffinityInstance = cookieBasedAffinityValue.getTextValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance .setCookieBasedAffinity(cookieBasedAffinityInstance); } JsonNode provisioningStateValue6 = propertiesValue16.get("provisioningState"); if (provisioningStateValue6 != null && provisioningStateValue6 instanceof NullNode == false) { String provisioningStateInstance6; provisioningStateInstance6 = provisioningStateValue6.getTextValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance .setProvisioningState(provisioningStateInstance6); } } JsonNode nameValue7 = backendHttpSettingsCollectionValue.get("name"); if (nameValue7 != null && nameValue7 instanceof NullNode == false) { String nameInstance7; nameInstance7 = nameValue7.getTextValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance.setName(nameInstance7); } JsonNode etagValue6 = backendHttpSettingsCollectionValue.get("etag"); if (etagValue6 != null && etagValue6 instanceof NullNode == false) { String etagInstance6; etagInstance6 = etagValue6.getTextValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance.setEtag(etagInstance6); } JsonNode idValue10 = backendHttpSettingsCollectionValue.get("id"); if (idValue10 != null && idValue10 instanceof NullNode == false) { String idInstance10; idInstance10 = idValue10.getTextValue(); applicationGatewayBackendHttpSettingsJsonFormatInstance.setId(idInstance10); } } } JsonNode httpListenersArray2 = propertiesValue10.get("httpListeners"); if (httpListenersArray2 != null && httpListenersArray2 instanceof NullNode == false) { for (JsonNode httpListenersValue : ((ArrayNode) httpListenersArray2)) { ApplicationGatewayHttpListener applicationGatewayHttpListenerJsonFormatInstance = new ApplicationGatewayHttpListener(); applicationGatewayInstance.getHttpListeners() .add(applicationGatewayHttpListenerJsonFormatInstance); JsonNode propertiesValue17 = httpListenersValue.get("properties"); if (propertiesValue17 != null && propertiesValue17 instanceof NullNode == false) { JsonNode frontendIPConfigurationValue2 = propertiesValue17 .get("frontendIPConfiguration"); if (frontendIPConfigurationValue2 != null && frontendIPConfigurationValue2 instanceof NullNode == false) { ResourceId frontendIPConfigurationInstance = new ResourceId(); applicationGatewayHttpListenerJsonFormatInstance .setFrontendIPConfiguration(frontendIPConfigurationInstance); JsonNode idValue11 = frontendIPConfigurationValue2.get("id"); if (idValue11 != null && idValue11 instanceof NullNode == false) { String idInstance11; idInstance11 = idValue11.getTextValue(); frontendIPConfigurationInstance.setId(idInstance11); } } JsonNode frontendPortValue2 = propertiesValue17.get("frontendPort"); if (frontendPortValue2 != null && frontendPortValue2 instanceof NullNode == false) { ResourceId frontendPortInstance = new ResourceId(); applicationGatewayHttpListenerJsonFormatInstance .setFrontendPort(frontendPortInstance); JsonNode idValue12 = frontendPortValue2.get("id"); if (idValue12 != null && idValue12 instanceof NullNode == false) { String idInstance12; idInstance12 = idValue12.getTextValue(); frontendPortInstance.setId(idInstance12); } } JsonNode protocolValue2 = propertiesValue17.get("protocol"); if (protocolValue2 != null && protocolValue2 instanceof NullNode == false) { String protocolInstance2; protocolInstance2 = protocolValue2.getTextValue(); applicationGatewayHttpListenerJsonFormatInstance .setProtocol(protocolInstance2); } JsonNode sslCertificateValue2 = propertiesValue17.get("sslCertificate"); if (sslCertificateValue2 != null && sslCertificateValue2 instanceof NullNode == false) { ResourceId sslCertificateInstance = new ResourceId(); applicationGatewayHttpListenerJsonFormatInstance .setSslCertificate(sslCertificateInstance); JsonNode idValue13 = sslCertificateValue2.get("id"); if (idValue13 != null && idValue13 instanceof NullNode == false) { String idInstance13; idInstance13 = idValue13.getTextValue(); sslCertificateInstance.setId(idInstance13); } } JsonNode provisioningStateValue7 = propertiesValue17.get("provisioningState"); if (provisioningStateValue7 != null && provisioningStateValue7 instanceof NullNode == false) { String provisioningStateInstance7; provisioningStateInstance7 = provisioningStateValue7.getTextValue(); applicationGatewayHttpListenerJsonFormatInstance .setProvisioningState(provisioningStateInstance7); } } JsonNode nameValue8 = httpListenersValue.get("name"); if (nameValue8 != null && nameValue8 instanceof NullNode == false) { String nameInstance8; nameInstance8 = nameValue8.getTextValue(); applicationGatewayHttpListenerJsonFormatInstance.setName(nameInstance8); } JsonNode etagValue7 = httpListenersValue.get("etag"); if (etagValue7 != null && etagValue7 instanceof NullNode == false) { String etagInstance7; etagInstance7 = etagValue7.getTextValue(); applicationGatewayHttpListenerJsonFormatInstance.setEtag(etagInstance7); } JsonNode idValue14 = httpListenersValue.get("id"); if (idValue14 != null && idValue14 instanceof NullNode == false) { String idInstance14; idInstance14 = idValue14.getTextValue(); applicationGatewayHttpListenerJsonFormatInstance.setId(idInstance14); } } } JsonNode requestRoutingRulesArray2 = propertiesValue10.get("requestRoutingRules"); if (requestRoutingRulesArray2 != null && requestRoutingRulesArray2 instanceof NullNode == false) { for (JsonNode requestRoutingRulesValue : ((ArrayNode) requestRoutingRulesArray2)) { ApplicationGatewayRequestRoutingRule applicationGatewayRequestRoutingRuleJsonFormatInstance = new ApplicationGatewayRequestRoutingRule(); applicationGatewayInstance.getRequestRoutingRules() .add(applicationGatewayRequestRoutingRuleJsonFormatInstance); JsonNode propertiesValue18 = requestRoutingRulesValue.get("properties"); if (propertiesValue18 != null && propertiesValue18 instanceof NullNode == false) { JsonNode ruleTypeValue = propertiesValue18.get("ruleType"); if (ruleTypeValue != null && ruleTypeValue instanceof NullNode == false) { String ruleTypeInstance; ruleTypeInstance = ruleTypeValue.getTextValue(); applicationGatewayRequestRoutingRuleJsonFormatInstance .setRuleType(ruleTypeInstance); } JsonNode backendAddressPoolValue2 = propertiesValue18.get("backendAddressPool"); if (backendAddressPoolValue2 != null && backendAddressPoolValue2 instanceof NullNode == false) { ResourceId backendAddressPoolInstance = new ResourceId(); applicationGatewayRequestRoutingRuleJsonFormatInstance .setBackendAddressPool(backendAddressPoolInstance); JsonNode idValue15 = backendAddressPoolValue2.get("id"); if (idValue15 != null && idValue15 instanceof NullNode == false) { String idInstance15; idInstance15 = idValue15.getTextValue(); backendAddressPoolInstance.setId(idInstance15); } } JsonNode backendHttpSettingsValue2 = propertiesValue18 .get("backendHttpSettings"); if (backendHttpSettingsValue2 != null && backendHttpSettingsValue2 instanceof NullNode == false) { ResourceId backendHttpSettingsInstance = new ResourceId(); applicationGatewayRequestRoutingRuleJsonFormatInstance .setBackendHttpSettings(backendHttpSettingsInstance); JsonNode idValue16 = backendHttpSettingsValue2.get("id"); if (idValue16 != null && idValue16 instanceof NullNode == false) { String idInstance16; idInstance16 = idValue16.getTextValue(); backendHttpSettingsInstance.setId(idInstance16); } } JsonNode httpListenerValue2 = propertiesValue18.get("httpListener"); if (httpListenerValue2 != null && httpListenerValue2 instanceof NullNode == false) { ResourceId httpListenerInstance = new ResourceId(); applicationGatewayRequestRoutingRuleJsonFormatInstance .setHttpListener(httpListenerInstance); JsonNode idValue17 = httpListenerValue2.get("id"); if (idValue17 != null && idValue17 instanceof NullNode == false) { String idInstance17; idInstance17 = idValue17.getTextValue(); httpListenerInstance.setId(idInstance17); } } JsonNode provisioningStateValue8 = propertiesValue18.get("provisioningState"); if (provisioningStateValue8 != null && provisioningStateValue8 instanceof NullNode == false) { String provisioningStateInstance8; provisioningStateInstance8 = provisioningStateValue8.getTextValue(); applicationGatewayRequestRoutingRuleJsonFormatInstance .setProvisioningState(provisioningStateInstance8); } } JsonNode nameValue9 = requestRoutingRulesValue.get("name"); if (nameValue9 != null && nameValue9 instanceof NullNode == false) { String nameInstance9; nameInstance9 = nameValue9.getTextValue(); applicationGatewayRequestRoutingRuleJsonFormatInstance.setName(nameInstance9); } JsonNode etagValue8 = requestRoutingRulesValue.get("etag"); if (etagValue8 != null && etagValue8 instanceof NullNode == false) { String etagInstance8; etagInstance8 = etagValue8.getTextValue(); applicationGatewayRequestRoutingRuleJsonFormatInstance.setEtag(etagInstance8); } JsonNode idValue18 = requestRoutingRulesValue.get("id"); if (idValue18 != null && idValue18 instanceof NullNode == false) { String idInstance18; idInstance18 = idValue18.getTextValue(); applicationGatewayRequestRoutingRuleJsonFormatInstance.setId(idInstance18); } } } JsonNode resourceGuidValue = propertiesValue10.get("resourceGuid"); if (resourceGuidValue != null && resourceGuidValue instanceof NullNode == false) { String resourceGuidInstance; resourceGuidInstance = resourceGuidValue.getTextValue(); applicationGatewayInstance.setResourceGuid(resourceGuidInstance); } JsonNode provisioningStateValue9 = propertiesValue10.get("provisioningState"); if (provisioningStateValue9 != null && provisioningStateValue9 instanceof NullNode == false) { String provisioningStateInstance9; provisioningStateInstance9 = provisioningStateValue9.getTextValue(); applicationGatewayInstance.setProvisioningState(provisioningStateInstance9); } } JsonNode etagValue9 = responseDoc.get("etag"); if (etagValue9 != null && etagValue9 instanceof NullNode == false) { String etagInstance9; etagInstance9 = etagValue9.getTextValue(); applicationGatewayInstance.setEtag(etagInstance9); } JsonNode idValue19 = responseDoc.get("id"); if (idValue19 != null && idValue19 instanceof NullNode == false) { String idInstance19; idInstance19 = idValue19.getTextValue(); applicationGatewayInstance.setId(idInstance19); } JsonNode nameValue10 = responseDoc.get("name"); if (nameValue10 != null && nameValue10 instanceof NullNode == false) { String nameInstance10; nameInstance10 = nameValue10.getTextValue(); applicationGatewayInstance.setName(nameInstance10); } JsonNode typeValue = responseDoc.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); applicationGatewayInstance.setType(typeInstance); } JsonNode locationValue = responseDoc.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); applicationGatewayInstance.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(); applicationGatewayInstance.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.VirtualMachineDiskOperationsImpl.java
/** * The List Disks operation retrieves a list of the disks in your image * repository. (see// w w w . ja v a 2s . co m * http://msdn.microsoft.com/en-us/library/windowsazure/jj157176.aspx for * more information) * * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws ParserConfigurationException Thrown if there was a serious * configuration error with the document parser. * @throws SAXException Thrown if there was an error parsing the XML * response. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The List Disks operation response. */ @Override public VirtualMachineDiskListResponse listDisks() throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException { // Validate // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); CloudTracing.enter(invocationId, this, "listDisksAsync", 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/disks"; 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 VirtualMachineDiskListResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new VirtualMachineDiskListResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element disksSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "Disks"); if (disksSequenceElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(disksSequenceElement, "http://schemas.microsoft.com/windowsazure", "Disk") .size(); i1 = i1 + 1) { org.w3c.dom.Element disksElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(disksSequenceElement, "http://schemas.microsoft.com/windowsazure", "Disk") .get(i1)); VirtualMachineDiskListResponse.VirtualMachineDisk diskInstance = new VirtualMachineDiskListResponse.VirtualMachineDisk(); result.getDisks().add(diskInstance); Element affinityGroupElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "AffinityGroup"); if (affinityGroupElement != null) { String affinityGroupInstance; affinityGroupInstance = affinityGroupElement.getTextContent(); diskInstance.setAffinityGroup(affinityGroupInstance); } Element locationElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "Location"); if (locationElement != null) { String locationInstance; locationInstance = locationElement.getTextContent(); diskInstance.setLocation(locationInstance); } Element labelElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "Label"); if (labelElement != null) { String labelInstance; labelInstance = labelElement.getTextContent(); diskInstance.setLabel(labelInstance); } Element logicalDiskSizeInGBElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "LogicalDiskSizeInGB"); if (logicalDiskSizeInGBElement != null) { int logicalDiskSizeInGBInstance; logicalDiskSizeInGBInstance = DatatypeConverter .parseInt(logicalDiskSizeInGBElement.getTextContent()); diskInstance.setLogicalSizeInGB(logicalDiskSizeInGBInstance); } Element mediaLinkElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "MediaLink"); if (mediaLinkElement != null) { URI mediaLinkInstance; mediaLinkInstance = new URI(mediaLinkElement.getTextContent()); diskInstance.setMediaLinkUri(mediaLinkInstance); } Element nameElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement != null) { String nameInstance; nameInstance = nameElement.getTextContent(); diskInstance.setName(nameInstance); } Element osElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "OS"); if (osElement != null) { String osInstance; osInstance = osElement.getTextContent(); diskInstance.setOperatingSystemType(osInstance); } Element sourceImageNameElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "SourceImageName"); if (sourceImageNameElement != null) { String sourceImageNameInstance; sourceImageNameInstance = sourceImageNameElement.getTextContent(); diskInstance.setSourceImageName(sourceImageNameInstance); } Element attachedToElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "AttachedTo"); if (attachedToElement != null) { VirtualMachineDiskListResponse.VirtualMachineDiskUsageDetails attachedToInstance = new VirtualMachineDiskListResponse.VirtualMachineDiskUsageDetails(); diskInstance.setUsageDetails(attachedToInstance); Element hostedServiceNameElement = XmlUtility.getElementByTagNameNS(attachedToElement, "http://schemas.microsoft.com/windowsazure", "HostedServiceName"); if (hostedServiceNameElement != null) { String hostedServiceNameInstance; hostedServiceNameInstance = hostedServiceNameElement.getTextContent(); attachedToInstance.setHostedServiceName(hostedServiceNameInstance); } Element deploymentNameElement = XmlUtility.getElementByTagNameNS(attachedToElement, "http://schemas.microsoft.com/windowsazure", "DeploymentName"); if (deploymentNameElement != null) { String deploymentNameInstance; deploymentNameInstance = deploymentNameElement.getTextContent(); attachedToInstance.setDeploymentName(deploymentNameInstance); } Element roleNameElement = XmlUtility.getElementByTagNameNS(attachedToElement, "http://schemas.microsoft.com/windowsazure", "RoleName"); if (roleNameElement != null) { String roleNameInstance; roleNameInstance = roleNameElement.getTextContent(); attachedToInstance.setRoleName(roleNameInstance); } } Element isCorruptedElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "IsCorrupted"); if (isCorruptedElement != null && isCorruptedElement.getTextContent() != null && !isCorruptedElement.getTextContent().isEmpty()) { boolean isCorruptedInstance; isCorruptedInstance = DatatypeConverter .parseBoolean(isCorruptedElement.getTextContent().toLowerCase()); diskInstance.setIsCorrupted(isCorruptedInstance); } Element isPremiumElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "IsPremium"); if (isPremiumElement != null && isPremiumElement.getTextContent() != null && !isPremiumElement.getTextContent().isEmpty()) { boolean isPremiumInstance; isPremiumInstance = DatatypeConverter .parseBoolean(isPremiumElement.getTextContent().toLowerCase()); diskInstance.setIsPremium(isPremiumInstance); } Element iOTypeElement = XmlUtility.getElementByTagNameNS(disksElement, "http://schemas.microsoft.com/windowsazure", "IOType"); if (iOTypeElement != null) { String iOTypeInstance; iOTypeInstance = iOTypeElement.getTextContent(); diskInstance.setIOType(iOTypeInstance); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.sql.DatabaseOperationsImpl.java
/** * Begins creating a new Azure SQL Database or updating an existing Azure * SQL Database. To determine the status of the operation call * GetDatabaseOperationStatus./* ww w . j a va 2s .c o m*/ * * @param resourceGroupName Required. The name of the Resource Group to * which the Azure SQL Database Server belongs. * @param serverName Required. The name of the Azure SQL Database Server on * which the database is hosted. * @param databaseName Required. The name of the Azure SQL Database to be * operated on (Updated or created). * @param parameters Required. The required parameters for creating or * updating a database. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Response for long running Azure Sql Database operations. */ @Override public DatabaseCreateOrUpdateResponse beginCreateOrUpdate(String resourceGroupName, String serverName, String databaseName, DatabaseCreateOrUpdateParameters parameters) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (serverName == null) { throw new NullPointerException("serverName"); } if (databaseName == null) { throw new NullPointerException("databaseName"); } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getLocation() == null) { throw new NullPointerException("parameters.Location"); } if (parameters.getProperties() == null) { throw new NullPointerException("parameters.Properties"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("resourceGroupName", resourceGroupName); tracingParameters.put("serverName", serverName); tracingParameters.put("databaseName", databaseName); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "beginCreateOrUpdateAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourceGroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/"; url = url + "Microsoft.Sql"; url = url + "/servers/"; url = url + URLEncoder.encode(serverName, "UTF-8"); url = url + "/databases/"; url = url + URLEncoder.encode(databaseName, "UTF-8"); ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2014-04-01"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpPut httpRequest = new HttpPut(url); // Set Headers httpRequest.setHeader("Content-Type", "application/json; charset=utf-8"); // Serialize Request String requestContent = null; JsonNode requestDoc = null; ObjectMapper objectMapper = new ObjectMapper(); ObjectNode databaseCreateOrUpdateParametersValue = objectMapper.createObjectNode(); requestDoc = databaseCreateOrUpdateParametersValue; ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) databaseCreateOrUpdateParametersValue).put("properties", propertiesValue); if (parameters.getProperties().getEdition() != null) { ((ObjectNode) propertiesValue).put("edition", parameters.getProperties().getEdition()); } if (parameters.getProperties().getCollation() != null) { ((ObjectNode) propertiesValue).put("collation", parameters.getProperties().getCollation()); } if (parameters.getProperties().getMaxSizeBytes() != null) { ((ObjectNode) propertiesValue).put("maxSizeBytes", Long.toString(parameters.getProperties().getMaxSizeBytes())); } if (parameters.getProperties().getRequestedServiceObjectiveId() != null) { ((ObjectNode) propertiesValue).put("requestedServiceObjectiveId", parameters.getProperties().getRequestedServiceObjectiveId()); } if (parameters.getProperties().getRequestedServiceObjectiveName() != null) { ((ObjectNode) propertiesValue).put("requestedServiceObjectiveName", parameters.getProperties().getRequestedServiceObjectiveName()); } if (parameters.getProperties().getElasticPoolName() != null) { ((ObjectNode) propertiesValue).put("elasticPoolName", parameters.getProperties().getElasticPoolName()); } if (parameters.getProperties().getSourceDatabaseId() != null) { ((ObjectNode) propertiesValue).put("sourceDatabaseId", parameters.getProperties().getSourceDatabaseId()); } if (parameters.getProperties().getCreateMode() != null) { ((ObjectNode) propertiesValue).put("createMode", parameters.getProperties().getCreateMode()); } ((ObjectNode) databaseCreateOrUpdateParametersValue).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) databaseCreateOrUpdateParametersValue).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; charset=utf-8"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_ACCEPTED) { ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result DatabaseCreateOrUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED || statusCode == HttpStatus.SC_ACCEPTED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new DatabaseCreateOrUpdateResponse(); JsonNode responseDoc = null; String responseDocContent = IOUtils.toString(responseContent); if (responseDocContent == null == false && responseDocContent.length() > 0) { responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { ErrorResponse errorInstance = new ErrorResponse(); result.setError(errorInstance); JsonNode codeValue = responseDoc.get("code"); if (codeValue != null && codeValue instanceof NullNode == false) { String codeInstance; codeInstance = codeValue.getTextValue(); errorInstance.setCode(codeInstance); } JsonNode messageValue = responseDoc.get("message"); if (messageValue != null && messageValue instanceof NullNode == false) { String messageInstance; messageInstance = messageValue.getTextValue(); errorInstance.setMessage(messageInstance); } JsonNode targetValue = responseDoc.get("target"); if (targetValue != null && targetValue instanceof NullNode == false) { String targetInstance; targetInstance = targetValue.getTextValue(); errorInstance.setTarget(targetInstance); } Database databaseInstance = new Database(); result.setDatabase(databaseInstance); JsonNode propertiesValue2 = responseDoc.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { DatabaseProperties propertiesInstance = new DatabaseProperties(); databaseInstance.setProperties(propertiesInstance); JsonNode collationValue = propertiesValue2.get("collation"); if (collationValue != null && collationValue instanceof NullNode == false) { String collationInstance; collationInstance = collationValue.getTextValue(); propertiesInstance.setCollation(collationInstance); } JsonNode creationDateValue = propertiesValue2.get("creationDate"); if (creationDateValue != null && creationDateValue instanceof NullNode == false) { Calendar creationDateInstance; creationDateInstance = DatatypeConverter .parseDateTime(creationDateValue.getTextValue()); propertiesInstance.setCreationDate(creationDateInstance); } JsonNode currentServiceObjectiveIdValue = propertiesValue2.get("currentServiceObjectiveId"); if (currentServiceObjectiveIdValue != null && currentServiceObjectiveIdValue instanceof NullNode == false) { String currentServiceObjectiveIdInstance; currentServiceObjectiveIdInstance = currentServiceObjectiveIdValue.getTextValue(); propertiesInstance.setCurrentServiceObjectiveId(currentServiceObjectiveIdInstance); } JsonNode databaseIdValue = propertiesValue2.get("databaseId"); if (databaseIdValue != null && databaseIdValue instanceof NullNode == false) { String databaseIdInstance; databaseIdInstance = databaseIdValue.getTextValue(); propertiesInstance.setDatabaseId(databaseIdInstance); } JsonNode earliestRestoreDateValue = propertiesValue2.get("earliestRestoreDate"); if (earliestRestoreDateValue != null && earliestRestoreDateValue instanceof NullNode == false) { Calendar earliestRestoreDateInstance; earliestRestoreDateInstance = DatatypeConverter .parseDateTime(earliestRestoreDateValue.getTextValue()); propertiesInstance.setEarliestRestoreDate(earliestRestoreDateInstance); } JsonNode editionValue = propertiesValue2.get("edition"); if (editionValue != null && editionValue instanceof NullNode == false) { String editionInstance; editionInstance = editionValue.getTextValue(); propertiesInstance.setEdition(editionInstance); } JsonNode maxSizeBytesValue = propertiesValue2.get("maxSizeBytes"); if (maxSizeBytesValue != null && maxSizeBytesValue instanceof NullNode == false) { long maxSizeBytesInstance; maxSizeBytesInstance = maxSizeBytesValue.getLongValue(); propertiesInstance.setMaxSizeBytes(maxSizeBytesInstance); } JsonNode requestedServiceObjectiveIdValue = propertiesValue2 .get("requestedServiceObjectiveId"); if (requestedServiceObjectiveIdValue != null && requestedServiceObjectiveIdValue instanceof NullNode == false) { String requestedServiceObjectiveIdInstance; requestedServiceObjectiveIdInstance = requestedServiceObjectiveIdValue.getTextValue(); propertiesInstance.setRequestedServiceObjectiveId(requestedServiceObjectiveIdInstance); } JsonNode requestedServiceObjectiveNameValue = propertiesValue2 .get("requestedServiceObjectiveName"); if (requestedServiceObjectiveNameValue != null && requestedServiceObjectiveNameValue instanceof NullNode == false) { String requestedServiceObjectiveNameInstance; requestedServiceObjectiveNameInstance = requestedServiceObjectiveNameValue .getTextValue(); propertiesInstance .setRequestedServiceObjectiveName(requestedServiceObjectiveNameInstance); } JsonNode serviceLevelObjectiveValue = propertiesValue2.get("serviceLevelObjective"); if (serviceLevelObjectiveValue != null && serviceLevelObjectiveValue instanceof NullNode == false) { String serviceLevelObjectiveInstance; serviceLevelObjectiveInstance = serviceLevelObjectiveValue.getTextValue(); propertiesInstance.setServiceObjective(serviceLevelObjectiveInstance); } JsonNode statusValue = propertiesValue2.get("status"); if (statusValue != null && statusValue instanceof NullNode == false) { String statusInstance; statusInstance = statusValue.getTextValue(); propertiesInstance.setStatus(statusInstance); } JsonNode elasticPoolNameValue = propertiesValue2.get("elasticPoolName"); if (elasticPoolNameValue != null && elasticPoolNameValue instanceof NullNode == false) { String elasticPoolNameInstance; elasticPoolNameInstance = elasticPoolNameValue.getTextValue(); propertiesInstance.setElasticPoolName(elasticPoolNameInstance); } JsonNode serviceTierAdvisorsArray = propertiesValue2.get("serviceTierAdvisors"); if (serviceTierAdvisorsArray != null && serviceTierAdvisorsArray instanceof NullNode == false) { for (JsonNode serviceTierAdvisorsValue : ((ArrayNode) serviceTierAdvisorsArray)) { ServiceTierAdvisor serviceTierAdvisorInstance = new ServiceTierAdvisor(); propertiesInstance.getServiceTierAdvisors().add(serviceTierAdvisorInstance); JsonNode propertiesValue3 = serviceTierAdvisorsValue.get("properties"); if (propertiesValue3 != null && propertiesValue3 instanceof NullNode == false) { ServiceTierAdvisorProperties propertiesInstance2 = new ServiceTierAdvisorProperties(); serviceTierAdvisorInstance.setProperties(propertiesInstance2); JsonNode observationPeriodStartValue = propertiesValue3 .get("observationPeriodStart"); if (observationPeriodStartValue != null && observationPeriodStartValue instanceof NullNode == false) { Calendar observationPeriodStartInstance; observationPeriodStartInstance = DatatypeConverter .parseDateTime(observationPeriodStartValue.getTextValue()); propertiesInstance2 .setObservationPeriodStart(observationPeriodStartInstance); } JsonNode observationPeriodEndValue = propertiesValue3 .get("observationPeriodEnd"); if (observationPeriodEndValue != null && observationPeriodEndValue instanceof NullNode == false) { Calendar observationPeriodEndInstance; observationPeriodEndInstance = DatatypeConverter .parseDateTime(observationPeriodEndValue.getTextValue()); propertiesInstance2.setObservationPeriodEnd(observationPeriodEndInstance); } JsonNode activeTimeRatioValue = propertiesValue3.get("activeTimeRatio"); if (activeTimeRatioValue != null && activeTimeRatioValue instanceof NullNode == false) { double activeTimeRatioInstance; activeTimeRatioInstance = activeTimeRatioValue.getDoubleValue(); propertiesInstance2.setActiveTimeRatio(activeTimeRatioInstance); } JsonNode minDtuValue = propertiesValue3.get("minDtu"); if (minDtuValue != null && minDtuValue instanceof NullNode == false) { double minDtuInstance; minDtuInstance = minDtuValue.getDoubleValue(); propertiesInstance2.setMinDtu(minDtuInstance); } JsonNode avgDtuValue = propertiesValue3.get("avgDtu"); if (avgDtuValue != null && avgDtuValue instanceof NullNode == false) { double avgDtuInstance; avgDtuInstance = avgDtuValue.getDoubleValue(); propertiesInstance2.setAvgDtu(avgDtuInstance); } JsonNode maxDtuValue = propertiesValue3.get("maxDtu"); if (maxDtuValue != null && maxDtuValue instanceof NullNode == false) { double maxDtuInstance; maxDtuInstance = maxDtuValue.getDoubleValue(); propertiesInstance2.setMaxDtu(maxDtuInstance); } JsonNode maxSizeInGBValue = propertiesValue3.get("maxSizeInGB"); if (maxSizeInGBValue != null && maxSizeInGBValue instanceof NullNode == false) { double maxSizeInGBInstance; maxSizeInGBInstance = maxSizeInGBValue.getDoubleValue(); propertiesInstance2.setMaxSizeInGB(maxSizeInGBInstance); } JsonNode serviceLevelObjectiveUsageMetricsArray = propertiesValue3 .get("serviceLevelObjectiveUsageMetrics"); if (serviceLevelObjectiveUsageMetricsArray != null && serviceLevelObjectiveUsageMetricsArray instanceof NullNode == false) { for (JsonNode serviceLevelObjectiveUsageMetricsValue : ((ArrayNode) serviceLevelObjectiveUsageMetricsArray)) { SloUsageMetric sloUsageMetricInstance = new SloUsageMetric(); propertiesInstance2.getServiceLevelObjectiveUsageMetrics() .add(sloUsageMetricInstance); JsonNode serviceLevelObjectiveValue2 = serviceLevelObjectiveUsageMetricsValue .get("serviceLevelObjective"); if (serviceLevelObjectiveValue2 != null && serviceLevelObjectiveValue2 instanceof NullNode == false) { String serviceLevelObjectiveInstance2; serviceLevelObjectiveInstance2 = serviceLevelObjectiveValue2 .getTextValue(); sloUsageMetricInstance .setServiceLevelObjective(serviceLevelObjectiveInstance2); } JsonNode serviceLevelObjectiveIdValue = serviceLevelObjectiveUsageMetricsValue .get("serviceLevelObjectiveId"); if (serviceLevelObjectiveIdValue != null && serviceLevelObjectiveIdValue instanceof NullNode == false) { String serviceLevelObjectiveIdInstance; serviceLevelObjectiveIdInstance = serviceLevelObjectiveIdValue .getTextValue(); sloUsageMetricInstance.setServiceLevelObjectiveId( serviceLevelObjectiveIdInstance); } JsonNode inRangeTimeRatioValue = serviceLevelObjectiveUsageMetricsValue .get("inRangeTimeRatio"); if (inRangeTimeRatioValue != null && inRangeTimeRatioValue instanceof NullNode == false) { double inRangeTimeRatioInstance; inRangeTimeRatioInstance = inRangeTimeRatioValue.getDoubleValue(); sloUsageMetricInstance .setInRangeTimeRatio(inRangeTimeRatioInstance); } JsonNode idValue = serviceLevelObjectiveUsageMetricsValue.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); sloUsageMetricInstance.setId(idInstance); } JsonNode nameValue = serviceLevelObjectiveUsageMetricsValue.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); sloUsageMetricInstance.setName(nameInstance); } JsonNode typeValue = serviceLevelObjectiveUsageMetricsValue.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); sloUsageMetricInstance.setType(typeInstance); } JsonNode locationValue = serviceLevelObjectiveUsageMetricsValue .get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); sloUsageMetricInstance.setLocation(locationInstance); } JsonNode tagsSequenceElement = ((JsonNode) serviceLevelObjectiveUsageMetricsValue .get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement .getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey2 = property.getKey(); String tagsValue2 = property.getValue().getTextValue(); sloUsageMetricInstance.getTags().put(tagsKey2, tagsValue2); } } } } JsonNode currentServiceLevelObjectiveValue = propertiesValue3 .get("currentServiceLevelObjective"); if (currentServiceLevelObjectiveValue != null && currentServiceLevelObjectiveValue instanceof NullNode == false) { String currentServiceLevelObjectiveInstance; currentServiceLevelObjectiveInstance = currentServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setCurrentServiceLevelObjective( currentServiceLevelObjectiveInstance); } JsonNode currentServiceLevelObjectiveIdValue = propertiesValue3 .get("currentServiceLevelObjectiveId"); if (currentServiceLevelObjectiveIdValue != null && currentServiceLevelObjectiveIdValue instanceof NullNode == false) { String currentServiceLevelObjectiveIdInstance; currentServiceLevelObjectiveIdInstance = currentServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2.setCurrentServiceLevelObjectiveId( currentServiceLevelObjectiveIdInstance); } JsonNode usageBasedRecommendationServiceLevelObjectiveValue = propertiesValue3 .get("usageBasedRecommendationServiceLevelObjective"); if (usageBasedRecommendationServiceLevelObjectiveValue != null && usageBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String usageBasedRecommendationServiceLevelObjectiveInstance; usageBasedRecommendationServiceLevelObjectiveInstance = usageBasedRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setUsageBasedRecommendationServiceLevelObjective( usageBasedRecommendationServiceLevelObjectiveInstance); } JsonNode usageBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue3 .get("usageBasedRecommendationServiceLevelObjectiveId"); if (usageBasedRecommendationServiceLevelObjectiveIdValue != null && usageBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String usageBasedRecommendationServiceLevelObjectiveIdInstance; usageBasedRecommendationServiceLevelObjectiveIdInstance = usageBasedRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2.setUsageBasedRecommendationServiceLevelObjectiveId( usageBasedRecommendationServiceLevelObjectiveIdInstance); } JsonNode databaseSizeBasedRecommendationServiceLevelObjectiveValue = propertiesValue3 .get("databaseSizeBasedRecommendationServiceLevelObjective"); if (databaseSizeBasedRecommendationServiceLevelObjectiveValue != null && databaseSizeBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String databaseSizeBasedRecommendationServiceLevelObjectiveInstance; databaseSizeBasedRecommendationServiceLevelObjectiveInstance = databaseSizeBasedRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setDatabaseSizeBasedRecommendationServiceLevelObjective( databaseSizeBasedRecommendationServiceLevelObjectiveInstance); } JsonNode databaseSizeBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue3 .get("databaseSizeBasedRecommendationServiceLevelObjectiveId"); if (databaseSizeBasedRecommendationServiceLevelObjectiveIdValue != null && databaseSizeBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance; databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance = databaseSizeBasedRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2 .setDatabaseSizeBasedRecommendationServiceLevelObjectiveId( databaseSizeBasedRecommendationServiceLevelObjectiveIdInstance); } JsonNode disasterPlanBasedRecommendationServiceLevelObjectiveValue = propertiesValue3 .get("disasterPlanBasedRecommendationServiceLevelObjective"); if (disasterPlanBasedRecommendationServiceLevelObjectiveValue != null && disasterPlanBasedRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String disasterPlanBasedRecommendationServiceLevelObjectiveInstance; disasterPlanBasedRecommendationServiceLevelObjectiveInstance = disasterPlanBasedRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setDisasterPlanBasedRecommendationServiceLevelObjective( disasterPlanBasedRecommendationServiceLevelObjectiveInstance); } JsonNode disasterPlanBasedRecommendationServiceLevelObjectiveIdValue = propertiesValue3 .get("disasterPlanBasedRecommendationServiceLevelObjectiveId"); if (disasterPlanBasedRecommendationServiceLevelObjectiveIdValue != null && disasterPlanBasedRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance; disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance = disasterPlanBasedRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2 .setDisasterPlanBasedRecommendationServiceLevelObjectiveId( disasterPlanBasedRecommendationServiceLevelObjectiveIdInstance); } JsonNode overallRecommendationServiceLevelObjectiveValue = propertiesValue3 .get("overallRecommendationServiceLevelObjective"); if (overallRecommendationServiceLevelObjectiveValue != null && overallRecommendationServiceLevelObjectiveValue instanceof NullNode == false) { String overallRecommendationServiceLevelObjectiveInstance; overallRecommendationServiceLevelObjectiveInstance = overallRecommendationServiceLevelObjectiveValue .getTextValue(); propertiesInstance2.setOverallRecommendationServiceLevelObjective( overallRecommendationServiceLevelObjectiveInstance); } JsonNode overallRecommendationServiceLevelObjectiveIdValue = propertiesValue3 .get("overallRecommendationServiceLevelObjectiveId"); if (overallRecommendationServiceLevelObjectiveIdValue != null && overallRecommendationServiceLevelObjectiveIdValue instanceof NullNode == false) { String overallRecommendationServiceLevelObjectiveIdInstance; overallRecommendationServiceLevelObjectiveIdInstance = overallRecommendationServiceLevelObjectiveIdValue .getTextValue(); propertiesInstance2.setOverallRecommendationServiceLevelObjectiveId( overallRecommendationServiceLevelObjectiveIdInstance); } JsonNode confidenceValue = propertiesValue3.get("confidence"); if (confidenceValue != null && confidenceValue instanceof NullNode == false) { double confidenceInstance; confidenceInstance = confidenceValue.getDoubleValue(); propertiesInstance2.setConfidence(confidenceInstance); } } JsonNode idValue2 = serviceTierAdvisorsValue.get("id"); if (idValue2 != null && idValue2 instanceof NullNode == false) { String idInstance2; idInstance2 = idValue2.getTextValue(); serviceTierAdvisorInstance.setId(idInstance2); } JsonNode nameValue2 = serviceTierAdvisorsValue.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); serviceTierAdvisorInstance.setName(nameInstance2); } JsonNode typeValue2 = serviceTierAdvisorsValue.get("type"); if (typeValue2 != null && typeValue2 instanceof NullNode == false) { String typeInstance2; typeInstance2 = typeValue2.getTextValue(); serviceTierAdvisorInstance.setType(typeInstance2); } JsonNode locationValue2 = serviceTierAdvisorsValue.get("location"); if (locationValue2 != null && locationValue2 instanceof NullNode == false) { String locationInstance2; locationInstance2 = locationValue2.getTextValue(); serviceTierAdvisorInstance.setLocation(locationInstance2); } JsonNode tagsSequenceElement2 = ((JsonNode) serviceTierAdvisorsValue.get("tags")); if (tagsSequenceElement2 != null && tagsSequenceElement2 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr2 = tagsSequenceElement2.getFields(); while (itr2.hasNext()) { Map.Entry<String, JsonNode> property2 = itr2.next(); String tagsKey3 = property2.getKey(); String tagsValue3 = property2.getValue().getTextValue(); serviceTierAdvisorInstance.getTags().put(tagsKey3, tagsValue3); } } } } JsonNode upgradeHintValue = propertiesValue2.get("upgradeHint"); if (upgradeHintValue != null && upgradeHintValue instanceof NullNode == false) { UpgradeHint upgradeHintInstance = new UpgradeHint(); propertiesInstance.setUpgradeHint(upgradeHintInstance); JsonNode targetServiceLevelObjectiveValue = upgradeHintValue .get("targetServiceLevelObjective"); if (targetServiceLevelObjectiveValue != null && targetServiceLevelObjectiveValue instanceof NullNode == false) { String targetServiceLevelObjectiveInstance; targetServiceLevelObjectiveInstance = targetServiceLevelObjectiveValue .getTextValue(); upgradeHintInstance .setTargetServiceLevelObjective(targetServiceLevelObjectiveInstance); } JsonNode targetServiceLevelObjectiveIdValue = upgradeHintValue .get("targetServiceLevelObjectiveId"); if (targetServiceLevelObjectiveIdValue != null && targetServiceLevelObjectiveIdValue instanceof NullNode == false) { String targetServiceLevelObjectiveIdInstance; targetServiceLevelObjectiveIdInstance = targetServiceLevelObjectiveIdValue .getTextValue(); upgradeHintInstance .setTargetServiceLevelObjectiveId(targetServiceLevelObjectiveIdInstance); } JsonNode idValue3 = upgradeHintValue.get("id"); if (idValue3 != null && idValue3 instanceof NullNode == false) { String idInstance3; idInstance3 = idValue3.getTextValue(); upgradeHintInstance.setId(idInstance3); } JsonNode nameValue3 = upgradeHintValue.get("name"); if (nameValue3 != null && nameValue3 instanceof NullNode == false) { String nameInstance3; nameInstance3 = nameValue3.getTextValue(); upgradeHintInstance.setName(nameInstance3); } JsonNode typeValue3 = upgradeHintValue.get("type"); if (typeValue3 != null && typeValue3 instanceof NullNode == false) { String typeInstance3; typeInstance3 = typeValue3.getTextValue(); upgradeHintInstance.setType(typeInstance3); } JsonNode locationValue3 = upgradeHintValue.get("location"); if (locationValue3 != null && locationValue3 instanceof NullNode == false) { String locationInstance3; locationInstance3 = locationValue3.getTextValue(); upgradeHintInstance.setLocation(locationInstance3); } JsonNode tagsSequenceElement3 = ((JsonNode) upgradeHintValue.get("tags")); if (tagsSequenceElement3 != null && tagsSequenceElement3 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr3 = tagsSequenceElement3.getFields(); while (itr3.hasNext()) { Map.Entry<String, JsonNode> property3 = itr3.next(); String tagsKey4 = property3.getKey(); String tagsValue4 = property3.getValue().getTextValue(); upgradeHintInstance.getTags().put(tagsKey4, tagsValue4); } } } JsonNode schemasArray = propertiesValue2.get("schemas"); if (schemasArray != null && schemasArray instanceof NullNode == false) { for (JsonNode schemasValue : ((ArrayNode) schemasArray)) { Schema schemaInstance = new Schema(); propertiesInstance.getSchemas().add(schemaInstance); JsonNode propertiesValue4 = schemasValue.get("properties"); if (propertiesValue4 != null && propertiesValue4 instanceof NullNode == false) { SchemaProperties propertiesInstance3 = new SchemaProperties(); schemaInstance.setProperties(propertiesInstance3); JsonNode tablesArray = propertiesValue4.get("tables"); if (tablesArray != null && tablesArray instanceof NullNode == false) { for (JsonNode tablesValue : ((ArrayNode) tablesArray)) { Table tableInstance = new Table(); propertiesInstance3.getTables().add(tableInstance); JsonNode propertiesValue5 = tablesValue.get("properties"); if (propertiesValue5 != null && propertiesValue5 instanceof NullNode == false) { TableProperties propertiesInstance4 = new TableProperties(); tableInstance.setProperties(propertiesInstance4); JsonNode tableTypeValue = propertiesValue5.get("tableType"); if (tableTypeValue != null && tableTypeValue instanceof NullNode == false) { String tableTypeInstance; tableTypeInstance = tableTypeValue.getTextValue(); propertiesInstance4.setTableType(tableTypeInstance); } JsonNode columnsArray = propertiesValue5.get("columns"); if (columnsArray != null && columnsArray instanceof NullNode == false) { for (JsonNode columnsValue : ((ArrayNode) columnsArray)) { Column columnInstance = new Column(); propertiesInstance4.getColumns().add(columnInstance); JsonNode propertiesValue6 = columnsValue.get("properties"); if (propertiesValue6 != null && propertiesValue6 instanceof NullNode == false) { ColumnProperties propertiesInstance5 = new ColumnProperties(); columnInstance.setProperties(propertiesInstance5); JsonNode columnTypeValue = propertiesValue6 .get("columnType"); if (columnTypeValue != null && columnTypeValue instanceof NullNode == false) { String columnTypeInstance; columnTypeInstance = columnTypeValue.getTextValue(); propertiesInstance5 .setColumnType(columnTypeInstance); } } JsonNode idValue4 = columnsValue.get("id"); if (idValue4 != null && idValue4 instanceof NullNode == false) { String idInstance4; idInstance4 = idValue4.getTextValue(); columnInstance.setId(idInstance4); } JsonNode nameValue4 = columnsValue.get("name"); if (nameValue4 != null && nameValue4 instanceof NullNode == false) { String nameInstance4; nameInstance4 = nameValue4.getTextValue(); columnInstance.setName(nameInstance4); } JsonNode typeValue4 = columnsValue.get("type"); if (typeValue4 != null && typeValue4 instanceof NullNode == false) { String typeInstance4; typeInstance4 = typeValue4.getTextValue(); columnInstance.setType(typeInstance4); } JsonNode locationValue4 = columnsValue.get("location"); if (locationValue4 != null && locationValue4 instanceof NullNode == false) { String locationInstance4; locationInstance4 = locationValue4.getTextValue(); columnInstance.setLocation(locationInstance4); } JsonNode tagsSequenceElement4 = ((JsonNode) columnsValue .get("tags")); if (tagsSequenceElement4 != null && tagsSequenceElement4 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr4 = tagsSequenceElement4 .getFields(); while (itr4.hasNext()) { Map.Entry<String, JsonNode> property4 = itr4.next(); String tagsKey5 = property4.getKey(); String tagsValue5 = property4.getValue() .getTextValue(); columnInstance.getTags().put(tagsKey5, tagsValue5); } } } } JsonNode recommendedIndexesArray = propertiesValue5 .get("recommendedIndexes"); if (recommendedIndexesArray != null && recommendedIndexesArray instanceof NullNode == false) { for (JsonNode recommendedIndexesValue : ((ArrayNode) recommendedIndexesArray)) { RecommendedIndex recommendedIndexInstance = new RecommendedIndex(); propertiesInstance4.getRecommendedIndexes() .add(recommendedIndexInstance); JsonNode propertiesValue7 = recommendedIndexesValue .get("properties"); if (propertiesValue7 != null && propertiesValue7 instanceof NullNode == false) { RecommendedIndexProperties propertiesInstance6 = new RecommendedIndexProperties(); recommendedIndexInstance .setProperties(propertiesInstance6); JsonNode actionValue = propertiesValue7.get("action"); if (actionValue != null && actionValue instanceof NullNode == false) { String actionInstance; actionInstance = actionValue.getTextValue(); propertiesInstance6.setAction(actionInstance); } JsonNode stateValue = propertiesValue7.get("state"); if (stateValue != null && stateValue instanceof NullNode == false) { String stateInstance; stateInstance = stateValue.getTextValue(); propertiesInstance6.setState(stateInstance); } JsonNode createdValue = propertiesValue7.get("created"); if (createdValue != null && createdValue instanceof NullNode == false) { Calendar createdInstance; createdInstance = DatatypeConverter .parseDateTime(createdValue.getTextValue()); propertiesInstance6.setCreated(createdInstance); } JsonNode lastModifiedValue = propertiesValue7 .get("lastModified"); if (lastModifiedValue != null && lastModifiedValue instanceof NullNode == false) { Calendar lastModifiedInstance; lastModifiedInstance = DatatypeConverter .parseDateTime( lastModifiedValue.getTextValue()); propertiesInstance6 .setLastModified(lastModifiedInstance); } JsonNode indexTypeValue = propertiesValue7 .get("indexType"); if (indexTypeValue != null && indexTypeValue instanceof NullNode == false) { String indexTypeInstance; indexTypeInstance = indexTypeValue.getTextValue(); propertiesInstance6.setIndexType(indexTypeInstance); } JsonNode schemaValue = propertiesValue7.get("schema"); if (schemaValue != null && schemaValue instanceof NullNode == false) { String schemaInstance2; schemaInstance2 = schemaValue.getTextValue(); propertiesInstance6.setSchema(schemaInstance2); } JsonNode tableValue = propertiesValue7.get("table"); if (tableValue != null && tableValue instanceof NullNode == false) { String tableInstance2; tableInstance2 = tableValue.getTextValue(); propertiesInstance6.setTable(tableInstance2); } JsonNode columnsArray2 = propertiesValue7 .get("columns"); if (columnsArray2 != null && columnsArray2 instanceof NullNode == false) { for (JsonNode columnsValue2 : ((ArrayNode) columnsArray2)) { propertiesInstance6.getColumns() .add(columnsValue2.getTextValue()); } } JsonNode includedColumnsArray = propertiesValue7 .get("includedColumns"); if (includedColumnsArray != null && includedColumnsArray instanceof NullNode == false) { for (JsonNode includedColumnsValue : ((ArrayNode) includedColumnsArray)) { propertiesInstance6.getIncludedColumns().add( includedColumnsValue.getTextValue()); } } JsonNode indexScriptValue = propertiesValue7 .get("indexScript"); if (indexScriptValue != null && indexScriptValue instanceof NullNode == false) { String indexScriptInstance; indexScriptInstance = indexScriptValue .getTextValue(); propertiesInstance6 .setIndexScript(indexScriptInstance); } JsonNode estimatedImpactArray = propertiesValue7 .get("estimatedImpact"); if (estimatedImpactArray != null && estimatedImpactArray instanceof NullNode == false) { for (JsonNode estimatedImpactValue : ((ArrayNode) estimatedImpactArray)) { OperationImpact operationImpactInstance = new OperationImpact(); propertiesInstance6.getEstimatedImpact() .add(operationImpactInstance); JsonNode nameValue5 = estimatedImpactValue .get("name"); if (nameValue5 != null && nameValue5 instanceof NullNode == false) { String nameInstance5; nameInstance5 = nameValue5.getTextValue(); operationImpactInstance .setName(nameInstance5); } JsonNode unitValue = estimatedImpactValue .get("unit"); if (unitValue != null && unitValue instanceof NullNode == false) { String unitInstance; unitInstance = unitValue.getTextValue(); operationImpactInstance .setUnit(unitInstance); } JsonNode changeValueAbsoluteValue = estimatedImpactValue .get("changeValueAbsolute"); if (changeValueAbsoluteValue != null && changeValueAbsoluteValue instanceof NullNode == false) { double changeValueAbsoluteInstance; changeValueAbsoluteInstance = changeValueAbsoluteValue .getDoubleValue(); operationImpactInstance .setChangeValueAbsolute( changeValueAbsoluteInstance); } JsonNode changeValueRelativeValue = estimatedImpactValue .get("changeValueRelative"); if (changeValueRelativeValue != null && changeValueRelativeValue instanceof NullNode == false) { double changeValueRelativeInstance; changeValueRelativeInstance = changeValueRelativeValue .getDoubleValue(); operationImpactInstance .setChangeValueRelative( changeValueRelativeInstance); } } } JsonNode reportedImpactArray = propertiesValue7 .get("reportedImpact"); if (reportedImpactArray != null && reportedImpactArray instanceof NullNode == false) { for (JsonNode reportedImpactValue : ((ArrayNode) reportedImpactArray)) { OperationImpact operationImpactInstance2 = new OperationImpact(); propertiesInstance6.getReportedImpact() .add(operationImpactInstance2); JsonNode nameValue6 = reportedImpactValue .get("name"); if (nameValue6 != null && nameValue6 instanceof NullNode == false) { String nameInstance6; nameInstance6 = nameValue6.getTextValue(); operationImpactInstance2 .setName(nameInstance6); } JsonNode unitValue2 = reportedImpactValue .get("unit"); if (unitValue2 != null && unitValue2 instanceof NullNode == false) { String unitInstance2; unitInstance2 = unitValue2.getTextValue(); operationImpactInstance2 .setUnit(unitInstance2); } JsonNode changeValueAbsoluteValue2 = reportedImpactValue .get("changeValueAbsolute"); if (changeValueAbsoluteValue2 != null && changeValueAbsoluteValue2 instanceof NullNode == false) { double changeValueAbsoluteInstance2; changeValueAbsoluteInstance2 = changeValueAbsoluteValue2 .getDoubleValue(); operationImpactInstance2 .setChangeValueAbsolute( changeValueAbsoluteInstance2); } JsonNode changeValueRelativeValue2 = reportedImpactValue .get("changeValueRelative"); if (changeValueRelativeValue2 != null && changeValueRelativeValue2 instanceof NullNode == false) { double changeValueRelativeInstance2; changeValueRelativeInstance2 = changeValueRelativeValue2 .getDoubleValue(); operationImpactInstance2 .setChangeValueRelative( changeValueRelativeInstance2); } } } } JsonNode idValue5 = recommendedIndexesValue.get("id"); if (idValue5 != null && idValue5 instanceof NullNode == false) { String idInstance5; idInstance5 = idValue5.getTextValue(); recommendedIndexInstance.setId(idInstance5); } JsonNode nameValue7 = recommendedIndexesValue.get("name"); if (nameValue7 != null && nameValue7 instanceof NullNode == false) { String nameInstance7; nameInstance7 = nameValue7.getTextValue(); recommendedIndexInstance.setName(nameInstance7); } JsonNode typeValue5 = recommendedIndexesValue.get("type"); if (typeValue5 != null && typeValue5 instanceof NullNode == false) { String typeInstance5; typeInstance5 = typeValue5.getTextValue(); recommendedIndexInstance.setType(typeInstance5); } JsonNode locationValue5 = recommendedIndexesValue .get("location"); if (locationValue5 != null && locationValue5 instanceof NullNode == false) { String locationInstance5; locationInstance5 = locationValue5.getTextValue(); recommendedIndexInstance.setLocation(locationInstance5); } JsonNode tagsSequenceElement5 = ((JsonNode) recommendedIndexesValue .get("tags")); if (tagsSequenceElement5 != null && tagsSequenceElement5 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr5 = tagsSequenceElement5 .getFields(); while (itr5.hasNext()) { Map.Entry<String, JsonNode> property5 = itr5.next(); String tagsKey6 = property5.getKey(); String tagsValue6 = property5.getValue() .getTextValue(); recommendedIndexInstance.getTags().put(tagsKey6, tagsValue6); } } } } } JsonNode idValue6 = tablesValue.get("id"); if (idValue6 != null && idValue6 instanceof NullNode == false) { String idInstance6; idInstance6 = idValue6.getTextValue(); tableInstance.setId(idInstance6); } JsonNode nameValue8 = tablesValue.get("name"); if (nameValue8 != null && nameValue8 instanceof NullNode == false) { String nameInstance8; nameInstance8 = nameValue8.getTextValue(); tableInstance.setName(nameInstance8); } JsonNode typeValue6 = tablesValue.get("type"); if (typeValue6 != null && typeValue6 instanceof NullNode == false) { String typeInstance6; typeInstance6 = typeValue6.getTextValue(); tableInstance.setType(typeInstance6); } JsonNode locationValue6 = tablesValue.get("location"); if (locationValue6 != null && locationValue6 instanceof NullNode == false) { String locationInstance6; locationInstance6 = locationValue6.getTextValue(); tableInstance.setLocation(locationInstance6); } JsonNode tagsSequenceElement6 = ((JsonNode) tablesValue.get("tags")); if (tagsSequenceElement6 != null && tagsSequenceElement6 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr6 = tagsSequenceElement6 .getFields(); while (itr6.hasNext()) { Map.Entry<String, JsonNode> property6 = itr6.next(); String tagsKey7 = property6.getKey(); String tagsValue7 = property6.getValue().getTextValue(); tableInstance.getTags().put(tagsKey7, tagsValue7); } } } } } JsonNode idValue7 = schemasValue.get("id"); if (idValue7 != null && idValue7 instanceof NullNode == false) { String idInstance7; idInstance7 = idValue7.getTextValue(); schemaInstance.setId(idInstance7); } JsonNode nameValue9 = schemasValue.get("name"); if (nameValue9 != null && nameValue9 instanceof NullNode == false) { String nameInstance9; nameInstance9 = nameValue9.getTextValue(); schemaInstance.setName(nameInstance9); } JsonNode typeValue7 = schemasValue.get("type"); if (typeValue7 != null && typeValue7 instanceof NullNode == false) { String typeInstance7; typeInstance7 = typeValue7.getTextValue(); schemaInstance.setType(typeInstance7); } JsonNode locationValue7 = schemasValue.get("location"); if (locationValue7 != null && locationValue7 instanceof NullNode == false) { String locationInstance7; locationInstance7 = locationValue7.getTextValue(); schemaInstance.setLocation(locationInstance7); } JsonNode tagsSequenceElement7 = ((JsonNode) schemasValue.get("tags")); if (tagsSequenceElement7 != null && tagsSequenceElement7 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr7 = tagsSequenceElement7.getFields(); while (itr7.hasNext()) { Map.Entry<String, JsonNode> property7 = itr7.next(); String tagsKey8 = property7.getKey(); String tagsValue8 = property7.getValue().getTextValue(); schemaInstance.getTags().put(tagsKey8, tagsValue8); } } } } JsonNode defaultSecondaryLocationValue = propertiesValue2.get("defaultSecondaryLocation"); if (defaultSecondaryLocationValue != null && defaultSecondaryLocationValue instanceof NullNode == false) { String defaultSecondaryLocationInstance; defaultSecondaryLocationInstance = defaultSecondaryLocationValue.getTextValue(); propertiesInstance.setDefaultSecondaryLocation(defaultSecondaryLocationInstance); } } JsonNode idValue8 = responseDoc.get("id"); if (idValue8 != null && idValue8 instanceof NullNode == false) { String idInstance8; idInstance8 = idValue8.getTextValue(); databaseInstance.setId(idInstance8); } JsonNode nameValue10 = responseDoc.get("name"); if (nameValue10 != null && nameValue10 instanceof NullNode == false) { String nameInstance10; nameInstance10 = nameValue10.getTextValue(); databaseInstance.setName(nameInstance10); } JsonNode typeValue8 = responseDoc.get("type"); if (typeValue8 != null && typeValue8 instanceof NullNode == false) { String typeInstance8; typeInstance8 = typeValue8.getTextValue(); databaseInstance.setType(typeInstance8); } JsonNode locationValue8 = responseDoc.get("location"); if (locationValue8 != null && locationValue8 instanceof NullNode == false) { String locationInstance8; locationInstance8 = locationValue8.getTextValue(); databaseInstance.setLocation(locationInstance8); } JsonNode tagsSequenceElement8 = ((JsonNode) responseDoc.get("tags")); if (tagsSequenceElement8 != null && tagsSequenceElement8 instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr8 = tagsSequenceElement8.getFields(); while (itr8.hasNext()) { Map.Entry<String, JsonNode> property8 = itr8.next(); String tagsKey9 = property8.getKey(); String tagsValue9 = property8.getValue().getTextValue(); databaseInstance.getTags().put(tagsKey9, tagsValue9); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("Location").length > 0) { result.setOperationStatusLink(httpResponse.getFirstHeader("Location").getValue()); } if (httpResponse.getHeaders("Retry-After").length > 0) { result.setRetryAfter( DatatypeConverter.parseInt(httpResponse.getFirstHeader("Retry-After").getValue())); } if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (statusCode == HttpStatus.SC_OK) { result.setStatus(OperationStatus.Succeeded); } if (statusCode == HttpStatus.SC_CREATED) { result.setStatus(OperationStatus.Succeeded); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.windowsazure.management.servicebus.NamespaceOperationsImpl.java
/** * The get authorization rule operation gets an authorization rule for a * namespace by name.//from w ww . ja va 2 s . c om * * @param namespaceName Required. The namespace to get the authorization * rule for. * @param entityName Required. The entity name to get the authorization rule * for. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws ParserConfigurationException Thrown if there was a serious * configuration error with the document parser. * @throws SAXException Thrown if there was an error parsing the XML * response. * @return A response to a request for a particular authorization rule. */ @Override public ServiceBusAuthorizationRuleResponse getAuthorizationRule(String namespaceName, String entityName) throws IOException, ServiceException, ParserConfigurationException, SAXException { // Validate if (namespaceName == null) { throw new NullPointerException("namespaceName"); } if (entityName == null) { throw new NullPointerException("entityName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("namespaceName", namespaceName); tracingParameters.put("entityName", entityName); CloudTracing.enter(invocationId, this, "getAuthorizationRuleAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/services/servicebus/namespaces/"; url = url + URLEncoder.encode(namespaceName, "UTF-8"); url = url + "/AuthorizationRules/"; url = url + URLEncoder.encode(entityName, "UTF-8"); String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("Accept", "application/atom+xml"); httpRequest.setHeader("Content-Type", "application/xml; charset=utf-8"); httpRequest.setHeader("x-ms-version", "2013-08-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result ServiceBusAuthorizationRuleResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ServiceBusAuthorizationRuleResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element entryElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://www.w3.org/2005/Atom", "entry"); if (entryElement != null) { Element contentElement = XmlUtility.getElementByTagNameNS(entryElement, "http://www.w3.org/2005/Atom", "content"); if (contentElement != null) { Element sharedAccessAuthorizationRuleElement = XmlUtility.getElementByTagNameNS( contentElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "SharedAccessAuthorizationRule"); if (sharedAccessAuthorizationRuleElement != null) { ServiceBusSharedAccessAuthorizationRule sharedAccessAuthorizationRuleInstance = new ServiceBusSharedAccessAuthorizationRule(); result.setAuthorizationRule(sharedAccessAuthorizationRuleInstance); Element claimTypeElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ClaimType"); if (claimTypeElement != null) { String claimTypeInstance; claimTypeInstance = claimTypeElement.getTextContent(); sharedAccessAuthorizationRuleInstance.setClaimType(claimTypeInstance); } Element claimValueElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ClaimValue"); if (claimValueElement != null) { String claimValueInstance; claimValueInstance = claimValueElement.getTextContent(); sharedAccessAuthorizationRuleInstance.setClaimValue(claimValueInstance); } Element rightsSequenceElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "Rights"); if (rightsSequenceElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(rightsSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AccessRights") .size(); i1 = i1 + 1) { org.w3c.dom.Element rightsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(rightsSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AccessRights") .get(i1)); sharedAccessAuthorizationRuleInstance.getRights() .add(AccessRight.valueOf(rightsElement.getTextContent())); } } Element createdTimeElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "CreatedTime"); if (createdTimeElement != null) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter .parseDateTime(createdTimeElement.getTextContent()); sharedAccessAuthorizationRuleInstance.setCreatedTime(createdTimeInstance); } Element modifiedTimeElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ModifiedTime"); if (modifiedTimeElement != null) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeElement.getTextContent()); sharedAccessAuthorizationRuleInstance.setModifiedTime(modifiedTimeInstance); } Element keyNameElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "KeyName"); if (keyNameElement != null) { String keyNameInstance; keyNameInstance = keyNameElement.getTextContent(); sharedAccessAuthorizationRuleInstance.setKeyName(keyNameInstance); } Element primaryKeyElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "PrimaryKey"); if (primaryKeyElement != null) { String primaryKeyInstance; primaryKeyInstance = primaryKeyElement.getTextContent(); sharedAccessAuthorizationRuleInstance.setPrimaryKey(primaryKeyInstance); } Element secondaryKeyElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "SecondaryKey"); if (secondaryKeyElement != null) { String secondaryKeyInstance; secondaryKeyInstance = secondaryKeyElement.getTextContent(); sharedAccessAuthorizationRuleInstance.setSecondaryKey(secondaryKeyInstance); } Element revisionElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "Revision"); if (revisionElement != null) { int revisionInstance; revisionInstance = DatatypeConverter.parseInt(revisionElement.getTextContent()); sharedAccessAuthorizationRuleInstance.setRevision(revisionInstance); } } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }