diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/HTTPException.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/APIException.java similarity index 78% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/HTTPException.java rename to guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/APIException.java index 1f00556f9..b26f9bd90 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/HTTPException.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/APIException.java @@ -28,29 +28,29 @@ import javax.ws.rs.core.Response; import org.glyptodon.guacamole.form.Parameter; /** - * An exception that will result in the given HTTP Status and error being + * An exception that will result in the given error error information being * returned from the API layer. All error messages have the same format which * is defined by APIError. * * @author James Muehlner * @author Michael Jumper */ -public class HTTPException extends WebApplicationException { +public class APIException extends WebApplicationException { /** - * Construct a new HTTPException with the given error. All information + * Construct a new APIException with the given error. All information * associated with this new exception will be extracted from the given * APIError. * * @param error * The error that occurred. */ - public HTTPException(APIError error) { + public APIException(APIError error) { super(Response.status(error.getType().getStatus()).entity(error).build()); } /** - * Creates a new HTTPException with the given type and message. The + * Creates a new APIException with the given type and message. The * corresponding APIError will be created from the provided information. * * @param type @@ -59,14 +59,14 @@ public class HTTPException extends WebApplicationException { * @param message * A human-readable message describing the error. */ - public HTTPException(APIError.Type type, String message) { + public APIException(APIError.Type type, String message) { this(new APIError(type, message)); } /** - * Creates a new HTTPException with the given type, message, and - * parameter information. The corresponding APIError will be created from - * the provided information. + * Creates a new APIException with the given type, message, and parameter + * information. The corresponding APIError will be created from the + * provided information. * * @param type * The type of error that occurred. @@ -78,7 +78,7 @@ public class HTTPException extends WebApplicationException { * All parameters expected in the original request, or now required as * a result of the original request. */ - public HTTPException(APIError.Type type, String message, Collection expected) { + public APIException(APIError.Type type, String message, Collection expected) { this(new APIError(type, message, expected)); } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/AuthProviderRESTExceptionWrapper.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/AuthProviderRESTExceptionWrapper.java index 741ed15df..0878d9632 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/AuthProviderRESTExceptionWrapper.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/AuthProviderRESTExceptionWrapper.java @@ -62,7 +62,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor { if (message == null) message = "Permission denied."; - throw new HTTPException( + throw new APIException( APIError.Type.INSUFFICIENT_CREDENTIALS, message, e.getCredentialsInfo().getParameters() @@ -77,7 +77,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor { if (message == null) message = "Permission denied."; - throw new HTTPException( + throw new APIException( APIError.Type.INVALID_CREDENTIALS, message, e.getCredentialsInfo().getParameters() @@ -92,7 +92,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor { if (message == null) message = "Permission denied."; - throw new HTTPException( + throw new APIException( APIError.Type.PERMISSION_DENIED, message ); @@ -107,7 +107,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor { if (message == null) message = "Not found."; - throw new HTTPException( + throw new APIException( APIError.Type.NOT_FOUND, message ); @@ -122,7 +122,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor { if (message == null) message = "Invalid request."; - throw new HTTPException( + throw new APIException( APIError.Type.BAD_REQUEST, message ); @@ -138,7 +138,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor { message = "Unexpected server error."; logger.debug("Unexpected exception in REST endpoint.", e); - throw new HTTPException( + throw new APIException( APIError.Type.INTERNAL_ERROR, message ); diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/TokenRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/TokenRESTService.java index 059173776..3951c59e4 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/TokenRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/auth/TokenRESTService.java @@ -46,7 +46,7 @@ import org.glyptodon.guacamole.net.basic.GuacamoleSession; import org.glyptodon.guacamole.net.basic.rest.APIError; import org.glyptodon.guacamole.net.basic.rest.APIRequest; import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure; -import org.glyptodon.guacamole.net.basic.rest.HTTPException; +import org.glyptodon.guacamole.net.basic.rest.APIException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -290,7 +290,7 @@ public class TokenRESTService { GuacamoleSession session = tokenSessionMap.remove(authToken); if (session == null) - throw new HTTPException(APIError.Type.NOT_FOUND, "No such token."); + throw new APIException(APIError.Type.NOT_FOUND, "No such token."); session.invalidate(); diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java index 8bae0cf27..af785fc65 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java @@ -56,7 +56,7 @@ import org.glyptodon.guacamole.net.basic.rest.APIPatch; import static org.glyptodon.guacamole.net.basic.rest.APIPatch.Operation.add; import static org.glyptodon.guacamole.net.basic.rest.APIPatch.Operation.remove; import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure; -import org.glyptodon.guacamole.net.basic.rest.HTTPException; +import org.glyptodon.guacamole.net.basic.rest.APIException; import org.glyptodon.guacamole.net.basic.rest.ObjectRetrievalService; import org.glyptodon.guacamole.net.basic.rest.PATCH; import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService; @@ -275,12 +275,12 @@ public class UserRESTService { // Validate data and path are sane if (!user.getUsername().equals(username)) - throw new HTTPException(APIError.Type.BAD_REQUEST, + throw new APIException(APIError.Type.BAD_REQUEST, "Username in path does not match username provided JSON data."); // A user may not use this endpoint to modify himself if (userContext.self().getIdentifier().equals(user.getUsername())) { - throw new HTTPException(APIError.Type.PERMISSION_DENIED, + throw new APIException(APIError.Type.PERMISSION_DENIED, "Permission denied."); } @@ -335,7 +335,7 @@ public class UserRESTService { // Verify that the old password was correct if (authProvider.getUserContext(credentials) == null) { - throw new HTTPException(APIError.Type.PERMISSION_DENIED, + throw new APIException(APIError.Type.PERMISSION_DENIED, "Permission denied."); } @@ -466,7 +466,7 @@ public class UserRESTService { // Unsupported patch operation default: - throw new HTTPException(APIError.Type.BAD_REQUEST, + throw new APIException(APIError.Type.BAD_REQUEST, "Unsupported patch operation: \"" + operation + "\""); } @@ -585,7 +585,7 @@ public class UserRESTService { // Otherwise, the path is not supported else - throw new HTTPException(APIError.Type.BAD_REQUEST, "Unsupported patch path: \"" + path + "\""); + throw new APIException(APIError.Type.BAD_REQUEST, "Unsupported patch path: \"" + path + "\""); } // end for each patch operation