1package org.apache.archiva.rest.services.interceptors;
2/*3 * Licensed to the Apache Software Foundation (ASF) under one4 * or more contributor license agreements. See the NOTICE file5 * distributed with this work for additional information6 * regarding copyright ownership. The ASF licenses this file7 * to you under the Apache License, Version 2.0 (the8 * "License"); you may not use this file except in compliance9 * with the License. You may obtain a copy of the License at10 *11 * http://www.apache.org/licenses/LICENSE-2.012 *13 * Unless required by applicable law or agreed to in writing,14 * software distributed under the License is distributed on an15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY16 * KIND, either express or implied. See the License for the17 * specific language governing permissions and limitations18 * under the License.19 */2021import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
22import org.apache.archiva.rest.services.ArchivaRestError;
23import org.springframework.stereotype.Service;
2425import javax.ws.rs.core.Response;
26import javax.ws.rs.ext.ExceptionMapper;
27import javax.ws.rs.ext.Provider;
2829/**30 * @author Olivier Lamy31 * @since 1.4-M232 */33 @Provider
34 @Service( "archivaRestServiceExceptionMapper" )
35publicclassArchivaRestServiceExceptionMapper36implements ExceptionMapper<ArchivaRestServiceException>
37 {
38 @Override
39public Response toResponse( finalArchivaRestServiceException e )
40 {
41ArchivaRestErrorchivaRestError.html#ArchivaRestError">ArchivaRestError restError = newArchivaRestError( e );
42 Response response = //43 Response.status( new Response.StatusType()
44 {
45 @Override
46publicint getStatusCode()
47 {
48return e.getHttpErrorCode();
49 }
5051 @Override
52public Response.Status.Family getFamily()
53 {
54return Response.Status.Family.familyOf( e.getHttpErrorCode() );
55 }
5657 @Override
58public String getReasonPhrase()
59 {
60return e.getMessage();
61 }
62 } )//63 .entity( restError ) //64 .build();
6566return response;
67 }
68 }