001: /*
002: * (C) Copyright 2000 - 2003 Nabh Information Systems, Inc.
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: *
018: */
019:
020: package com.nabhinc.portal.container;
021:
022: import java.util.HashMap;
023: import java.util.Iterator;
024: import java.util.Map;
025:
026: import javax.portlet.PortletMode;
027: import javax.portlet.PortletModeException;
028: import javax.portlet.PortletSecurityException;
029: import javax.portlet.PortletURL;
030: import javax.portlet.WindowState;
031: import javax.portlet.WindowStateException;
032: import javax.servlet.http.HttpServletRequest;
033:
034: /**
035: *
036: *
037: * @author Padmanabh dabke
038: * (c) 2003 Nabh Information Systems, Inc. All Rights Reserved.
039: */
040: public abstract class PortletURLImpl implements PortletURL {
041:
042: protected WindowState puiWindowState = null;
043:
044: protected PortletMode puiPortletMode = null;
045:
046: protected HashMap puiParams = new HashMap();
047:
048: protected boolean puiSecure = false;
049:
050: protected PortalInterface puiPortalInterface = null;
051:
052: protected HttpServletRequest puiRequest = null;
053:
054: protected String puiMimeType = null;
055:
056: protected String puiDisplayMode = "normal";
057:
058: public PortletURLImpl(PortalInterface accessChecker,
059: HttpServletRequest req, String mimeType, String displayMode) {
060: puiPortalInterface = accessChecker;
061: puiRequest = req;
062: puiMimeType = mimeType;
063: puiDisplayMode = displayMode;
064: }
065:
066: /**
067: * @see javax.portlet.PortletURL#setWindowState(javax.portlet.WindowState)
068: */
069: public void setWindowState(WindowState windowState)
070: throws WindowStateException {
071: // puiPortalInterface.checkWindowState(windowState, puiMimeType);
072: puiWindowState = windowState;
073:
074: }
075:
076: /**
077: * @see javax.portlet.PortletURL#setPortletMode(javax.portlet.PortletMode)
078: */
079: public void setPortletMode(PortletMode portletMode)
080: throws PortletModeException {
081: try {
082: puiPortalInterface.checkPortletMode(portletMode,
083: puiMimeType, puiRequest);
084: puiPortletMode = portletMode;
085: } catch (PortletSecurityException ex) {
086: throw new PortletModeException("Permission denied.",
087: portletMode);
088: }
089:
090: }
091:
092: /**
093: * @see javax.portlet.PortletURL#addParameter(java.lang.String, java.lang.String)
094: */
095: @SuppressWarnings("unchecked")
096: public void setParameter(String name, String value) {
097: if (name == null)
098: throw new IllegalArgumentException(
099: "Parameter name cannot be null.");
100: if (value == null)
101: throw new IllegalArgumentException(
102: "Parameter value cannot be null.");
103: puiParams.put(name, new String[] { value });
104:
105: }
106:
107: /**
108: * @see javax.portlet.PortletURL#addParameter(java.lang.String, java.lang.String[])
109: */
110: @SuppressWarnings("unchecked")
111: public void setParameter(String name, String[] values) {
112: if (name == null)
113: throw new IllegalArgumentException(
114: "Parameter name cannot be null.");
115: if (values == null)
116: throw new IllegalArgumentException(
117: "Parameter value cannot be null.");
118: puiParams.put(name, values);
119: }
120:
121: /**
122: * @see javax.portlet.PortletURL#setParameters(java.util.Map)
123: */
124: @SuppressWarnings("unchecked")
125: public void setParameters(Map parameters) {
126: Iterator it = parameters.entrySet().iterator();
127: while (it.hasNext()) {
128: Map.Entry entry = (Map.Entry) it.next();
129: puiParams.put(entry.getKey(), entry.getValue());
130: }
131:
132: }
133:
134: /**
135: * @see javax.portlet.PortletURL#setSecure(boolean)
136: */
137: public void setSecure(boolean secure)
138: throws PortletSecurityException {
139: puiSecure = secure;
140:
141: }
142: }
|