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.core.impl.api.node;
023:
024: import org.jboss.portal.api.node.PortalNodeURL;
025: import org.jboss.portal.core.controller.ControllerContext;
026: import org.jboss.portal.core.model.portal.PortalObjectId;
027: import org.jboss.portal.portlet.PortletParametersStateString;
028: import org.jboss.portal.server.request.URLContext;
029:
030: /**
031: * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
032: * @version $Revision: 8786 $
033: */
034: public class AbstractPortalNodeURL implements PortalNodeURL {
035:
036: /** . */
037: protected PortalObjectId id;
038:
039: /** . */
040: protected ControllerContext controllerContext;
041:
042: /** . */
043: protected PortletParametersStateString parameters;
044:
045: /** . */
046: protected Boolean wantSecure;
047:
048: /** . */
049: protected Boolean wantAuthenticated;
050:
051: /** . */
052: protected boolean relative;
053:
054: /** . */
055: protected URLContext urlContext;
056:
057: public AbstractPortalNodeURL(PortalObjectId id,
058: ControllerContext controllerContext) {
059: this .id = id;
060: this .controllerContext = controllerContext;
061: this .relative = true;
062: this .parameters = new PortletParametersStateString();
063: }
064:
065: public void setParameter(String name, String value) {
066: parameters.setValue(name, value);
067: }
068:
069: public void setParameter(String name, String[] values) {
070: parameters.setValues(name, values);
071: }
072:
073: public void setAuthenticated(Boolean authenticated) {
074: this .wantAuthenticated = authenticated;
075:
076: //
077: this .urlContext = null;
078: }
079:
080: public void setSecure(Boolean secure) {
081: this .wantSecure = secure;
082:
083: //
084: this .urlContext = null;
085: }
086:
087: public void setRelative(boolean relative) {
088: this .relative = relative;
089: }
090:
091: protected URLContext getURLContext() {
092: if (urlContext == null) {
093: URLContext tmp = controllerContext.getServerInvocation()
094: .getServerContext().getURLContext();
095:
096: //
097: if (wantSecure != null) {
098: if (wantSecure.booleanValue()) {
099: tmp = tmp.asSecured();
100: } else {
101: tmp = tmp.asNonSecured();
102: }
103: }
104:
105: //
106: if (wantAuthenticated != null) {
107: if (wantAuthenticated.booleanValue()) {
108: tmp = tmp.asAuthenticated();
109: } else {
110: tmp = tmp.asNonAuthenticated();
111: }
112: }
113:
114: //
115: urlContext = tmp;
116: }
117:
118: //
119: return urlContext;
120: }
121: }
|