}
throw ex;
}
// Create Result
GatewayGetResponse result = null;
// Deserialize Response
InputStream responseContent = httpResponse.getEntity().getContent();
result = new GatewayGetResponse();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));
Element gatewayElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "Gateway");
if (gatewayElement != null) {
Element stateElement = XmlUtility.getElementByTagNameNS(gatewayElement, "http://schemas.microsoft.com/windowsazure", "State");
if (stateElement != null) {
String stateInstance;
stateInstance = stateElement.getTextContent();
result.setState(stateInstance);
}
Element vIPAddressElement = XmlUtility.getElementByTagNameNS(gatewayElement, "http://schemas.microsoft.com/windowsazure", "VIPAddress");
if (vIPAddressElement != null) {
InetAddress vIPAddressInstance;
vIPAddressInstance = InetAddress.getByName(vIPAddressElement.getTextContent());
result.setVipAddress(vIPAddressInstance);
}
Element lastEventElement = XmlUtility.getElementByTagNameNS(gatewayElement, "http://schemas.microsoft.com/windowsazure", "LastEvent");
if (lastEventElement != null) {
GatewayEvent lastEventInstance = new GatewayEvent();
result.setLastEvent(lastEventInstance);
Element timestampElement = XmlUtility.getElementByTagNameNS(lastEventElement, "http://schemas.microsoft.com/windowsazure", "Timestamp");
if (timestampElement != null) {
Calendar timestampInstance;
timestampInstance = DatatypeConverter.parseDateTime(timestampElement.getTextContent());
lastEventInstance.setTimestamp(timestampInstance);
}
Element idElement = XmlUtility.getElementByTagNameNS(lastEventElement, "http://schemas.microsoft.com/windowsazure", "Id");
if (idElement != null) {
String idInstance;
idInstance = idElement.getTextContent();
lastEventInstance.setId(idInstance);
}
Element messageElement = XmlUtility.getElementByTagNameNS(lastEventElement, "http://schemas.microsoft.com/windowsazure", "Message");
if (messageElement != null) {
String messageInstance;
messageInstance = messageElement.getTextContent();
lastEventInstance.setMessage(messageInstance);
}
Element dataElement = XmlUtility.getElementByTagNameNS(lastEventElement, "http://schemas.microsoft.com/windowsazure", "Data");
if (dataElement != null) {
String dataInstance;
dataInstance = dataElement.getTextContent();
lastEventInstance.setData(dataInstance);
}
}
Element gatewayTypeElement = XmlUtility.getElementByTagNameNS(gatewayElement, "http://schemas.microsoft.com/windowsazure", "GatewayType");
if (gatewayTypeElement != null) {
GatewayType gatewayTypeInstance;
gatewayTypeInstance = GatewayType.valueOf(gatewayTypeElement.getTextContent());
result.setGatewayType(gatewayTypeInstance);
}
}
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);
}