@@ -0,0 +1,2266 @@
+/*%0A * Copyright 2012 SFB 632.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage annis.rest.provider;%0A%0Aimport javax.ws.rs.core.Response;%0Aimport javax.ws.rs.ext.ExceptionMapper;%0Aimport javax.ws.rs.ext.Provider;%0A%0Aimport org.corpus_tools.graphannis.errors.GraphANNISException;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A/**%0A *%0A * @author Thomas Krause %3Ckrauseto@hu-berlin.de%3E%0A */%0A@Provider%0Apublic class GraphANNISExceptionMapper implements ExceptionMapper%3CGraphANNISException%3E %7B%0A    private final Logger log = LoggerFactory.getLogger(GraphANNISExceptionMapper.class);%0A%0A    /**%0A     * Maps an exception to a response or returns null if it wasn't handled%0A     * %0A     * @param ex%0A     * @return%0A     */%0A    public static Response map(GraphANNISException ex) %7B%0A        // go through each cause%0A        StringBuilder sb = new StringBuilder();%0A        %0A        sb.append(ex.getMessage());%0A        sb.append(%22 (%22);%0A        sb.append(ex.getClass().getSimpleName());%0A        sb.append(%22)%22);%0A        %0A        // build %22stack trace%22 of causes%0A        Throwable cause = ex.getCause();%0A        while(cause != null) %7B%0A            sb.append(%22%5Cncaused by: %22);%0A            sb.append(cause.getMessage());%0A            sb.append(%22 (%22);%0A            sb.append(ex.getClass().getSimpleName());%0A            sb.append(%22)%22);%0A            cause = cause.getCause();%0A        %7D%0A        return Response.status(500).entity(sb.toString()).build();%0A    %7D%0A%0A    @Override%0A    public Response toResponse(GraphANNISException ex) %7B%0A        Response r = map(ex);%0A        if (r != null) %7B%0A            return r;%0A        %7D%0A%0A        // default%0A        log.error(%22Unhandled GraphANNISException%22, ex);%0A        return Response.status(500).entity(ex.getMessage()).build();%0A%0A    %7D%0A%0A%7D%0A

Add mapper for GraphANNISExceptions