marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tk...@apache.org
Subject [5/8] git commit: deleted some files only used for testing
Date Mon, 08 Apr 2013 10:51:32 GMT
deleted some files only used for testing


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/c8d07165
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/c8d07165
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/c8d07165

Branch: refs/heads/master
Commit: c8d071656a257093b99d0f5ead64fb20db654fa1
Parents: fc74e3c
Author: tkurz <tkurz@apache.org>
Authored: Mon Apr 8 11:50:58 2013 +0200
Committer: tkurz <tkurz@apache.org>
Committed: Mon Apr 8 11:50:58 2013 +0200

----------------------------------------------------------------------
 .../platform/core/filters/MarmottaCorsFilter.java  |  100 ---------------
 .../marmotta/platform/core/util/CorsHandler.java   |   90 -------------
 2 files changed, 0 insertions(+), 190 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c8d07165/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java
deleted file mode 100644
index 8828135..0000000
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.marmotta.platform.core.filters;
-
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
-import org.apache.marmotta.platform.core.api.modules.MarmottaHttpFilter;
-import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent;
-import org.apache.marmotta.platform.core.util.CorsHandler;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Observes;
-import javax.inject.Inject;
-import javax.servlet.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * ...
- * <p/>
- * Author: Thomas Kurz (tkurz@apache.org)
- */
-@ApplicationScoped
-public class MarmottaCorsFilter implements MarmottaHttpFilter {
-
-    public static Map<String,Object> options;
-
-    @Inject
-    ConfigurationService configurationService;
-
-    @Override
-    public void init(FilterConfig filterConfig) throws ServletException {
-        initializeOptions();
-    }
-
-    public void configChanged(@Observes ConfigurationChangedEvent event) {
-        if (event.getKeys().contains("kiwi.allow_origin")
-                || event.getKeys().contains("kiwi.allow_methods")) {
-            initializeOptions();
-        }
-    }
-
-    private void initializeOptions() {
-        options = new HashMap<String,Object>();
-        options.put("Access-Control-Allow-Origin",configurationService.getStringConfiguration("kiwi.allow_origin","*"));
-        options.put("Access-Control-Allow-Methods", configurationService.getStringConfiguration("kiwi.allow_methods","POST,
PUT, GET, DELETE, HEAD"));
-    }
-
-    @Override
-    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
-        if(response instanceof HttpServletResponse) {
-            HttpServletResponse resp = (HttpServletResponse)response;
-            HttpServletRequest req  = (HttpServletRequest)request;
-
-            String origin = req.getHeader("Origin");
-
-            if(origin != null) {
-                CorsHandler.run(req,resp,options);
-            }
-
-            if(req.getMethod().equalsIgnoreCase("OPTIONS")) {
-                resp.setStatus(200);
-            }
-        }
-        chain.doFilter(request,response);
-    }
-
-    @Override
-    public void destroy() {
-        //
-    }
-
-    @Override
-    public String getPattern() {
-        return "^/.*";
-    }
-
-    @Override
-    public int getPriority() {
-        return 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c8d07165/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java
b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java
deleted file mode 100644
index abd6b61..0000000
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.marmotta.platform.core.util;
-
-import org.apache.commons.lang.StringUtils;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
-import java.util.Map;
-
-/**
- * ...
- * <p/>
- * Author: Thomas Kurz (tkurz@apache.org)
- */
-public class CorsHandler {
-
-    private static final String[] CORS_HEADERS= {
-            "Access-Control-Allow-Origin",
-            "Access-Control-Expose-Headers",
-            "Access-Control-Max-Age",
-            "Access-Control-Allow-Credentials",
-            "Access-Control-Allow-Methods",
-            "Access-Control-Allow-Headers"};
-
-    /**
-     * This method sets the response headers for CORS request. The options may contain following
fields:
-     * <ul>
-     * <li>
-     *     "Access-Control-Allow-Origin" : List&lt;String&gt; | "*"
-     * </li>
-     * <li>
-     *     "Access-Control-Expose-Headers" : List&lt;String&gt;
-     * </li>
-     * <li>
-     *     "Access-Control-Max-Age" : long
-     * </li>
-     * <li>
-     *    "Access-Control-Allow-Credentials" : boolean
-     * </li>
-     * <li>
-     *     "Access-Control-Allow-Methods" : List&lt;String&gt;
-     * </li>
-     * <li>
-     *     "Access-Control-Allow-Headers" : List&lt;String&gt;
-     * </li>
-     * </ul>
-     * @param request the HTTP servlet request
-     * @param response the HTTP servlet response
-     * @param options the options
-     */
-    public static void run(HttpServletRequest request, HttpServletResponse response, Map<String,Object>
options) {
-
-        //remove all existing cors headers
-        for(String header : CORS_HEADERS) {
-            response.setHeader(header,null);
-        }
-
-        //add headers from options
-        for(String key : options.keySet()) {
-            response.addHeader(key,buildHeader(options.get(key)));
-        }
-
-    }
-
-    private static String buildHeader(Object value) {
-        if(value instanceof List) {
-            return StringUtils.join((List)value,",");
-        }
-        return value.toString();
-    }
-
-}


Mime
View raw message