001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.kernel.util;
022:
023: import javax.portlet.ActionRequest;
024: import javax.portlet.PortletRequest;
025: import javax.portlet.PortletResponse;
026: import javax.portlet.RenderRequest;
027:
028: import javax.servlet.http.HttpServletRequest;
029: import javax.servlet.http.HttpServletResponse;
030: import javax.servlet.http.HttpSession;
031:
032: /**
033: * <a href="PortalUtil.java.html"><b><i>View Source</i></b></a>
034: *
035: * @author Brian Wing Shun Chan
036: *
037: */
038: public class PortalUtil {
039:
040: public static String getCDNHost() throws Exception {
041: Object returnObj = PortalClassInvoker.invoke(_CLASS,
042: _METHOD_GETCDNHOST, false);
043:
044: if (returnObj != null) {
045: return (String) returnObj;
046: } else {
047: return null;
048: }
049: }
050:
051: public static String getComputerName() throws Exception {
052: Object returnObj = PortalClassInvoker.invoke(_CLASS,
053: _METHOD_GETCOMPUTERNAME, false);
054:
055: if (returnObj != null) {
056: return (String) returnObj;
057: } else {
058: return null;
059: }
060: }
061:
062: public static HttpServletRequest getHttpServletRequest(
063: PortletRequest req) throws Exception {
064:
065: Object returnObj = PortalClassInvoker.invoke(_CLASS,
066: _METHOD_GETHTTPSERVLETREQUEST, req, false);
067:
068: if (returnObj != null) {
069: return (HttpServletRequest) returnObj;
070: } else {
071: return null;
072: }
073: }
074:
075: public static HttpServletResponse getHttpServletResponse(
076: PortletResponse res) throws Exception {
077:
078: Object returnObj = PortalClassInvoker.invoke(_CLASS,
079: _METHOD_GETHTTPSERVLETRESPONSE, res, false);
080:
081: if (returnObj != null) {
082: return (HttpServletResponse) returnObj;
083: } else {
084: return null;
085: }
086: }
087:
088: public static String getPortletNamespace(String portletId)
089: throws Exception {
090:
091: Object returnObj = PortalClassInvoker.invoke(_CLASS,
092: _METHOD_GETPORTLETNAMESPACE, portletId, false);
093:
094: if (returnObj != null) {
095: return (String) returnObj;
096: } else {
097: return null;
098: }
099: }
100:
101: public static String getUserPassword(HttpSession ses)
102: throws Exception {
103:
104: Object returnObj = PortalClassInvoker.invoke(_CLASS,
105: _METHOD_GETUSERPASSWORD, ses, false);
106:
107: if (returnObj != null) {
108: return (String) returnObj;
109: } else {
110: return null;
111: }
112: }
113:
114: public static String getUserPassword(HttpServletRequest req)
115: throws Exception {
116:
117: Object returnObj = PortalClassInvoker.invoke(_CLASS,
118: _METHOD_GETUSERPASSWORD, req, false);
119:
120: if (returnObj != null) {
121: return (String) returnObj;
122: } else {
123: return null;
124: }
125: }
126:
127: public static String getUserPassword(ActionRequest req)
128: throws Exception {
129:
130: Object returnObj = PortalClassInvoker.invoke(_CLASS,
131: _METHOD_GETUSERPASSWORD, req, false);
132:
133: if (returnObj != null) {
134: return (String) returnObj;
135: } else {
136: return null;
137: }
138: }
139:
140: public static String getUserPassword(RenderRequest req)
141: throws Exception {
142:
143: Object returnObj = PortalClassInvoker.invoke(_CLASS,
144: _METHOD_GETUSERPASSWORD, req, false);
145:
146: if (returnObj != null) {
147: return (String) returnObj;
148: } else {
149: return null;
150: }
151: }
152:
153: public static void setPageSubtitle(String subtitle,
154: HttpServletRequest req) throws Exception {
155:
156: PortalClassInvoker.invoke(_CLASS, _METHOD_SETPAGESUBTITLE,
157: subtitle, req, false);
158: }
159:
160: public static void setPageTitle(String title, HttpServletRequest req)
161: throws Exception {
162:
163: PortalClassInvoker.invoke(_CLASS, _METHOD_SETPAGETITLE, title,
164: req, false);
165: }
166:
167: private static final String _CLASS = "com.liferay.portal.util.PortalUtil";
168:
169: private static final String _METHOD_GETCDNHOST = "getCDNHost";
170:
171: private static final String _METHOD_GETCOMPUTERNAME = "getComputerName";
172:
173: private static final String _METHOD_GETHTTPSERVLETREQUEST = "getHttpServletRequest";
174:
175: private static final String _METHOD_GETHTTPSERVLETRESPONSE = "getHttpServletResponse";
176:
177: private static final String _METHOD_GETPORTLETNAMESPACE = "getPortletNamespace";
178:
179: private static final String _METHOD_GETUSERPASSWORD = "getUserPassword";
180:
181: private static final String _METHOD_SETPAGESUBTITLE = "setPageSubtitle";
182:
183: private static final String _METHOD_SETPAGETITLE = "setPageTitle";
184:
185: }
|