@@ -0,0 +1,2605 @@
+/*%0A * Copyright 2015, Red Hat, Inc. and individual contributors as indicated by the%0A * @author tags. See the copyright.txt file in the distribution for a full%0A * listing of individual contributors.%0A *%0A * This is free software; you can redistribute it and/or modify it under the%0A * terms of the GNU Lesser General Public License as published by the Free%0A * Software Foundation; either version 2.1 of the License, or (at your option)%0A * any later version.%0A *%0A * This software is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS%0A * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more%0A * details.%0A *%0A * You should have received a copy of the GNU Lesser General Public License%0A * along with this software; if not, write to the Free Software Foundation,%0A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF%0A * site: http://www.fsf.org.%0A */%0A%0Apackage org.zanata.rest;%0A%0Aimport java.io.IOException;%0Aimport java.util.List;%0Aimport javax.ws.rs.container.ContainerRequestContext;%0Aimport javax.ws.rs.container.ContainerResponseContext;%0Aimport javax.ws.rs.container.ContainerResponseFilter;%0Aimport javax.ws.rs.core.MultivaluedMap;%0Aimport javax.ws.rs.ext.Provider;%0A%0Aimport org.jboss.resteasy.annotations.interception.HeaderDecoratorPrecedence;%0A%0Aimport com.google.common.base.Joiner;%0Aimport com.google.common.collect.Lists;%0A%0A/**%0A * This Interceptor is a POST process for Zanata REST API request.%0A * It support Cross-Origin resource sharing (CORS) by enabling Access-Control header in%0A * response header. CORS is needed for request from different domain.%0A *%0A * @author Alex Eng %3Ca href=%22mailto:aeng@redhat.com%22%3Eaeng@redhat.com%3C/a%3E%0A */%0A@Provider%0A@HeaderDecoratorPrecedence%0Apublic class ZanataRestResponseInterceptor implements ContainerResponseFilter %7B%0A    public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)%0A        throws IOException %7B%0A%0A        List%3CString%3E requestHeaders = requestContext.getHeaders().get(%22Access-Control-Request-Headers%22);%0A        if(requestHeaders == null) %7B%0A            requestHeaders = Lists.newArrayList();%0A        %7D%0A        MultivaluedMap%3CString, Object%3E headers = responseContext.getHeaders();%0A%0A        headers.add(%22Access-Control-Allow-Origin%22, %22*%22);%0A        headers.add(%22Access-Control-Allow-Methods%22, requestContext.getMethod());%0A        headers.add(%22Access-Control-Allow-Headers%22,%0A            %22X-Requested-With, Content-Type, Accept, %22 + Joiner.on(%22,%22).join(%0A                requestHeaders));%0A    %7D%0A%7D%0A

Add CORS to response