List of usage examples for java.lang Enum valueOf
public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name)
From source file:org.apache.openjpa.persistence.jdbc.XMLPersistenceMappingParser.java
private void parseDiscriminatorColumn(Attributes attrs) { String val = attrs.getValue("discriminator-type"); if (val != null) { _discType = Enum.valueOf(DiscriminatorType.class, val); } else {// ww w . jav a 2 s . com _discType = DiscriminatorType.STRING; } }
From source file:com.evolveum.midpoint.prism.schema.DomToSchemaPostProcessor.java
private <T> Collection<? extends DisplayableValue<T>> parseEnumAllowedValues(QName typeName, ComplexTypeDefinition ctd, XSType xsType) { if (xsType.isSimpleType()) { if (xsType.asSimpleType().isRestriction()) { XSRestrictionSimpleType restriction = xsType.asSimpleType().asRestriction(); List<XSFacet> enumerations = restriction.getDeclaredFacets(XSFacet.FACET_ENUMERATION); List<DisplayableValueImpl<T>> enumValues = new ArrayList<>(enumerations.size()); for (XSFacet facet : enumerations) { String value = facet.getValue().value; Element descriptionE = SchemaProcessorUtil.getAnnotationElement(facet.getAnnotation(), SCHEMA_DOCUMENTATION); Element appInfo = SchemaProcessorUtil.getAnnotationElement(facet.getAnnotation(), SCHEMA_APP_INFO); Element valueE = null; if (appInfo != null) { NodeList list = appInfo.getElementsByTagNameNS(PrismConstants.A_LABEL.getNamespaceURI(), PrismConstants.A_LABEL.getLocalPart()); if (list.getLength() != 0) { valueE = (Element) list.item(0); }//from w w w . ja va 2s.c o m } String label = null; if (valueE != null) { label = valueE.getTextContent(); } else { label = value; } DisplayableValueImpl<T> edv = null; Class compileTimeClass = prismContext.getSchemaRegistry().getCompileTimeClass(typeName); if (ctd != null && !ctd.isRuntimeSchema() && compileTimeClass != null) { String fieldName = null; for (Field field : compileTimeClass.getDeclaredFields()) { XmlEnumValue xmlEnumValue = field.getAnnotation(XmlEnumValue.class); if (xmlEnumValue != null && xmlEnumValue.value() != null && xmlEnumValue.value().equals(value)) { fieldName = field.getName(); } } if (fieldName != null) { T enumValue = (T) Enum.valueOf((Class<Enum>) compileTimeClass, fieldName); edv = new DisplayableValueImpl(enumValue, label, descriptionE != null ? descriptionE.getTextContent() : null); } else { edv = new DisplayableValueImpl(value, label, descriptionE != null ? descriptionE.getTextContent() : null); } } else { edv = new DisplayableValueImpl(value, label, descriptionE != null ? descriptionE.getTextContent() : null); } enumValues.add(edv); } if (enumValues != null && !enumValues.isEmpty()) { return enumValues; } } } return null; }
From source file:com.delcyon.capo.Configuration.java
@SuppressWarnings("unchecked") public Preference[] getDirectoryPreferences() { boolean isServer = CapoApplication.getApplication() instanceof CapoServer; Vector<Preference> preferenceVector = new Vector<Preference>(); Set<String> directoryProvidersSet = CapoApplication.getAnnotationMap() .get(DirectoyProvider.class.getCanonicalName()); if (directoryProvidersSet != null) { for (String className : directoryProvidersSet) { try { Location location = Class.forName(className).getAnnotation(DirectoyProvider.class).location(); Class preferenceClass = Class.forName(className).getAnnotation(DirectoyProvider.class) .preferences();/* www.j av a2 s .c o m*/ String preferenceName = Class.forName(className).getAnnotation(DirectoyProvider.class) .preferenceName(); if (location == Location.BOTH) { preferenceVector.add((Preference) Enum.valueOf(preferenceClass, preferenceName)); } else if (isServer == true && location == Location.SERVER) { preferenceVector.add((Preference) Enum.valueOf(preferenceClass, preferenceName)); } else if (isServer == false && location == Location.CLIENT) { preferenceVector.add((Preference) Enum.valueOf(preferenceClass, preferenceName)); } } catch (ClassNotFoundException classNotFoundException) { CapoApplication.logger.log(Level.WARNING, "Error getting directory providers", classNotFoundException); } } } return preferenceVector.toArray(new Preference[] {}); }
From source file:com.alliander.osgp.webdevicesimulator.service.OslpChannelHandler.java
private void handleSetConfigurationRequest(final Device device, final Oslp.SetConfigurationRequest setConfigurationRequest) { if (setConfigurationRequest.hasPreferredLinkType()) { device.setPreferredLinkType(/*from w ww.j a v a 2 s. c om*/ Enum.valueOf(LinkType.class, setConfigurationRequest.getPreferredLinkType().name())); } if (setConfigurationRequest.hasLightType()) { device.setLightType(Enum.valueOf(LightType.class, setConfigurationRequest.getLightType().name())); } if (setConfigurationRequest.hasRelayConfiguration()) { final List<DeviceOutputSetting> outputSettings = new ArrayList<>(); for (final IndexAddressMap iam : setConfigurationRequest.getRelayConfiguration().getAddressMapList()) { final int index = iam.getIndex().byteAt(0); final int address = iam.getAddress().byteAt(0); final OutputType outputType = OutputType.valueOf(iam.getRelayType().name()); outputSettings.add(new DeviceOutputSetting(index, address, outputType)); } device.setOutputSettings(outputSettings); } }
From source file:com.microsoft.azure.management.notificationhubs.NotificationHubOperationsImpl.java
/** * Creates a new NotificationHub in a namespace. (see * http://msdn.microsoft.com/en-us/library/windowsazure/jj856303.aspx for * more information)//from www .j a v a 2 s . com * * @param resourceGroupName Required. The name of the resource group. * @param namespaceName Required. The namespace name. * @param notificationHubName Required. The notification hub name. * @param parameters Required. Parameters supplied to the create a Namespace * Resource. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Response of the CreateOrUpdate operation on the NotificationHub */ @Override public NotificationHubCreateOrUpdateResponse create(String resourceGroupName, String namespaceName, String notificationHubName, NotificationHubCreateOrUpdateParameters parameters) 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 (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getLocation() == null) { throw new NullPointerException("parameters.Location"); } if (parameters.getProperties() == null) { throw new NullPointerException("parameters.Properties"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("resourceGroupName", resourceGroupName); tracingParameters.put("namespaceName", namespaceName); tracingParameters.put("notificationHubName", notificationHubName); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "createAsync", 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"); 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 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 notificationHubCreateOrUpdateParametersValue = objectMapper.createObjectNode(); requestDoc = notificationHubCreateOrUpdateParametersValue; ((ObjectNode) notificationHubCreateOrUpdateParametersValue).put("location", parameters.getLocation()); 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) notificationHubCreateOrUpdateParametersValue).put("tags", tagsDictionary); } } ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) notificationHubCreateOrUpdateParametersValue).put("properties", propertiesValue); if (parameters.getProperties().getName() != null) { ((ObjectNode) propertiesValue).put("name", parameters.getProperties().getName()); } if (parameters.getProperties().getRegistrationTtl() != null) { ((ObjectNode) propertiesValue).put("registrationTtl", parameters.getProperties().getRegistrationTtl()); } if (parameters.getProperties().getAuthorizationRules() != null) { if (parameters.getProperties().getAuthorizationRules() instanceof LazyCollection == false || ((LazyCollection) parameters.getProperties().getAuthorizationRules()).isInitialized()) { ArrayNode authorizationRulesArray = objectMapper.createArrayNode(); for (SharedAccessAuthorizationRuleProperties authorizationRulesItem : parameters.getProperties() .getAuthorizationRules()) { if (authorizationRulesItem.getPrimaryKey() != null) { requestDoc = authorizationRulesItem.getPrimaryKey(); } if (authorizationRulesItem.getSecondaryKey() != null) { requestDoc = authorizationRulesItem.getSecondaryKey(); } if (authorizationRulesItem.getKeyName() != null) { requestDoc = authorizationRulesItem.getKeyName(); } if (authorizationRulesItem.getClaimType() != null) { requestDoc = authorizationRulesItem.getClaimType(); } if (authorizationRulesItem.getClaimValue() != null) { requestDoc = authorizationRulesItem.getClaimValue(); } if (authorizationRulesItem.getRights() != null) { ArrayNode rightsArray = objectMapper.createArrayNode(); for (AccessRights rightsItem : authorizationRulesItem.getRights()) { rightsArray.add(rightsItem.toString()); } requestDoc = rightsArray; } SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); requestDoc = simpleDateFormat.format(authorizationRulesItem.getCreatedTime().getTime()); SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC")); requestDoc = simpleDateFormat2.format(authorizationRulesItem.getModifiedTime().getTime()); requestDoc = authorizationRulesItem.getRevision(); } ((ObjectNode) propertiesValue).put("authorizationRules", authorizationRulesArray); } } if (parameters.getProperties().getApnsCredential() != null) { ObjectNode apnsCredentialValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("apnsCredential", apnsCredentialValue); if (parameters.getProperties().getApnsCredential().getProperties() != null) { ObjectNode propertiesValue2 = objectMapper.createObjectNode(); ((ObjectNode) apnsCredentialValue).put("properties", propertiesValue2); if (parameters.getProperties().getApnsCredential().getProperties().getApnsCertificate() != null) { ((ObjectNode) propertiesValue2).put("apnsCertificate", parameters.getProperties().getApnsCredential().getProperties().getApnsCertificate()); } if (parameters.getProperties().getApnsCredential().getProperties().getCertificateKey() != null) { ((ObjectNode) propertiesValue2).put("certificateKey", parameters.getProperties().getApnsCredential().getProperties().getCertificateKey()); } if (parameters.getProperties().getApnsCredential().getProperties().getEndpoint() != null) { ((ObjectNode) propertiesValue2).put("endpoint", parameters.getProperties().getApnsCredential().getProperties().getEndpoint()); } if (parameters.getProperties().getApnsCredential().getProperties().getThumbprint() != null) { ((ObjectNode) propertiesValue2).put("thumbprint", parameters.getProperties().getApnsCredential().getProperties().getThumbprint()); } } } if (parameters.getProperties().getWnsCredential() != null) { ObjectNode wnsCredentialValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("wnsCredential", wnsCredentialValue); if (parameters.getProperties().getWnsCredential().getProperties() != null) { ObjectNode propertiesValue3 = objectMapper.createObjectNode(); ((ObjectNode) wnsCredentialValue).put("properties", propertiesValue3); if (parameters.getProperties().getWnsCredential().getProperties().getPackageSid() != null) { ((ObjectNode) propertiesValue3).put("packageSid", parameters.getProperties().getWnsCredential().getProperties().getPackageSid()); } if (parameters.getProperties().getWnsCredential().getProperties().getSecretKey() != null) { ((ObjectNode) propertiesValue3).put("secretKey", parameters.getProperties().getWnsCredential().getProperties().getSecretKey()); } if (parameters.getProperties().getWnsCredential().getProperties() .getWindowsLiveEndpoint() != null) { ((ObjectNode) propertiesValue3).put("windowsLiveEndpoint", parameters.getProperties().getWnsCredential().getProperties().getWindowsLiveEndpoint()); } } } if (parameters.getProperties().getGcmCredential() != null) { ObjectNode gcmCredentialValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("gcmCredential", gcmCredentialValue); if (parameters.getProperties().getGcmCredential().getProperties() != null) { ObjectNode propertiesValue4 = objectMapper.createObjectNode(); ((ObjectNode) gcmCredentialValue).put("properties", propertiesValue4); if (parameters.getProperties().getGcmCredential().getProperties().getGcmEndpoint() != null) { ((ObjectNode) propertiesValue4).put("gcmEndpoint", parameters.getProperties().getGcmCredential().getProperties().getGcmEndpoint()); } if (parameters.getProperties().getGcmCredential().getProperties().getGoogleApiKey() != null) { ((ObjectNode) propertiesValue4).put("googleApiKey", parameters.getProperties().getGcmCredential().getProperties().getGoogleApiKey()); } } } if (parameters.getProperties().getMpnsCredential() != null) { ObjectNode mpnsCredentialValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("mpnsCredential", mpnsCredentialValue); if (parameters.getProperties().getMpnsCredential().getProperties() != null) { ObjectNode propertiesValue5 = objectMapper.createObjectNode(); ((ObjectNode) mpnsCredentialValue).put("properties", propertiesValue5); if (parameters.getProperties().getMpnsCredential().getProperties().getMpnsCertificate() != null) { ((ObjectNode) propertiesValue5).put("mpnsCertificate", parameters.getProperties().getMpnsCredential().getProperties().getMpnsCertificate()); } if (parameters.getProperties().getMpnsCredential().getProperties().getCertificateKey() != null) { ((ObjectNode) propertiesValue5).put("certificateKey", parameters.getProperties().getMpnsCredential().getProperties().getCertificateKey()); } if (parameters.getProperties().getMpnsCredential().getProperties().getThumbprint() != null) { ((ObjectNode) propertiesValue5).put("thumbprint", parameters.getProperties().getMpnsCredential().getProperties().getThumbprint()); } } } if (parameters.getProperties().getAdmCredential() != null) { ObjectNode admCredentialValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("admCredential", admCredentialValue); if (parameters.getProperties().getAdmCredential().getProperties() != null) { ObjectNode propertiesValue6 = objectMapper.createObjectNode(); ((ObjectNode) admCredentialValue).put("properties", propertiesValue6); if (parameters.getProperties().getAdmCredential().getProperties().getClientId() != null) { ((ObjectNode) propertiesValue6).put("clientId", parameters.getProperties().getAdmCredential().getProperties().getClientId()); } if (parameters.getProperties().getAdmCredential().getProperties().getClientSecret() != null) { ((ObjectNode) propertiesValue6).put("clientSecret", parameters.getProperties().getAdmCredential().getProperties().getClientSecret()); } if (parameters.getProperties().getAdmCredential().getProperties().getAuthTokenUrl() != null) { ((ObjectNode) propertiesValue6).put("authTokenUrl", parameters.getProperties().getAdmCredential().getProperties().getAuthTokenUrl()); } } } if (parameters.getProperties().getBaiduCredential() != null) { ObjectNode baiduCredentialValue = objectMapper.createObjectNode(); ((ObjectNode) propertiesValue).put("baiduCredential", baiduCredentialValue); if (parameters.getProperties().getBaiduCredential().getProperties() != null) { ObjectNode propertiesValue7 = objectMapper.createObjectNode(); ((ObjectNode) baiduCredentialValue).put("properties", propertiesValue7); if (parameters.getProperties().getBaiduCredential().getProperties().getBaiduApiKey() != null) { ((ObjectNode) propertiesValue7).put("baiduApiKey", parameters.getProperties().getBaiduCredential().getProperties().getBaiduApiKey()); } if (parameters.getProperties().getBaiduCredential().getProperties().getBaiduEndPoint() != null) { ((ObjectNode) propertiesValue7).put("baiduEndPoint", parameters.getProperties().getBaiduCredential().getProperties().getBaiduEndPoint()); } if (parameters.getProperties().getBaiduCredential().getProperties().getBaiduSecretKey() != null) { ((ObjectNode) propertiesValue7).put("baiduSecretKey", parameters.getProperties().getBaiduCredential().getProperties().getBaiduSecretKey()); } } } 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 NotificationHubCreateOrUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new NotificationHubCreateOrUpdateResponse(); 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) { NotificationHubResource valueInstance = new NotificationHubResource(); 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 tagsKey2 = property.getKey(); String tagsValue2 = property.getValue().getTextValue(); valueInstance.getTags().put(tagsKey2, tagsValue2); } } JsonNode propertiesValue8 = responseDoc.get("properties"); if (propertiesValue8 != null && propertiesValue8 instanceof NullNode == false) { NotificationHubProperties propertiesInstance = new NotificationHubProperties(); valueInstance.setProperties(propertiesInstance); JsonNode nameValue2 = propertiesValue8.get("name"); if (nameValue2 != null && nameValue2 instanceof NullNode == false) { String nameInstance2; nameInstance2 = nameValue2.getTextValue(); propertiesInstance.setName(nameInstance2); } JsonNode registrationTtlValue = propertiesValue8.get("registrationTtl"); if (registrationTtlValue != null && registrationTtlValue instanceof NullNode == false) { String registrationTtlInstance; registrationTtlInstance = registrationTtlValue.getTextValue(); propertiesInstance.setRegistrationTtl(registrationTtlInstance); } JsonNode authorizationRulesArray2 = propertiesValue8.get("authorizationRules"); if (authorizationRulesArray2 != null && authorizationRulesArray2 instanceof NullNode == false) { for (JsonNode authorizationRulesValue : ((ArrayNode) authorizationRulesArray2)) { SharedAccessAuthorizationRuleProperties sharedAccessAuthorizationRulePropertiesInstance = new SharedAccessAuthorizationRuleProperties(); propertiesInstance.getAuthorizationRules() .add(sharedAccessAuthorizationRulePropertiesInstance); JsonNode primaryKeyValue = authorizationRulesValue.get("primaryKey"); if (primaryKeyValue != null && primaryKeyValue instanceof NullNode == false) { String primaryKeyInstance; primaryKeyInstance = primaryKeyValue.getTextValue(); sharedAccessAuthorizationRulePropertiesInstance .setPrimaryKey(primaryKeyInstance); } JsonNode secondaryKeyValue = authorizationRulesValue.get("secondaryKey"); if (secondaryKeyValue != null && secondaryKeyValue instanceof NullNode == false) { String secondaryKeyInstance; secondaryKeyInstance = secondaryKeyValue.getTextValue(); sharedAccessAuthorizationRulePropertiesInstance .setSecondaryKey(secondaryKeyInstance); } JsonNode keyNameValue = authorizationRulesValue.get("keyName"); if (keyNameValue != null && keyNameValue instanceof NullNode == false) { String keyNameInstance; keyNameInstance = keyNameValue.getTextValue(); sharedAccessAuthorizationRulePropertiesInstance.setKeyName(keyNameInstance); } JsonNode claimTypeValue = authorizationRulesValue.get("claimType"); if (claimTypeValue != null && claimTypeValue instanceof NullNode == false) { String claimTypeInstance; claimTypeInstance = claimTypeValue.getTextValue(); sharedAccessAuthorizationRulePropertiesInstance.setClaimType(claimTypeInstance); } JsonNode claimValueValue = authorizationRulesValue.get("claimValue"); if (claimValueValue != null && claimValueValue instanceof NullNode == false) { String claimValueInstance; claimValueInstance = claimValueValue.getTextValue(); sharedAccessAuthorizationRulePropertiesInstance .setClaimValue(claimValueInstance); } JsonNode rightsArray2 = authorizationRulesValue.get("rights"); if (rightsArray2 != null && rightsArray2 instanceof NullNode == false) { for (JsonNode rightsValue : ((ArrayNode) rightsArray2)) { sharedAccessAuthorizationRulePropertiesInstance.getRights() .add(Enum.valueOf(AccessRights.class, rightsValue.getTextValue())); } } JsonNode createdTimeValue = authorizationRulesValue.get("createdTime"); if (createdTimeValue != null && createdTimeValue instanceof NullNode == false) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter .parseDateTime(createdTimeValue.getTextValue()); sharedAccessAuthorizationRulePropertiesInstance .setCreatedTime(createdTimeInstance); } JsonNode modifiedTimeValue = authorizationRulesValue.get("modifiedTime"); if (modifiedTimeValue != null && modifiedTimeValue instanceof NullNode == false) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeValue.getTextValue()); sharedAccessAuthorizationRulePropertiesInstance .setModifiedTime(modifiedTimeInstance); } JsonNode revisionValue = authorizationRulesValue.get("revision"); if (revisionValue != null && revisionValue instanceof NullNode == false) { int revisionInstance; revisionInstance = revisionValue.getIntValue(); sharedAccessAuthorizationRulePropertiesInstance.setRevision(revisionInstance); } } } JsonNode apnsCredentialValue2 = propertiesValue8.get("apnsCredential"); if (apnsCredentialValue2 != null && apnsCredentialValue2 instanceof NullNode == false) { ApnsCredential apnsCredentialInstance = new ApnsCredential(); propertiesInstance.setApnsCredential(apnsCredentialInstance); JsonNode propertiesValue9 = apnsCredentialValue2.get("properties"); if (propertiesValue9 != null && propertiesValue9 instanceof NullNode == false) { ApnsCredentialProperties propertiesInstance2 = new ApnsCredentialProperties(); apnsCredentialInstance.setProperties(propertiesInstance2); JsonNode apnsCertificateValue = propertiesValue9.get("apnsCertificate"); if (apnsCertificateValue != null && apnsCertificateValue instanceof NullNode == false) { String apnsCertificateInstance; apnsCertificateInstance = apnsCertificateValue.getTextValue(); propertiesInstance2.setApnsCertificate(apnsCertificateInstance); } JsonNode certificateKeyValue = propertiesValue9.get("certificateKey"); if (certificateKeyValue != null && certificateKeyValue instanceof NullNode == false) { String certificateKeyInstance; certificateKeyInstance = certificateKeyValue.getTextValue(); propertiesInstance2.setCertificateKey(certificateKeyInstance); } JsonNode endpointValue = propertiesValue9.get("endpoint"); if (endpointValue != null && endpointValue instanceof NullNode == false) { String endpointInstance; endpointInstance = endpointValue.getTextValue(); propertiesInstance2.setEndpoint(endpointInstance); } JsonNode thumbprintValue = propertiesValue9.get("thumbprint"); if (thumbprintValue != null && thumbprintValue instanceof NullNode == false) { String thumbprintInstance; thumbprintInstance = thumbprintValue.getTextValue(); propertiesInstance2.setThumbprint(thumbprintInstance); } } } JsonNode wnsCredentialValue2 = propertiesValue8.get("wnsCredential"); if (wnsCredentialValue2 != null && wnsCredentialValue2 instanceof NullNode == false) { WnsCredential wnsCredentialInstance = new WnsCredential(); propertiesInstance.setWnsCredential(wnsCredentialInstance); JsonNode propertiesValue10 = wnsCredentialValue2.get("properties"); if (propertiesValue10 != null && propertiesValue10 instanceof NullNode == false) { WnsCredentialProperties propertiesInstance3 = new WnsCredentialProperties(); wnsCredentialInstance.setProperties(propertiesInstance3); JsonNode packageSidValue = propertiesValue10.get("packageSid"); if (packageSidValue != null && packageSidValue instanceof NullNode == false) { String packageSidInstance; packageSidInstance = packageSidValue.getTextValue(); propertiesInstance3.setPackageSid(packageSidInstance); } JsonNode secretKeyValue = propertiesValue10.get("secretKey"); if (secretKeyValue != null && secretKeyValue instanceof NullNode == false) { String secretKeyInstance; secretKeyInstance = secretKeyValue.getTextValue(); propertiesInstance3.setSecretKey(secretKeyInstance); } JsonNode windowsLiveEndpointValue = propertiesValue10.get("windowsLiveEndpoint"); if (windowsLiveEndpointValue != null && windowsLiveEndpointValue instanceof NullNode == false) { String windowsLiveEndpointInstance; windowsLiveEndpointInstance = windowsLiveEndpointValue.getTextValue(); propertiesInstance3.setWindowsLiveEndpoint(windowsLiveEndpointInstance); } } } JsonNode gcmCredentialValue2 = propertiesValue8.get("gcmCredential"); if (gcmCredentialValue2 != null && gcmCredentialValue2 instanceof NullNode == false) { GcmCredential gcmCredentialInstance = new GcmCredential(); propertiesInstance.setGcmCredential(gcmCredentialInstance); JsonNode propertiesValue11 = gcmCredentialValue2.get("properties"); if (propertiesValue11 != null && propertiesValue11 instanceof NullNode == false) { GcmCredentialProperties propertiesInstance4 = new GcmCredentialProperties(); gcmCredentialInstance.setProperties(propertiesInstance4); JsonNode gcmEndpointValue = propertiesValue11.get("gcmEndpoint"); if (gcmEndpointValue != null && gcmEndpointValue instanceof NullNode == false) { String gcmEndpointInstance; gcmEndpointInstance = gcmEndpointValue.getTextValue(); propertiesInstance4.setGcmEndpoint(gcmEndpointInstance); } JsonNode googleApiKeyValue = propertiesValue11.get("googleApiKey"); if (googleApiKeyValue != null && googleApiKeyValue instanceof NullNode == false) { String googleApiKeyInstance; googleApiKeyInstance = googleApiKeyValue.getTextValue(); propertiesInstance4.setGoogleApiKey(googleApiKeyInstance); } } } JsonNode mpnsCredentialValue2 = propertiesValue8.get("mpnsCredential"); if (mpnsCredentialValue2 != null && mpnsCredentialValue2 instanceof NullNode == false) { MpnsCredential mpnsCredentialInstance = new MpnsCredential(); propertiesInstance.setMpnsCredential(mpnsCredentialInstance); JsonNode propertiesValue12 = mpnsCredentialValue2.get("properties"); if (propertiesValue12 != null && propertiesValue12 instanceof NullNode == false) { MpnsCredentialProperties propertiesInstance5 = new MpnsCredentialProperties(); mpnsCredentialInstance.setProperties(propertiesInstance5); JsonNode mpnsCertificateValue = propertiesValue12.get("mpnsCertificate"); if (mpnsCertificateValue != null && mpnsCertificateValue instanceof NullNode == false) { String mpnsCertificateInstance; mpnsCertificateInstance = mpnsCertificateValue.getTextValue(); propertiesInstance5.setMpnsCertificate(mpnsCertificateInstance); } JsonNode certificateKeyValue2 = propertiesValue12.get("certificateKey"); if (certificateKeyValue2 != null && certificateKeyValue2 instanceof NullNode == false) { String certificateKeyInstance2; certificateKeyInstance2 = certificateKeyValue2.getTextValue(); propertiesInstance5.setCertificateKey(certificateKeyInstance2); } JsonNode thumbprintValue2 = propertiesValue12.get("thumbprint"); if (thumbprintValue2 != null && thumbprintValue2 instanceof NullNode == false) { String thumbprintInstance2; thumbprintInstance2 = thumbprintValue2.getTextValue(); propertiesInstance5.setThumbprint(thumbprintInstance2); } } } JsonNode admCredentialValue2 = propertiesValue8.get("admCredential"); if (admCredentialValue2 != null && admCredentialValue2 instanceof NullNode == false) { AdmCredential admCredentialInstance = new AdmCredential(); propertiesInstance.setAdmCredential(admCredentialInstance); JsonNode propertiesValue13 = admCredentialValue2.get("properties"); if (propertiesValue13 != null && propertiesValue13 instanceof NullNode == false) { AdmCredentialProperties propertiesInstance6 = new AdmCredentialProperties(); admCredentialInstance.setProperties(propertiesInstance6); JsonNode clientIdValue = propertiesValue13.get("clientId"); if (clientIdValue != null && clientIdValue instanceof NullNode == false) { String clientIdInstance; clientIdInstance = clientIdValue.getTextValue(); propertiesInstance6.setClientId(clientIdInstance); } JsonNode clientSecretValue = propertiesValue13.get("clientSecret"); if (clientSecretValue != null && clientSecretValue instanceof NullNode == false) { String clientSecretInstance; clientSecretInstance = clientSecretValue.getTextValue(); propertiesInstance6.setClientSecret(clientSecretInstance); } JsonNode authTokenUrlValue = propertiesValue13.get("authTokenUrl"); if (authTokenUrlValue != null && authTokenUrlValue instanceof NullNode == false) { String authTokenUrlInstance; authTokenUrlInstance = authTokenUrlValue.getTextValue(); propertiesInstance6.setAuthTokenUrl(authTokenUrlInstance); } } } JsonNode baiduCredentialValue2 = propertiesValue8.get("baiduCredential"); if (baiduCredentialValue2 != null && baiduCredentialValue2 instanceof NullNode == false) { BaiduCredential baiduCredentialInstance = new BaiduCredential(); propertiesInstance.setBaiduCredential(baiduCredentialInstance); JsonNode propertiesValue14 = baiduCredentialValue2.get("properties"); if (propertiesValue14 != null && propertiesValue14 instanceof NullNode == false) { BaiduCredentialProperties propertiesInstance7 = new BaiduCredentialProperties(); baiduCredentialInstance.setProperties(propertiesInstance7); JsonNode baiduApiKeyValue = propertiesValue14.get("baiduApiKey"); if (baiduApiKeyValue != null && baiduApiKeyValue instanceof NullNode == false) { String baiduApiKeyInstance; baiduApiKeyInstance = baiduApiKeyValue.getTextValue(); propertiesInstance7.setBaiduApiKey(baiduApiKeyInstance); } JsonNode baiduEndPointValue = propertiesValue14.get("baiduEndPoint"); if (baiduEndPointValue != null && baiduEndPointValue instanceof NullNode == false) { String baiduEndPointInstance; baiduEndPointInstance = baiduEndPointValue.getTextValue(); propertiesInstance7.setBaiduEndPoint(baiduEndPointInstance); } JsonNode baiduSecretKeyValue = propertiesValue14.get("baiduSecretKey"); if (baiduSecretKeyValue != null && baiduSecretKeyValue instanceof NullNode == false) { String baiduSecretKeyInstance; baiduSecretKeyInstance = baiduSecretKeyValue.getTextValue(); propertiesInstance7.setBaiduSecretKey(baiduSecretKeyInstance); } } } } } } 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
/** * Create a named template deployment using a template. * * @param resourceGroupName Required. The name of the resource group. The * name is case insensitive./*from w w w .ja v a 2s. c o m*/ * @param deploymentName Required. The name of the deployment. * @param parameters Required. Additional parameters supplied to the * operation. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return Template deployment operation create result. */ @Override public DeploymentOperationsCreateResult createOrUpdate(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, "createOrUpdateAsync", 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 + "/deployments/"; url = url + URLEncoder.encode(deploymentName, "UTF-8"); 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 HttpPut httpRequest = new HttpPut(url); // Set Headers httpRequest.setHeader("Content-Type", "application/json; charset=utf-8"); // Serialize Request String requestContent = null; JsonNode requestDoc = null; ObjectMapper objectMapper = new ObjectMapper(); ObjectNode 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_CREATED) { ServiceException ex = ServiceException.createFromJson(httpRequest, requestContent, httpResponse, httpResponse.getEntity()); if (shouldTrace) { CloudTracing.error(invocationId, ex); } throw ex; } // Create Result DeploymentOperationsCreateResult result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK || statusCode == HttpStatus.SC_CREATED) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new DeploymentOperationsCreateResult(); 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) { DeploymentExtended deploymentInstance = new DeploymentExtended(); result.setDeployment(deploymentInstance); JsonNode idValue = responseDoc.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); deploymentInstance.setId(idInstance); } JsonNode nameValue = responseDoc.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); deploymentInstance.setName(nameInstance); } JsonNode propertiesValue2 = responseDoc.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); deploymentInstance.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 idValue2 = providersValue.get("id"); if (idValue2 != null && idValue2 instanceof NullNode == false) { String idInstance2; idInstance2 = idValue2.getTextValue(); providerInstance.setId(idInstance2); } 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 idValue3 = dependsOnValue.get("id"); if (idValue3 != null && idValue3 instanceof NullNode == false) { String idInstance3; idInstance3 = idValue3.getTextValue(); basicDependencyInstance.setId(idInstance3); } 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 idValue4 = dependenciesValue.get("id"); if (idValue4 != null && idValue4 instanceof NullNode == false) { String idInstance4; idInstance4 = idValue4.getTextValue(); dependencyInstance.setId(idInstance4); } 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 (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }
From source file:org.apache.openjpa.meta.FieldMetaData.java
/** * Return the string value converted to the given type code. The string * must be non-null and trimmed./*from ww w . ja v a 2 s . c o m*/ */ private Object transform(String val, int typeCode) { if ("null".equals(val)) return null; switch (typeCode) { case JavaTypes.BOOLEAN: case JavaTypes.BOOLEAN_OBJ: return Boolean.valueOf(val); case JavaTypes.BYTE: case JavaTypes.BYTE_OBJ: return Byte.valueOf(val); case JavaTypes.INT: case JavaTypes.INT_OBJ: return Integer.valueOf(val); case JavaTypes.LONG: case JavaTypes.LONG_OBJ: return Long.valueOf(val); case JavaTypes.SHORT: case JavaTypes.SHORT_OBJ: return Short.valueOf(val); case JavaTypes.DOUBLE: case JavaTypes.DOUBLE_OBJ: return Double.valueOf(val); case JavaTypes.FLOAT: case JavaTypes.FLOAT_OBJ: return Float.valueOf(val); case JavaTypes.CHAR: case JavaTypes.CHAR_OBJ: return Character.valueOf(val.charAt(0)); case JavaTypes.STRING: return val; case JavaTypes.ENUM: return Enum.valueOf((Class<? extends Enum>) getDeclaredType(), val); } throw new MetaDataException(_loc.get("bad-external-type", this)); }
From source file:com.buaa.cfs.conf.Configuration.java
/** * Return value matching this enumerated type. Note that the returned value is trimmed by this method. * * @param name Property name/*from ww w . ja v a 2s.c o m*/ * @param defaultValue Value returned if no mapping exists * * @throws IllegalArgumentException If mapping is illegal for the type provided */ public <T extends Enum<T>> T getEnum(String name, T defaultValue) { final String val = getTrimmed(name); return null == val ? defaultValue : Enum.valueOf(defaultValue.getDeclaringClass(), val); }
From source file:com.microsoft.azure.management.notificationhubs.NamespaceOperationsImpl.java
/** * The create namespace authorization rule operation creates an * authorization rule for a namespace/*from ww w . ja v a2s .c o m*/ * * @param resourceGroupName Required. The name of the resource group. * @param namespaceName Required. The namespace name. * @param authorizationRuleName Required. The namespace * authorizationRuleName name. * @param parameters Required. The shared access authorization rule. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @return Response of the CreateOrUpdate operation on the AuthorizationRules */ @Override public SharedAccessAuthorizationRuleCreateOrUpdateResponse createOrUpdateAuthorizationRule( String resourceGroupName, String namespaceName, String authorizationRuleName, SharedAccessAuthorizationRuleCreateOrUpdateParameters parameters) throws IOException, ServiceException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } if (namespaceName == null) { throw new NullPointerException("namespaceName"); } if (authorizationRuleName == null) { throw new NullPointerException("authorizationRuleName"); } if (parameters == null) { throw new NullPointerException("parameters"); } if (parameters.getProperties() == null) { throw new NullPointerException("parameters.Properties"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("resourceGroupName", resourceGroupName); tracingParameters.put("namespaceName", namespaceName); tracingParameters.put("authorizationRuleName", authorizationRuleName); tracingParameters.put("parameters", parameters); CloudTracing.enter(invocationId, this, "createOrUpdateAuthorizationRuleAsync", 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 + "/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 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 sharedAccessAuthorizationRuleCreateOrUpdateParametersValue = objectMapper.createObjectNode(); requestDoc = sharedAccessAuthorizationRuleCreateOrUpdateParametersValue; if (parameters.getLocation() != null) { ((ObjectNode) sharedAccessAuthorizationRuleCreateOrUpdateParametersValue).put("location", parameters.getLocation()); } if (parameters.getName() != null) { ((ObjectNode) sharedAccessAuthorizationRuleCreateOrUpdateParametersValue).put("name", parameters.getName()); } ObjectNode propertiesValue = objectMapper.createObjectNode(); ((ObjectNode) sharedAccessAuthorizationRuleCreateOrUpdateParametersValue).put("properties", propertiesValue); if (parameters.getProperties().getPrimaryKey() != null) { ((ObjectNode) propertiesValue).put("primaryKey", parameters.getProperties().getPrimaryKey()); } if (parameters.getProperties().getSecondaryKey() != null) { ((ObjectNode) propertiesValue).put("secondaryKey", parameters.getProperties().getSecondaryKey()); } if (parameters.getProperties().getKeyName() != null) { ((ObjectNode) propertiesValue).put("keyName", parameters.getProperties().getKeyName()); } if (parameters.getProperties().getClaimType() != null) { ((ObjectNode) propertiesValue).put("claimType", parameters.getProperties().getClaimType()); } if (parameters.getProperties().getClaimValue() != null) { ((ObjectNode) propertiesValue).put("claimValue", parameters.getProperties().getClaimValue()); } if (parameters.getProperties().getRights() != null) { ArrayNode rightsArray = objectMapper.createArrayNode(); for (AccessRights rightsItem : parameters.getProperties().getRights()) { rightsArray.add(rightsItem.toString()); } ((ObjectNode) propertiesValue).put("rights", rightsArray); } SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) propertiesValue).put("createdTime", simpleDateFormat.format(parameters.getProperties().getCreatedTime().getTime())); SimpleDateFormat simpleDateFormat2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'"); simpleDateFormat2.setTimeZone(TimeZone.getTimeZone("UTC")); ((ObjectNode) propertiesValue).put("modifiedTime", simpleDateFormat2.format(parameters.getProperties().getModifiedTime().getTime())); ((ObjectNode) propertiesValue).put("revision", parameters.getProperties().getRevision()); 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 SharedAccessAuthorizationRuleCreateOrUpdateResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new SharedAccessAuthorizationRuleCreateOrUpdateResponse(); 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 propertiesValue2 = responseDoc.get("properties"); if (propertiesValue2 != null && propertiesValue2 instanceof NullNode == false) { SharedAccessAuthorizationRuleProperties propertiesInstance = new SharedAccessAuthorizationRuleProperties(); valueInstance.setProperties(propertiesInstance); JsonNode primaryKeyValue = propertiesValue2.get("primaryKey"); if (primaryKeyValue != null && primaryKeyValue instanceof NullNode == false) { String primaryKeyInstance; primaryKeyInstance = primaryKeyValue.getTextValue(); propertiesInstance.setPrimaryKey(primaryKeyInstance); } JsonNode secondaryKeyValue = propertiesValue2.get("secondaryKey"); if (secondaryKeyValue != null && secondaryKeyValue instanceof NullNode == false) { String secondaryKeyInstance; secondaryKeyInstance = secondaryKeyValue.getTextValue(); propertiesInstance.setSecondaryKey(secondaryKeyInstance); } JsonNode keyNameValue = propertiesValue2.get("keyName"); if (keyNameValue != null && keyNameValue instanceof NullNode == false) { String keyNameInstance; keyNameInstance = keyNameValue.getTextValue(); propertiesInstance.setKeyName(keyNameInstance); } JsonNode claimTypeValue = propertiesValue2.get("claimType"); if (claimTypeValue != null && claimTypeValue instanceof NullNode == false) { String claimTypeInstance; claimTypeInstance = claimTypeValue.getTextValue(); propertiesInstance.setClaimType(claimTypeInstance); } JsonNode claimValueValue = propertiesValue2.get("claimValue"); if (claimValueValue != null && claimValueValue instanceof NullNode == false) { String claimValueInstance; claimValueInstance = claimValueValue.getTextValue(); propertiesInstance.setClaimValue(claimValueInstance); } JsonNode rightsArray2 = propertiesValue2.get("rights"); if (rightsArray2 != null && rightsArray2 instanceof NullNode == false) { for (JsonNode rightsValue : ((ArrayNode) rightsArray2)) { propertiesInstance.getRights() .add(Enum.valueOf(AccessRights.class, rightsValue.getTextValue())); } } JsonNode createdTimeValue = propertiesValue2.get("createdTime"); if (createdTimeValue != null && createdTimeValue instanceof NullNode == false) { Calendar createdTimeInstance; createdTimeInstance = DatatypeConverter.parseDateTime(createdTimeValue.getTextValue()); propertiesInstance.setCreatedTime(createdTimeInstance); } JsonNode modifiedTimeValue = propertiesValue2.get("modifiedTime"); if (modifiedTimeValue != null && modifiedTimeValue instanceof NullNode == false) { Calendar modifiedTimeInstance; modifiedTimeInstance = DatatypeConverter .parseDateTime(modifiedTimeValue.getTextValue()); propertiesInstance.setModifiedTime(modifiedTimeInstance); } JsonNode revisionValue = propertiesValue2.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.websites.WebHostingPlanOperationsImpl.java
/** * Gets all Web Hosting Plans in a current subscription and Resource Group. * (see http://msdn.microsoft.com/en-us/library/windowsazure/dn194277.aspx * for more information)/* www. j a va 2 s . c o m*/ * * @param resourceGroupName Required. The name of the resource group. * @throws IOException Signals that an I/O exception of some sort has * occurred. This class is the general class of exceptions produced by * failed or interrupted I/O operations. * @throws ServiceException Thrown if an unexpected response is found. * @throws URISyntaxException Thrown if there was an error parsing a URI in * the response. * @return The List Web Hosting Plans operation response. */ @Override public WebHostingPlanListResponse list(String resourceGroupName) throws IOException, ServiceException, URISyntaxException { // Validate if (resourceGroupName == null) { throw new NullPointerException("resourceGroupName"); } // Tracing boolean shouldTrace = CloudTracing.getIsEnabled(); String invocationId = null; if (shouldTrace) { invocationId = Long.toString(CloudTracing.getNextInvocationId()); HashMap<String, Object> tracingParameters = new HashMap<String, Object>(); tracingParameters.put("resourceGroupName", resourceGroupName); CloudTracing.enter(invocationId, this, "listAsync", tracingParameters); } // Construct URL String url = ""; url = url + "/subscriptions/"; if (this.getClient().getCredentials().getSubscriptionId() != null) { url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8"); } url = url + "/resourceGroups/"; url = url + URLEncoder.encode(resourceGroupName, "UTF-8"); url = url + "/providers/"; url = url + "Microsoft.Web"; url = url + "/serverFarms"; ArrayList<String> queryParameters = new ArrayList<String>(); queryParameters.add("api-version=" + "2014-06-01"); if (queryParameters.size() > 0) { url = url + "?" + CollectionStringBuilder.join(queryParameters, "&"); } String baseUrl = this.getClient().getBaseUri().toString(); // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl.charAt(baseUrl.length() - 1) == '/') { baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0); } if (url.charAt(0) == '/') { url = url.substring(1); } url = baseUrl + "/" + url; url = url.replace(" ", "%20"); // Create HTTP transport objects HttpGet httpRequest = new HttpGet(url); // Set Headers // 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 WebHostingPlanListResponse result = null; // Deserialize Response if (statusCode == HttpStatus.SC_OK) { InputStream responseContent = httpResponse.getEntity().getContent(); result = new WebHostingPlanListResponse(); 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)) { WebHostingPlan webHostingPlanInstance = new WebHostingPlan(); result.getWebHostingPlans().add(webHostingPlanInstance); JsonNode propertiesValue = valueValue.get("properties"); if (propertiesValue != null && propertiesValue instanceof NullNode == false) { WebHostingPlanProperties propertiesInstance = new WebHostingPlanProperties(); webHostingPlanInstance.setProperties(propertiesInstance); JsonNode skuValue = propertiesValue.get("sku"); if (skuValue != null && skuValue instanceof NullNode == false) { SkuOptions skuInstance; skuInstance = Enum.valueOf(SkuOptions.class, skuValue.getTextValue()); propertiesInstance.setSku(skuInstance); } JsonNode numberOfWorkersValue = propertiesValue.get("numberOfWorkers"); if (numberOfWorkersValue != null && numberOfWorkersValue instanceof NullNode == false) { int numberOfWorkersInstance; numberOfWorkersInstance = numberOfWorkersValue.getIntValue(); propertiesInstance.setNumberOfWorkers(numberOfWorkersInstance); } JsonNode workerSizeValue = propertiesValue.get("workerSize"); if (workerSizeValue != null && workerSizeValue instanceof NullNode == false) { WorkerSizeOptions workerSizeInstance; workerSizeInstance = Enum.valueOf(WorkerSizeOptions.class, workerSizeValue.getTextValue()); propertiesInstance.setWorkerSize(workerSizeInstance); } JsonNode adminSiteNameValue = propertiesValue.get("adminSiteName"); if (adminSiteNameValue != null && adminSiteNameValue instanceof NullNode == false) { String adminSiteNameInstance; adminSiteNameInstance = adminSiteNameValue.getTextValue(); propertiesInstance.setAdminSiteName(adminSiteNameInstance); } } JsonNode idValue = valueValue.get("id"); if (idValue != null && idValue instanceof NullNode == false) { String idInstance; idInstance = idValue.getTextValue(); webHostingPlanInstance.setId(idInstance); } JsonNode nameValue = valueValue.get("name"); if (nameValue != null && nameValue instanceof NullNode == false) { String nameInstance; nameInstance = nameValue.getTextValue(); webHostingPlanInstance.setName(nameInstance); } JsonNode locationValue = valueValue.get("location"); if (locationValue != null && locationValue instanceof NullNode == false) { String locationInstance; locationInstance = locationValue.getTextValue(); webHostingPlanInstance.setLocation(locationInstance); } JsonNode tagsSequenceElement = ((JsonNode) valueValue.get("tags")); if (tagsSequenceElement != null && tagsSequenceElement instanceof NullNode == false) { Iterator<Map.Entry<String, JsonNode>> itr = tagsSequenceElement.getFields(); while (itr.hasNext()) { Map.Entry<String, JsonNode> property = itr.next(); String tagsKey = property.getKey(); String tagsValue = property.getValue().getTextValue(); webHostingPlanInstance.getTags().put(tagsKey, tagsValue); } } JsonNode typeValue = valueValue.get("type"); if (typeValue != null && typeValue instanceof NullNode == false) { String typeInstance; typeInstance = typeValue.getTextValue(); webHostingPlanInstance.setType(typeInstance); } } } } } result.setStatusCode(statusCode); if (httpResponse.getHeaders("x-ms-request-id").length > 0) { result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue()); } if (shouldTrace) { CloudTracing.exit(invocationId, result); } return result; } finally { if (httpResponse != null && httpResponse.getEntity() != null) { httpResponse.getEntity().getContent().close(); } } }