CurlRequest request = toCurlRequest();
CurlResult result;
try {
result = request.executeRequest(target);
} catch (OpsException e) {
throw new OpenstackException("Error issuing request", e);
}
int httpStatus = result.getHttpResult();
switch (httpStatus) {
case 200:
break;
case 201:
// Created
break;
case 202:
// Accepted
break;
case 401:
throw new OpenstackAuthenticationException("Not authorized");
case 403:
throw new OpenstackForbiddenException("Forbidden");
case 404:
throw new OpenstackNotFoundException("Item not found");
default:
throw new OpenstackException("Error processing request. Status code=" + httpStatus);
}
if (c == Void.class) {
return null;
} else {
String xml = result.getBody();
JaxbHelper jaxb = JaxbHelper.get(c);
try {
return (T) jaxb.unmarshal(xml);
} catch (JAXBException e) {
throw new OpenstackException("Error deserializing response", e);
}
}
}