}
throw ex;
}
// Create Result
JobCollectionCheckNameAvailabilityResponse result = null;
// Deserialize Response
InputStream responseContent = httpResponse.getEntity().getContent();
result = new JobCollectionCheckNameAvailabilityResponse();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));
Element resourceNameAvailabilityResponseElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "ResourceNameAvailabilityResponse");
if (resourceNameAvailabilityResponseElement != null) {
Element isAvailableElement = XmlUtility.getElementByTagNameNS(resourceNameAvailabilityResponseElement, "http://schemas.microsoft.com/windowsazure", "IsAvailable");
if (isAvailableElement != null) {
boolean isAvailableInstance;
isAvailableInstance = DatatypeConverter.parseBoolean(isAvailableElement.getTextContent().toLowerCase());
result.setIsAvailable(isAvailableInstance);
}
}
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);
}