Package org.openstack.client

Examples of org.openstack.client.OpenstackException


      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);
        }
      }
    }
View Full Code Here


        JaxbHelper jaxb = JaxbHelper.get(body.getClass());
        String xml;
        try {
          xml = jaxb.marshal(body, false);
        } catch (JAXBException e) {
          throw new OpenstackException("Error serializing request body", e);
        }
        request.body = xml;
      }
      request.method = this.method;
      if (this.contentType != null) {
View Full Code Here

TOP

Related Classes of org.openstack.client.OpenstackException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.