}
throw ex;
}
// Create Result
VirtualMachineDataDiskGetResponse result = null;
// Deserialize Response
InputStream responseContent = httpResponse.getEntity().getContent();
result = new VirtualMachineDataDiskGetResponse();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));
Element dataVirtualHardDiskElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "DataVirtualHardDisk");
if (dataVirtualHardDiskElement != null) {
Element hostCachingElement = XmlUtility.getElementByTagNameNS(dataVirtualHardDiskElement, "http://schemas.microsoft.com/windowsazure", "HostCaching");
if (hostCachingElement != null) {
String hostCachingInstance;
hostCachingInstance = hostCachingElement.getTextContent();
result.setHostCaching(hostCachingInstance);
}
Element diskLabelElement = XmlUtility.getElementByTagNameNS(dataVirtualHardDiskElement, "http://schemas.microsoft.com/windowsazure", "DiskLabel");
if (diskLabelElement != null) {
String diskLabelInstance;
diskLabelInstance = diskLabelElement.getTextContent();
result.setLabel(diskLabelInstance);
}
Element diskNameElement = XmlUtility.getElementByTagNameNS(dataVirtualHardDiskElement, "http://schemas.microsoft.com/windowsazure", "DiskName");
if (diskNameElement != null) {
String diskNameInstance;
diskNameInstance = diskNameElement.getTextContent();
result.setName(diskNameInstance);
}
Element lunElement = XmlUtility.getElementByTagNameNS(dataVirtualHardDiskElement, "http://schemas.microsoft.com/windowsazure", "Lun");
if (lunElement != null && (lunElement.getTextContent() == null || lunElement.getTextContent().isEmpty() == true) == false) {
int lunInstance;
lunInstance = DatatypeConverter.parseInt(lunElement.getTextContent());
result.setLogicalUnitNumber(lunInstance);
}
Element logicalDiskSizeInGBElement = XmlUtility.getElementByTagNameNS(dataVirtualHardDiskElement, "http://schemas.microsoft.com/windowsazure", "LogicalDiskSizeInGB");
if (logicalDiskSizeInGBElement != null) {
int logicalDiskSizeInGBInstance;
logicalDiskSizeInGBInstance = DatatypeConverter.parseInt(logicalDiskSizeInGBElement.getTextContent());
result.setLogicalDiskSizeInGB(logicalDiskSizeInGBInstance);
}
Element mediaLinkElement = XmlUtility.getElementByTagNameNS(dataVirtualHardDiskElement, "http://schemas.microsoft.com/windowsazure", "MediaLink");
if (mediaLinkElement != null) {
URI mediaLinkInstance;
mediaLinkInstance = new URI(mediaLinkElement.getTextContent());
result.setMediaLinkUri(mediaLinkInstance);
}
}
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);
}