BVB Source Codes

che Show DashboardRedirectionFilter.java Source code

Return Download che: download DashboardRedirectionFilter.java Source code - Download che Source code - Type:.java
  1. /*******************************************************************************
  2.  * Copyright (c) 2012-2017 Codenvy, S.A.
  3.  * All rights reserved. This program and the accompanying materials
  4.  * are made available under the terms of the Eclipse Public License v1.0
  5.  * which accompanies this distribution, and is available at
  6.  * http://www.eclipse.org/legal/epl-v10.html
  7.  *
  8.  * Contributors:
  9.  *   Codenvy, S.A. - initial API and implementation
  10.  *******************************************************************************/
  11. package org.eclipse.che;
  12.  
  13.  
  14. import javax.servlet.Filter;
  15. import javax.servlet.FilterChain;
  16. import javax.servlet.FilterConfig;
  17. import javax.servlet.ServletException;
  18. import javax.servlet.ServletRequest;
  19. import javax.servlet.ServletResponse;
  20. import javax.servlet.http.HttpServletRequest;
  21. import javax.servlet.http.HttpServletResponse;
  22. import java.io.IOException;
  23. import java.util.regex.Pattern;
  24.  
  25. /**
  26.  * Redirect user to dashboard if request wasn't made to namespace/workspacename  address.
  27.  *
  28.  * @author Max Shaposhnik
  29.  */
  30.  
  31. public class DashboardRedirectionFilter implements Filter {
  32.     private static Pattern projectPattern = Pattern.compile("^/[^/]+?/.+");
  33.  
  34.     @Override
  35.     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  36.         HttpServletRequest req = (HttpServletRequest)request;
  37.         HttpServletResponse resp = (HttpServletResponse)response;
  38.  
  39.         if ("GET".equals(req.getMethod()) && !projectPattern.matcher(req.getRequestURI()).matches()) {
  40.             resp.sendRedirect("/dashboard/");
  41.             return;
  42.         }
  43.         chain.doFilter(request, response);
  44.     }
  45.  
  46.     @Override
  47.     public void init(FilterConfig filterConfig) throws ServletException {
  48.     }
  49.  
  50.     @Override
  51.     public void destroy() {
  52.     }
  53. }
  54.  
downloadDashboardRedirectionFilter.java Source code - Download che Source code
Related Source Codes/Software:
Gource - oftware version control visualization ... 2017-01-10
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
ImageOptim - GUI image optimizer for Mac htt... 2017-01-09
falcon - Falcon is a low-level, high-performance Python fra... 2017-01-09
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
waterline - An adapter-based ORM for Node.js with support for ... 2017-01-10
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
structor - An advanced visual editor for React components ... 2017-01-10
golearn - Machine Learning for Go 2017-01-10
RKNotificationHub - Make any UIView a full fledged notification center 2017-02-19
vimr - Project VimR - Refined Neovim experience for macOS... 2017-02-19
vue-admin - Vue Admin Panel Framework, Powered by Vue 2.0 and ... 2017-02-19
dev-setup - Mac OS X development environment setup: Easy-to-un... 2017-02-19
CMPopTipView - Custom UIView for iOS that pops up an animated "bu... 2017-02-19
git-recipes - Git for recipes in Chinese. The high quality of Gi... 2017-02-19
CLNDR - 2017-02-19
OptiKey - OptiKey - Full computer control and speech with yo... 2017-02-19
MRProgress - Collection of iOS drop-in components to visualize ... 2017-02-19
BGARefreshLayout-Android - On a variety of drop-down refresh effect, loading ... 2017-02-19

 Back to top