KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > net > admin > SetupProxy


1 /*
2  * This file is part of "SnipSnap Wiki/Weblog".
3  *
4  * Copyright (c) 2002,2003 Fraunhofer Gesellschaft
5  * Fraunhofer Institut for Computer Architecture and Software Technology
6  * All Rights Reserved.
7  *
8  * Please visit http://snipsnap.org/ for updates and contact.
9  *
10  * --LICENSE NOTICE--
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  * --LICENSE NOTICE--
25  */

26 package org.snipsnap.net.admin;
27
28 import org.snipsnap.config.Configuration;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32 import java.util.Map JavaDoc;
33
34 public class SetupProxy implements SetupHandler {
35   public String JavaDoc getName() {
36     return "proxy";
37   }
38
39   public Map JavaDoc setup(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, Configuration config, Map JavaDoc errors) {
40     String JavaDoc autodetect = request.getParameter(Configuration.APP_REAL_AUTODETECT) != null ? "true" : "false";
41     config.setRealAutodetect(autodetect);
42     if ("false".equals(autodetect)) {
43       config.setRealHost(request.getParameter(Configuration.APP_REAL_HOST));
44       String JavaDoc portStr = request.getParameter(Configuration.APP_REAL_PORT);
45       config.setRealPort(request.getParameter(Configuration.APP_REAL_PORT));
46       if (portStr != null && !"".equals(portStr)) {
47         try {
48           Integer.parseInt(portStr);
49         } catch (NumberFormatException JavaDoc e) {
50           errors.put(Configuration.APP_REAL_PORT, Configuration.APP_REAL_PORT);
51         }
52       }
53     }
54     String JavaDoc realProtocol = request.getParameter(Configuration.APP_REAL_PROTOCOL);
55     if (null != realProtocol && !"".equals(realProtocol)) {
56       config.setRealProtocol(realProtocol.trim());
57     }
58     String JavaDoc realPath = request.getParameter(Configuration.APP_REAL_PATH);
59     if (null != realPath && !"".equals(realPath)) {
60       realPath = realPath.trim();
61       config.setRealPath(realPath.startsWith("/") ? realPath : "/" + realPath);
62     }
63
64     return errors;
65   }
66 }
67
Popular Tags