You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2021/04/15 13:45:33 UTC
[myfaces-tobago] branch master updated: refactor: cleanup - remove
temporary workaround
This is an automated email from the ASF dual-hosted git repository.
lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 3db23f0 refactor: cleanup - remove temporary workaround
3db23f0 is described below
commit 3db23f0b63802f91b0be176fdf36ef88b6035d08
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Thu Apr 15 15:28:15 2021 +0200
refactor: cleanup - remove temporary workaround
---
.../facelets/HackResourceExtentionFilter.java | 94 ----------------------
1 file changed, 94 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/HackResourceExtentionFilter.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/HackResourceExtentionFilter.java
deleted file mode 100644
index eebadb7..0000000
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/facelets/HackResourceExtentionFilter.java
+++ /dev/null
@@ -1,94 +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.myfaces.tobago.facelets;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.annotation.WebFilter;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.lang.invoke.MethodHandles;
-
-// XXX hack, whould be nice to find a ES6/TypeScript conform way.
-
-@WebFilter(urlPatterns = "/*")
-public class HackResourceExtentionFilter implements Filter {
-
- private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- private String prefix;
-
- @Override
- public void init(final FilterConfig filterConfig) throws ServletException {
- if (LOG.isInfoEnabled()) {
- LOG.info("Filter initialized.");
- }
- final String version = Package.getPackage("org.apache.myfaces.tobago.component").getImplementationVersion();
- final String contextPath = filterConfig.getServletContext().getContextPath();
- prefix = contextPath + "/tobago/standard/" + version + "/js/";
- }
-
- @Override
- public void doFilter(
- final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain)
- throws IOException, ServletException {
- if (servletRequest instanceof HttpServletRequest && servletResponse instanceof HttpServletResponse) {
- final HttpServletRequest request = (HttpServletRequest) servletRequest;
- final String requestUri = request.getRequestURI();
- if (requestUri.startsWith(prefix) && !requestUri.endsWith(".js") && !requestUri.endsWith(".map")) {
- HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request) {
- @Override
- public String getRequestURI() {
- return super.getRequestURI() + ".js";
- }
- @Override
- public String getServletPath() {
- return super.getServletPath() + ".js";
- }
-
- @Override
- public StringBuffer getRequestURL() {
- final StringBuffer buffer = super.getRequestURL();
- buffer.append(".js");
- return buffer;
- }
- };
- filterChain.doFilter(wrapper, servletResponse);
- } else {
- filterChain.doFilter(servletRequest, servletResponse);
- }
- } else {
- filterChain.doFilter(servletRequest, servletResponse);
- }
- }
-
- @Override
- public void destroy() {
- }
-}