1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.web

File HomePageRedirectServlet.java

 

Coverage histogram

../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

2
5
2
1
57
24
3
0.6
2.5
2
1.5

Classes

Class Line # Actions
HomePageRedirectServlet 34 5 0% 3 2
0.777777877.8%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package com.xpn.xwiki.web;
21   
22    import java.io.IOException;
23   
24    import javax.servlet.ServletException;
25    import javax.servlet.http.HttpServlet;
26    import javax.servlet.http.HttpServletRequest;
27    import javax.servlet.http.HttpServletResponse;
28   
29    /**
30    * A simple action that redirects to the main page of the wiki. This is to allow users to enter a URL like
31    * <code>http://localhost:8080/xwiki</code> and be redirected automatically to
32    * <code>http://localhost:8080/xwiki/bin/view/Main/</code>.
33    */
 
34    public class HomePageRedirectServlet extends HttpServlet
35    {
36    /** The address to use as a home page where the users are redirected. */
37    private String home = "bin/view/Main/";
38   
 
39  1 toggle @Override
40    public void init() throws ServletException
41    {
42  1 super.init();
43    // TODO: we cannot use the XWiki API to determine the right URL, because this is a servlet and the core
44    // is reachable mainly from Struts. Getting access to the core requires too much duplication, so for the
45    // moment we're going the easy way: hardcoded values.
46  1 String homeParameter = getInitParameter("homePage");
47  1 if (homeParameter != null) {
48  0 this.home = homeParameter;
49    }
50    }
51   
 
52  1 toggle @Override
53    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
54    {
55  1 response.sendRedirect(this.home);
56    }
57    }