001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.server;
023:
024: import org.jboss.portal.common.util.ContentInfo;
025: import org.jboss.portal.server.request.URLContext;
026: import org.jboss.portal.server.request.URLFormat;
027:
028: /**
029: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
030: * @version $Revision: 8784 $
031: */
032: public class ServerResponse {
033:
034: /** Default format which is relative and servlet encoded. */
035: protected static final URLFormat DEFAULT_FORMAT = URLFormat
036: .newInstance(true, true);
037:
038: /** The server request. */
039: protected ServerRequest req;
040:
041: /** . */
042: protected ContentInfo contentInfo;
043:
044: /** Indicate that the invocation requires a sign out of the current authenticated user. */
045: boolean wantSignOut;
046:
047: /** . */
048: protected ServerInvocationContext invocationCtx;
049:
050: public ServerResponse(ServerRequest req,
051: ServerInvocationContext invocationCtx) {
052: this .req = req;
053: this .invocationCtx = invocationCtx;
054: }
055:
056: public ContentInfo getContentInfo() {
057: return contentInfo;
058: }
059:
060: public void setContentInfo(ContentInfo contentInfo) {
061: this .contentInfo = contentInfo;
062: }
063:
064: public boolean getWantSignOut() {
065: return wantSignOut;
066: }
067:
068: public void setWantSignOut(boolean wantSignOut) {
069: this .wantSignOut = wantSignOut;
070: }
071:
072: public String renderURL(ServerURL url) {
073: return invocationCtx.renderURL(url, invocationCtx
074: .getURLContext(), DEFAULT_FORMAT);
075: }
076:
077: public String renderURL(ServerURL url, URLFormat format) {
078: if (format == null) {
079: format = DEFAULT_FORMAT;
080: }
081: return invocationCtx.renderURL(url, invocationCtx
082: .getURLContext(), format);
083: }
084:
085: public String renderURL(ServerURL url, URLContext context,
086: URLFormat format) {
087: if (context == null) {
088: context = invocationCtx.getURLContext();
089: }
090: if (format == null) {
091: format = DEFAULT_FORMAT;
092: }
093: return invocationCtx.renderURL(url, context, format);
094: }
095:
096: public String renderURL(ServerURL url, URLContext context) {
097: if (context == null) {
098: context = invocationCtx.getURLContext();
099: }
100: return invocationCtx.renderURL(url, context, DEFAULT_FORMAT);
101: }
102: }
|