}
throw ex;
}
// Create Result
DatabaseOperationGetResponse result = null;
// Deserialize Response
InputStream responseContent = httpResponse.getEntity().getContent();
result = new DatabaseOperationGetResponse();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));
Element serviceResourceElement = XmlUtility.getElementByTagNameNS(responseDoc, "http://schemas.microsoft.com/windowsazure", "ServiceResource");
if (serviceResourceElement != null) {
DatabaseOperation serviceResourceInstance = new DatabaseOperation();
result.setDatabaseOperation(serviceResourceInstance);
Element idElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "Id");
if (idElement != null) {
String idInstance;
idInstance = idElement.getTextContent();
serviceResourceInstance.setId(idInstance);
}
Element stateIdElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "StateId");
if (stateIdElement != null) {
int stateIdInstance;
stateIdInstance = DatatypeConverter.parseInt(stateIdElement.getTextContent());
serviceResourceInstance.setStateId(stateIdInstance);
}
Element sessionActivityIdElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "SessionActivityId");
if (sessionActivityIdElement != null) {
String sessionActivityIdInstance;
sessionActivityIdInstance = sessionActivityIdElement.getTextContent();
serviceResourceInstance.setSessionActivityId(sessionActivityIdInstance);
}
Element databaseNameElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "DatabaseName");
if (databaseNameElement != null) {
String databaseNameInstance;
databaseNameInstance = databaseNameElement.getTextContent();
serviceResourceInstance.setDatabaseName(databaseNameInstance);
}
Element percentCompleteElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "PercentComplete");
if (percentCompleteElement != null) {
int percentCompleteInstance;
percentCompleteInstance = DatatypeConverter.parseInt(percentCompleteElement.getTextContent());
serviceResourceInstance.setPercentComplete(percentCompleteInstance);
}
Element errorCodeElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "ErrorCode");
if (errorCodeElement != null) {
int errorCodeInstance;
errorCodeInstance = DatatypeConverter.parseInt(errorCodeElement.getTextContent());
serviceResourceInstance.setErrorCode(errorCodeInstance);
}
Element errorElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "Error");
if (errorElement != null) {
String errorInstance;
errorInstance = errorElement.getTextContent();
serviceResourceInstance.setError(errorInstance);
}
Element errorSeverityElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "ErrorSeverity");
if (errorSeverityElement != null) {
int errorSeverityInstance;
errorSeverityInstance = DatatypeConverter.parseInt(errorSeverityElement.getTextContent());
serviceResourceInstance.setErrorSeverity(errorSeverityInstance);
}
Element errorStateElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "ErrorState");
if (errorStateElement != null) {
int errorStateInstance;
errorStateInstance = DatatypeConverter.parseInt(errorStateElement.getTextContent());
serviceResourceInstance.setErrorState(errorStateInstance);
}
Element startTimeElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "StartTime");
if (startTimeElement != null) {
Calendar startTimeInstance;
startTimeInstance = DatatypeConverter.parseDateTime(startTimeElement.getTextContent());
serviceResourceInstance.setStartTime(startTimeInstance);
}
Element lastModifyTimeElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "LastModifyTime");
if (lastModifyTimeElement != null) {
Calendar lastModifyTimeInstance;
lastModifyTimeInstance = DatatypeConverter.parseDateTime(lastModifyTimeElement.getTextContent());
serviceResourceInstance.setLastModifyTime(lastModifyTimeInstance);
}
Element nameElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "Name");
if (nameElement != null) {
String nameInstance;
nameInstance = nameElement.getTextContent();
serviceResourceInstance.setName(nameInstance);
}
Element typeElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "Type");
if (typeElement != null) {
String typeInstance;
typeInstance = typeElement.getTextContent();
serviceResourceInstance.setType(typeInstance);
}
Element stateElement = XmlUtility.getElementByTagNameNS(serviceResourceElement, "http://schemas.microsoft.com/windowsazure", "State");
if (stateElement != null) {
String stateInstance;
stateInstance = stateElement.getTextContent();
serviceResourceInstance.setState(stateInstance);
}
}
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);
}