List of usage examples for javax.xml.bind DatatypeConverter parseDateTime
public static java.util.Calendar parseDateTime(String lexicalXSDDateTime)
Converts the string argument into a Calendar value.
From source file:com.microsoft.azure.management.sql.RecommendedElasticPoolOperationsImpl.java
/** * Returns information about an Azure SQL Database inside of an Azure Sql * Recommended Elastic Pool./* ww w.j a v a 2s.c o m*/ * * @param resourceGroupName Required. The name of the Resource Group to * which the server belongs. * @param serverName Required. The name of the Azure SQL Database Server on * which the database is hosted. * @param recommendedElasticPoolName Required. The name of the Azure SQL * Database Elastic Pool to be retrieved. * @param databaseName Required. The name of the Azure SQL Database to be * retrieved. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Represents the response to a Get Azure Sql Database request. */ @Override public DatabaseGetResponse getDatabases(String resourceGroupName, String serverName, String recommendedElasticPoolName, String databaseName) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (serverName == null) { throw new NullPointerException("serverName"); } if (recommendedElasticPoolName == null) { throw new NullPointerException("recommendedElasticPoolName"); } 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("recommendedElasticPoolName", recommendedElasticPoolName); tracingParameters.put("databaseName", databaseName); CloudTracing.enter(invocationId, this, "getDatabasesAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourceGroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/"; url = url + "Microsoft.Sql"; url = url + "/servers/"; url = url + URLEncoder.encode(serverName, "UTF-8"); url = url + "/recommendedElasticPools/"; url = url + URLEncoder.encode(recommendedElasticPoolName, "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 HttpGet httpRequest = new HttpGet(url); // Set Headers // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result DatabaseGetResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new DatabaseGetResponse(); 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) { 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("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.compute.VirtualMachineOperationsImpl.java
/** * The operation to create or update a virtual machine. * * @param resourceGroupName Required. The name of the resource group. * @param parameters Required. Parameters supplied to the Create Virtual * Machine operation.//from ww w. jav a2s .co m * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The Create Virtual Machine operation response. */ @Override public VirtualMachineCreateOrUpdateResponse beginCreatingOrUpdating(String resourceGroupName, VirtualMachine parameters) throws IOException, ServiceException, URISyntaxException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getExtensions() != null) { for (VirtualMachineExtension extensionsParameterItem : parameters.getExtensions()) { if (extensionsParameterItem.getLocation() == null) { throw new NullPointerException("parameters.Extensions.Location"); } } } if (parameters.getLocation() == null) { throw new NullPointerException("parameters.Location"); } if (parameters.getStorageProfile() != null) { if (parameters.getStorageProfile().getDataDisks() != null) { for (DataDisk dataDisksParameterItem : parameters.getStorageProfile().getDataDisks()) { if (dataDisksParameterItem.getCreateOption() == null) { throw new NullPointerException("parameters.StorageProfile.DataDisks.CreateOption"); } if (dataDisksParameterItem.getName() == null) { throw new NullPointerException("parameters.StorageProfile.DataDisks.Name"); } if (dataDisksParameterItem.getVirtualHardDisk() == null) { throw new NullPointerException("parameters.StorageProfile.DataDisks.VirtualHardDisk"); } } } if (parameters.getStorageProfile().getOSDisk() != null) { if (parameters.getStorageProfile().getOSDisk().getCreateOption() == null) { throw new NullPointerException("parameters.StorageProfile.OSDisk.CreateOption"); } if (parameters.getStorageProfile().getOSDisk().getName() == null) { throw new NullPointerException("parameters.StorageProfile.OSDisk.Name"); } if (parameters.getStorageProfile().getOSDisk().getVirtualHardDisk() == null) { throw new NullPointerException("parameters.StorageProfile.OSDisk.VirtualHardDisk"); } } } // 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("parameters", parameters); CloudTracing.enter(invocationId, this, "beginCreatingOrUpdatingAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourceGroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/"; url = url + "Microsoft.Compute"; url = url + "/"; url = url + "virtualMachines"; url = url + "/"; if (parameters.getName() != null) { url = url + URLEncoder.encode(parameters.getName(), "UTF-8"); } ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects 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 virtualMachineJsonValue = objectMapper.createObjectNode(); requestDoc = virtualMachineJsonValue; if (parameters.getPlan() != null) { ObjectNode planValue = objectMapper.createObjectNode(); ((ObjectNode) virtualMachineJsonValue).put("plan", planValue); if (parameters.getPlan().getName() != null) { ((ObjectNode) planValue).put("name", parameters.getPlan().getName()); } if (parameters.getPlan().getPublisher() != null) { ((ObjectNode) planValue).put("publisher", parameters.getPlan().getPublisher()); } if (parameters.getPlan().getProduct() != null) { ((ObjectNode) planValue).put("product", parameters.getPlan().getProduct()); } if (parameters.getPlan().getPromotionCode() != null) { ((ObjectNode) planValue).put("promotionCode", parameters.getPlan().getPromotionCode()); } } ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) virtualMachineJsonValue).put("properties", propertiesValue); if (parameters.getHardwareProfile() != null) { ObjectNode hardwareProfileValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("hardwareProfile", hardwareProfileValue); if (parameters.getHardwareProfile().getVirtualMachineSize() != null) { ((ObjectNode) hardwareProfileValue).put("vmSize", parameters.getHardwareProfile().getVirtualMachineSize()); } } if (parameters.getStorageProfile() != null) { ObjectNode storageProfileValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("storageProfile", storageProfileValue); if (parameters.getStorageProfile().getImageReference() != null) { ObjectNode imageReferenceValue = objectMapper.createObjectNode(); ((ObjectNode) storageProfileValue).put("imageReference", imageReferenceValue); if (parameters.getStorageProfile().getImageReference().getPublisher() != null) { ((ObjectNode) imageReferenceValue).put("publisher", parameters.getStorageProfile().getImageReference().getPublisher()); } if (parameters.getStorageProfile().getImageReference().getOffer() != null) { ((ObjectNode) imageReferenceValue).put("offer", parameters.getStorageProfile().getImageReference().getOffer()); } if (parameters.getStorageProfile().getImageReference().getSku() != null) { ((ObjectNode) imageReferenceValue).put("sku", parameters.getStorageProfile().getImageReference().getSku()); } if (parameters.getStorageProfile().getImageReference().getVersion() != null) { ((ObjectNode) imageReferenceValue).put("version", parameters.getStorageProfile().getImageReference().getVersion()); } } if (parameters.getStorageProfile().getOSDisk() != null) { ObjectNode osDiskValue = objectMapper.createObjectNode(); ((ObjectNode) storageProfileValue).put("osDisk", osDiskValue); if (parameters.getStorageProfile().getOSDisk().getOperatingSystemType() != null) { ((ObjectNode) osDiskValue).put("osType", parameters.getStorageProfile().getOSDisk().getOperatingSystemType()); } ((ObjectNode) osDiskValue).put("name", parameters.getStorageProfile().getOSDisk().getName()); ObjectNode vhdValue = objectMapper.createObjectNode(); ((ObjectNode) osDiskValue).put("vhd", vhdValue); if (parameters.getStorageProfile().getOSDisk().getVirtualHardDisk().getUri() != null) { ((ObjectNode) vhdValue).put("uri", parameters.getStorageProfile().getOSDisk().getVirtualHardDisk().getUri()); } if (parameters.getStorageProfile().getOSDisk().getSourceImage() != null) { ObjectNode imageValue = objectMapper.createObjectNode(); ((ObjectNode) osDiskValue).put("image", imageValue); if (parameters.getStorageProfile().getOSDisk().getSourceImage().getUri() != null) { ((ObjectNode) imageValue).put("uri", parameters.getStorageProfile().getOSDisk().getSourceImage().getUri()); } } if (parameters.getStorageProfile().getOSDisk().getCaching() != null) { ((ObjectNode) osDiskValue).put("caching", parameters.getStorageProfile().getOSDisk().getCaching()); } ((ObjectNode) osDiskValue).put("createOption", parameters.getStorageProfile().getOSDisk().getCreateOption()); if (parameters.getStorageProfile().getOSDisk().getDiskSizeGB() != null) { ((ObjectNode) osDiskValue).put("diskSizeGB", parameters.getStorageProfile().getOSDisk().getDiskSizeGB()); } } if (parameters.getStorageProfile().getDataDisks() != null) { if (parameters.getStorageProfile().getDataDisks() instanceof LazyCollection == false || ((LazyCollection) parameters.getStorageProfile().getDataDisks()).isInitialized()) { ArrayNode dataDisksArray = objectMapper.createArrayNode(); for (DataDisk dataDisksItem : parameters.getStorageProfile().getDataDisks()) { ObjectNode dataDiskValue = objectMapper.createObjectNode(); dataDisksArray.add(dataDiskValue); ((ObjectNode) dataDiskValue).put("lun", dataDisksItem.getLun()); ((ObjectNode) dataDiskValue).put("name", dataDisksItem.getName()); ObjectNode vhdValue2 = objectMapper.createObjectNode(); ((ObjectNode) dataDiskValue).put("vhd", vhdValue2); if (dataDisksItem.getVirtualHardDisk().getUri() != null) { ((ObjectNode) vhdValue2).put("uri", dataDisksItem.getVirtualHardDisk().getUri()); } if (dataDisksItem.getSourceImage() != null) { ObjectNode imageValue2 = objectMapper.createObjectNode(); ((ObjectNode) dataDiskValue).put("image", imageValue2); if (dataDisksItem.getSourceImage().getUri() != null) { ((ObjectNode) imageValue2).put("uri", dataDisksItem.getSourceImage().getUri()); } } if (dataDisksItem.getCaching() != null) { ((ObjectNode) dataDiskValue).put("caching", dataDisksItem.getCaching()); } ((ObjectNode) dataDiskValue).put("createOption", dataDisksItem.getCreateOption()); if (dataDisksItem.getDiskSizeGB() != null) { ((ObjectNode) dataDiskValue).put("diskSizeGB", dataDisksItem.getDiskSizeGB()); } } ((ObjectNode) storageProfileValue).put("dataDisks", dataDisksArray); } } } if (parameters.getOSProfile() != null) { ObjectNode osProfileValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("osProfile", osProfileValue); if (parameters.getOSProfile().getComputerName() != null) { ((ObjectNode) osProfileValue).put("computerName", parameters.getOSProfile().getComputerName()); } if (parameters.getOSProfile().getAdminUsername() != null) { ((ObjectNode) osProfileValue).put("adminUsername", parameters.getOSProfile().getAdminUsername()); } if (parameters.getOSProfile().getAdminPassword() != null) { ((ObjectNode) osProfileValue).put("adminPassword", parameters.getOSProfile().getAdminPassword()); } if (parameters.getOSProfile().getCustomData() != null) { ((ObjectNode) osProfileValue).put("customData", parameters.getOSProfile().getCustomData()); } if (parameters.getOSProfile().getWindowsConfiguration() != null) { ObjectNode windowsConfigurationValue = objectMapper.createObjectNode(); ((ObjectNode) osProfileValue).put("windowsConfiguration", windowsConfigurationValue); if (parameters.getOSProfile().getWindowsConfiguration().isProvisionVMAgent() != null) { ((ObjectNode) windowsConfigurationValue).put("provisionVMAgent", parameters.getOSProfile().getWindowsConfiguration().isProvisionVMAgent()); } if (parameters.getOSProfile().getWindowsConfiguration().isEnableAutomaticUpdates() != null) { ((ObjectNode) windowsConfigurationValue).put("enableAutomaticUpdates", parameters.getOSProfile().getWindowsConfiguration().isEnableAutomaticUpdates()); } if (parameters.getOSProfile().getWindowsConfiguration().getTimeZone() != null) { ((ObjectNode) windowsConfigurationValue).put("timeZone", parameters.getOSProfile().getWindowsConfiguration().getTimeZone()); } if (parameters.getOSProfile().getWindowsConfiguration().getAdditionalUnattendContents() != null) { if (parameters.getOSProfile().getWindowsConfiguration() .getAdditionalUnattendContents() instanceof LazyCollection == false || ((LazyCollection) parameters.getOSProfile().getWindowsConfiguration() .getAdditionalUnattendContents()).isInitialized()) { ArrayNode additionalUnattendContentArray = objectMapper.createArrayNode(); for (AdditionalUnattendContent additionalUnattendContentItem : parameters.getOSProfile() .getWindowsConfiguration().getAdditionalUnattendContents()) { ObjectNode additionalUnattendContentValue = objectMapper.createObjectNode(); additionalUnattendContentArray.add(additionalUnattendContentValue); if (additionalUnattendContentItem.getPassName() != null) { ((ObjectNode) additionalUnattendContentValue).put("passName", additionalUnattendContentItem.getPassName()); } if (additionalUnattendContentItem.getComponentName() != null) { ((ObjectNode) additionalUnattendContentValue).put("componentName", additionalUnattendContentItem.getComponentName()); } if (additionalUnattendContentItem.getSettingName() != null) { ((ObjectNode) additionalUnattendContentValue).put("settingName", additionalUnattendContentItem.getSettingName()); } if (additionalUnattendContentItem.getContent() != null) { ((ObjectNode) additionalUnattendContentValue).put("content", additionalUnattendContentItem.getContent()); } } ((ObjectNode) windowsConfigurationValue).put("additionalUnattendContent", additionalUnattendContentArray); } } if (parameters.getOSProfile().getWindowsConfiguration().getWinRMConfiguration() != null) { ObjectNode winRMValue = objectMapper.createObjectNode(); ((ObjectNode) windowsConfigurationValue).put("winRM", winRMValue); if (parameters.getOSProfile().getWindowsConfiguration().getWinRMConfiguration() .getListeners() != null) { if (parameters.getOSProfile().getWindowsConfiguration().getWinRMConfiguration() .getListeners() instanceof LazyCollection == false || ((LazyCollection) parameters.getOSProfile().getWindowsConfiguration() .getWinRMConfiguration().getListeners()).isInitialized()) { ArrayNode listenersArray = objectMapper.createArrayNode(); for (WinRMListener listenersItem : parameters.getOSProfile().getWindowsConfiguration() .getWinRMConfiguration().getListeners()) { ObjectNode winRMListenerValue = objectMapper.createObjectNode(); listenersArray.add(winRMListenerValue); if (listenersItem.getProtocol() != null) { ((ObjectNode) winRMListenerValue).put("protocol", listenersItem.getProtocol()); } if (listenersItem.getCertificateUrl() != null) { ((ObjectNode) winRMListenerValue).put("certificateUrl", listenersItem.getCertificateUrl().toString()); } } ((ObjectNode) winRMValue).put("listeners", listenersArray); } } } } if (parameters.getOSProfile().getLinuxConfiguration() != null) { ObjectNode linuxConfigurationValue = objectMapper.createObjectNode(); ((ObjectNode) osProfileValue).put("linuxConfiguration", linuxConfigurationValue); if (parameters.getOSProfile().getLinuxConfiguration().isDisablePasswordAuthentication() != null) { ((ObjectNode) linuxConfigurationValue).put("disablePasswordAuthentication", parameters.getOSProfile().getLinuxConfiguration().isDisablePasswordAuthentication()); } if (parameters.getOSProfile().getLinuxConfiguration().getSshConfiguration() != null) { ObjectNode sshValue = objectMapper.createObjectNode(); ((ObjectNode) linuxConfigurationValue).put("ssh", sshValue); if (parameters.getOSProfile().getLinuxConfiguration().getSshConfiguration() .getPublicKeys() != null) { if (parameters.getOSProfile().getLinuxConfiguration().getSshConfiguration() .getPublicKeys() instanceof LazyCollection == false || ((LazyCollection) parameters.getOSProfile().getLinuxConfiguration() .getSshConfiguration().getPublicKeys()).isInitialized()) { ArrayNode publicKeysArray = objectMapper.createArrayNode(); for (SshPublicKey publicKeysItem : parameters.getOSProfile().getLinuxConfiguration() .getSshConfiguration().getPublicKeys()) { ObjectNode sshPublicKeyValue = objectMapper.createObjectNode(); publicKeysArray.add(sshPublicKeyValue); if (publicKeysItem.getPath() != null) { ((ObjectNode) sshPublicKeyValue).put("path", publicKeysItem.getPath()); } if (publicKeysItem.getKeyData() != null) { ((ObjectNode) sshPublicKeyValue).put("keyData", publicKeysItem.getKeyData()); } } ((ObjectNode) sshValue).put("publicKeys", publicKeysArray); } } } } if (parameters.getOSProfile().getSecrets() != null) { ArrayNode secretsArray = objectMapper.createArrayNode(); for (VaultSecretGroup secretsItem : parameters.getOSProfile().getSecrets()) { ObjectNode vaultSecretGroupValue = objectMapper.createObjectNode(); secretsArray.add(vaultSecretGroupValue); if (secretsItem.getSourceVault() != null) { ObjectNode sourceVaultValue = objectMapper.createObjectNode(); ((ObjectNode) vaultSecretGroupValue).put("sourceVault", sourceVaultValue); if (secretsItem.getSourceVault().getReferenceUri() != null) { ((ObjectNode) sourceVaultValue).put("id", secretsItem.getSourceVault().getReferenceUri()); } } if (secretsItem.getVaultCertificates() != null) { if (secretsItem.getVaultCertificates() instanceof LazyCollection == false || ((LazyCollection) secretsItem.getVaultCertificates()).isInitialized()) { ArrayNode vaultCertificatesArray = objectMapper.createArrayNode(); for (VaultCertificate vaultCertificatesItem : secretsItem.getVaultCertificates()) { ObjectNode vaultCertificateValue = objectMapper.createObjectNode(); vaultCertificatesArray.add(vaultCertificateValue); if (vaultCertificatesItem.getCertificateUrl() != null) { ((ObjectNode) vaultCertificateValue).put("certificateUrl", vaultCertificatesItem.getCertificateUrl()); } if (vaultCertificatesItem.getCertificateStore() != null) { ((ObjectNode) vaultCertificateValue).put("certificateStore", vaultCertificatesItem.getCertificateStore()); } } ((ObjectNode) vaultSecretGroupValue).put("vaultCertificates", vaultCertificatesArray); } } } ((ObjectNode) osProfileValue).put("secrets", secretsArray); } } if (parameters.getNetworkProfile() != null) { ObjectNode networkProfileValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("networkProfile", networkProfileValue); if (parameters.getNetworkProfile().getNetworkInterfaces() != null) { if (parameters.getNetworkProfile().getNetworkInterfaces() instanceof LazyCollection == false || ((LazyCollection) parameters.getNetworkProfile().getNetworkInterfaces()) .isInitialized()) { ArrayNode networkInterfacesArray = objectMapper.createArrayNode(); for (NetworkInterfaceReference networkInterfacesItem : parameters.getNetworkProfile() .getNetworkInterfaces()) { ObjectNode networkInterfaceReferenceJsonValue = objectMapper.createObjectNode(); networkInterfacesArray.add(networkInterfaceReferenceJsonValue); ObjectNode propertiesValue2 = objectMapper.createObjectNode(); ((ObjectNode) networkInterfaceReferenceJsonValue).put("properties", propertiesValue2); if (networkInterfacesItem.isPrimary() != null) { ((ObjectNode) propertiesValue2).put("primary", networkInterfacesItem.isPrimary()); } if (networkInterfacesItem.getReferenceUri() != null) { ((ObjectNode) networkInterfaceReferenceJsonValue).put("id", networkInterfacesItem.getReferenceUri()); } } ((ObjectNode) networkProfileValue).put("networkInterfaces", networkInterfacesArray); } } } if (parameters.getDiagnosticsProfile() != null) { ObjectNode diagnosticsProfileValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("diagnosticsProfile", diagnosticsProfileValue); if (parameters.getDiagnosticsProfile().getBootDiagnostics() != null) { ObjectNode bootDiagnosticsValue = objectMapper.createObjectNode(); ((ObjectNode) diagnosticsProfileValue).put("bootDiagnostics", bootDiagnosticsValue); if (parameters.getDiagnosticsProfile().getBootDiagnostics().isEnabled() != null) { ((ObjectNode) bootDiagnosticsValue).put("enabled", parameters.getDiagnosticsProfile().getBootDiagnostics().isEnabled()); } if (parameters.getDiagnosticsProfile().getBootDiagnostics().getStorageUri() != null) { ((ObjectNode) bootDiagnosticsValue).put("storageUri", parameters.getDiagnosticsProfile().getBootDiagnostics().getStorageUri().toString()); } } } if (parameters.getAvailabilitySetReference() != null) { ObjectNode availabilitySetValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("availabilitySet", availabilitySetValue); if (parameters.getAvailabilitySetReference().getReferenceUri() != null) { ((ObjectNode) availabilitySetValue).put("id", parameters.getAvailabilitySetReference().getReferenceUri()); } } if (parameters.getProvisioningState() != null) { ((ObjectNode) propertiesValue).put("provisioningState", parameters.getProvisioningState()); } if (parameters.getInstanceView() != null) { ObjectNode instanceViewValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("instanceView", instanceViewValue); if (parameters.getInstanceView().getPlatformUpdateDomain() != null) { ((ObjectNode) instanceViewValue).put("platformUpdateDomain", parameters.getInstanceView().getPlatformUpdateDomain()); } if (parameters.getInstanceView().getPlatformFaultDomain() != null) { ((ObjectNode) instanceViewValue).put("platformFaultDomain", parameters.getInstanceView().getPlatformFaultDomain()); } if (parameters.getInstanceView().getRemoteDesktopThumbprint() != null) { ((ObjectNode) instanceViewValue).put("rdpThumbPrint", parameters.getInstanceView().getRemoteDesktopThumbprint()); } if (parameters.getInstanceView().getVMAgent() != null) { ObjectNode vmAgentValue = objectMapper.createObjectNode(); ((ObjectNode) instanceViewValue).put("vmAgent", vmAgentValue); if (parameters.getInstanceView().getVMAgent().getVMAgentVersion() != null) { ((ObjectNode) vmAgentValue).put("vmAgentVersion", parameters.getInstanceView().getVMAgent().getVMAgentVersion()); } if (parameters.getInstanceView().getVMAgent().getExtensionHandlers() != null) { if (parameters.getInstanceView().getVMAgent() .getExtensionHandlers() instanceof LazyCollection == false || ((LazyCollection) parameters.getInstanceView().getVMAgent().getExtensionHandlers()) .isInitialized()) { ArrayNode extensionHandlersArray = objectMapper.createArrayNode(); for (VirtualMachineExtensionHandlerInstanceView extensionHandlersItem : parameters .getInstanceView().getVMAgent().getExtensionHandlers()) { ObjectNode virtualMachineExtensionHandlerInstanceViewValue = objectMapper .createObjectNode(); extensionHandlersArray.add(virtualMachineExtensionHandlerInstanceViewValue); if (extensionHandlersItem.getType() != null) { ((ObjectNode) virtualMachineExtensionHandlerInstanceViewValue).put("type", extensionHandlersItem.getType()); } if (extensionHandlersItem.getTypeHandlerVersion() != null) { ((ObjectNode) virtualMachineExtensionHandlerInstanceViewValue) .put("typeHandlerVersion", extensionHandlersItem.getTypeHandlerVersion()); } if (extensionHandlersItem.getStatus() != null) { ObjectNode statusValue = objectMapper.createObjectNode(); ((ObjectNode) virtualMachineExtensionHandlerInstanceViewValue).put("status", statusValue); if (extensionHandlersItem.getStatus().getCode() != null) { ((ObjectNode) statusValue).put("code", extensionHandlersItem.getStatus().getCode()); } if (extensionHandlersItem.getStatus().getLevel() != null) { ((ObjectNode) statusValue).put("level", extensionHandlersItem.getStatus().getLevel()); } if (extensionHandlersItem.getStatus().getDisplayStatus() != null) { ((ObjectNode) statusValue).put("displayStatus", extensionHandlersItem.getStatus().getDisplayStatus()); } if (extensionHandlersItem.getStatus().getMessage() != null) { ((ObjectNode) statusValue).put("message", extensionHandlersItem.getStatus().getMessage()); } if (extensionHandlersItem.getStatus().getTime() != null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) statusValue).put("time", simpleDateFormat .format(extensionHandlersItem.getStatus().getTime().getTime())); } } } ((ObjectNode) vmAgentValue).put("extensionHandlers", extensionHandlersArray); } } if (parameters.getInstanceView().getVMAgent().getStatuses() != null) { ArrayNode statusesArray = objectMapper.createArrayNode(); for (InstanceViewStatus statusesItem : parameters.getInstanceView().getVMAgent() .getStatuses()) { ObjectNode instanceViewStatusValue = objectMapper.createObjectNode(); statusesArray.add(instanceViewStatusValue); if (statusesItem.getCode() != null) { ((ObjectNode) instanceViewStatusValue).put("code", statusesItem.getCode()); } if (statusesItem.getLevel() != null) { ((ObjectNode) instanceViewStatusValue).put("level", statusesItem.getLevel()); } if (statusesItem.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue).put("displayStatus", statusesItem.getDisplayStatus()); } if (statusesItem.getMessage() != null) { ((ObjectNode) instanceViewStatusValue).put("message", statusesItem.getMessage()); } if (statusesItem.getTime() != null) { SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue).put("time", simpleDateFormat2.format(statusesItem.getTime().getTime())); } } ((ObjectNode) vmAgentValue).put("statuses", statusesArray); } } if (parameters.getInstanceView().getDisks() != null) { if (parameters.getInstanceView().getDisks() instanceof LazyCollection == false || ((LazyCollection) parameters.getInstanceView().getDisks()).isInitialized()) { ArrayNode disksArray = objectMapper.createArrayNode(); for (DiskInstanceView disksItem : parameters.getInstanceView().getDisks()) { ObjectNode diskInstanceViewValue = objectMapper.createObjectNode(); disksArray.add(diskInstanceViewValue); if (disksItem.getName() != null) { ((ObjectNode) diskInstanceViewValue).put("name", disksItem.getName()); } if (disksItem.getStatuses() != null) { ArrayNode statusesArray2 = objectMapper.createArrayNode(); for (InstanceViewStatus statusesItem2 : disksItem.getStatuses()) { ObjectNode instanceViewStatusValue2 = objectMapper.createObjectNode(); statusesArray2.add(instanceViewStatusValue2); if (statusesItem2.getCode() != null) { ((ObjectNode) instanceViewStatusValue2).put("code", statusesItem2.getCode()); } if (statusesItem2.getLevel() != null) { ((ObjectNode) instanceViewStatusValue2).put("level", statusesItem2.getLevel()); } if (statusesItem2.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue2).put("displayStatus", statusesItem2.getDisplayStatus()); } if (statusesItem2.getMessage() != null) { ((ObjectNode) instanceViewStatusValue2).put("message", statusesItem2.getMessage()); } if (statusesItem2.getTime() != null) { SimpleDateFormat simpleDateFormat3 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat3.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue2).put("time", simpleDateFormat3.format(statusesItem2.getTime().getTime())); } } ((ObjectNode) diskInstanceViewValue).put("statuses", statusesArray2); } } ((ObjectNode) instanceViewValue).put("disks", disksArray); } } if (parameters.getInstanceView().getExtensions() != null) { if (parameters.getInstanceView().getExtensions() instanceof LazyCollection == false || ((LazyCollection) parameters.getInstanceView().getExtensions()).isInitialized()) { ArrayNode extensionsArray = objectMapper.createArrayNode(); for (VirtualMachineExtensionInstanceView extensionsItem : parameters.getInstanceView() .getExtensions()) { ObjectNode virtualMachineExtensionInstanceViewValue = objectMapper.createObjectNode(); extensionsArray.add(virtualMachineExtensionInstanceViewValue); if (extensionsItem.getName() != null) { ((ObjectNode) virtualMachineExtensionInstanceViewValue).put("name", extensionsItem.getName()); } if (extensionsItem.getExtensionType() != null) { ((ObjectNode) virtualMachineExtensionInstanceViewValue).put("type", extensionsItem.getExtensionType()); } if (extensionsItem.getTypeHandlerVersion() != null) { ((ObjectNode) virtualMachineExtensionInstanceViewValue).put("typeHandlerVersion", extensionsItem.getTypeHandlerVersion()); } if (extensionsItem.getSubStatuses() != null) { if (extensionsItem.getSubStatuses() instanceof LazyCollection == false || ((LazyCollection) extensionsItem.getSubStatuses()).isInitialized()) { ArrayNode substatusesArray = objectMapper.createArrayNode(); for (InstanceViewStatus substatusesItem : extensionsItem.getSubStatuses()) { ObjectNode instanceViewStatusValue3 = objectMapper.createObjectNode(); substatusesArray.add(instanceViewStatusValue3); if (substatusesItem.getCode() != null) { ((ObjectNode) instanceViewStatusValue3).put("code", substatusesItem.getCode()); } if (substatusesItem.getLevel() != null) { ((ObjectNode) instanceViewStatusValue3).put("level", substatusesItem.getLevel()); } if (substatusesItem.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue3).put("displayStatus", substatusesItem.getDisplayStatus()); } if (substatusesItem.getMessage() != null) { ((ObjectNode) instanceViewStatusValue3).put("message", substatusesItem.getMessage()); } if (substatusesItem.getTime() != null) { SimpleDateFormat simpleDateFormat4 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat4.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue3).put("time", simpleDateFormat4.format(substatusesItem.getTime().getTime())); } } ((ObjectNode) virtualMachineExtensionInstanceViewValue).put("substatuses", substatusesArray); } } if (extensionsItem.getStatuses() != null) { ArrayNode statusesArray3 = objectMapper.createArrayNode(); for (InstanceViewStatus statusesItem3 : extensionsItem.getStatuses()) { ObjectNode instanceViewStatusValue4 = objectMapper.createObjectNode(); statusesArray3.add(instanceViewStatusValue4); if (statusesItem3.getCode() != null) { ((ObjectNode) instanceViewStatusValue4).put("code", statusesItem3.getCode()); } if (statusesItem3.getLevel() != null) { ((ObjectNode) instanceViewStatusValue4).put("level", statusesItem3.getLevel()); } if (statusesItem3.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue4).put("displayStatus", statusesItem3.getDisplayStatus()); } if (statusesItem3.getMessage() != null) { ((ObjectNode) instanceViewStatusValue4).put("message", statusesItem3.getMessage()); } if (statusesItem3.getTime() != null) { SimpleDateFormat simpleDateFormat5 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat5.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue4).put("time", simpleDateFormat5.format(statusesItem3.getTime().getTime())); } } ((ObjectNode) virtualMachineExtensionInstanceViewValue).put("statuses", statusesArray3); } } ((ObjectNode) instanceViewValue).put("extensions", extensionsArray); } } if (parameters.getInstanceView().getBootDiagnostics() != null) { ObjectNode bootDiagnosticsValue2 = objectMapper.createObjectNode(); ((ObjectNode) instanceViewValue).put("bootDiagnostics", bootDiagnosticsValue2); if (parameters.getInstanceView().getBootDiagnostics().getConsoleScreenshotBlobUri() != null) { ((ObjectNode) bootDiagnosticsValue2).put("consoleScreenshotBlobUri", parameters .getInstanceView().getBootDiagnostics().getConsoleScreenshotBlobUri().toString()); } if (parameters.getInstanceView().getBootDiagnostics().getSerialConsoleLogBlobUri() != null) { ((ObjectNode) bootDiagnosticsValue2).put("serialConsoleLogBlobUri", parameters.getInstanceView() .getBootDiagnostics().getSerialConsoleLogBlobUri().toString()); } } if (parameters.getInstanceView().getStatuses() != null) { ArrayNode statusesArray4 = objectMapper.createArrayNode(); for (InstanceViewStatus statusesItem4 : parameters.getInstanceView().getStatuses()) { ObjectNode instanceViewStatusValue5 = objectMapper.createObjectNode(); statusesArray4.add(instanceViewStatusValue5); if (statusesItem4.getCode() != null) { ((ObjectNode) instanceViewStatusValue5).put("code", statusesItem4.getCode()); } if (statusesItem4.getLevel() != null) { ((ObjectNode) instanceViewStatusValue5).put("level", statusesItem4.getLevel()); } if (statusesItem4.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue5).put("displayStatus", statusesItem4.getDisplayStatus()); } if (statusesItem4.getMessage() != null) { ((ObjectNode) instanceViewStatusValue5).put("message", statusesItem4.getMessage()); } if (statusesItem4.getTime() != null) { SimpleDateFormat simpleDateFormat6 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat6.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue5).put("time", simpleDateFormat6.format(statusesItem4.getTime().getTime())); } } ((ObjectNode) instanceViewValue).put("statuses", statusesArray4); } } if (parameters.getExtensions() != null) { ArrayNode resourcesArray = objectMapper.createArrayNode(); for (VirtualMachineExtension resourcesItem : parameters.getExtensions()) { ObjectNode virtualMachineExtensionJsonValue = objectMapper.createObjectNode(); resourcesArray.add(virtualMachineExtensionJsonValue); ObjectNode propertiesValue3 = objectMapper.createObjectNode(); ((ObjectNode) virtualMachineExtensionJsonValue).put("properties", propertiesValue3); if (resourcesItem.getPublisher() != null) { ((ObjectNode) propertiesValue3).put("publisher", resourcesItem.getPublisher()); } if (resourcesItem.getExtensionType() != null) { ((ObjectNode) propertiesValue3).put("type", resourcesItem.getExtensionType()); } if (resourcesItem.getTypeHandlerVersion() != null) { ((ObjectNode) propertiesValue3).put("typeHandlerVersion", resourcesItem.getTypeHandlerVersion()); } ((ObjectNode) propertiesValue3).put("autoUpgradeMinorVersion", resourcesItem.isAutoUpgradeMinorVersion()); if (resourcesItem.getSettings() != null) { ((ObjectNode) propertiesValue3).put("settings", objectMapper.readTree(resourcesItem.getSettings())); } if (resourcesItem.getProtectedSettings() != null) { ((ObjectNode) propertiesValue3).put("protectedSettings", objectMapper.readTree(resourcesItem.getProtectedSettings())); } if (resourcesItem.getProvisioningState() != null) { ((ObjectNode) propertiesValue3).put("provisioningState", resourcesItem.getProvisioningState()); } if (resourcesItem.getInstanceView() != null) { ObjectNode instanceViewValue2 = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue3).put("instanceView", instanceViewValue2); if (resourcesItem.getInstanceView().getName() != null) { ((ObjectNode) instanceViewValue2).put("name", resourcesItem.getInstanceView().getName()); } if (resourcesItem.getInstanceView().getExtensionType() != null) { ((ObjectNode) instanceViewValue2).put("type", resourcesItem.getInstanceView().getExtensionType()); } if (resourcesItem.getInstanceView().getTypeHandlerVersion() != null) { ((ObjectNode) instanceViewValue2).put("typeHandlerVersion", resourcesItem.getInstanceView().getTypeHandlerVersion()); } if (resourcesItem.getInstanceView().getSubStatuses() != null) { if (resourcesItem.getInstanceView().getSubStatuses() instanceof LazyCollection == false || ((LazyCollection) resourcesItem.getInstanceView().getSubStatuses()) .isInitialized()) { ArrayNode substatusesArray2 = objectMapper.createArrayNode(); for (InstanceViewStatus substatusesItem2 : resourcesItem.getInstanceView() .getSubStatuses()) { ObjectNode instanceViewStatusValue6 = objectMapper.createObjectNode(); substatusesArray2.add(instanceViewStatusValue6); if (substatusesItem2.getCode() != null) { ((ObjectNode) instanceViewStatusValue6).put("code", substatusesItem2.getCode()); } if (substatusesItem2.getLevel() != null) { ((ObjectNode) instanceViewStatusValue6).put("level", substatusesItem2.getLevel()); } if (substatusesItem2.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue6).put("displayStatus", substatusesItem2.getDisplayStatus()); } if (substatusesItem2.getMessage() != null) { ((ObjectNode) instanceViewStatusValue6).put("message", substatusesItem2.getMessage()); } if (substatusesItem2.getTime() != null) { SimpleDateFormat simpleDateFormat7 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat7.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue6).put("time", simpleDateFormat7.format(substatusesItem2.getTime().getTime())); } } ((ObjectNode) instanceViewValue2).put("substatuses", substatusesArray2); } } if (resourcesItem.getInstanceView().getStatuses() != null) { ArrayNode statusesArray5 = objectMapper.createArrayNode(); for (InstanceViewStatus statusesItem5 : resourcesItem.getInstanceView().getStatuses()) { ObjectNode instanceViewStatusValue7 = objectMapper.createObjectNode(); statusesArray5.add(instanceViewStatusValue7); if (statusesItem5.getCode() != null) { ((ObjectNode) instanceViewStatusValue7).put("code", statusesItem5.getCode()); } if (statusesItem5.getLevel() != null) { ((ObjectNode) instanceViewStatusValue7).put("level", statusesItem5.getLevel()); } if (statusesItem5.getDisplayStatus() != null) { ((ObjectNode) instanceViewStatusValue7).put("displayStatus", statusesItem5.getDisplayStatus()); } if (statusesItem5.getMessage() != null) { ((ObjectNode) instanceViewStatusValue7).put("message", statusesItem5.getMessage()); } if (statusesItem5.getTime() != null) { SimpleDateFormat simpleDateFormat8 = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat8.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) instanceViewStatusValue7).put("time", simpleDateFormat8.format(statusesItem5.getTime().getTime())); } } ((ObjectNode) instanceViewValue2).put("statuses", statusesArray5); } } if (resourcesItem.getId() != null) { ((ObjectNode) virtualMachineExtensionJsonValue).put("id", resourcesItem.getId()); } if (resourcesItem.getName() != null) { ((ObjectNode) virtualMachineExtensionJsonValue).put("name", resourcesItem.getName()); } if (resourcesItem.getType() != null) { ((ObjectNode) virtualMachineExtensionJsonValue).put("type", resourcesItem.getType()); } ((ObjectNode) virtualMachineExtensionJsonValue).put("location", resourcesItem.getLocation()); if (resourcesItem.getTags() != null) { ObjectNode tagsDictionary = objectMapper.createObjectNode(); for (Map.Entry<String, String> entry : resourcesItem.getTags().entrySet()) { String tagsKey = entry.getKey(); String tagsValue = entry.getValue(); ((ObjectNode) tagsDictionary).put(tagsKey, tagsValue); } ((ObjectNode) virtualMachineExtensionJsonValue).put("tags", tagsDictionary); } } ((ObjectNode) virtualMachineJsonValue).put("resources", resourcesArray); } if (parameters.getId() != null) { ((ObjectNode) virtualMachineJsonValue).put("id", parameters.getId()); } if (parameters.getName() != null) { ((ObjectNode) virtualMachineJsonValue).put("name", parameters.getName()); } if (parameters.getType() != null) { ((ObjectNode) virtualMachineJsonValue).put("type", parameters.getType()); } ((ObjectNode) virtualMachineJsonValue).put("location", parameters.getLocation()); if (parameters.getTags() != null) { ObjectNode tagsDictionary2 = objectMapper.createObjectNode(); for (Map.Entry<String, String> entry2 : parameters.getTags().entrySet()) { String tagsKey2 = entry2.getKey(); String tagsValue2 = entry2.getValue(); ((ObjectNode) tagsDictionary2).put(tagsKey2, tagsValue2); } ((ObjectNode) virtualMachineJsonValue).put("tags", tagsDictionary2); } 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 VirtualMachineCreateOrUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new VirtualMachineCreateOrUpdateResponse(); 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) { VirtualMachine virtualMachineInstance = new VirtualMachine(); result.setVirtualMachine(virtualMachineInstance); JsonNode planValue2 = responseDoc.get("plan"); if (planValue2 != null && planValue2 instanceof NullNode == false) { Plan planInstance = new Plan(); virtualMachineInstance.setPlan(planInstance); JsonNode nameValue = planValue2.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); planInstance.setName(nameInstance); } JsonNode publisherValue = planValue2.get("publisher"); if (publisherValue != null && publisherValue instanceof NullNode == false) { String publisherInstance; publisherInstance = publisherValue.getTextValue(); planInstance.setPublisher(publisherInstance); } JsonNode productValue = planValue2.get("product"); if (productValue != null && productValue instanceof NullNode == false) { String productInstance; productInstance = productValue.getTextValue(); planInstance.setProduct(productInstance); } JsonNode promotionCodeValue = planValue2.get("promotionCode"); if (promotionCodeValue != null && promotionCodeValue instanceof NullNode == false) { String promotionCodeInstance; promotionCodeInstance = promotionCodeValue.getTextValue(); planInstance.setPromotionCode(promotionCodeInstance); } } JsonNode propertiesValue4 = responseDoc.get("properties"); if (propertiesValue4 != null && propertiesValue4 instanceof NullNode == false) { JsonNode hardwareProfileValue2 = propertiesValue4.get("hardwareProfile"); if (hardwareProfileValue2 != null && hardwareProfileValue2 instanceof NullNode == false) { HardwareProfile hardwareProfileInstance = new HardwareProfile(); virtualMachineInstance.setHardwareProfile(hardwareProfileInstance); JsonNode vmSizeValue = hardwareProfileValue2.get("vmSize"); if (vmSizeValue != null && vmSizeValue instanceof NullNode == false) { String vmSizeInstance; vmSizeInstance = vmSizeValue.getTextValue(); hardwareProfileInstance.setVirtualMachineSize(vmSizeInstance); } } JsonNode storageProfileValue2 = propertiesValue4.get("storageProfile"); if (storageProfileValue2 != null && storageProfileValue2 instanceof NullNode == false) { StorageProfile storageProfileInstance = new StorageProfile(); virtualMachineInstance.setStorageProfile(storageProfileInstance); JsonNode imageReferenceValue2 = storageProfileValue2.get("imageReference"); if (imageReferenceValue2 != null && imageReferenceValue2 instanceof NullNode == false) { ImageReference imageReferenceInstance = new ImageReference(); storageProfileInstance.setImageReference(imageReferenceInstance); JsonNode publisherValue2 = imageReferenceValue2.get("publisher"); if (publisherValue2 != null && publisherValue2 instanceof NullNode == false) { String publisherInstance2; publisherInstance2 = publisherValue2.getTextValue(); imageReferenceInstance.setPublisher(publisherInstance2); } JsonNode offerValue = imageReferenceValue2.get("offer"); if (offerValue != null && offerValue instanceof NullNode == false) { String offerInstance; offerInstance = offerValue.getTextValue(); imageReferenceInstance.setOffer(offerInstance); } JsonNode skuValue = imageReferenceValue2.get("sku"); if (skuValue != null && skuValue instanceof NullNode == false) { String skuInstance; skuInstance = skuValue.getTextValue(); imageReferenceInstance.setSku(skuInstance); } JsonNode versionValue = imageReferenceValue2.get("version"); if (versionValue != null && versionValue instanceof NullNode == false) { String versionInstance; versionInstance = versionValue.getTextValue(); imageReferenceInstance.setVersion(versionInstance); } } JsonNode osDiskValue2 = storageProfileValue2.get("osDisk"); if (osDiskValue2 != null && osDiskValue2 instanceof NullNode == false) { OSDisk osDiskInstance = new OSDisk(); storageProfileInstance.setOSDisk(osDiskInstance); JsonNode osTypeValue = osDiskValue2.get("osType"); if (osTypeValue != null && osTypeValue instanceof NullNode == false) { String osTypeInstance; osTypeInstance = osTypeValue.getTextValue(); osDiskInstance.setOperatingSystemType(osTypeInstance); } JsonNode nameValue2 = osDiskValue2.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); osDiskInstance.setName(nameInstance2); } JsonNode vhdValue3 = osDiskValue2.get("vhd"); if (vhdValue3 != null && vhdValue3 instanceof NullNode == false) { VirtualHardDisk vhdInstance = new VirtualHardDisk(); osDiskInstance.setVirtualHardDisk(vhdInstance); JsonNode uriValue = vhdValue3.get("uri"); if (uriValue != null && uriValue instanceof NullNode == false) { String uriInstance; uriInstance = uriValue.getTextValue(); vhdInstance.setUri(uriInstance); } } JsonNode imageValue3 = osDiskValue2.get("image"); if (imageValue3 != null && imageValue3 instanceof NullNode == false) { VirtualHardDisk imageInstance = new VirtualHardDisk(); osDiskInstance.setSourceImage(imageInstance); JsonNode uriValue2 = imageValue3.get("uri"); if (uriValue2 != null && uriValue2 instanceof NullNode == false) { String uriInstance2; uriInstance2 = uriValue2.getTextValue(); imageInstance.setUri(uriInstance2); } } JsonNode cachingValue = osDiskValue2.get("caching"); if (cachingValue != null && cachingValue instanceof NullNode == false) { String cachingInstance; cachingInstance = cachingValue.getTextValue(); osDiskInstance.setCaching(cachingInstance); } JsonNode createOptionValue = osDiskValue2.get("createOption"); if (createOptionValue != null && createOptionValue instanceof NullNode == false) { String createOptionInstance; createOptionInstance = createOptionValue.getTextValue(); osDiskInstance.setCreateOption(createOptionInstance); } JsonNode diskSizeGBValue = osDiskValue2.get("diskSizeGB"); if (diskSizeGBValue != null && diskSizeGBValue instanceof NullNode == false) { int diskSizeGBInstance; diskSizeGBInstance = diskSizeGBValue.getIntValue(); osDiskInstance.setDiskSizeGB(diskSizeGBInstance); } } JsonNode dataDisksArray2 = storageProfileValue2.get("dataDisks"); if (dataDisksArray2 != null && dataDisksArray2 instanceof NullNode == false) { for (JsonNode dataDisksValue : ((ArrayNode) dataDisksArray2)) { DataDisk dataDiskInstance = new DataDisk(); storageProfileInstance.getDataDisks().add(dataDiskInstance); JsonNode lunValue = dataDisksValue.get("lun"); if (lunValue != null && lunValue instanceof NullNode == false) { int lunInstance; lunInstance = lunValue.getIntValue(); dataDiskInstance.setLun(lunInstance); } JsonNode nameValue3 = dataDisksValue.get("name"); if (nameValue3 != null && nameValue3 instanceof NullNode == false) { String nameInstance3; nameInstance3 = nameValue3.getTextValue(); dataDiskInstance.setName(nameInstance3); } JsonNode vhdValue4 = dataDisksValue.get("vhd"); if (vhdValue4 != null && vhdValue4 instanceof NullNode == false) { VirtualHardDisk vhdInstance2 = new VirtualHardDisk(); dataDiskInstance.setVirtualHardDisk(vhdInstance2); JsonNode uriValue3 = vhdValue4.get("uri"); if (uriValue3 != null && uriValue3 instanceof NullNode == false) { String uriInstance3; uriInstance3 = uriValue3.getTextValue(); vhdInstance2.setUri(uriInstance3); } } JsonNode imageValue4 = dataDisksValue.get("image"); if (imageValue4 != null && imageValue4 instanceof NullNode == false) { VirtualHardDisk imageInstance2 = new VirtualHardDisk(); dataDiskInstance.setSourceImage(imageInstance2); JsonNode uriValue4 = imageValue4.get("uri"); if (uriValue4 != null && uriValue4 instanceof NullNode == false) { String uriInstance4; uriInstance4 = uriValue4.getTextValue(); imageInstance2.setUri(uriInstance4); } } JsonNode cachingValue2 = dataDisksValue.get("caching"); if (cachingValue2 != null && cachingValue2 instanceof NullNode == false) { String cachingInstance2; cachingInstance2 = cachingValue2.getTextValue(); dataDiskInstance.setCaching(cachingInstance2); } JsonNode createOptionValue2 = dataDisksValue.get("createOption"); if (createOptionValue2 != null && createOptionValue2 instanceof NullNode == false) { String createOptionInstance2; createOptionInstance2 = createOptionValue2.getTextValue(); dataDiskInstance.setCreateOption(createOptionInstance2); } JsonNode diskSizeGBValue2 = dataDisksValue.get("diskSizeGB"); if (diskSizeGBValue2 != null && diskSizeGBValue2 instanceof NullNode == false) { int diskSizeGBInstance2; diskSizeGBInstance2 = diskSizeGBValue2.getIntValue(); dataDiskInstance.setDiskSizeGB(diskSizeGBInstance2); } } } } JsonNode osProfileValue2 = propertiesValue4.get("osProfile"); if (osProfileValue2 != null && osProfileValue2 instanceof NullNode == false) { OSProfile osProfileInstance = new OSProfile(); virtualMachineInstance.setOSProfile(osProfileInstance); JsonNode computerNameValue = osProfileValue2.get("computerName"); if (computerNameValue != null && computerNameValue instanceof NullNode == false) { String computerNameInstance; computerNameInstance = computerNameValue.getTextValue(); osProfileInstance.setComputerName(computerNameInstance); } JsonNode adminUsernameValue = osProfileValue2.get("adminUsername"); if (adminUsernameValue != null && adminUsernameValue instanceof NullNode == false) { String adminUsernameInstance; adminUsernameInstance = adminUsernameValue.getTextValue(); osProfileInstance.setAdminUsername(adminUsernameInstance); } JsonNode adminPasswordValue = osProfileValue2.get("adminPassword"); if (adminPasswordValue != null && adminPasswordValue instanceof NullNode == false) { String adminPasswordInstance; adminPasswordInstance = adminPasswordValue.getTextValue(); osProfileInstance.setAdminPassword(adminPasswordInstance); } JsonNode customDataValue = osProfileValue2.get("customData"); if (customDataValue != null && customDataValue instanceof NullNode == false) { String customDataInstance; customDataInstance = customDataValue.getTextValue(); osProfileInstance.setCustomData(customDataInstance); } JsonNode windowsConfigurationValue2 = osProfileValue2.get("windowsConfiguration"); if (windowsConfigurationValue2 != null && windowsConfigurationValue2 instanceof NullNode == false) { WindowsConfiguration windowsConfigurationInstance = new WindowsConfiguration(); osProfileInstance.setWindowsConfiguration(windowsConfigurationInstance); JsonNode provisionVMAgentValue = windowsConfigurationValue2.get("provisionVMAgent"); if (provisionVMAgentValue != null && provisionVMAgentValue instanceof NullNode == false) { boolean provisionVMAgentInstance; provisionVMAgentInstance = provisionVMAgentValue.getBooleanValue(); windowsConfigurationInstance.setProvisionVMAgent(provisionVMAgentInstance); } JsonNode enableAutomaticUpdatesValue = windowsConfigurationValue2 .get("enableAutomaticUpdates"); if (enableAutomaticUpdatesValue != null && enableAutomaticUpdatesValue instanceof NullNode == false) { boolean enableAutomaticUpdatesInstance; enableAutomaticUpdatesInstance = enableAutomaticUpdatesValue.getBooleanValue(); windowsConfigurationInstance .setEnableAutomaticUpdates(enableAutomaticUpdatesInstance); } JsonNode timeZoneValue = windowsConfigurationValue2.get("timeZone"); if (timeZoneValue != null && timeZoneValue instanceof NullNode == false) { String timeZoneInstance; timeZoneInstance = timeZoneValue.getTextValue(); windowsConfigurationInstance.setTimeZone(timeZoneInstance); } JsonNode additionalUnattendContentArray2 = windowsConfigurationValue2 .get("additionalUnattendContent"); if (additionalUnattendContentArray2 != null && additionalUnattendContentArray2 instanceof NullNode == false) { for (JsonNode additionalUnattendContentValue2 : ((ArrayNode) additionalUnattendContentArray2)) { AdditionalUnattendContent additionalUnattendContentInstance = new AdditionalUnattendContent(); windowsConfigurationInstance.getAdditionalUnattendContents() .add(additionalUnattendContentInstance); JsonNode passNameValue = additionalUnattendContentValue2.get("passName"); if (passNameValue != null && passNameValue instanceof NullNode == false) { String passNameInstance; passNameInstance = passNameValue.getTextValue(); additionalUnattendContentInstance.setPassName(passNameInstance); } JsonNode componentNameValue = additionalUnattendContentValue2 .get("componentName"); if (componentNameValue != null && componentNameValue instanceof NullNode == false) { String componentNameInstance; componentNameInstance = componentNameValue.getTextValue(); additionalUnattendContentInstance .setComponentName(componentNameInstance); } JsonNode settingNameValue = additionalUnattendContentValue2 .get("settingName"); if (settingNameValue != null && settingNameValue instanceof NullNode == false) { String settingNameInstance; settingNameInstance = settingNameValue.getTextValue(); additionalUnattendContentInstance.setSettingName(settingNameInstance); } JsonNode contentValue = additionalUnattendContentValue2.get("content"); if (contentValue != null && contentValue instanceof NullNode == false) { String contentInstance; contentInstance = contentValue.getTextValue(); additionalUnattendContentInstance.setContent(contentInstance); } } } JsonNode winRMValue2 = windowsConfigurationValue2.get("winRM"); if (winRMValue2 != null && winRMValue2 instanceof NullNode == false) { WinRMConfiguration winRMInstance = new WinRMConfiguration(); windowsConfigurationInstance.setWinRMConfiguration(winRMInstance); JsonNode listenersArray2 = winRMValue2.get("listeners"); if (listenersArray2 != null && listenersArray2 instanceof NullNode == false) { for (JsonNode listenersValue : ((ArrayNode) listenersArray2)) { WinRMListener winRMListenerInstance = new WinRMListener(); winRMInstance.getListeners().add(winRMListenerInstance); JsonNode protocolValue = listenersValue.get("protocol"); if (protocolValue != null && protocolValue instanceof NullNode == false) { String protocolInstance; protocolInstance = protocolValue.getTextValue(); winRMListenerInstance.setProtocol(protocolInstance); } JsonNode certificateUrlValue = listenersValue.get("certificateUrl"); if (certificateUrlValue != null && certificateUrlValue instanceof NullNode == false) { URI certificateUrlInstance; certificateUrlInstance = new URI( certificateUrlValue.getTextValue()); winRMListenerInstance.setCertificateUrl(certificateUrlInstance); } } } } } JsonNode linuxConfigurationValue2 = osProfileValue2.get("linuxConfiguration"); if (linuxConfigurationValue2 != null && linuxConfigurationValue2 instanceof NullNode == false) { LinuxConfiguration linuxConfigurationInstance = new LinuxConfiguration(); osProfileInstance.setLinuxConfiguration(linuxConfigurationInstance); JsonNode disablePasswordAuthenticationValue = linuxConfigurationValue2 .get("disablePasswordAuthentication"); if (disablePasswordAuthenticationValue != null && disablePasswordAuthenticationValue instanceof NullNode == false) { boolean disablePasswordAuthenticationInstance; disablePasswordAuthenticationInstance = disablePasswordAuthenticationValue .getBooleanValue(); linuxConfigurationInstance.setDisablePasswordAuthentication( disablePasswordAuthenticationInstance); } JsonNode sshValue2 = linuxConfigurationValue2.get("ssh"); if (sshValue2 != null && sshValue2 instanceof NullNode == false) { SshConfiguration sshInstance = new SshConfiguration(); linuxConfigurationInstance.setSshConfiguration(sshInstance); JsonNode publicKeysArray2 = sshValue2.get("publicKeys"); if (publicKeysArray2 != null && publicKeysArray2 instanceof NullNode == false) { for (JsonNode publicKeysValue : ((ArrayNode) publicKeysArray2)) { SshPublicKey sshPublicKeyInstance = new SshPublicKey(); sshInstance.getPublicKeys().add(sshPublicKeyInstance); JsonNode pathValue = publicKeysValue.get("path"); if (pathValue != null && pathValue instanceof NullNode == false) { String pathInstance; pathInstance = pathValue.getTextValue(); sshPublicKeyInstance.setPath(pathInstance); } JsonNode keyDataValue = publicKeysValue.get("keyData"); if (keyDataValue != null && keyDataValue instanceof NullNode == false) { String keyDataInstance; keyDataInstance = keyDataValue.getTextValue(); sshPublicKeyInstance.setKeyData(keyDataInstance); } } } } } JsonNode secretsArray2 = osProfileValue2.get("secrets"); if (secretsArray2 != null && secretsArray2 instanceof NullNode == false) { for (JsonNode secretsValue : ((ArrayNode) secretsArray2)) { VaultSecretGroup vaultSecretGroupInstance = new VaultSecretGroup(); osProfileInstance.getSecrets().add(vaultSecretGroupInstance); JsonNode sourceVaultValue2 = secretsValue.get("sourceVault"); if (sourceVaultValue2 != null && sourceVaultValue2 instanceof NullNode == false) { SourceVaultReference sourceVaultInstance = new SourceVaultReference(); vaultSecretGroupInstance.setSourceVault(sourceVaultInstance); JsonNode idValue = sourceVaultValue2.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); sourceVaultInstance.setReferenceUri(idInstance); } } JsonNode vaultCertificatesArray2 = secretsValue.get("vaultCertificates"); if (vaultCertificatesArray2 != null && vaultCertificatesArray2 instanceof NullNode == false) { for (JsonNode vaultCertificatesValue : ((ArrayNode) vaultCertificatesArray2)) { VaultCertificate vaultCertificateInstance = new VaultCertificate(); vaultSecretGroupInstance.getVaultCertificates() .add(vaultCertificateInstance); JsonNode certificateUrlValue2 = vaultCertificatesValue .get("certificateUrl"); if (certificateUrlValue2 != null && certificateUrlValue2 instanceof NullNode == false) { String certificateUrlInstance2; certificateUrlInstance2 = certificateUrlValue2.getTextValue(); vaultCertificateInstance.setCertificateUrl(certificateUrlInstance2); } JsonNode certificateStoreValue = vaultCertificatesValue .get("certificateStore"); if (certificateStoreValue != null && certificateStoreValue instanceof NullNode == false) { String certificateStoreInstance; certificateStoreInstance = certificateStoreValue.getTextValue(); vaultCertificateInstance .setCertificateStore(certificateStoreInstance); } } } } } } JsonNode networkProfileValue2 = propertiesValue4.get("networkProfile"); if (networkProfileValue2 != null && networkProfileValue2 instanceof NullNode == false) { NetworkProfile networkProfileInstance = new NetworkProfile(); virtualMachineInstance.setNetworkProfile(networkProfileInstance); JsonNode networkInterfacesArray2 = networkProfileValue2.get("networkInterfaces"); if (networkInterfacesArray2 != null && networkInterfacesArray2 instanceof NullNode == false) { for (JsonNode networkInterfacesValue : ((ArrayNode) networkInterfacesArray2)) { NetworkInterfaceReference networkInterfaceReferenceJsonInstance = new NetworkInterfaceReference(); networkProfileInstance.getNetworkInterfaces() .add(networkInterfaceReferenceJsonInstance); JsonNode propertiesValue5 = networkInterfacesValue.get("properties"); if (propertiesValue5 != null && propertiesValue5 instanceof NullNode == false) { JsonNode primaryValue = propertiesValue5.get("primary"); if (primaryValue != null && primaryValue instanceof NullNode == false) { boolean primaryInstance; primaryInstance = primaryValue.getBooleanValue(); networkInterfaceReferenceJsonInstance.setPrimary(primaryInstance); } } JsonNode idValue2 = networkInterfacesValue.get("id"); if (idValue2 != null && idValue2 instanceof NullNode == false) { String idInstance2; idInstance2 = idValue2.getTextValue(); networkInterfaceReferenceJsonInstance.setReferenceUri(idInstance2); } } } } JsonNode diagnosticsProfileValue2 = propertiesValue4.get("diagnosticsProfile"); if (diagnosticsProfileValue2 != null && diagnosticsProfileValue2 instanceof NullNode == false) { DiagnosticsProfile diagnosticsProfileInstance = new DiagnosticsProfile(); virtualMachineInstance.setDiagnosticsProfile(diagnosticsProfileInstance); JsonNode bootDiagnosticsValue3 = diagnosticsProfileValue2.get("bootDiagnostics"); if (bootDiagnosticsValue3 != null && bootDiagnosticsValue3 instanceof NullNode == false) { BootDiagnostics bootDiagnosticsInstance = new BootDiagnostics(); diagnosticsProfileInstance.setBootDiagnostics(bootDiagnosticsInstance); JsonNode enabledValue = bootDiagnosticsValue3.get("enabled"); if (enabledValue != null && enabledValue instanceof NullNode == false) { boolean enabledInstance; enabledInstance = enabledValue.getBooleanValue(); bootDiagnosticsInstance.setEnabled(enabledInstance); } JsonNode storageUriValue = bootDiagnosticsValue3.get("storageUri"); if (storageUriValue != null && storageUriValue instanceof NullNode == false) { URI storageUriInstance; storageUriInstance = new URI(storageUriValue.getTextValue()); bootDiagnosticsInstance.setStorageUri(storageUriInstance); } } } JsonNode availabilitySetValue2 = propertiesValue4.get("availabilitySet"); if (availabilitySetValue2 != null && availabilitySetValue2 instanceof NullNode == false) { AvailabilitySetReference availabilitySetInstance = new AvailabilitySetReference(); virtualMachineInstance.setAvailabilitySetReference(availabilitySetInstance); JsonNode idValue3 = availabilitySetValue2.get("id"); if (idValue3 != null && idValue3 instanceof NullNode == false) { String idInstance3; idInstance3 = idValue3.getTextValue(); availabilitySetInstance.setReferenceUri(idInstance3); } } JsonNode provisioningStateValue = propertiesValue4.get("provisioningState"); if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) { String provisioningStateInstance; provisioningStateInstance = provisioningStateValue.getTextValue(); virtualMachineInstance.setProvisioningState(provisioningStateInstance); } JsonNode instanceViewValue3 = propertiesValue4.get("instanceView"); if (instanceViewValue3 != null && instanceViewValue3 instanceof NullNode == false) { VirtualMachineInstanceView instanceViewInstance = new VirtualMachineInstanceView(); virtualMachineInstance.setInstanceView(instanceViewInstance); JsonNode platformUpdateDomainValue = instanceViewValue3.get("platformUpdateDomain"); if (platformUpdateDomainValue != null && platformUpdateDomainValue instanceof NullNode == false) { int platformUpdateDomainInstance; platformUpdateDomainInstance = platformUpdateDomainValue.getIntValue(); instanceViewInstance.setPlatformUpdateDomain(platformUpdateDomainInstance); } JsonNode platformFaultDomainValue = instanceViewValue3.get("platformFaultDomain"); if (platformFaultDomainValue != null && platformFaultDomainValue instanceof NullNode == false) { int platformFaultDomainInstance; platformFaultDomainInstance = platformFaultDomainValue.getIntValue(); instanceViewInstance.setPlatformFaultDomain(platformFaultDomainInstance); } JsonNode rdpThumbPrintValue = instanceViewValue3.get("rdpThumbPrint"); if (rdpThumbPrintValue != null && rdpThumbPrintValue instanceof NullNode == false) { String rdpThumbPrintInstance; rdpThumbPrintInstance = rdpThumbPrintValue.getTextValue(); instanceViewInstance.setRemoteDesktopThumbprint(rdpThumbPrintInstance); } JsonNode vmAgentValue2 = instanceViewValue3.get("vmAgent"); if (vmAgentValue2 != null && vmAgentValue2 instanceof NullNode == false) { VirtualMachineAgentInstanceView vmAgentInstance = new VirtualMachineAgentInstanceView(); instanceViewInstance.setVMAgent(vmAgentInstance); JsonNode vmAgentVersionValue = vmAgentValue2.get("vmAgentVersion"); if (vmAgentVersionValue != null && vmAgentVersionValue instanceof NullNode == false) { String vmAgentVersionInstance; vmAgentVersionInstance = vmAgentVersionValue.getTextValue(); vmAgentInstance.setVMAgentVersion(vmAgentVersionInstance); } JsonNode extensionHandlersArray2 = vmAgentValue2.get("extensionHandlers"); if (extensionHandlersArray2 != null && extensionHandlersArray2 instanceof NullNode == false) { for (JsonNode extensionHandlersValue : ((ArrayNode) extensionHandlersArray2)) { VirtualMachineExtensionHandlerInstanceView virtualMachineExtensionHandlerInstanceViewInstance = new VirtualMachineExtensionHandlerInstanceView(); vmAgentInstance.getExtensionHandlers() .add(virtualMachineExtensionHandlerInstanceViewInstance); JsonNode typeValue = extensionHandlersValue.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); virtualMachineExtensionHandlerInstanceViewInstance .setType(typeInstance); } JsonNode typeHandlerVersionValue = extensionHandlersValue .get("typeHandlerVersion"); if (typeHandlerVersionValue != null && typeHandlerVersionValue instanceof NullNode == false) { String typeHandlerVersionInstance; typeHandlerVersionInstance = typeHandlerVersionValue.getTextValue(); virtualMachineExtensionHandlerInstanceViewInstance .setTypeHandlerVersion(typeHandlerVersionInstance); } JsonNode statusValue2 = extensionHandlersValue.get("status"); if (statusValue2 != null && statusValue2 instanceof NullNode == false) { InstanceViewStatus statusInstance = new InstanceViewStatus(); virtualMachineExtensionHandlerInstanceViewInstance .setStatus(statusInstance); JsonNode codeValue = statusValue2.get("code"); if (codeValue != null && codeValue instanceof NullNode == false) { String codeInstance; codeInstance = codeValue.getTextValue(); statusInstance.setCode(codeInstance); } JsonNode levelValue = statusValue2.get("level"); if (levelValue != null && levelValue instanceof NullNode == false) { String levelInstance; levelInstance = levelValue.getTextValue(); statusInstance.setLevel(levelInstance); } JsonNode displayStatusValue = statusValue2.get("displayStatus"); if (displayStatusValue != null && displayStatusValue instanceof NullNode == false) { String displayStatusInstance; displayStatusInstance = displayStatusValue.getTextValue(); statusInstance.setDisplayStatus(displayStatusInstance); } JsonNode messageValue = statusValue2.get("message"); if (messageValue != null && messageValue instanceof NullNode == false) { String messageInstance; messageInstance = messageValue.getTextValue(); statusInstance.setMessage(messageInstance); } JsonNode timeValue = statusValue2.get("time"); if (timeValue != null && timeValue instanceof NullNode == false) { Calendar timeInstance; timeInstance = DatatypeConverter .parseDateTime(timeValue.getTextValue()); statusInstance.setTime(timeInstance); } } } } JsonNode statusesArray6 = vmAgentValue2.get("statuses"); if (statusesArray6 != null && statusesArray6 instanceof NullNode == false) { for (JsonNode statusesValue : ((ArrayNode) statusesArray6)) { InstanceViewStatus instanceViewStatusInstance = new InstanceViewStatus(); vmAgentInstance.getStatuses().add(instanceViewStatusInstance); JsonNode codeValue2 = statusesValue.get("code"); if (codeValue2 != null && codeValue2 instanceof NullNode == false) { String codeInstance2; codeInstance2 = codeValue2.getTextValue(); instanceViewStatusInstance.setCode(codeInstance2); } JsonNode levelValue2 = statusesValue.get("level"); if (levelValue2 != null && levelValue2 instanceof NullNode == false) { String levelInstance2; levelInstance2 = levelValue2.getTextValue(); instanceViewStatusInstance.setLevel(levelInstance2); } JsonNode displayStatusValue2 = statusesValue.get("displayStatus"); if (displayStatusValue2 != null && displayStatusValue2 instanceof NullNode == false) { String displayStatusInstance2; displayStatusInstance2 = displayStatusValue2.getTextValue(); instanceViewStatusInstance.setDisplayStatus(displayStatusInstance2); } JsonNode messageValue2 = statusesValue.get("message"); if (messageValue2 != null && messageValue2 instanceof NullNode == false) { String messageInstance2; messageInstance2 = messageValue2.getTextValue(); instanceViewStatusInstance.setMessage(messageInstance2); } JsonNode timeValue2 = statusesValue.get("time"); if (timeValue2 != null && timeValue2 instanceof NullNode == false) { Calendar timeInstance2; timeInstance2 = DatatypeConverter .parseDateTime(timeValue2.getTextValue()); instanceViewStatusInstance.setTime(timeInstance2); } } } } JsonNode disksArray2 = instanceViewValue3.get("disks"); if (disksArray2 != null && disksArray2 instanceof NullNode == false) { for (JsonNode disksValue : ((ArrayNode) disksArray2)) { DiskInstanceView diskInstanceViewInstance = new DiskInstanceView(); instanceViewInstance.getDisks().add(diskInstanceViewInstance); JsonNode nameValue4 = disksValue.get("name"); if (nameValue4 != null && nameValue4 instanceof NullNode == false) { String nameInstance4; nameInstance4 = nameValue4.getTextValue(); diskInstanceViewInstance.setName(nameInstance4); } JsonNode statusesArray7 = disksValue.get("statuses"); if (statusesArray7 != null && statusesArray7 instanceof NullNode == false) { for (JsonNode statusesValue2 : ((ArrayNode) statusesArray7)) { InstanceViewStatus instanceViewStatusInstance2 = new InstanceViewStatus(); diskInstanceViewInstance.getStatuses().add(instanceViewStatusInstance2); JsonNode codeValue3 = statusesValue2.get("code"); if (codeValue3 != null && codeValue3 instanceof NullNode == false) { String codeInstance3; codeInstance3 = codeValue3.getTextValue(); instanceViewStatusInstance2.setCode(codeInstance3); } JsonNode levelValue3 = statusesValue2.get("level"); if (levelValue3 != null && levelValue3 instanceof NullNode == false) { String levelInstance3; levelInstance3 = levelValue3.getTextValue(); instanceViewStatusInstance2.setLevel(levelInstance3); } JsonNode displayStatusValue3 = statusesValue2.get("displayStatus"); if (displayStatusValue3 != null && displayStatusValue3 instanceof NullNode == false) { String displayStatusInstance3; displayStatusInstance3 = displayStatusValue3.getTextValue(); instanceViewStatusInstance2 .setDisplayStatus(displayStatusInstance3); } JsonNode messageValue3 = statusesValue2.get("message"); if (messageValue3 != null && messageValue3 instanceof NullNode == false) { String messageInstance3; messageInstance3 = messageValue3.getTextValue(); instanceViewStatusInstance2.setMessage(messageInstance3); } JsonNode timeValue3 = statusesValue2.get("time"); if (timeValue3 != null && timeValue3 instanceof NullNode == false) { Calendar timeInstance3; timeInstance3 = DatatypeConverter .parseDateTime(timeValue3.getTextValue()); instanceViewStatusInstance2.setTime(timeInstance3); } } } } } JsonNode extensionsArray2 = instanceViewValue3.get("extensions"); if (extensionsArray2 != null && extensionsArray2 instanceof NullNode == false) { for (JsonNode extensionsValue : ((ArrayNode) extensionsArray2)) { VirtualMachineExtensionInstanceView virtualMachineExtensionInstanceViewInstance = new VirtualMachineExtensionInstanceView(); instanceViewInstance.getExtensions() .add(virtualMachineExtensionInstanceViewInstance); JsonNode nameValue5 = extensionsValue.get("name"); if (nameValue5 != null && nameValue5 instanceof NullNode == false) { String nameInstance5; nameInstance5 = nameValue5.getTextValue(); virtualMachineExtensionInstanceViewInstance.setName(nameInstance5); } JsonNode typeValue2 = extensionsValue.get("type"); if (typeValue2 != null && typeValue2 instanceof NullNode == false) { String typeInstance2; typeInstance2 = typeValue2.getTextValue(); virtualMachineExtensionInstanceViewInstance.setExtensionType(typeInstance2); } JsonNode typeHandlerVersionValue2 = extensionsValue.get("typeHandlerVersion"); if (typeHandlerVersionValue2 != null && typeHandlerVersionValue2 instanceof NullNode == false) { String typeHandlerVersionInstance2; typeHandlerVersionInstance2 = typeHandlerVersionValue2.getTextValue(); virtualMachineExtensionInstanceViewInstance .setTypeHandlerVersion(typeHandlerVersionInstance2); } JsonNode substatusesArray3 = extensionsValue.get("substatuses"); if (substatusesArray3 != null && substatusesArray3 instanceof NullNode == false) { for (JsonNode substatusesValue : ((ArrayNode) substatusesArray3)) { InstanceViewStatus instanceViewStatusInstance3 = new InstanceViewStatus(); virtualMachineExtensionInstanceViewInstance.getSubStatuses() .add(instanceViewStatusInstance3); JsonNode codeValue4 = substatusesValue.get("code"); if (codeValue4 != null && codeValue4 instanceof NullNode == false) { String codeInstance4; codeInstance4 = codeValue4.getTextValue(); instanceViewStatusInstance3.setCode(codeInstance4); } JsonNode levelValue4 = substatusesValue.get("level"); if (levelValue4 != null && levelValue4 instanceof NullNode == false) { String levelInstance4; levelInstance4 = levelValue4.getTextValue(); instanceViewStatusInstance3.setLevel(levelInstance4); } JsonNode displayStatusValue4 = substatusesValue.get("displayStatus"); if (displayStatusValue4 != null && displayStatusValue4 instanceof NullNode == false) { String displayStatusInstance4; displayStatusInstance4 = displayStatusValue4.getTextValue(); instanceViewStatusInstance3 .setDisplayStatus(displayStatusInstance4); } JsonNode messageValue4 = substatusesValue.get("message"); if (messageValue4 != null && messageValue4 instanceof NullNode == false) { String messageInstance4; messageInstance4 = messageValue4.getTextValue(); instanceViewStatusInstance3.setMessage(messageInstance4); } JsonNode timeValue4 = substatusesValue.get("time"); if (timeValue4 != null && timeValue4 instanceof NullNode == false) { Calendar timeInstance4; timeInstance4 = DatatypeConverter .parseDateTime(timeValue4.getTextValue()); instanceViewStatusInstance3.setTime(timeInstance4); } } } JsonNode statusesArray8 = extensionsValue.get("statuses"); if (statusesArray8 != null && statusesArray8 instanceof NullNode == false) { for (JsonNode statusesValue3 : ((ArrayNode) statusesArray8)) { InstanceViewStatus instanceViewStatusInstance4 = new InstanceViewStatus(); virtualMachineExtensionInstanceViewInstance.getStatuses() .add(instanceViewStatusInstance4); JsonNode codeValue5 = statusesValue3.get("code"); if (codeValue5 != null && codeValue5 instanceof NullNode == false) { String codeInstance5; codeInstance5 = codeValue5.getTextValue(); instanceViewStatusInstance4.setCode(codeInstance5); } JsonNode levelValue5 = statusesValue3.get("level"); if (levelValue5 != null && levelValue5 instanceof NullNode == false) { String levelInstance5; levelInstance5 = levelValue5.getTextValue(); instanceViewStatusInstance4.setLevel(levelInstance5); } JsonNode displayStatusValue5 = statusesValue3.get("displayStatus"); if (displayStatusValue5 != null && displayStatusValue5 instanceof NullNode == false) { String displayStatusInstance5; displayStatusInstance5 = displayStatusValue5.getTextValue(); instanceViewStatusInstance4 .setDisplayStatus(displayStatusInstance5); } JsonNode messageValue5 = statusesValue3.get("message"); if (messageValue5 != null && messageValue5 instanceof NullNode == false) { String messageInstance5; messageInstance5 = messageValue5.getTextValue(); instanceViewStatusInstance4.setMessage(messageInstance5); } JsonNode timeValue5 = statusesValue3.get("time"); if (timeValue5 != null && timeValue5 instanceof NullNode == false) { Calendar timeInstance5; timeInstance5 = DatatypeConverter .parseDateTime(timeValue5.getTextValue()); instanceViewStatusInstance4.setTime(timeInstance5); } } } } } JsonNode bootDiagnosticsValue4 = instanceViewValue3.get("bootDiagnostics"); if (bootDiagnosticsValue4 != null && bootDiagnosticsValue4 instanceof NullNode == false) { BootDiagnosticsInstanceView bootDiagnosticsInstance2 = new BootDiagnosticsInstanceView(); instanceViewInstance.setBootDiagnostics(bootDiagnosticsInstance2); JsonNode consoleScreenshotBlobUriValue = bootDiagnosticsValue4 .get("consoleScreenshotBlobUri"); if (consoleScreenshotBlobUriValue != null && consoleScreenshotBlobUriValue instanceof NullNode == false) { URI consoleScreenshotBlobUriInstance; consoleScreenshotBlobUriInstance = new URI( consoleScreenshotBlobUriValue.getTextValue()); bootDiagnosticsInstance2 .setConsoleScreenshotBlobUri(consoleScreenshotBlobUriInstance); } JsonNode serialConsoleLogBlobUriValue = bootDiagnosticsValue4 .get("serialConsoleLogBlobUri"); if (serialConsoleLogBlobUriValue != null && serialConsoleLogBlobUriValue instanceof NullNode == false) { URI serialConsoleLogBlobUriInstance; serialConsoleLogBlobUriInstance = new URI( serialConsoleLogBlobUriValue.getTextValue()); bootDiagnosticsInstance2 .setSerialConsoleLogBlobUri(serialConsoleLogBlobUriInstance); } } JsonNode statusesArray9 = instanceViewValue3.get("statuses"); if (statusesArray9 != null && statusesArray9 instanceof NullNode == false) { for (JsonNode statusesValue4 : ((ArrayNode) statusesArray9)) { InstanceViewStatus instanceViewStatusInstance5 = new InstanceViewStatus(); instanceViewInstance.getStatuses().add(instanceViewStatusInstance5); JsonNode codeValue6 = statusesValue4.get("code"); if (codeValue6 != null && codeValue6 instanceof NullNode == false) { String codeInstance6; codeInstance6 = codeValue6.getTextValue(); instanceViewStatusInstance5.setCode(codeInstance6); } JsonNode levelValue6 = statusesValue4.get("level"); if (levelValue6 != null && levelValue6 instanceof NullNode == false) { String levelInstance6; levelInstance6 = levelValue6.getTextValue(); instanceViewStatusInstance5.setLevel(levelInstance6); } JsonNode displayStatusValue6 = statusesValue4.get("displayStatus"); if (displayStatusValue6 != null && displayStatusValue6 instanceof NullNode == false) { String displayStatusInstance6; displayStatusInstance6 = displayStatusValue6.getTextValue(); instanceViewStatusInstance5.setDisplayStatus(displayStatusInstance6); } JsonNode messageValue6 = statusesValue4.get("message"); if (messageValue6 != null && messageValue6 instanceof NullNode == false) { String messageInstance6; messageInstance6 = messageValue6.getTextValue(); instanceViewStatusInstance5.setMessage(messageInstance6); } JsonNode timeValue6 = statusesValue4.get("time"); if (timeValue6 != null && timeValue6 instanceof NullNode == false) { Calendar timeInstance6; timeInstance6 = DatatypeConverter.parseDateTime(timeValue6.getTextValue()); instanceViewStatusInstance5.setTime(timeInstance6); } } } } } JsonNode resourcesArray2 = responseDoc.get("resources"); if (resourcesArray2 != null && resourcesArray2 instanceof NullNode == false) { virtualMachineInstance.setExtensions(new ArrayList<VirtualMachineExtension>()); for (JsonNode resourcesValue : ((ArrayNode) resourcesArray2)) { VirtualMachineExtension virtualMachineExtensionJsonInstance = new VirtualMachineExtension(); virtualMachineInstance.getExtensions().add(virtualMachineExtensionJsonInstance); JsonNode propertiesValue6 = resourcesValue.get("properties"); if (propertiesValue6 != null && propertiesValue6 instanceof NullNode == false) { JsonNode publisherValue3 = propertiesValue6.get("publisher"); if (publisherValue3 != null && publisherValue3 instanceof NullNode == false) { String publisherInstance3; publisherInstance3 = publisherValue3.getTextValue(); virtualMachineExtensionJsonInstance.setPublisher(publisherInstance3); } JsonNode typeValue3 = propertiesValue6.get("type"); if (typeValue3 != null && typeValue3 instanceof NullNode == false) { String typeInstance3; typeInstance3 = typeValue3.getTextValue(); virtualMachineExtensionJsonInstance.setExtensionType(typeInstance3); } JsonNode typeHandlerVersionValue3 = propertiesValue6.get("typeHandlerVersion"); if (typeHandlerVersionValue3 != null && typeHandlerVersionValue3 instanceof NullNode == false) { String typeHandlerVersionInstance3; typeHandlerVersionInstance3 = typeHandlerVersionValue3.getTextValue(); virtualMachineExtensionJsonInstance .setTypeHandlerVersion(typeHandlerVersionInstance3); } JsonNode autoUpgradeMinorVersionValue = propertiesValue6 .get("autoUpgradeMinorVersion"); if (autoUpgradeMinorVersionValue != null && autoUpgradeMinorVersionValue instanceof NullNode == false) { boolean autoUpgradeMinorVersionInstance; autoUpgradeMinorVersionInstance = autoUpgradeMinorVersionValue .getBooleanValue(); virtualMachineExtensionJsonInstance .setAutoUpgradeMinorVersion(autoUpgradeMinorVersionInstance); } JsonNode settingsValue = propertiesValue6.get("settings"); if (settingsValue != null && settingsValue instanceof NullNode == false) { String settingsInstance; settingsInstance = settingsValue.getTextValue(); virtualMachineExtensionJsonInstance.setSettings(settingsInstance); } JsonNode protectedSettingsValue = propertiesValue6.get("protectedSettings"); if (protectedSettingsValue != null && protectedSettingsValue instanceof NullNode == false) { String protectedSettingsInstance; protectedSettingsInstance = protectedSettingsValue.getTextValue(); virtualMachineExtensionJsonInstance .setProtectedSettings(protectedSettingsInstance); } JsonNode provisioningStateValue2 = propertiesValue6.get("provisioningState"); if (provisioningStateValue2 != null && provisioningStateValue2 instanceof NullNode == false) { String provisioningStateInstance2; provisioningStateInstance2 = provisioningStateValue2.getTextValue(); virtualMachineExtensionJsonInstance .setProvisioningState(provisioningStateInstance2); } JsonNode instanceViewValue4 = propertiesValue6.get("instanceView"); if (instanceViewValue4 != null && instanceViewValue4 instanceof NullNode == false) { VirtualMachineExtensionInstanceView instanceViewInstance2 = new VirtualMachineExtensionInstanceView(); virtualMachineExtensionJsonInstance.setInstanceView(instanceViewInstance2); JsonNode nameValue6 = instanceViewValue4.get("name"); if (nameValue6 != null && nameValue6 instanceof NullNode == false) { String nameInstance6; nameInstance6 = nameValue6.getTextValue(); instanceViewInstance2.setName(nameInstance6); } JsonNode typeValue4 = instanceViewValue4.get("type"); if (typeValue4 != null && typeValue4 instanceof NullNode == false) { String typeInstance4; typeInstance4 = typeValue4.getTextValue(); instanceViewInstance2.setExtensionType(typeInstance4); } JsonNode typeHandlerVersionValue4 = instanceViewValue4 .get("typeHandlerVersion"); if (typeHandlerVersionValue4 != null && typeHandlerVersionValue4 instanceof NullNode == false) { String typeHandlerVersionInstance4; typeHandlerVersionInstance4 = typeHandlerVersionValue4.getTextValue(); instanceViewInstance2.setTypeHandlerVersion(typeHandlerVersionInstance4); } JsonNode substatusesArray4 = instanceViewValue4.get("substatuses"); if (substatusesArray4 != null && substatusesArray4 instanceof NullNode == false) { for (JsonNode substatusesValue2 : ((ArrayNode) substatusesArray4)) { InstanceViewStatus instanceViewStatusInstance6 = new InstanceViewStatus(); instanceViewInstance2.getSubStatuses().add(instanceViewStatusInstance6); JsonNode codeValue7 = substatusesValue2.get("code"); if (codeValue7 != null && codeValue7 instanceof NullNode == false) { String codeInstance7; codeInstance7 = codeValue7.getTextValue(); instanceViewStatusInstance6.setCode(codeInstance7); } JsonNode levelValue7 = substatusesValue2.get("level"); if (levelValue7 != null && levelValue7 instanceof NullNode == false) { String levelInstance7; levelInstance7 = levelValue7.getTextValue(); instanceViewStatusInstance6.setLevel(levelInstance7); } JsonNode displayStatusValue7 = substatusesValue2.get("displayStatus"); if (displayStatusValue7 != null && displayStatusValue7 instanceof NullNode == false) { String displayStatusInstance7; displayStatusInstance7 = displayStatusValue7.getTextValue(); instanceViewStatusInstance6 .setDisplayStatus(displayStatusInstance7); } JsonNode messageValue7 = substatusesValue2.get("message"); if (messageValue7 != null && messageValue7 instanceof NullNode == false) { String messageInstance7; messageInstance7 = messageValue7.getTextValue(); instanceViewStatusInstance6.setMessage(messageInstance7); } JsonNode timeValue7 = substatusesValue2.get("time"); if (timeValue7 != null && timeValue7 instanceof NullNode == false) { Calendar timeInstance7; timeInstance7 = DatatypeConverter .parseDateTime(timeValue7.getTextValue()); instanceViewStatusInstance6.setTime(timeInstance7); } } } JsonNode statusesArray10 = instanceViewValue4.get("statuses"); if (statusesArray10 != null && statusesArray10 instanceof NullNode == false) { for (JsonNode statusesValue5 : ((ArrayNode) statusesArray10)) { InstanceViewStatus instanceViewStatusInstance7 = new InstanceViewStatus(); instanceViewInstance2.getStatuses().add(instanceViewStatusInstance7); JsonNode codeValue8 = statusesValue5.get("code"); if (codeValue8 != null && codeValue8 instanceof NullNode == false) { String codeInstance8; codeInstance8 = codeValue8.getTextValue(); instanceViewStatusInstance7.setCode(codeInstance8); } JsonNode levelValue8 = statusesValue5.get("level"); if (levelValue8 != null && levelValue8 instanceof NullNode == false) { String levelInstance8; levelInstance8 = levelValue8.getTextValue(); instanceViewStatusInstance7.setLevel(levelInstance8); } JsonNode displayStatusValue8 = statusesValue5.get("displayStatus"); if (displayStatusValue8 != null && displayStatusValue8 instanceof NullNode == false) { String displayStatusInstance8; displayStatusInstance8 = displayStatusValue8.getTextValue(); instanceViewStatusInstance7 .setDisplayStatus(displayStatusInstance8); } JsonNode messageValue8 = statusesValue5.get("message"); if (messageValue8 != null && messageValue8 instanceof NullNode == false) { String messageInstance8; messageInstance8 = messageValue8.getTextValue(); instanceViewStatusInstance7.setMessage(messageInstance8); } JsonNode timeValue8 = statusesValue5.get("time"); if (timeValue8 != null && timeValue8 instanceof NullNode == false) { Calendar timeInstance8; timeInstance8 = DatatypeConverter .parseDateTime(timeValue8.getTextValue()); instanceViewStatusInstance7.setTime(timeInstance8); } } } } } JsonNode idValue4 = resourcesValue.get("id"); if (idValue4 != null && idValue4 instanceof NullNode == false) { String idInstance4; idInstance4 = idValue4.getTextValue(); virtualMachineExtensionJsonInstance.setId(idInstance4); } JsonNode nameValue7 = resourcesValue.get("name"); if (nameValue7 != null && nameValue7 instanceof NullNode == false) { String nameInstance7; nameInstance7 = nameValue7.getTextValue(); virtualMachineExtensionJsonInstance.setName(nameInstance7); } JsonNode typeValue5 = resourcesValue.get("type"); if (typeValue5 != null && typeValue5 instanceof NullNode == false) { String typeInstance5; typeInstance5 = typeValue5.getTextValue(); virtualMachineExtensionJsonInstance.setType(typeInstance5); } JsonNode locationValue = resourcesValue.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); virtualMachineExtensionJsonInstance.setLocation(locationInstance); } JsonNode tagsSequenceElement = ((JsonNode) resourcesValue.get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey3 = property.getKey(); String tagsValue3 = property.getValue().getTextValue(); virtualMachineExtensionJsonInstance.getTags().put(tagsKey3, tagsValue3); } } } } JsonNode idValue5 = responseDoc.get("id"); if (idValue5 != null && idValue5 instanceof NullNode == false) { String idInstance5; idInstance5 = idValue5.getTextValue(); virtualMachineInstance.setId(idInstance5); } JsonNode nameValue8 = responseDoc.get("name"); if (nameValue8 != null && nameValue8 instanceof NullNode == false) { String nameInstance8; nameInstance8 = nameValue8.getTextValue(); virtualMachineInstance.setName(nameInstance8); } JsonNode typeValue6 = responseDoc.get("type"); if (typeValue6 != null && typeValue6 instanceof NullNode == false) { String typeInstance6; typeInstance6 = typeValue6.getTextValue(); virtualMachineInstance.setType(typeInstance6); } JsonNode locationValue2 = responseDoc.get("location"); if (locationValue2 != null && locationValue2 instanceof NullNode == false) { String locationInstance2; locationInstance2 = locationValue2.getTextValue(); virtualMachineInstance.setLocation(locationInstance2); } JsonNode tagsSequenceElement2 = ((JsonNode) responseDoc.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 tagsKey4 = property2.getKey(); String tagsValue4 = property2.getValue().getTextValue(); virtualMachineInstance.getTags().put(tagsKey4, tagsValue4); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("Azure-AsyncOperation").length > 0) { result.setAzureAsyncOperation(httpResponse.getFirstHeader("Azure-AsyncOperation").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.servicebus.QueueOperationsImpl.java
/** * Enumerates the queues in the service namespace. The result is returned in * pages, each containing up to 100 queues. If the namespace contains more * than 100 queues, a feed is returned that contains the first page and a * next link with the URI to view the next page of data. (see * http://msdn.microsoft.com/en-us/library/windowsazure/hh780759.asp for * more information)/*w w w . java2 s . co m*/ * * @param namespaceName Required. The namespace name. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws ParserConfigurationException Thrown if there was a serious * configuration error with the document parser. * @throws SAXException Thrown if there was an error parsing the XML * response. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return A response to a request for a list of queues. */ @Override public ServiceBusQueuesResponse list(String namespaceName) throws IOException, ServiceException, ParserConfigurationException, SAXException, URISyntaxException { // Validate if (namespaceName == null) { throw new NullPointerException("namespaceName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("namespaceName", namespaceName); CloudTracing.enter(invocationId, this, "listAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/services/servicebus/namespaces/"; url = url + URLEncoder.encode(namespaceName, "UTF-8"); url = url + "/Queues"; String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("Content-Type", "application/xml; charset=utf-8"); httpRequest.setHeader("x-ms-version", "2013-08-01"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result ServiceBusQueuesResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ServiceBusQueuesResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element feedElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://www.w3.org/2005/Atom", "feed"); if (feedElement != null) { if (feedElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(feedElement, "http://www.w3.org/2005/Atom", "entry") .size(); i1 = i1 + 1) { org.w3c.dom.Element entriesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(feedElement, "http://www.w3.org/2005/Atom", "entry") .get(i1)); ServiceBusQueue entryInstance = new ServiceBusQueue(); result.getQueues().add(entryInstance); Element titleElement = XmlUtility.getElementByTagNameNS(entriesElement, "http://www.w3.org/2005/Atom", "title"); if (titleElement != null) { String titleInstance; titleInstance = titleElement.getTextContent(); entryInstance.setName(titleInstance); } Element contentElement = XmlUtility.getElementByTagNameNS(entriesElement, "http://www.w3.org/2005/Atom", "content"); if (contentElement != null) { Element queueDescriptionElement = XmlUtility.getElementByTagNameNS(contentElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "QueueDescription"); if (queueDescriptionElement != null) { Element lockDurationElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "LockDuration"); if (lockDurationElement != null) { String lockDurationInstance; lockDurationInstance = lockDurationElement.getTextContent(); entryInstance.setLockDuration(lockDurationInstance); } Element maxSizeInMegabytesElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "MaxSizeInMegabytes"); if (maxSizeInMegabytesElement != null) { int maxSizeInMegabytesInstance; maxSizeInMegabytesInstance = DatatypeConverter .parseInt(maxSizeInMegabytesElement.getTextContent()); entryInstance.setMaxSizeInMegabytes(maxSizeInMegabytesInstance); } Element requiresDuplicateDetectionElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "RequiresDuplicateDetection"); if (requiresDuplicateDetectionElement != null) { boolean requiresDuplicateDetectionInstance; requiresDuplicateDetectionInstance = DatatypeConverter.parseBoolean( requiresDuplicateDetectionElement.getTextContent().toLowerCase()); entryInstance .setRequiresDuplicateDetection(requiresDuplicateDetectionInstance); } Element requiresSessionElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "RequiresSession"); if (requiresSessionElement != null) { boolean requiresSessionInstance; requiresSessionInstance = DatatypeConverter.parseBoolean( requiresSessionElement.getTextContent().toLowerCase()); entryInstance.setRequiresSession(requiresSessionInstance); } Element defaultMessageTimeToLiveElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "DefaultMessageTimeToLive"); if (defaultMessageTimeToLiveElement != null) { String defaultMessageTimeToLiveInstance; defaultMessageTimeToLiveInstance = defaultMessageTimeToLiveElement .getTextContent(); entryInstance.setDefaultMessageTimeToLive(defaultMessageTimeToLiveInstance); } Element deadLetteringOnMessageExpirationElement = XmlUtility .getElementByTagNameNS(queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "DeadLetteringOnMessageExpiration"); if (deadLetteringOnMessageExpirationElement != null) { boolean deadLetteringOnMessageExpirationInstance; deadLetteringOnMessageExpirationInstance = DatatypeConverter .parseBoolean(deadLetteringOnMessageExpirationElement .getTextContent().toLowerCase()); entryInstance.setDeadLetteringOnMessageExpiration( deadLetteringOnMessageExpirationInstance); } Element duplicateDetectionHistoryTimeWindowElement = XmlUtility .getElementByTagNameNS(queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "DuplicateDetectionHistoryTimeWindow"); if (duplicateDetectionHistoryTimeWindowElement != null) { String duplicateDetectionHistoryTimeWindowInstance; duplicateDetectionHistoryTimeWindowInstance = duplicateDetectionHistoryTimeWindowElement .getTextContent(); entryInstance.setDuplicateDetectionHistoryTimeWindow( duplicateDetectionHistoryTimeWindowInstance); } Element maxDeliveryCountElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "MaxDeliveryCount"); if (maxDeliveryCountElement != null) { int maxDeliveryCountInstance; maxDeliveryCountInstance = DatatypeConverter .parseInt(maxDeliveryCountElement.getTextContent()); entryInstance.setMaxDeliveryCount(maxDeliveryCountInstance); } Element enableBatchedOperationsElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "EnableBatchedOperations"); if (enableBatchedOperationsElement != null) { boolean enableBatchedOperationsInstance; enableBatchedOperationsInstance = DatatypeConverter.parseBoolean( enableBatchedOperationsElement.getTextContent().toLowerCase()); entryInstance.setEnableBatchedOperations(enableBatchedOperationsInstance); } Element sizeInBytesElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "SizeInBytes"); if (sizeInBytesElement != null) { int sizeInBytesInstance; sizeInBytesInstance = DatatypeConverter .parseInt(sizeInBytesElement.getTextContent()); entryInstance.setSizeInBytes(sizeInBytesInstance); } Element messageCountElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "MessageCount"); if (messageCountElement != null) { int messageCountInstance; messageCountInstance = DatatypeConverter .parseInt(messageCountElement.getTextContent()); entryInstance.setMessageCount(messageCountInstance); } Element isAnonymousAccessibleElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "IsAnonymousAccessible"); if (isAnonymousAccessibleElement != null) { boolean isAnonymousAccessibleInstance; isAnonymousAccessibleInstance = DatatypeConverter.parseBoolean( isAnonymousAccessibleElement.getTextContent().toLowerCase()); entryInstance.setIsAnonymousAccessible(isAnonymousAccessibleInstance); } Element authorizationRulesSequenceElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AuthorizationRules"); if (authorizationRulesSequenceElement != null) { for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(authorizationRulesSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AuthorizationRule") .size(); i2 = i2 + 1) { org.w3c.dom.Element authorizationRulesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(authorizationRulesSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AuthorizationRule") .get(i2)); ServiceBusSharedAccessAuthorizationRule authorizationRuleInstance = new ServiceBusSharedAccessAuthorizationRule(); entryInstance.getAuthorizationRules().add(authorizationRuleInstance); Element claimTypeElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ClaimType"); if (claimTypeElement != null) { String claimTypeInstance; claimTypeInstance = claimTypeElement.getTextContent(); authorizationRuleInstance.setClaimType(claimTypeInstance); } Element claimValueElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ClaimValue"); if (claimValueElement != null) { String claimValueInstance; claimValueInstance = claimValueElement.getTextContent(); authorizationRuleInstance.setClaimValue(claimValueInstance); } Element rightsSequenceElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "Rights"); if (rightsSequenceElement != null) { for (int i3 = 0; i3 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(rightsSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AccessRights") .size(); i3 = i3 + 1) { org.w3c.dom.Element rightsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(rightsSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AccessRights") .get(i3)); authorizationRuleInstance.getRights().add( AccessRight.valueOf(rightsElement.getTextContent())); } } Element createdTimeElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "CreatedTime"); if (createdTimeElement != null) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter .parseDateTime(createdTimeElement.getTextContent()); authorizationRuleInstance.setCreatedTime(createdTimeInstance); } Element keyNameElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "KeyName"); if (keyNameElement != null) { String keyNameInstance; keyNameInstance = keyNameElement.getTextContent(); authorizationRuleInstance.setKeyName(keyNameInstance); } Element modifiedTimeElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ModifiedTime"); if (modifiedTimeElement != null) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeElement.getTextContent()); authorizationRuleInstance.setModifiedTime(modifiedTimeInstance); } Element primaryKeyElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "PrimaryKey"); if (primaryKeyElement != null) { String primaryKeyInstance; primaryKeyInstance = primaryKeyElement.getTextContent(); authorizationRuleInstance.setPrimaryKey(primaryKeyInstance); } Element secondaryKeyElement = XmlUtility.getElementByTagNameNS( authorizationRulesElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "SecondaryKey"); if (secondaryKeyElement != null) { String secondaryKeyInstance; secondaryKeyInstance = secondaryKeyElement.getTextContent(); authorizationRuleInstance.setSecondaryKey(secondaryKeyInstance); } } } Element statusElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "Status"); if (statusElement != null) { String statusInstance; statusInstance = statusElement.getTextContent(); entryInstance.setStatus(statusInstance); } Element createdAtElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "CreatedAt"); if (createdAtElement != null) { Calendar createdAtInstance; createdAtInstance = DatatypeConverter .parseDateTime(createdAtElement.getTextContent()); entryInstance.setCreatedAt(createdAtInstance); } Element updatedAtElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "UpdatedAt"); if (updatedAtElement != null) { Calendar updatedAtInstance; updatedAtInstance = DatatypeConverter .parseDateTime(updatedAtElement.getTextContent()); entryInstance.setUpdatedAt(updatedAtInstance); } Element accessedAtElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AccessedAt"); if (accessedAtElement != null) { Calendar accessedAtInstance; accessedAtInstance = DatatypeConverter .parseDateTime(accessedAtElement.getTextContent()); entryInstance.setAccessedAt(accessedAtInstance); } Element supportOrderingElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "SupportOrdering"); if (supportOrderingElement != null) { boolean supportOrderingInstance; supportOrderingInstance = DatatypeConverter.parseBoolean( supportOrderingElement.getTextContent().toLowerCase()); entryInstance.setSupportOrdering(supportOrderingInstance); } Element countDetailsElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "CountDetails"); if (countDetailsElement != null) { CountDetails countDetailsInstance = new CountDetails(); entryInstance.setCountDetails(countDetailsInstance); Element activeMessageCountElement = XmlUtility.getElementByTagNameNS( countDetailsElement, "http://schemas.microsoft.com/netservices/2011/06/servicebus", "ActiveMessageCount"); if (activeMessageCountElement != null) { int activeMessageCountInstance; activeMessageCountInstance = DatatypeConverter .parseInt(activeMessageCountElement.getTextContent()); countDetailsInstance.setActiveMessageCount(activeMessageCountInstance); } Element deadLetterMessageCountElement = XmlUtility.getElementByTagNameNS( countDetailsElement, "http://schemas.microsoft.com/netservices/2011/06/servicebus", "DeadLetterMessageCount"); if (deadLetterMessageCountElement != null) { int deadLetterMessageCountInstance; deadLetterMessageCountInstance = DatatypeConverter .parseInt(deadLetterMessageCountElement.getTextContent()); countDetailsInstance .setDeadLetterMessageCount(deadLetterMessageCountInstance); } Element scheduledMessageCountElement = XmlUtility.getElementByTagNameNS( countDetailsElement, "http://schemas.microsoft.com/netservices/2011/06/servicebus", "ScheduledMessageCount"); if (scheduledMessageCountElement != null) { int scheduledMessageCountInstance; scheduledMessageCountInstance = DatatypeConverter .parseInt(scheduledMessageCountElement.getTextContent()); countDetailsInstance .setScheduledMessageCount(scheduledMessageCountInstance); } Element transferDeadLetterMessageCountElement = XmlUtility .getElementByTagNameNS(countDetailsElement, "http://schemas.microsoft.com/netservices/2011/06/servicebus", "TransferDeadLetterMessageCount"); if (transferDeadLetterMessageCountElement != null) { int transferDeadLetterMessageCountInstance; transferDeadLetterMessageCountInstance = DatatypeConverter.parseInt( transferDeadLetterMessageCountElement.getTextContent()); countDetailsInstance.setTransferDeadLetterMessageCount( transferDeadLetterMessageCountInstance); } Element transferMessageCountElement = XmlUtility.getElementByTagNameNS( countDetailsElement, "http://schemas.microsoft.com/netservices/2011/06/servicebus", "TransferMessageCount"); if (transferMessageCountElement != null) { int transferMessageCountInstance; transferMessageCountInstance = DatatypeConverter .parseInt(transferMessageCountElement.getTextContent()); countDetailsInstance .setTransferMessageCount(transferMessageCountInstance); } } Element autoDeleteOnIdleElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AutoDeleteOnIdle"); if (autoDeleteOnIdleElement != null) { String autoDeleteOnIdleInstance; autoDeleteOnIdleInstance = autoDeleteOnIdleElement.getTextContent(); entryInstance.setAutoDeleteOnIdle(autoDeleteOnIdleInstance); } Element entityAvailabilityStatusElement = XmlUtility.getElementByTagNameNS( queueDescriptionElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "EntityAvailabilityStatus"); if (entityAvailabilityStatusElement != null) { String entityAvailabilityStatusInstance; entityAvailabilityStatusInstance = entityAvailabilityStatusElement .getTextContent(); entryInstance.setEntityAvailabilityStatus(entityAvailabilityStatusInstance); } } } } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.notificationhubs.NotificationHubOperationsImpl.java
/** * The get authorization rule operation gets an authorization rule for a * NotificationHub by name.//from w w w. j a va 2 s. c o m * * @param resourceGroupName Required. The name of the resource group. * @param namespaceName Required. The namespace to get the authorization * rule for. * @param notificationHubName Required. The notification hub name. * @param authorizationRuleName 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. * @return The response of the Get Namespace operation. */ @Override public SharedAccessAuthorizationRuleGetResponse getAuthorizationRule(String resourceGroupName, String namespaceName, String notificationHubName, String authorizationRuleName) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (namespaceName == null) { throw new NullPointerException("namespaceName"); } if (notificationHubName == null) { throw new NullPointerException("notificationHubName"); } if (authorizationRuleName == null) { throw new NullPointerException("authorizationRuleName"); } // 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("namespaceName", namespaceName); tracingParameters.put("notificationHubName", notificationHubName); tracingParameters.put("authorizationRuleName", authorizationRuleName); CloudTracing.enter(invocationId, this, "getAuthorizationRuleAsync", 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.NotificationHubs"; url = url + "/namespaces/"; url = url + URLEncoder.encode(namespaceName, "UTF-8"); url = url + "/notificationHubs/"; url = url + URLEncoder.encode(notificationHubName, "UTF-8"); url = url + "/AuthorizationRules/"; url = url + URLEncoder.encode(authorizationRuleName, "UTF-8"); ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2014-09-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"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result SharedAccessAuthorizationRuleGetResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new SharedAccessAuthorizationRuleGetResponse(); 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) { SharedAccessAuthorizationRuleResource valueInstance = new SharedAccessAuthorizationRuleResource(); result.setValue(valueInstance); JsonNode idValue = responseDoc.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); valueInstance.setId(idInstance); } JsonNode locationValue = responseDoc.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); valueInstance.setLocation(locationInstance); } JsonNode nameValue = responseDoc.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); valueInstance.setName(nameInstance); } JsonNode typeValue = responseDoc.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); valueInstance.setType(typeInstance); } JsonNode tagsSequenceElement = ((JsonNode) responseDoc.get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey = property.getKey(); String tagsValue = property.getValue().getTextValue(); valueInstance.getTags().put(tagsKey, tagsValue); } } JsonNode propertiesValue = responseDoc.get("properties"); if (propertiesValue != null && propertiesValue instanceof NullNode == false) { SharedAccessAuthorizationRuleProperties propertiesInstance = new SharedAccessAuthorizationRuleProperties(); valueInstance.setProperties(propertiesInstance); JsonNode primaryKeyValue = propertiesValue.get("primaryKey"); if (primaryKeyValue != null && primaryKeyValue instanceof NullNode == false) { String primaryKeyInstance; primaryKeyInstance = primaryKeyValue.getTextValue(); propertiesInstance.setPrimaryKey(primaryKeyInstance); } JsonNode secondaryKeyValue = propertiesValue.get("secondaryKey"); if (secondaryKeyValue != null && secondaryKeyValue instanceof NullNode == false) { String secondaryKeyInstance; secondaryKeyInstance = secondaryKeyValue.getTextValue(); propertiesInstance.setSecondaryKey(secondaryKeyInstance); } JsonNode keyNameValue = propertiesValue.get("keyName"); if (keyNameValue != null && keyNameValue instanceof NullNode == false) { String keyNameInstance; keyNameInstance = keyNameValue.getTextValue(); propertiesInstance.setKeyName(keyNameInstance); } JsonNode claimTypeValue = propertiesValue.get("claimType"); if (claimTypeValue != null && claimTypeValue instanceof NullNode == false) { String claimTypeInstance; claimTypeInstance = claimTypeValue.getTextValue(); propertiesInstance.setClaimType(claimTypeInstance); } JsonNode claimValueValue = propertiesValue.get("claimValue"); if (claimValueValue != null && claimValueValue instanceof NullNode == false) { String claimValueInstance; claimValueInstance = claimValueValue.getTextValue(); propertiesInstance.setClaimValue(claimValueInstance); } JsonNode rightsArray = propertiesValue.get("rights"); if (rightsArray != null && rightsArray instanceof NullNode == false) { for (JsonNode rightsValue : ((ArrayNode) rightsArray)) { propertiesInstance.getRights() .add(Enum.valueOf(AccessRights.class, rightsValue.getTextValue())); } } JsonNode createdTimeValue = propertiesValue.get("createdTime"); if (createdTimeValue != null && createdTimeValue instanceof NullNode == false) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter.parseDateTime(createdTimeValue.getTextValue()); propertiesInstance.setCreatedTime(createdTimeInstance); } JsonNode modifiedTimeValue = propertiesValue.get("modifiedTime"); if (modifiedTimeValue != null && modifiedTimeValue instanceof NullNode == false) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeValue.getTextValue()); propertiesInstance.setModifiedTime(modifiedTimeInstance); } JsonNode revisionValue = propertiesValue.get("revision"); if (revisionValue != null && revisionValue instanceof NullNode == false) { int revisionInstance; revisionInstance = revisionValue.getIntValue(); propertiesInstance.setRevision(revisionInstance); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.sql.ElasticPoolOperationsImpl.java
/** * Gets the status of an Azure Sql Database Elastic Pool create or update * operation./*from w w w . jav a 2 s . c om*/ * * @param operationStatusLink Required. Location value returned by the Begin * operation * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Response for long running Azure Sql Database Elastic Pool * operation. */ @Override public ElasticPoolCreateOrUpdateResponse getElasticPoolOperationStatus(String operationStatusLink) throws IOException, ServiceException { // Validate if (operationStatusLink == null) { throw new NullPointerException("operationStatusLink"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("operationStatusLink", operationStatusLink); CloudTracing.enter(invocationId, this, "getElasticPoolOperationStatusAsync", tracingParameters); } // Construct URL String url = ""; url = url + operationStatusLink; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_CREATED && statusCode != HttpStatus.SC_ACCEPTED) { ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result ElasticPoolCreateOrUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED || statusCode == HttpStatus.SC_ACCEPTED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ElasticPoolCreateOrUpdateResponse(); 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); } ElasticPool elasticPoolInstance = new ElasticPool(); result.setElasticPool(elasticPoolInstance); JsonNode propertiesValue = responseDoc.get("properties"); if (propertiesValue != null && propertiesValue instanceof NullNode == false) { ElasticPoolProperties propertiesInstance = new ElasticPoolProperties(); elasticPoolInstance.setProperties(propertiesInstance); JsonNode creationDateValue = propertiesValue.get("creationDate"); if (creationDateValue != null && creationDateValue instanceof NullNode == false) { Calendar creationDateInstance; creationDateInstance = DatatypeConverter .parseDateTime(creationDateValue.getTextValue()); propertiesInstance.setCreationDate(creationDateInstance); } JsonNode stateValue = propertiesValue.get("state"); if (stateValue != null && stateValue instanceof NullNode == false) { String stateInstance; stateInstance = stateValue.getTextValue(); propertiesInstance.setState(stateInstance); } JsonNode editionValue = propertiesValue.get("edition"); if (editionValue != null && editionValue instanceof NullNode == false) { String editionInstance; editionInstance = editionValue.getTextValue(); propertiesInstance.setEdition(editionInstance); } JsonNode dtuValue = propertiesValue.get("dtu"); if (dtuValue != null && dtuValue instanceof NullNode == false) { int dtuInstance; dtuInstance = dtuValue.getIntValue(); propertiesInstance.setDtu(dtuInstance); } JsonNode databaseDtuMaxValue = propertiesValue.get("databaseDtuMax"); if (databaseDtuMaxValue != null && databaseDtuMaxValue instanceof NullNode == false) { int databaseDtuMaxInstance; databaseDtuMaxInstance = databaseDtuMaxValue.getIntValue(); propertiesInstance.setDatabaseDtuMax(databaseDtuMaxInstance); } JsonNode databaseDtuMinValue = propertiesValue.get("databaseDtuMin"); if (databaseDtuMinValue != null && databaseDtuMinValue instanceof NullNode == false) { int databaseDtuMinInstance; databaseDtuMinInstance = databaseDtuMinValue.getIntValue(); propertiesInstance.setDatabaseDtuMin(databaseDtuMinInstance); } JsonNode storageMBValue = propertiesValue.get("storageMB"); if (storageMBValue != null && storageMBValue instanceof NullNode == false) { int storageMBInstance; storageMBInstance = storageMBValue.getIntValue(); propertiesInstance.setStorageMB(storageMBInstance); } } JsonNode idValue = responseDoc.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); elasticPoolInstance.setId(idInstance); } JsonNode nameValue = responseDoc.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); elasticPoolInstance.setName(nameInstance); } JsonNode typeValue = responseDoc.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); elasticPoolInstance.setType(typeInstance); } JsonNode locationValue = responseDoc.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); elasticPoolInstance.setLocation(locationInstance); } JsonNode tagsSequenceElement = ((JsonNode) responseDoc.get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey = property.getKey(); String tagsValue = property.getValue().getTextValue(); elasticPoolInstance.getTags().put(tagsKey, tagsValue); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (statusCode == HttpStatus.SC_CREATED) { result.setStatus(OperationStatus.Succeeded); } 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.windowsazure.management.servicebus.NamespaceOperationsImpl.java
/** * The get authorization rules operation gets the authorization rules for a * namespace.//from www .j av a 2 s. c om * * @param namespaceName Required. The namespace 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 list of authorization rules. */ @Override public ServiceBusAuthorizationRulesResponse listAuthorizationRules(String namespaceName) throws IOException, ServiceException, ParserConfigurationException, SAXException { // Validate if (namespaceName == null) { throw new NullPointerException("namespaceName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("namespaceName", namespaceName); CloudTracing.enter(invocationId, this, "listAuthorizationRulesAsync", 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"; 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"); 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 ServiceBusAuthorizationRulesResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new ServiceBusAuthorizationRulesResponse(); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent)); Element feedElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://www.w3.org/2005/Atom", "feed"); if (feedElement != null) { if (feedElement != null) { for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(feedElement, "http://www.w3.org/2005/Atom", "entry") .size(); i1 = i1 + 1) { org.w3c.dom.Element entriesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(feedElement, "http://www.w3.org/2005/Atom", "entry") .get(i1)); ServiceBusSharedAccessAuthorizationRule entryInstance = new ServiceBusSharedAccessAuthorizationRule(); result.getAuthorizationRules().add(entryInstance); Element contentElement = XmlUtility.getElementByTagNameNS(entriesElement, "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) { Element claimTypeElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "ClaimType"); if (claimTypeElement != null) { String claimTypeInstance; claimTypeInstance = claimTypeElement.getTextContent(); entryInstance.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(); entryInstance.setClaimValue(claimValueInstance); } Element rightsSequenceElement = XmlUtility.getElementByTagNameNS( sharedAccessAuthorizationRuleElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "Rights"); if (rightsSequenceElement != null) { for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility .getElementsByTagNameNS(rightsSequenceElement, "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect", "AccessRights") .size(); i2 = i2 + 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(i2)); entryInstance.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()); entryInstance.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()); entryInstance.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(); entryInstance.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(); entryInstance.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(); entryInstance.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()); entryInstance.setRevision(revisionInstance); } } } } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.notificationhubs.NamespaceOperationsImpl.java
/** * Lists all the available namespaces within the subscription irrespective * of the resourceGroups. (see//from w w w . j a v a 2s .com * http://msdn.microsoft.com/en-us/library/azure/hh780759.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 URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The response of the List Namespace operation. */ @Override public NamespaceListResponse listAll() throws IOException, ServiceException, 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, "listAllAsync", 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 + "/providers/"; url = url + "Microsoft.NotificationHubs"; url = url + "/namespaces"; ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2014-09-01"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers httpRequest.setHeader("Content-Type", "application/json"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromJson(httpRequest, null, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result NamespaceListResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new NamespaceListResponse(); ObjectMapper objectMapper = new ObjectMapper(); JsonNode responseDoc = null; String responseDocContent = IOUtils.toString(responseContent); if (responseDocContent == null == false && responseDocContent.length() > 0) { responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { JsonNode valueArray = responseDoc.get("value"); if (valueArray != null && valueArray instanceof NullNode == false) { for (JsonNode valueValue : ((ArrayNode) valueArray)) { NamespaceResource namespaceResourceInstance = new NamespaceResource(); result.getValue().add(namespaceResourceInstance); JsonNode idValue = valueValue.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); namespaceResourceInstance.setId(idInstance); } JsonNode locationValue = valueValue.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); namespaceResourceInstance.setLocation(locationInstance); } JsonNode nameValue = valueValue.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); namespaceResourceInstance.setName(nameInstance); } JsonNode typeValue = valueValue.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); namespaceResourceInstance.setType(typeInstance); } JsonNode tagsSequenceElement = ((JsonNode) valueValue.get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey = property.getKey(); String tagsValue = property.getValue().getTextValue(); namespaceResourceInstance.getTags().put(tagsKey, tagsValue); } } JsonNode propertiesValue = valueValue.get("properties"); if (propertiesValue != null && propertiesValue instanceof NullNode == false) { NamespaceProperties propertiesInstance = new NamespaceProperties(); namespaceResourceInstance.setProperties(propertiesInstance); JsonNode nameValue2 = propertiesValue.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); propertiesInstance.setName(nameInstance2); } JsonNode provisioningStateValue = propertiesValue.get("provisioningState"); if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) { String provisioningStateInstance; provisioningStateInstance = provisioningStateValue.getTextValue(); propertiesInstance.setProvisioningState(provisioningStateInstance); } JsonNode regionValue = propertiesValue.get("region"); if (regionValue != null && regionValue instanceof NullNode == false) { String regionInstance; regionInstance = regionValue.getTextValue(); propertiesInstance.setRegion(regionInstance); } JsonNode statusValue = propertiesValue.get("status"); if (statusValue != null && statusValue instanceof NullNode == false) { String statusInstance; statusInstance = statusValue.getTextValue(); propertiesInstance.setStatus(statusInstance); } JsonNode createdAtValue = propertiesValue.get("createdAt"); if (createdAtValue != null && createdAtValue instanceof NullNode == false) { Calendar createdAtInstance; createdAtInstance = DatatypeConverter .parseDateTime(createdAtValue.getTextValue()); propertiesInstance.setCreatedAt(createdAtInstance); } JsonNode serviceBusEndpointValue = propertiesValue.get("serviceBusEndpoint"); if (serviceBusEndpointValue != null && serviceBusEndpointValue instanceof NullNode == false) { URI serviceBusEndpointInstance; serviceBusEndpointInstance = new URI(serviceBusEndpointValue.getTextValue()); propertiesInstance.setServiceBusEndpoint(serviceBusEndpointInstance); } JsonNode subscriptionIdValue = propertiesValue.get("subscriptionId"); if (subscriptionIdValue != null && subscriptionIdValue instanceof NullNode == false) { String subscriptionIdInstance; subscriptionIdInstance = subscriptionIdValue.getTextValue(); propertiesInstance.setSubscriptionId(subscriptionIdInstance); } JsonNode scaleUnitValue = propertiesValue.get("scaleUnit"); if (scaleUnitValue != null && scaleUnitValue instanceof NullNode == false) { String scaleUnitInstance; scaleUnitInstance = scaleUnitValue.getTextValue(); propertiesInstance.setScaleUnit(scaleUnitInstance); } JsonNode enabledValue = propertiesValue.get("enabled"); if (enabledValue != null && enabledValue instanceof NullNode == false) { boolean enabledInstance; enabledInstance = enabledValue.getBooleanValue(); propertiesInstance.setEnabled(enabledInstance); } JsonNode criticalValue = propertiesValue.get("critical"); if (criticalValue != null && criticalValue instanceof NullNode == false) { boolean criticalInstance; criticalInstance = criticalValue.getBooleanValue(); propertiesInstance.setCritical(criticalInstance); } JsonNode namespaceTypeValue = propertiesValue.get("namespaceType"); if (namespaceTypeValue != null && namespaceTypeValue instanceof NullNode == false) { NamespaceType namespaceTypeInstance; namespaceTypeInstance = Enum.valueOf(NamespaceType.class, namespaceTypeValue.getTextValue()); propertiesInstance.setNamespaceType(namespaceTypeInstance); } } } } JsonNode nextLinkValue = responseDoc.get("nextLink"); if (nextLinkValue != null && nextLinkValue instanceof NullNode == false) { String nextLinkInstance; nextLinkInstance = nextLinkValue.getTextValue(); result.setNextLink(nextLinkInstance); } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.storage.StorageAccountOperationsImpl.java
/** * Updates the account type or tags for a storage account. It can also be * used to add a custom domain (note that custom domains cannot be added * via the Create operation). Only one custom domain is supported per * storage account. In order to replace a custom domain, the old value must * be cleared before a new value may be set. To clear a custom domain, * simply update the custom domain with empty string. Then call update * again with the new cutsom domain name. The update API can only be used * to update one of tags, accountType, or customDomain per call. To update * multiple of these properties, call the API multiple times with one * change per call. This call does not change the storage keys for the * account. If you want to change storage account keys, use the * RegenerateKey operation. The location and name of the storage account * cannot be changed after creation./*from w w w. ja v a2 s . co m*/ * * @param resourceGroupName Required. The name of the resource group within * the user's subscription. * @param accountName Required. The name of the storage account within the * specified resource group. Storage account names must be between 3 and 24 * characters in length and use numbers and lower-case letters only. * @param parameters Required. The parameters to update on the account. Note * that only one property can be changed at a time using this API. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The Update storage account operation response. */ @Override public StorageAccountUpdateResponse update(String resourceGroupName, String accountName, StorageAccountUpdateParameters parameters) throws IOException, ServiceException, URISyntaxException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (accountName == null) { throw new NullPointerException("accountName"); } if (accountName.length() < 3) { throw new IllegalArgumentException("accountName"); } if (accountName.length() > 24) { throw new IllegalArgumentException("accountName"); } for (char accountNameChar : accountName.toCharArray()) { if (Character.isLowerCase(accountNameChar) == false && Character.isDigit(accountNameChar) == false) { throw new IllegalArgumentException("accountName"); } } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getCustomDomain() != null) { if (parameters.getCustomDomain().getName() == null) { throw new NullPointerException("parameters.CustomDomain.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("resourceGroupName", resourceGroupName); tracingParameters.put("accountName", accountName); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "updateAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourceGroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/Microsoft.Storage/storageAccounts/"; url = url + URLEncoder.encode(accountName, "UTF-8"); ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2015-06-15"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpPatch httpRequest = new HttpPatch(url); // Set Headers httpRequest.setHeader("Content-Type", "application/json"); httpRequest.setHeader("x-ms-client-request-id", UUID.randomUUID().toString()); // Serialize Request String requestContent = null; JsonNode requestDoc = null; ObjectMapper objectMapper = new ObjectMapper(); ObjectNode storageAccountUpdateParametersJsonValue = objectMapper.createObjectNode(); requestDoc = storageAccountUpdateParametersJsonValue; if (parameters.getTags() != null) { if (parameters.getTags() instanceof LazyCollection == false || ((LazyCollection) parameters.getTags()).isInitialized()) { 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) storageAccountUpdateParametersJsonValue).put("tags", tagsDictionary); } } ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) storageAccountUpdateParametersJsonValue).put("properties", propertiesValue); if (parameters.getAccountType() != null) { ((ObjectNode) propertiesValue).put("accountType", StorageManagementClientImpl.accountTypeToString(parameters.getAccountType())); } if (parameters.getCustomDomain() != null) { ObjectNode customDomainValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("customDomain", customDomainValue); ((ObjectNode) customDomainValue).put("name", parameters.getCustomDomain().getName()); if (parameters.getCustomDomain().isUseSubDomain() != null) { ((ObjectNode) customDomainValue).put("useSubDomain", parameters.getCustomDomain().isUseSubDomain()); } } 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) { ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result StorageAccountUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new StorageAccountUpdateResponse(); 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) { StorageAccount storageAccountInstance = new StorageAccount(); result.setStorageAccount(storageAccountInstance); JsonNode idValue = responseDoc.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); storageAccountInstance.setId(idInstance); } JsonNode nameValue = responseDoc.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); storageAccountInstance.setName(nameInstance); } JsonNode typeValue = responseDoc.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); storageAccountInstance.setType(typeInstance); } JsonNode locationValue = responseDoc.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); storageAccountInstance.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(); storageAccountInstance.getTags().put(tagsKey2, tagsValue2); } } JsonNode propertiesValue2 = responseDoc.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { JsonNode provisioningStateValue = propertiesValue2.get("provisioningState"); if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) { ProvisioningState provisioningStateInstance; provisioningStateInstance = EnumUtility.fromString(ProvisioningState.class, provisioningStateValue.getTextValue()); storageAccountInstance.setProvisioningState(provisioningStateInstance); } JsonNode accountTypeValue = propertiesValue2.get("accountType"); if (accountTypeValue != null && accountTypeValue instanceof NullNode == false) { AccountType accountTypeInstance; accountTypeInstance = StorageManagementClientImpl .parseAccountType(accountTypeValue.getTextValue()); storageAccountInstance.setAccountType(accountTypeInstance); } JsonNode primaryEndpointsValue = propertiesValue2.get("primaryEndpoints"); if (primaryEndpointsValue != null && primaryEndpointsValue instanceof NullNode == false) { Endpoints primaryEndpointsInstance = new Endpoints(); storageAccountInstance.setPrimaryEndpoints(primaryEndpointsInstance); JsonNode blobValue = primaryEndpointsValue.get("blob"); if (blobValue != null && blobValue instanceof NullNode == false) { URI blobInstance; blobInstance = new URI(blobValue.getTextValue()); primaryEndpointsInstance.setBlob(blobInstance); } JsonNode queueValue = primaryEndpointsValue.get("queue"); if (queueValue != null && queueValue instanceof NullNode == false) { URI queueInstance; queueInstance = new URI(queueValue.getTextValue()); primaryEndpointsInstance.setQueue(queueInstance); } JsonNode tableValue = primaryEndpointsValue.get("table"); if (tableValue != null && tableValue instanceof NullNode == false) { URI tableInstance; tableInstance = new URI(tableValue.getTextValue()); primaryEndpointsInstance.setTable(tableInstance); } JsonNode fileValue = primaryEndpointsValue.get("file"); if (fileValue != null && fileValue instanceof NullNode == false) { URI fileInstance; fileInstance = new URI(fileValue.getTextValue()); primaryEndpointsInstance.setFile(fileInstance); } } JsonNode primaryLocationValue = propertiesValue2.get("primaryLocation"); if (primaryLocationValue != null && primaryLocationValue instanceof NullNode == false) { String primaryLocationInstance; primaryLocationInstance = primaryLocationValue.getTextValue(); storageAccountInstance.setPrimaryLocation(primaryLocationInstance); } JsonNode statusOfPrimaryValue = propertiesValue2.get("statusOfPrimary"); if (statusOfPrimaryValue != null && statusOfPrimaryValue instanceof NullNode == false) { AccountStatus statusOfPrimaryInstance; statusOfPrimaryInstance = EnumUtility.fromString(AccountStatus.class, statusOfPrimaryValue.getTextValue()); storageAccountInstance.setStatusOfPrimary(statusOfPrimaryInstance); } JsonNode lastGeoFailoverTimeValue = propertiesValue2.get("lastGeoFailoverTime"); if (lastGeoFailoverTimeValue != null && lastGeoFailoverTimeValue instanceof NullNode == false) { Calendar lastGeoFailoverTimeInstance; lastGeoFailoverTimeInstance = DatatypeConverter .parseDateTime(lastGeoFailoverTimeValue.getTextValue()); storageAccountInstance.setLastGeoFailoverTime(lastGeoFailoverTimeInstance); } JsonNode secondaryLocationValue = propertiesValue2.get("secondaryLocation"); if (secondaryLocationValue != null && secondaryLocationValue instanceof NullNode == false) { String secondaryLocationInstance; secondaryLocationInstance = secondaryLocationValue.getTextValue(); storageAccountInstance.setSecondaryLocation(secondaryLocationInstance); } JsonNode statusOfSecondaryValue = propertiesValue2.get("statusOfSecondary"); if (statusOfSecondaryValue != null && statusOfSecondaryValue instanceof NullNode == false) { AccountStatus statusOfSecondaryInstance; statusOfSecondaryInstance = EnumUtility.fromString(AccountStatus.class, statusOfSecondaryValue.getTextValue()); storageAccountInstance.setStatusOfSecondary(statusOfSecondaryInstance); } JsonNode creationTimeValue = propertiesValue2.get("creationTime"); if (creationTimeValue != null && creationTimeValue instanceof NullNode == false) { Calendar creationTimeInstance; creationTimeInstance = DatatypeConverter .parseDateTime(creationTimeValue.getTextValue()); storageAccountInstance.setCreationTime(creationTimeInstance); } JsonNode customDomainValue2 = propertiesValue2.get("customDomain"); if (customDomainValue2 != null && customDomainValue2 instanceof NullNode == false) { CustomDomain customDomainInstance = new CustomDomain(); storageAccountInstance.setCustomDomain(customDomainInstance); JsonNode nameValue2 = customDomainValue2.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); customDomainInstance.setName(nameInstance2); } JsonNode useSubDomainValue = customDomainValue2.get("useSubDomain"); if (useSubDomainValue != null && useSubDomainValue instanceof NullNode == false) { boolean useSubDomainInstance; useSubDomainInstance = useSubDomainValue.getBooleanValue(); customDomainInstance.setUseSubDomain(useSubDomainInstance); } } JsonNode secondaryEndpointsValue = propertiesValue2.get("secondaryEndpoints"); if (secondaryEndpointsValue != null && secondaryEndpointsValue instanceof NullNode == false) { Endpoints secondaryEndpointsInstance = new Endpoints(); storageAccountInstance.setSecondaryEndpoints(secondaryEndpointsInstance); JsonNode blobValue2 = secondaryEndpointsValue.get("blob"); if (blobValue2 != null && blobValue2 instanceof NullNode == false) { URI blobInstance2; blobInstance2 = new URI(blobValue2.getTextValue()); secondaryEndpointsInstance.setBlob(blobInstance2); } JsonNode queueValue2 = secondaryEndpointsValue.get("queue"); if (queueValue2 != null && queueValue2 instanceof NullNode == false) { URI queueInstance2; queueInstance2 = new URI(queueValue2.getTextValue()); secondaryEndpointsInstance.setQueue(queueInstance2); } JsonNode tableValue2 = secondaryEndpointsValue.get("table"); if (tableValue2 != null && tableValue2 instanceof NullNode == false) { URI tableInstance2; tableInstance2 = new URI(tableValue2.getTextValue()); secondaryEndpointsInstance.setTable(tableInstance2); } JsonNode fileValue2 = secondaryEndpointsValue.get("file"); if (fileValue2 != null && fileValue2 instanceof NullNode == false) { URI fileInstance2; fileInstance2 = new URI(fileValue2.getTextValue()); secondaryEndpointsInstance.setFile(fileInstance2); } } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:com.microsoft.azure.management.resources.DeploymentOperationsImpl.java
/** * Validate a deployment template.//from ww w . j av a 2 s .co m * * @param resourceGroupName Required. The name of the resource group. The * name is case insensitive. * @param deploymentName Required. The name of the deployment. * @param parameters Required. Deployment to validate. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return Information from validate template deployment response. */ @Override public DeploymentValidateResponse validate(String resourceGroupName, String deploymentName, Deployment parameters) throws IOException, ServiceException, URISyntaxException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (resourceGroupName != null && resourceGroupName.length() > 1000) { throw new IllegalArgumentException("resourceGroupName"); } if (Pattern.matches("^[-\\w\\._]+$", resourceGroupName) == false) { throw new IllegalArgumentException("resourceGroupName"); } if (deploymentName == null) { throw new NullPointerException("deploymentName"); } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getProperties() != null) { if (parameters.getProperties().getParametersLink() != null) { if (parameters.getProperties().getParametersLink().getUri() == null) { throw new NullPointerException("parameters.Properties.ParametersLink.Uri"); } } if (parameters.getProperties().getTemplateLink() != null) { if (parameters.getProperties().getTemplateLink().getUri() == null) { throw new NullPointerException("parameters.Properties.TemplateLink.Uri"); } } } // 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("deploymentName", deploymentName); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "validateAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourcegroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/microsoft.resources/deployments/"; url = url + URLEncoder.encode(deploymentName, "UTF-8"); url = url + "/validate"; ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2014-04-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; charset=utf-8"); // Serialize Request String requestContent = null; JsonNode requestDoc = null; ObjectMapper objectMapper = new ObjectMapper(); ObjectNode deploymentValue = objectMapper.createObjectNode(); requestDoc = deploymentValue; if (parameters.getProperties() != null) { ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) deploymentValue).put("properties", propertiesValue); if (parameters.getProperties().getTemplate() != null) { ((ObjectNode) propertiesValue).put("template", objectMapper.readTree(parameters.getProperties().getTemplate())); } if (parameters.getProperties().getTemplateLink() != null) { ObjectNode templateLinkValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("templateLink", templateLinkValue); ((ObjectNode) templateLinkValue).put("uri", parameters.getProperties().getTemplateLink().getUri().toString()); if (parameters.getProperties().getTemplateLink().getContentVersion() != null) { ((ObjectNode) templateLinkValue).put("contentVersion", parameters.getProperties().getTemplateLink().getContentVersion()); } } if (parameters.getProperties().getParameters() != null) { ((ObjectNode) propertiesValue).put("parameters", objectMapper.readTree(parameters.getProperties().getParameters())); } if (parameters.getProperties().getParametersLink() != null) { ObjectNode parametersLinkValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("parametersLink", parametersLinkValue); ((ObjectNode) parametersLinkValue).put("uri", parameters.getProperties().getParametersLink().getUri().toString()); if (parameters.getProperties().getParametersLink().getContentVersion() != null) { ((ObjectNode) parametersLinkValue).put("contentVersion", parameters.getProperties().getParametersLink().getContentVersion()); } } if (parameters.getProperties().getMode() != null) { ((ObjectNode) propertiesValue).put("mode", parameters.getProperties().getMode().toString()); } } 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_BAD_REQUEST) { ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result DeploymentValidateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_BAD_REQUEST) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new DeploymentValidateResponse(); JsonNode responseDoc = null; String responseDocContent = IOUtils.toString(responseContent); if (responseDocContent == null == false && responseDocContent.length() > 0) { responseDoc = objectMapper.readTree(responseDocContent); } if (responseDoc != null && responseDoc instanceof NullNode == false) { JsonNode errorValue = responseDoc.get("error"); if (errorValue != null && errorValue instanceof NullNode == false) { ResourceManagementErrorWithDetails errorInstance = new ResourceManagementErrorWithDetails(); result.setError(errorInstance); JsonNode detailsArray = errorValue.get("details"); if (detailsArray != null && detailsArray instanceof NullNode == false) { for (JsonNode detailsValue : ((ArrayNode) detailsArray)) { ResourceManagementError resourceManagementErrorInstance = new ResourceManagementError(); errorInstance.getDetails().add(resourceManagementErrorInstance); JsonNode codeValue = detailsValue.get("code"); if (codeValue != null && codeValue instanceof NullNode == false) { String codeInstance; codeInstance = codeValue.getTextValue(); resourceManagementErrorInstance.setCode(codeInstance); } JsonNode messageValue = detailsValue.get("message"); if (messageValue != null && messageValue instanceof NullNode == false) { String messageInstance; messageInstance = messageValue.getTextValue(); resourceManagementErrorInstance.setMessage(messageInstance); } JsonNode targetValue = detailsValue.get("target"); if (targetValue != null && targetValue instanceof NullNode == false) { String targetInstance; targetInstance = targetValue.getTextValue(); resourceManagementErrorInstance.setTarget(targetInstance); } } } JsonNode codeValue2 = errorValue.get("code"); if (codeValue2 != null && codeValue2 instanceof NullNode == false) { String codeInstance2; codeInstance2 = codeValue2.getTextValue(); errorInstance.setCode(codeInstance2); } JsonNode messageValue2 = errorValue.get("message"); if (messageValue2 != null && messageValue2 instanceof NullNode == false) { String messageInstance2; messageInstance2 = messageValue2.getTextValue(); errorInstance.setMessage(messageInstance2); } JsonNode targetValue2 = errorValue.get("target"); if (targetValue2 != null && targetValue2 instanceof NullNode == false) { String targetInstance2; targetInstance2 = targetValue2.getTextValue(); errorInstance.setTarget(targetInstance2); } } JsonNode propertiesValue2 = responseDoc.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); result.setProperties(propertiesInstance); JsonNode provisioningStateValue = propertiesValue2.get("provisioningState"); if (provisioningStateValue != null && provisioningStateValue instanceof NullNode == false) { String provisioningStateInstance; provisioningStateInstance = provisioningStateValue.getTextValue(); propertiesInstance.setProvisioningState(provisioningStateInstance); } JsonNode correlationIdValue = propertiesValue2.get("correlationId"); if (correlationIdValue != null && correlationIdValue instanceof NullNode == false) { String correlationIdInstance; correlationIdInstance = correlationIdValue.getTextValue(); propertiesInstance.setCorrelationId(correlationIdInstance); } JsonNode timestampValue = propertiesValue2.get("timestamp"); if (timestampValue != null && timestampValue instanceof NullNode == false) { Calendar timestampInstance; timestampInstance = DatatypeConverter.parseDateTime(timestampValue.getTextValue()); propertiesInstance.setTimestamp(timestampInstance); } JsonNode outputsValue = propertiesValue2.get("outputs"); if (outputsValue != null && outputsValue instanceof NullNode == false) { String outputsInstance; outputsInstance = outputsValue.getTextValue(); propertiesInstance.setOutputs(outputsInstance); } JsonNode providersArray = propertiesValue2.get("providers"); if (providersArray != null && providersArray instanceof NullNode == false) { for (JsonNode providersValue : ((ArrayNode) providersArray)) { Provider providerInstance = new Provider(); propertiesInstance.getProviders().add(providerInstance); JsonNode idValue = providersValue.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); providerInstance.setId(idInstance); } JsonNode namespaceValue = providersValue.get("namespace"); if (namespaceValue != null && namespaceValue instanceof NullNode == false) { String namespaceInstance; namespaceInstance = namespaceValue.getTextValue(); providerInstance.setNamespace(namespaceInstance); } JsonNode registrationStateValue = providersValue.get("registrationState"); if (registrationStateValue != null && registrationStateValue instanceof NullNode == false) { String registrationStateInstance; registrationStateInstance = registrationStateValue.getTextValue(); providerInstance.setRegistrationState(registrationStateInstance); } JsonNode resourceTypesArray = providersValue.get("resourceTypes"); if (resourceTypesArray != null && resourceTypesArray instanceof NullNode == false) { for (JsonNode resourceTypesValue : ((ArrayNode) resourceTypesArray)) { ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); providerInstance.getResourceTypes().add(providerResourceTypeInstance); JsonNode resourceTypeValue = resourceTypesValue.get("resourceType"); if (resourceTypeValue != null && resourceTypeValue instanceof NullNode == false) { String resourceTypeInstance; resourceTypeInstance = resourceTypeValue.getTextValue(); providerResourceTypeInstance.setName(resourceTypeInstance); } JsonNode locationsArray = resourceTypesValue.get("locations"); if (locationsArray != null && locationsArray instanceof NullNode == false) { for (JsonNode locationsValue : ((ArrayNode) locationsArray)) { providerResourceTypeInstance.getLocations() .add(locationsValue.getTextValue()); } } JsonNode apiVersionsArray = resourceTypesValue.get("apiVersions"); if (apiVersionsArray != null && apiVersionsArray instanceof NullNode == false) { for (JsonNode apiVersionsValue : ((ArrayNode) apiVersionsArray)) { providerResourceTypeInstance.getApiVersions() .add(apiVersionsValue.getTextValue()); } } JsonNode propertiesSequenceElement = ((JsonNode) resourceTypesValue .get("properties")); if (propertiesSequenceElement != null && propertiesSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = propertiesSequenceElement .getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String propertiesKey = property.getKey(); String propertiesValue3 = property.getValue().getTextValue(); providerResourceTypeInstance.getProperties().put(propertiesKey, propertiesValue3); } } } } } } JsonNode dependenciesArray = propertiesValue2.get("dependencies"); if (dependenciesArray != null && dependenciesArray instanceof NullNode == false) { for (JsonNode dependenciesValue : ((ArrayNode) dependenciesArray)) { Dependency dependencyInstance = new Dependency(); propertiesInstance.getDependencies().add(dependencyInstance); JsonNode dependsOnArray = dependenciesValue.get("dependsOn"); if (dependsOnArray != null && dependsOnArray instanceof NullNode == false) { for (JsonNode dependsOnValue : ((ArrayNode) dependsOnArray)) { BasicDependency basicDependencyInstance = new BasicDependency(); dependencyInstance.getDependsOn().add(basicDependencyInstance); JsonNode idValue2 = dependsOnValue.get("id"); if (idValue2 != null && idValue2 instanceof NullNode == false) { String idInstance2; idInstance2 = idValue2.getTextValue(); basicDependencyInstance.setId(idInstance2); } JsonNode resourceTypeValue2 = dependsOnValue.get("resourceType"); if (resourceTypeValue2 != null && resourceTypeValue2 instanceof NullNode == false) { String resourceTypeInstance2; resourceTypeInstance2 = resourceTypeValue2.getTextValue(); basicDependencyInstance.setResourceType(resourceTypeInstance2); } JsonNode resourceNameValue = dependsOnValue.get("resourceName"); if (resourceNameValue != null && resourceNameValue instanceof NullNode == false) { String resourceNameInstance; resourceNameInstance = resourceNameValue.getTextValue(); basicDependencyInstance.setResourceName(resourceNameInstance); } } } JsonNode idValue3 = dependenciesValue.get("id"); if (idValue3 != null && idValue3 instanceof NullNode == false) { String idInstance3; idInstance3 = idValue3.getTextValue(); dependencyInstance.setId(idInstance3); } JsonNode resourceTypeValue3 = dependenciesValue.get("resourceType"); if (resourceTypeValue3 != null && resourceTypeValue3 instanceof NullNode == false) { String resourceTypeInstance3; resourceTypeInstance3 = resourceTypeValue3.getTextValue(); dependencyInstance.setResourceType(resourceTypeInstance3); } JsonNode resourceNameValue2 = dependenciesValue.get("resourceName"); if (resourceNameValue2 != null && resourceNameValue2 instanceof NullNode == false) { String resourceNameInstance2; resourceNameInstance2 = resourceNameValue2.getTextValue(); dependencyInstance.setResourceName(resourceNameInstance2); } } } JsonNode templateValue = propertiesValue2.get("template"); if (templateValue != null && templateValue instanceof NullNode == false) { String templateInstance; templateInstance = templateValue.getTextValue(); propertiesInstance.setTemplate(templateInstance); } JsonNode templateLinkValue2 = propertiesValue2.get("templateLink"); if (templateLinkValue2 != null && templateLinkValue2 instanceof NullNode == false) { TemplateLink templateLinkInstance = new TemplateLink(); propertiesInstance.setTemplateLink(templateLinkInstance); JsonNode uriValue = templateLinkValue2.get("uri"); if (uriValue != null && uriValue instanceof NullNode == false) { URI uriInstance; uriInstance = new URI(uriValue.getTextValue()); templateLinkInstance.setUri(uriInstance); } JsonNode contentVersionValue = templateLinkValue2.get("contentVersion"); if (contentVersionValue != null && contentVersionValue instanceof NullNode == false) { String contentVersionInstance; contentVersionInstance = contentVersionValue.getTextValue(); templateLinkInstance.setContentVersion(contentVersionInstance); } } JsonNode parametersValue = propertiesValue2.get("parameters"); if (parametersValue != null && parametersValue instanceof NullNode == false) { String parametersInstance; parametersInstance = parametersValue.getTextValue(); propertiesInstance.setParameters(parametersInstance); } JsonNode parametersLinkValue2 = propertiesValue2.get("parametersLink"); if (parametersLinkValue2 != null && parametersLinkValue2 instanceof NullNode == false) { ParametersLink parametersLinkInstance = new ParametersLink(); propertiesInstance.setParametersLink(parametersLinkInstance); JsonNode uriValue2 = parametersLinkValue2.get("uri"); if (uriValue2 != null && uriValue2 instanceof NullNode == false) { URI uriInstance2; uriInstance2 = new URI(uriValue2.getTextValue()); parametersLinkInstance.setUri(uriInstance2); } JsonNode contentVersionValue2 = parametersLinkValue2.get("contentVersion"); if (contentVersionValue2 != null && contentVersionValue2 instanceof NullNode == false) { String contentVersionInstance2; contentVersionInstance2 = contentVersionValue2.getTextValue(); parametersLinkInstance.setContentVersion(contentVersionInstance2); } } JsonNode modeValue = propertiesValue2.get("mode"); if (modeValue != null && modeValue instanceof NullNode == false) { DeploymentMode modeInstance; modeInstance = Enum.valueOf(DeploymentMode.class, modeValue.getTextValue()); propertiesInstance.setMode(modeInstance); } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (statusCode == HttpStatus.SC_OK) { result.setIsValid(true); } 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.VirtualMachineOSImageOperationsImpl.java
/** * The Update OS Image operation updates an OS image that in your image * repository. (see/*from w ww .ja va 2 s .com*/ * http://msdn.microsoft.com/en-us/library/windowsazure/jj157198.aspx for * more information) * * @param imageName Required. The name of the virtual machine image to be * updated. * @param parameters Required. Parameters supplied to the Update Virtual * Machine Image operation. * @throws InterruptedException Thrown when a thread is waiting, sleeping, * or otherwise occupied, and the thread is interrupted, either before or * during the activity. Occasionally a method may wish to test whether the * current thread has been interrupted, and if so, to immediately throw * this exception. The following code can be used to achieve this effect: * @throws ExecutionException Thrown when attempting to retrieve the result * of a task that aborted by throwing an exception. This exception can be * inspected using the Throwable.getCause() method. * @throws ServiceException Thrown if the server returned an error for the * request. * @throws IOException Thrown if there was an error setting up tracing for * the request. * @throws ParserConfigurationException Thrown if there was an error * configuring the parser for the response body. * @throws SAXException Thrown if there was an error parsing the response * body. * @throws TransformerException Thrown if there was an error creating the * DOM transformer. * @throws ServiceException Thrown if an unexpected response is found. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return Parameters returned from the Create Virtual Machine Image * operation. */ @Override public VirtualMachineOSImageUpdateResponse update(String imageName, VirtualMachineOSImageUpdateParameters parameters) throws InterruptedException, ExecutionException, ServiceException, IOException, ParserConfigurationException, SAXException, TransformerException, URISyntaxException { // Validate if (imageName == null) { throw new NullPointerException("imageName"); } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getLabel() == null) { throw new NullPointerException("parameters.Label"); } // 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("imageName", imageName); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "updateAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/services/images/"; url = url + URLEncoder.encode(imageName, "UTF-8"); String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpPut httpRequest = new HttpPut(url); // Set Headers httpRequest.setHeader("Content-Type", "application/xml"); httpRequest.setHeader("x-ms-version", "2015-04-01"); // Serialize Request String requestContent = null; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document requestDoc = documentBuilder.newDocument(); Element oSImageElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "OSImage"); requestDoc.appendChild(oSImageElement); Element labelElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Label"); labelElement.appendChild(requestDoc.createTextNode(parameters.getLabel())); oSImageElement.appendChild(labelElement); if (parameters.getEula() != null) { Element eulaElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Eula"); eulaElement.appendChild(requestDoc.createTextNode(parameters.getEula())); oSImageElement.appendChild(eulaElement); } if (parameters.getDescription() != null) { Element descriptionElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Description"); descriptionElement.appendChild(requestDoc.createTextNode(parameters.getDescription())); oSImageElement.appendChild(descriptionElement); } if (parameters.getImageFamily() != null) { Element imageFamilyElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "ImageFamily"); imageFamilyElement.appendChild(requestDoc.createTextNode(parameters.getImageFamily())); oSImageElement.appendChild(imageFamilyElement); } if (parameters.isShowInGui() != null) { Element showInGuiElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "ShowInGui"); showInGuiElement.appendChild( requestDoc.createTextNode(Boolean.toString(parameters.isShowInGui()).toLowerCase())); oSImageElement.appendChild(showInGuiElement); } if (parameters.getPublishedDate() != null) { Element publishedDateElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "PublishedDate"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); publishedDateElement.appendChild( requestDoc.createTextNode(simpleDateFormat.format(parameters.getPublishedDate().getTime()))); oSImageElement.appendChild(publishedDateElement); } if (parameters.isPremium() != null) { Element isPremiumElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "IsPremium"); isPremiumElement .appendChild(requestDoc.createTextNode(Boolean.toString(parameters.isPremium()).toLowerCase())); oSImageElement.appendChild(isPremiumElement); } if (parameters.getPrivacyUri() != null) { Element privacyUriElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "PrivacyUri"); privacyUriElement.appendChild(requestDoc.createTextNode(parameters.getPrivacyUri().toString())); oSImageElement.appendChild(privacyUriElement); } if (parameters.getIconUri() != null) { Element iconUriElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "IconUri"); iconUriElement.appendChild(requestDoc.createTextNode(parameters.getIconUri())); oSImageElement.appendChild(iconUriElement); } if (parameters.getRecommendedVMSize() != null) { Element recommendedVMSizeElement = requestDoc .createElementNS("http://schemas.microsoft.com/windowsazure", "RecommendedVMSize"); recommendedVMSizeElement.appendChild(requestDoc.createTextNode(parameters.getRecommendedVMSize())); oSImageElement.appendChild(recommendedVMSizeElement); } if (parameters.getSmallIconUri() != null) { Element smallIconUriElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "SmallIconUri"); smallIconUriElement.appendChild(requestDoc.createTextNode(parameters.getSmallIconUri())); oSImageElement.appendChild(smallIconUriElement); } if (parameters.getLanguage() != null) { Element languageElement = requestDoc.createElementNS("http://schemas.microsoft.com/windowsazure", "Language"); languageElement.appendChild(requestDoc.createTextNode(parameters.getLanguage())); oSImageElement.appendChild(languageElement); } DOMSource domSource = new DOMSource(requestDoc); StringWriter stringWriter = new StringWriter(); StreamResult streamResult = new StreamResult(stringWriter); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.transform(domSource, streamResult); requestContent = stringWriter.toString(); StringEntity entity = new StringEntity(requestContent); httpRequest.setEntity(entity); httpRequest.setHeader("Content-Type", "application/xml"); // Send Request HttpResponse httpResponse = null; try { if (shouldTrace) { CloudTracing.sendRequest(invocationId, httpRequest); } httpResponse = this.getClient().getHttpClient().execute(httpRequest); if (shouldTrace) { CloudTracing.receiveResponse(invocationId, httpResponse); } int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { ServiceException ex = ServiceException.createFromXml(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result VirtualMachineOSImageUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new VirtualMachineOSImageUpdateResponse(); DocumentBuilderFactory documentBuilderFactory2 = DocumentBuilderFactory.newInstance(); documentBuilderFactory2.setNamespaceAware(true); DocumentBuilder documentBuilder2 = documentBuilderFactory2.newDocumentBuilder(); Document responseDoc = documentBuilder2.parse(new BOMInputStream(responseContent)); Element oSImageElement2 = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "OSImage"); if (oSImageElement2 != null) { Element locationElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Location"); if (locationElement != null) { String locationInstance; locationInstance = locationElement.getTextContent(); result.setLocation(locationInstance); } Element categoryElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Category"); if (categoryElement != null) { String categoryInstance; categoryInstance = categoryElement.getTextContent(); result.setCategory(categoryInstance); } Element labelElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Label"); if (labelElement2 != null) { String labelInstance; labelInstance = labelElement2.getTextContent(); result.setLabel(labelInstance); } Element logicalSizeInGBElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "LogicalSizeInGB"); if (logicalSizeInGBElement != null) { double logicalSizeInGBInstance; logicalSizeInGBInstance = DatatypeConverter .parseDouble(logicalSizeInGBElement.getTextContent()); result.setLogicalSizeInGB(logicalSizeInGBInstance); } Element mediaLinkElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "MediaLink"); if (mediaLinkElement != null) { URI mediaLinkInstance; mediaLinkInstance = new URI(mediaLinkElement.getTextContent()); result.setMediaLinkUri(mediaLinkInstance); } Element nameElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Name"); if (nameElement != null) { String nameInstance; nameInstance = nameElement.getTextContent(); result.setName(nameInstance); } Element osElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "OS"); if (osElement != null) { String osInstance; osInstance = osElement.getTextContent(); result.setOperatingSystemType(osInstance); } Element eulaElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Eula"); if (eulaElement2 != null) { String eulaInstance; eulaInstance = eulaElement2.getTextContent(); result.setEula(eulaInstance); } Element descriptionElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Description"); if (descriptionElement2 != null) { String descriptionInstance; descriptionInstance = descriptionElement2.getTextContent(); result.setDescription(descriptionInstance); } Element imageFamilyElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "ImageFamily"); if (imageFamilyElement2 != null) { String imageFamilyInstance; imageFamilyInstance = imageFamilyElement2.getTextContent(); result.setImageFamily(imageFamilyInstance); } Element publishedDateElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "PublishedDate"); if (publishedDateElement2 != null && publishedDateElement2.getTextContent() != null && !publishedDateElement2.getTextContent().isEmpty()) { Calendar publishedDateInstance; publishedDateInstance = DatatypeConverter .parseDateTime(publishedDateElement2.getTextContent()); result.setPublishedDate(publishedDateInstance); } Element publisherNameElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "PublisherName"); if (publisherNameElement != null) { String publisherNameInstance; publisherNameInstance = publisherNameElement.getTextContent(); result.setPublisherName(publisherNameInstance); } Element isPremiumElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "IsPremium"); if (isPremiumElement2 != null && isPremiumElement2.getTextContent() != null && !isPremiumElement2.getTextContent().isEmpty()) { boolean isPremiumInstance; isPremiumInstance = DatatypeConverter .parseBoolean(isPremiumElement2.getTextContent().toLowerCase()); result.setIsPremium(isPremiumInstance); } Element showInGuiElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "ShowInGui"); if (showInGuiElement2 != null && showInGuiElement2.getTextContent() != null && !showInGuiElement2.getTextContent().isEmpty()) { boolean showInGuiInstance; showInGuiInstance = DatatypeConverter .parseBoolean(showInGuiElement2.getTextContent().toLowerCase()); result.setShowInGui(showInGuiInstance); } Element privacyUriElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "PrivacyUri"); if (privacyUriElement2 != null) { URI privacyUriInstance; privacyUriInstance = new URI(privacyUriElement2.getTextContent()); result.setPrivacyUri(privacyUriInstance); } Element iconUriElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "IconUri"); if (iconUriElement2 != null) { String iconUriInstance; iconUriInstance = iconUriElement2.getTextContent(); result.setIconUri(iconUriInstance); } Element recommendedVMSizeElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "RecommendedVMSize"); if (recommendedVMSizeElement2 != null) { String recommendedVMSizeInstance; recommendedVMSizeInstance = recommendedVMSizeElement2.getTextContent(); result.setRecommendedVMSize(recommendedVMSizeInstance); } Element smallIconUriElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "SmallIconUri"); if (smallIconUriElement2 != null) { String smallIconUriInstance; smallIconUriInstance = smallIconUriElement2.getTextContent(); result.setSmallIconUri(smallIconUriInstance); } Element languageElement2 = XmlUtility.getElementByTagNameNS(oSImageElement2, "http://schemas.microsoft.com/windowsazure", "Language"); if (languageElement2 != null) { String languageInstance; languageInstance = languageElement2.getTextContent(); result.setLanguage(languageInstance); } Element iOTypeElement = XmlUtility.getElementByTagNameNS(oSImageElement2, "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(); } } }