Package com.cloudbees.cloud_resource.types

Examples of com.cloudbees.cloud_resource.types.CloudResourceError


* @author Vivek Pandey
*/
public class AuthException extends WebApplicationException {

    public AuthException(int httpStatus, String message) {
        super(Response.status(httpStatus).type(MediaType.APPLICATION_JSON_TYPE).entity(new CloudResourceError(message)).build());
    }
View Full Code Here


* @author Vivek Pandey
*/
public class CloudResourceException extends WebApplicationException {

    public CloudResourceException(int httpStatus, String message) {
        super(Response.status(httpStatus).type(MediaType.APPLICATION_JSON_TYPE).header("Cloud-Resource-Type", "https://types.cloudbees.com/error").entity(new CloudResourceError(message)).build());
    }
View Full Code Here

    public Response toResponse(Exception e) {
        if (e instanceof CloudResourceException) {
            return ((CloudResourceException) e).getResponse();
        } else if (e instanceof JsonParseException) {
            return Response.status(400)
                    .entity(new CloudResourceError("Error parsing JSON: " + e.getMessage())).build();
        } else if (e instanceof WebApplicationException) {
            if(((WebApplicationException) e).getResponse().getEntity() != null && ((WebApplicationException) e).getResponse().getEntity() instanceof CloudResourceError){
                return ((WebApplicationException) e).getResponse();
            }else{
                return Response.status(((WebApplicationException) e).getResponse().getStatus())
                        .entity(((WebApplicationException) e).getResponse().getEntity()).build();
            }
        }
        return Response.status(500).type(MediaType.APPLICATION_JSON_TYPE).header("Cloud-Resource-Type","https://types.cloudbees.com/error").entity(new CloudResourceError("Unexpected error" + e.getMessage())).build();
    }
View Full Code Here

        for(String cap:capabilities){
            try {
                scopes.add(new Capability(cap).to(request.getRequestUri().toURL()));
            } catch (MalformedURLException e) {
                throw new CloudResourceException(500, new CloudResourceError("Invalid host name: "+ request.getRequestUri().toString()));
            }
        }
        logger.debug("Expecting scopes: "+Arrays.toString(scopes.toArray()));

        // Create OAuth client
View Full Code Here

TOP

Related Classes of com.cloudbees.cloud_resource.types.CloudResourceError

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.