Juan Hernandez has uploaded a new change for review. Change subject: restapi: Standard exception mappers ......................................................................
restapi: Standard exception mappers Currently we use Resteasy specific code in the exception mappers. This patch removes this code, as is now unnecessary. Change-Id: If033d3370f705149747d37ebfb76d053044823c4 Signed-off-by: Juan Hernandez <[email protected]> --- M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java D backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbExceptionMapper.java D backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbMarshallExceptionMapper.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JsonExceptionMapper.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MalformedIdExceptionMapper.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MappingExceptionMapper.java 6 files changed, 48 insertions(+), 84 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/02/30102/1 diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java index 7939d49..40dc568 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/BackendApplication.java @@ -59,8 +59,6 @@ import org.ovirt.engine.api.restapi.resource.BackendVmsResource; import org.ovirt.engine.api.restapi.resource.BackendVnicProfilesResource; import org.ovirt.engine.api.restapi.resource.validation.IOExceptionMapper; -import org.ovirt.engine.api.restapi.resource.validation.JaxbExceptionMapper; -import org.ovirt.engine.api.restapi.resource.validation.JaxbMarshallExceptionMapper; import org.ovirt.engine.api.restapi.resource.validation.JsonExceptionMapper; import org.ovirt.engine.api.restapi.resource.validation.MalformedIdExceptionMapper; import org.ovirt.engine.api.restapi.resource.validation.MappingExceptionMapper; @@ -162,8 +160,6 @@ // Intercepter that maps exceptions cause by illegal guid string to 400 status (BAD_REQUEST). singletons.add(new MalformedIdExceptionMapper()); - singletons.add(new JaxbExceptionMapper()); - singletons.add(new JaxbMarshallExceptionMapper()); singletons.add(new JsonExceptionMapper()); singletons.add(new MappingExceptionMapper()); singletons.add(new IOExceptionMapper()); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbExceptionMapper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbExceptionMapper.java deleted file mode 100644 index 21775e6..0000000 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbExceptionMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.ovirt.engine.api.restapi.resource.validation; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; -import javax.xml.bind.JAXBException; - -import org.jboss.resteasy.annotations.interception.ServerInterceptor; - -@Provider -@ServerInterceptor -public class JaxbExceptionMapper implements ExceptionMapper<JAXBException> { - - @Context - protected UriInfo uriInfo; - @Context - protected Request request; - @Context - protected Application application; - - @Override - public Response toResponse(JAXBException exception) { - try { - return Response.status(Status.BAD_REQUEST) - .entity(new UsageFinder().getUsageMessage(application, uriInfo, request)) - .build(); - } catch (Exception e) { - throw new WebApplicationException(e, Response.status(Response.Status.INTERNAL_SERVER_ERROR).build()); - } - } -} diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbMarshallExceptionMapper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbMarshallExceptionMapper.java deleted file mode 100644 index d5c2840..0000000 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JaxbMarshallExceptionMapper.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.ovirt.engine.api.restapi.resource.validation; - -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Application; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Request; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import javax.ws.rs.core.UriInfo; -import javax.ws.rs.ext.ExceptionMapper; -import javax.ws.rs.ext.Provider; - -import org.jboss.resteasy.annotations.interception.ServerInterceptor; -import org.jboss.resteasy.plugins.providers.jaxb.JAXBMarshalException; - -@Provider -@ServerInterceptor -public class JaxbMarshallExceptionMapper implements ExceptionMapper<JAXBMarshalException> { - - @Context - protected UriInfo uriInfo; - @Context - protected Request request; - @Context - protected Application application; - - @Override - public Response toResponse(JAXBMarshalException ex) { - try { - return Response.status(Status.BAD_REQUEST) - .entity(new UsageFinder().getUsageMessage(application, uriInfo, request)) - .build(); - } catch (Exception e) { - throw new WebApplicationException(e, Response.status(Response.Status.INTERNAL_SERVER_ERROR).build()); - } - } -} diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JsonExceptionMapper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JsonExceptionMapper.java index 4f091d1..a226e63 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JsonExceptionMapper.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/JsonExceptionMapper.java @@ -1,3 +1,19 @@ +/* +* Copyright (c) 2014 Red Hat, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + package org.ovirt.engine.api.restapi.resource.validation; import javax.ws.rs.WebApplicationException; @@ -11,10 +27,8 @@ import javax.ws.rs.ext.Provider; import org.codehaus.jackson.JsonProcessingException; -import org.jboss.resteasy.annotations.interception.ServerInterceptor; @Provider -@ServerInterceptor public class JsonExceptionMapper implements ExceptionMapper<JsonProcessingException> { @Context diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MalformedIdExceptionMapper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MalformedIdExceptionMapper.java index 86be95e..780fc2b 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MalformedIdExceptionMapper.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MalformedIdExceptionMapper.java @@ -1,3 +1,19 @@ +/* +* Copyright (c) 2014 Red Hat, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + package org.ovirt.engine.api.restapi.resource.validation; import javax.ws.rs.core.Response; @@ -5,11 +21,9 @@ import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; -import org.jboss.resteasy.annotations.interception.ServerInterceptor; import org.ovirt.engine.api.restapi.utils.MalformedIdException; @Provider -@ServerInterceptor public class MalformedIdExceptionMapper implements ExceptionMapper<MalformedIdException> { @Override diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MappingExceptionMapper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MappingExceptionMapper.java index 572ccd6..3c77059 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MappingExceptionMapper.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/validation/MappingExceptionMapper.java @@ -1,17 +1,31 @@ +/* +* Copyright (c) 2014 Red Hat, Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + package org.ovirt.engine.api.restapi.resource.validation; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; -import org.jboss.resteasy.annotations.interception.ServerInterceptor; import org.ovirt.engine.api.model.Fault; import org.ovirt.engine.api.restapi.utils.MappingException; import org.ovirt.engine.core.utils.log.Log; import org.ovirt.engine.core.utils.log.LogFactory; @Provider -@ServerInterceptor public class MappingExceptionMapper implements ExceptionMapper<MappingException> { private static final Log LOGGER = LogFactory.getLog(MappingExceptionMapper.class); -- To view, visit http://gerrit.ovirt.org/30102 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If033d3370f705149747d37ebfb76d053044823c4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
