KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > common > URLResolverServletImpl


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/common/URLResolverServletImpl.java,v 1.7 2006/04/14 17:05:26 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.7 $
5  * $Date: 2006/04/14 17:05:26 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Minh Nguyen
39  */

40
41 package com.mvnforum.common;
42
43 import javax.servlet.http.HttpServletRequest JavaDoc;
44 import javax.servlet.http.HttpServletResponse JavaDoc;
45
46 import com.mvnforum.admin.AdminModuleConfig;
47 import com.mvnforum.user.UserModuleConfig;
48 import net.myvietnam.mvncore.MVNCoreConfig;
49 import net.myvietnam.mvncore.web.*;
50
51 public class URLResolverServletImpl implements URLResolver {
52
53     public boolean isSupportServlet() {
54         return true;
55     }
56
57     public boolean isSupportPortlet() {
58         return false;
59     }
60
61     public String JavaDoc encodeURL(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, String JavaDoc url) {
62         if (MVNCoreConfig.getEnableEncodeURL()) {
63             url = response.encodeURL(url);
64         }
65         return url;
66     }
67
68     public String JavaDoc encodeURL(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, String JavaDoc url, int option) {
69         if (MVNCoreConfig.getEnableEncodeURL()) {
70             url = response.encodeURL(url);
71         }
72         return url;
73     }
74
75     public String JavaDoc encodeURL(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, String JavaDoc url, int option, String JavaDoc mode) {
76
77         String JavaDoc resultURL;
78
79         if ("view".equalsIgnoreCase(mode) || "admin".equalsIgnoreCase(mode)) {
80             StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(64);
81             buffer.append("..");
82             if ("view".equalsIgnoreCase(mode)) {
83                 buffer.append(UserModuleConfig.getUrlPattern()).append("/");
84             } else {// now mode must be 'admin'
85
buffer.append(AdminModuleConfig.getUrlPattern()).append("/");
86             }
87             buffer.append(url);
88             resultURL = buffer.toString();
89         } else {
90             resultURL = url;
91         }
92
93         if (MVNCoreConfig.getEnableEncodeURL()) {
94             resultURL = response.encodeURL(resultURL);
95         }
96         return resultURL;
97     }
98
99     public String JavaDoc decodeAction(GenericRequest request, GenericResponse response) {
100         return "";
101     }
102
103     public String JavaDoc generateFormAction(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response, String JavaDoc url) {
104         return "";
105     }
106
107     public String JavaDoc getActionParam() {
108         return "";
109     }
110
111 }
112
Popular Tags