001: /*
002: * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/service/impl/URLResolverServiceImplServletMvnForum.java,v 1.2 2007/10/09 11:09:21 lexuanttkhtn Exp $
003: * $Author: lexuanttkhtn $
004: * $Revision: 1.2 $
005: * $Date: 2007/10/09 11:09:21 $
006: *
007: * ====================================================================
008: *
009: * Copyright (C) 2002-2007 by MyVietnam.net
010: *
011: * All copyright notices regarding mvnForum MUST remain
012: * intact in the scripts and in the outputted HTML.
013: * The "powered by" text/logo with a link back to
014: * http://www.mvnForum.com and http://www.MyVietnam.net in
015: * the footer of the pages MUST remain visible when the pages
016: * are viewed on the internet or intranet.
017: *
018: * This program is free software; you can redistribute it and/or modify
019: * it under the terms of the GNU General Public License as published by
020: * the Free Software Foundation; either version 2 of the License, or
021: * any later version.
022: *
023: * This program is distributed in the hope that it will be useful,
024: * but WITHOUT ANY WARRANTY; without even the implied warranty of
025: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
026: * GNU General Public License for more details.
027: *
028: * You should have received a copy of the GNU General Public License
029: * along with this program; if not, write to the Free Software
030: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
031: *
032: * Support can be obtained from support forums at:
033: * http://www.mvnForum.com/mvnforum/index
034: *
035: * Correspondence and Marketing Questions can be sent to:
036: * info at MyVietnam net
037: *
038: * @author: Minh Nguyen
039: */
040: package com.mvnforum.service.impl;
041:
042: import javax.servlet.http.HttpServletRequest;
043: import javax.servlet.http.HttpServletResponse;
044:
045: import net.myvietnam.mvncore.MVNCoreConfig;
046: import net.myvietnam.mvncore.service.URLResolverService;
047: import net.myvietnam.mvncore.web.GenericRequest;
048: import net.myvietnam.mvncore.web.GenericResponse;
049:
050: import com.mvnforum.admin.AdminModuleConfig;
051: import com.mvnforum.user.UserModuleConfig;
052:
053: public class URLResolverServiceImplServletMvnForum implements
054: URLResolverService {
055:
056: public boolean isSupportServlet() {
057: return true;
058: }
059:
060: public boolean isSupportPortlet() {
061: return false;
062: }
063:
064: public String encodeURL(HttpServletRequest request,
065: HttpServletResponse response, String url) {
066: if (MVNCoreConfig.getEnableEncodeURL()) {
067: url = response.encodeURL(url);
068: }
069: return url;
070: }
071:
072: public String encodeURL(GenericRequest request,
073: GenericResponse response, String url) {
074: return encodeURL(request.getServletRequest(), response
075: .getServletResponse(), url);
076: }
077:
078: public String encodeURL(HttpServletRequest request,
079: HttpServletResponse response, String url, int option) {
080: if (MVNCoreConfig.getEnableEncodeURL()) {
081: url = response.encodeURL(url);
082: }
083: return url;
084: }
085:
086: public String encodeURL(GenericRequest request,
087: GenericResponse response, String url, int option) {
088: return encodeURL(request.getServletRequest(), response
089: .getServletResponse(), url, option);
090: }
091:
092: public String encodeURL(HttpServletRequest request,
093: HttpServletResponse response, String url, int option,
094: String mode) {
095:
096: String resultURL;
097:
098: if ("view".equalsIgnoreCase(mode)
099: || "admin".equalsIgnoreCase(mode)) {
100: StringBuffer buffer = new StringBuffer(64);
101: buffer.append("..");
102: if ("view".equalsIgnoreCase(mode)) {
103: buffer.append(UserModuleConfig.getUrlPattern()).append(
104: "/");
105: } else {// now mode must be 'admin'
106: buffer.append(AdminModuleConfig.getUrlPattern())
107: .append("/");
108: }
109: buffer.append(url);
110: resultURL = buffer.toString();
111: } else {
112: resultURL = url;
113: }
114:
115: if (MVNCoreConfig.getEnableEncodeURL()) {
116: resultURL = response.encodeURL(resultURL);
117: }
118: return resultURL;
119: }
120:
121: public String encodeURL(GenericRequest request,
122: GenericResponse response, String url, int option,
123: String mode) {
124: return encodeURL(request.getServletRequest(), response
125: .getServletResponse(), url, option, mode);
126: }
127:
128: public String decodeAction(GenericRequest request,
129: GenericResponse response) {
130: return "";
131: }
132:
133: public String generateFormAction(HttpServletRequest request,
134: HttpServletResponse response, String url) {
135: return "";
136: }
137:
138: public String getActionParam() {
139: return "";
140: }
141:
142: }
|