Return-Path: Delivered-To: apmail-portals-pluto-scm-archive@www.apache.org Received: (qmail 91974 invoked from network); 3 Sep 2005 04:24:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Sep 2005 04:24:06 -0000 Received: (qmail 64698 invoked by uid 500); 3 Sep 2005 04:24:05 -0000 Delivered-To: apmail-portals-pluto-scm-archive@portals.apache.org Received: (qmail 64620 invoked by uid 500); 3 Sep 2005 04:24:05 -0000 Mailing-List: contact pluto-scm-help@portals.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list pluto-scm@portals.apache.org Received: (qmail 64599 invoked by uid 99); 3 Sep 2005 04:24:04 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2005 21:24:04 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 02 Sep 2005 21:24:16 -0700 Received: (qmail 91959 invoked by uid 65534); 3 Sep 2005 04:24:00 -0000 Message-ID: <20050903042400.91958.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r267416 [2/2] - in /portals/pluto/branches/pluto-1.1: ./ pluto-portal-driver/ pluto-portal-driver/src/ pluto-portal-driver/src/assemble/ pluto-portal-driver/src/main/ pluto-portal-driver/src/main/java/ pluto-portal-driver/src/main/java/org/... Date: Sat, 03 Sep 2005 04:23:52 -0000 To: pluto-scm@portals.apache.org From: ddewolf@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,98 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.container; + +import org.apache.pluto.services.*; + +import javax.portlet.PortalContext; +import javax.servlet.http.HttpServletRequest; + +/** + * The Portal Driver's PortletContainerServices implementation. The + * PortletContainerServices interface is the main integration point + * between the pluto container and the surrounding portal. + * @author David H. DeWolf + * @version 1.0 + * @since Sep 21, 2004 + */ +public class ContainerServicesImpl implements PortletContainerServices { + + + private PortalContextImpl context; + + private PortletPreferencesFactory preferencesFactory; + private PortalCallbackProvider callback; + private PropertyManagerService propertyService; + + /** + * Default Constructor. + */ + public ContainerServicesImpl(PortalContextImpl context) { + this.context = context; + preferencesFactory = new PortletPreferencesProviderImpl(); + callback = new PortalCallbackProviderImpl(); + propertyService = new PropertyManagerProviderImpl(); + } + + /** + * Standard Getter. + * @return the portal context for the portal which we service. + */ + public PortalContext getPortalContext() { + return context; + } + + /** + * The PortletPreferencesFactory provides access to the portal's + * PortletPreference persistence mechanism. + * @return a PortletPreferencesFactory instance. + */ + public PortletPreferencesFactory getPortletPreferencesFactory() { + return preferencesFactory; + } + + /** + * The DynamicInformationProvider provides dynamic, runtime evaluated, + * information. + * @param req the HttpServletRequest identifying the request + * @return a DynamicInformationProvider implementation. + */ + public DynamicInformationProvider getDynamicInformationProvider( + HttpServletRequest req) { + return new DynamicInformationProviderImpl(req); + } + + + /** + * The PortalCallbackProvider allows the container to communicate + * actions back to the portal. + * @return a PortalCallbackProvider implementation. + */ + public PortalCallbackProvider getPortalCallbackProvider() { + return callback; + } + + /** + * The PropertyManagerService manages portal properties. + * @return a PropertyManagerService implemenatation. + */ + public PropertyManagerService getPropertyManagerService() { + return this.propertyService; + } + + +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/DynamicInformationProviderImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/DynamicInformationProviderImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/DynamicInformationProviderImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/DynamicInformationProviderImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,61 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + + */ + +package org.apache.pluto.driver.services.container; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.pluto.PortletWindow; +import org.apache.pluto.driver.core.PortalEnvironment; +import org.apache.pluto.driver.core.ResourceURLProviderImpl; +import org.apache.pluto.services.DynamicInformationProvider; +import org.apache.pluto.services.PortletURLProvider; +import org.apache.pluto.services.ResourceURLProvider; + + +public class DynamicInformationProviderImpl + implements DynamicInformationProvider { + + /** + * The number of known MimtTypes which may be added to the response content + * type set. This number is used to initialize the HashSets created here. + */ + private final static int NUMBER_KNOWN_MIMETYPES = 15; + + + private PortalEnvironment env; + + public DynamicInformationProviderImpl(HttpServletRequest request) { + env = PortalEnvironment.getPortalEnvironment(request); + } + + // DynamicInformationProviderImpl implementation. + + public PortletURLProvider getPortletURLProvider( + PortletWindow internalPortletWindow) { + return new PortletURLProviderImpl(env.getRequest(), + internalPortletWindow); + } + + public ResourceURLProvider getResourceURLProvider( + PortletWindow internalPortletWindow) { + return new ResourceURLProviderImpl(env.getRequest(), + internalPortletWindow); + } +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackProviderImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackProviderImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackProviderImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackProviderImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,42 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.container; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.pluto.PortletWindow; +import org.apache.pluto.services.PortalCallbackProvider; + +/** + * @author David H. DeWolf + * @version 1.0 + * @since Sep 22, 2004 + */ +public class PortalCallbackProviderImpl implements PortalCallbackProvider { + + public PortalCallbackProviderImpl() { + + } + + public void setTitle(HttpServletRequest request, + PortletWindow window, + String title) { + request.setAttribute("org.apache.pluto.dynamic_title", title); + } + + +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalContextImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalContextImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalContextImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalContextImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,166 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + + */ + +package org.apache.pluto.driver.services.container; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Vector; + +import javax.portlet.PortalContext; +import javax.portlet.PortletMode; +import javax.portlet.WindowState; + +import org.apache.pluto.driver.config.DriverConfiguration; + +/** + * PortalContext implementation for the Pluto Portal Driver. + */ +public class PortalContextImpl implements PortalContext { + + /** + * The DriverConfigurationImpl from which this + * PortalContext recieves it's configuration information. + */ + private DriverConfiguration config; + + /** + * Portal information. + */ + private String info = null; + + /** + * Portal Properties + */ + private HashMap properties = new HashMap(); + + /** + * Supported PortletModes. + */ + private Vector portletModes; + + /** + * Supported WindowStates. + */ + private Vector windowStates; + + + /** + * Default Constructor. + * @param config + */ + public PortalContextImpl(DriverConfiguration config) { + this.config = config; + reset(); + } + + /** + * Get a dynamic portal property. + * @param name + * @return the property value associated with the given key. + * @throws IllegalArgumentException if the specified name is null. + */ + public String getProperty(String name) { + if (name == null) { + throw new IllegalArgumentException("Property name == null"); + } + + return (String) properties.get(name); + } + + + /** + * Get an enumeration containing all names of the portal properties. + * @return an enumeration of all keys to which properties are bound. + */ + public Enumeration getPropertyNames() { + Vector names = new Vector(properties.keySet()); + return names.elements(); + } + + + /** + * Get an enumeration of all PortletModes supported by this + * portal. + * @return enumeration of all supported portlet modes. + */ + public Enumeration getSupportedPortletModes() { + if (portletModes == null) { + portletModes = new Vector(); + Enumeration enumeration = new Vector(config.getSupportedPortletModes()).elements(); + while (enumeration.hasMoreElements()) { + portletModes.add( + new PortletMode(enumeration.nextElement().toString())); + } + } + return portletModes.elements(); + } + + /** + * Get an enumeration of all WindowStates supported by this + * portal. + * @return an enumeration of all supported window states. + */ + public Enumeration getSupportedWindowStates() { + if (windowStates == null) { + windowStates = new Vector(); + Enumeration enumeration = new Vector(config.getSupportedWindowStates()).elements(); + while (enumeration.hasMoreElements()) { + windowStates.add( + new WindowState(enumeration.nextElement().toString())); + } + } + return windowStates.elements(); + } + + /** + * Get the portal info for this portal. + * @return the portal information for this context. + */ + public String getPortalInfo() { + return info; + } + + + // additional methods. + // methods used container internally to set + + public void setProperty(String name, String value) { + if (name == null) { + throw new IllegalArgumentException("Property name == null"); + } + + properties.put(name, value); + } + + + /** + * reset all values to default portlet modes and window states; delete all + * properties and set the given portlet information as portlet info string. + */ + public void reset() { + info = config.getPortalName() + "/" + config.getPortalVersion(); + properties.clear(); + } + + public DriverConfiguration getDriverConfiguration() { + return config; + } + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferenceImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferenceImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferenceImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferenceImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,69 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.container; + +import java.util.ArrayList; +import java.util.Arrays; + +import org.apache.pluto.core.PortletPreference; + +/** + * PortletPreference implementation used by the PortletPreferencesManager + * to retrieve the preferences from storage. + * + * @author David H. DeWolf + * @version 1.0 + * @since Oct 8, 2004 + */ +public class PortletPreferenceImpl implements PortletPreference { + + private String name; + private ArrayList values; + + public PortletPreferenceImpl() { + this.values = new ArrayList(); + } + + public String getName() { + return name; + } + + public String[] getValues() { + return ((String[])values.toArray(new String[values.size()])); + } + + public void setValues(String[] values) { + this.values.addAll(Arrays.asList(values)); + } + + /** + * Returns false. Any PortletPreference retrieved by + * the manager can't be read only. + * @return + */ + public boolean isReadOnly() { + return false; + } + + public void setName(String name) { + this.name = name; + } + + public void addValue(String value) { + this.values.add(value); + } +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferencesProviderImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferencesProviderImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferencesProviderImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferencesProviderImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,150 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.container; + +import java.util.Collection; +import java.util.ArrayList; +import java.io.File; +import java.io.IOException; +import java.io.FileWriter; +import java.io.PrintWriter; + +import javax.portlet.PortletRequest; + +import org.apache.pluto.PortletWindow; +import org.apache.pluto.PortletContainerException; +import org.apache.pluto.driver.services.container.PortletPreferenceImpl; +import org.apache.pluto.core.PortletPreference; +import org.apache.pluto.services.PortletPreferencesFactory; +import org.apache.commons.digester.Digester; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; +import org.xml.sax.SAXException; + +/** + * The Portal Driver's PortletPreferencesFactory implementation. This + * implementation makes use of the filesystem for writing portlet preferences. + * @author David H. DeWolf + * @version 1.0 + * @since Sep 22, 2004 + */ +public class PortletPreferencesProviderImpl + implements PortletPreferencesFactory { + private static final Log LOG = + LogFactory.getLog(PortletPreferencesProviderImpl.class); + + private File storage = new File(System.getProperty("user.home")+File.separator+".pluto"); + + public PortletPreferencesProviderImpl() { + + } + + public PortletPreference[] getStoredPreferences(PortletWindow window, + PortletRequest req) + throws PortletContainerException { + /* For testing purposes, we'll assume that all + null users share prefs. + if(req.getRemoteUser() == null) { + return new PortletPreference[0]; + } + */ + + Digester dig = new Digester(); + dig.setClassLoader(getClass().getClassLoader()); + dig.addObjectCreate("portlet-preferences", ArrayList.class); + dig.addObjectCreate("portlet-preferences/portlet-preference", PortletPreferenceImpl.class); + dig.addBeanPropertySetter("portlet-preferences/portlet-preference/name"); + dig.addCallMethod("portlet-preferences/portlet-preference/value", "addValue", 0); + + File xmlFile = getFileFor(req, window); + + Collection col = null; + try { + if(xmlFile.exists()) { + col = (Collection)dig.parse(xmlFile); + } + else { + col = new ArrayList(); + } + } + catch(IOException io) { + throw new PortletContainerException(io); + } + catch (SAXException e) { + throw new PortletContainerException(e); + } + + return (PortletPreference[])col.toArray(new PortletPreference[col.size()]); + } + + public void store(PortletWindow window, + PortletRequest request, + PortletPreference[] preferences) + throws PortletContainerException { + /* For testing purposes, we'll assume that all + null users share prefs. + if(req.getRemoteUser() == null) { + return; + } + */ + + File file = getFileFor(request, window); + try { + FileWriter writer = new FileWriter(file); + PrintWriter out = new PrintWriter(writer); + + if(LOG.isDebugEnabled()) { + LOG.debug("Saving Preferences to file: "+file.getAbsolutePath()); + } + out.println(""); + for(int i=0;i"); + out.println(" "+preferences[i].getName()+""); + String[] values = preferences[i].getValues(); + for(int j=0;j"+values[j]+""); + } + out.println(" "); + } + out.println(""); + out.flush(); + out.close(); + } + catch(IOException io) { + throw new PortletContainerException(io); + } + } + + + private File getFileFor(PortletRequest req, PortletWindow window) { + + String userId = req.getRemoteUser(); + + StringBuffer windowDirectoryPath = new StringBuffer(); + String sep = File.separator; + windowDirectoryPath.append(req.getServerName()).append(sep); + windowDirectoryPath.append(req.getContextPath()).append(sep); + windowDirectoryPath.append(window.getId().toString()); + + File windowDir = new File(storage, windowDirectoryPath.toString()); + windowDir.mkdirs(); + + return new File(windowDir, userId+".prefs"); + } + + +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,90 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + + */ + +package org.apache.pluto.driver.services.container; + +import java.util.Iterator; +import java.util.Map; + +import javax.portlet.PortletMode; +import javax.portlet.WindowState; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.pluto.PortletWindow; +import org.apache.pluto.driver.core.PortalURL; +import org.apache.pluto.driver.core.PortalUrlFactory; +import org.apache.pluto.driver.core.PortalUrlParameter; +import org.apache.pluto.services.PortletURLProvider; + +public class PortletURLProviderImpl implements PortletURLProvider { + + private static final Log LOG = + LogFactory.getLog(PortletURLProviderImpl.class); + + private PortalURL url; + private String window; + + public PortletURLProviderImpl(HttpServletRequest request, + PortletWindow internalPortletWindow) { + url = PortalUrlFactory.getFactory().createPortalUrl(request); + this.window = internalPortletWindow.getId().toString(); + } + + public void setPortletMode(PortletMode mode) { + url.setPortletMode(window, mode); + } + + public void setWindowState(WindowState state) { + url.setWindowState(window, state); + } + + public void setAction(boolean action) { + if (action) { + url.setActionWindow(window); + } else { + url.setActionWindow(null); + } + } + + public void setSecure() { + //url.setSecure(true); + } + + public void clearParameters() { + url.clearParameters(window); + } + + public void setParameters(Map parameters) { + Iterator it = parameters.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = (Map.Entry) it.next(); + PortalUrlParameter param = new PortalUrlParameter(window, + (String) entry.getKey(), + (String[]) entry.getValue()); + url.addParameter(param); + } + } + + public String toString() { + return url.toString(); + } + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PropertyManagerProviderImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PropertyManagerProviderImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PropertyManagerProviderImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PropertyManagerProviderImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,45 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.container; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.pluto.PortletWindow; +import org.apache.pluto.services.PropertyManagerService; + +/** + * @author David H. DeWolf + * @version 1.0 + * @since Sep 22, 2004 + */ +public class PropertyManagerProviderImpl implements PropertyManagerService { + + + public void setResponseProperties(PortletWindow window, + HttpServletRequest request, + HttpServletResponse response, + Map properties) { + } + + public Map getRequestProperties(PortletWindow window, + HttpServletRequest request) { + return null; + } +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html Fri Sep 2 21:23:31 2005 @@ -0,0 +1,14 @@ + + +Service implementations of the driver configuration services. + +
  • rdbms: + Relational Database Management System implementations. +
  • + +
  • resource: + Classpath Resources (file) based implementations. +
  • + + + \ No newline at end of file Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/Configuration.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/Configuration.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/Configuration.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/Configuration.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,255 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.*; + +/** + * Encapsulation of the Pluto Driver Configuration Info. + * + * @author David H. DeWolf + * @version 1.0 + * @since Sep 23, 2004 + */ +public class Configuration { + /** Internal Logger. */ + private static final Log LOG = + LogFactory.getLog(Configuration.class); + + /** The name of the portal. */ + private String portalName; + + /** The Version of the Portal. */ + private String portalVersion; + + /** The name of the container wrapped by this portal. */ + private String containerName; + + /** The portlet modes we will support. */ + private Set supportedPortletModes; + + /** The window states we will support. */ + private Set supportedWindowStates; + + /** The portlet applications registered with us. */ + private Map portletApplications; + + /** Encapsulation of render configuration data. */ + private RenderConfig renderConfig; + + /** + * Default Constructor. + */ + public Configuration() { + this.supportedWindowStates = new HashSet(); + this.supportedPortletModes = new HashSet(); + this.portletApplications = new java.util.HashMap(); + } + + /** + * Standard Getter. + * @return the name of the portal. + */ + public String getPortalName() { + return portalName; + } + + /** + * Standard Getter. + * @param portalName the name of the portal. + */ + public void setPortalName(String portalName) { + this.portalName = portalName; + } + + /** + * Standard Getter. + * @return the portal version. + */ + public String getPortalVersion() { + return portalVersion; + } + + /** + * Standard Setter. + * @param portalVersion the portal version. + */ + public void setPortalVersion(String portalVersion) { + this.portalVersion = portalVersion; + } + + /** + * Standard Getter. + * @return the name of the container. + */ + public String getContainerName() { + return containerName; + } + + /** + * Standard Setter. + * @param containerName the name of the container. + */ + public void setContainerName(String containerName) { + this.containerName = containerName; + } + + /** + * Standard Getter. + * @return the names of the supported portlet modes. + */ + public Set getSupportedPortletModes() { + return supportedPortletModes; + } + + /** + * Standard Setter. + * @param supportedPortletModes the names of the supported portlet modes. + */ + public void setSupportedPortletModes(Set supportedPortletModes) { + this.supportedPortletModes = supportedPortletModes; + } + + /** + * Add the named supported portlet mode to the list of supported modes. + * @param mode a supported mode. + */ + public void addSupportedPortletMode(String mode) { + supportedPortletModes.add(mode); + } + + /** + * Standard Getter. + * @return the names of the supported window states. + */ + public Set getSupportedWindowStates() { + return supportedWindowStates; + } + + /** + * Standard Setter. + * @param supportedWindowStates the names of the supported window states. + */ + public void setSupportedWindowStates(Set supportedWindowStates) { + this.supportedWindowStates = supportedWindowStates; + } + + /** + * Add the named supported window state to the list of supported states. + * @param state the name of the supported state. + */ + public void addSupportedWindowState(String state) { + this.supportedWindowStates.add(state); + } + + /** + * Standard Getter. + * @return the configuration data of all configured portlet applications. + */ + public Set getPortletApplications() { + return new HashSet(portletApplications.values()); + } + + /** + * Add a porltet applicaiton conofiguration to this list of portlet apps. + * @param app portlet application coniguration data. + */ + public void addPortletApp(PortletApplicationConfig app) { + if (LOG.isDebugEnabled()) { + LOG.debug( + " - - Adding PortletApp Configuration for: " + + app.getContextPath()); + } + portletApplications.put(app.getContextPath(), app); + } + + /** + * Retrieve the portlet application with the given id. + * @param id the id of the portlet application. + * @return the portlet application configuration data. + */ + public PortletApplicationConfig getPortletApp(String id) { + return (PortletApplicationConfig) portletApplications.get(id); + } + + /** + * Retrieve the window configuration associated with the given id. + * @param id the id of the portlet window. + * @return the portlet window configuration data. + */ + public PortletWindowConfig getPortletWindowConfig(String id) { + if (id == null) { + return null; + } + String context = getContextFromPortletId(id); + String portlet = getPortletNameFromPortletId(id); + + PortletApplicationConfig app = getPortletApp(context); + if (app == null) { + if (LOG.isErrorEnabled()) { + LOG.error("Portlet Application '" + context + "' not found."); + } + return null; + } + return app.getPortlet(portlet); + } + + /** + * Standard Getter. + * @return the render configuration. + */ + public RenderConfig getRenderConfig() { + return renderConfig; + } + + /** + * Standard Setter. + * @param renderConfig the render configuration. + */ + public void setRenderConfig(RenderConfig renderConfig) { + this.renderConfig = renderConfig; + } + + /** + * Retrieve the id of the context from the portlet id. + * @param portletId the id of the portlet. + * @return the context, derived from the portlet id. + */ + private String getContextFromPortletId(String portletId) { + int idx = portletId.indexOf("."); + if (idx < 0) { + return null; + } + return portletId.substring(0, idx); + } + + /** + * Retreive the porlet name from the given portletId. + * @param portletId the portlet id. + * @return the name of the portlet. + */ + private String getPortletNameFromPortletId(String portletId) { + int idx = portletId.indexOf("."); + if (idx < 0) { + return null; + } + return portletId.substring(idx + 1); + } +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ConfigurationFactory.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ConfigurationFactory.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ConfigurationFactory.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ConfigurationFactory.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,115 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +import org.apache.commons.digester.Digester; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.xml.sax.SAXException; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author David H. DeWolf + * @version 1.0 + * @since Sep 23, 2004 + */ +class ConfigurationFactory { + + private static final Log LOG = + LogFactory.getLog(ConfigurationFactory.class); + + private static ConfigurationFactory factory; + + public static ConfigurationFactory getFactory() { + if (factory == null) { + factory = new ConfigurationFactory(); + } + return factory; + } + + private Digester digester; + + private ConfigurationFactory() { + digester = new Digester(); + digester.setLogger(LOG); + digester.setClassLoader(Thread.currentThread().getContextClassLoader()); + init(); + } + + public Configuration parse(InputStream in) + throws IOException, SAXException { + return (Configuration) digester.parse(in); + } + + +// Digester Setup + + private void init() { + digester.addObjectCreate("pluto-portal-driver", + Configuration.class); + digester.addBeanPropertySetter("pluto-portal-driver/portal-name", + "portalName"); + digester.addBeanPropertySetter("pluto-portal-driver/portal-version", + "portalVersion"); + digester.addBeanPropertySetter("pluto-portal-driver/container-name", + "containerName"); + + digester.addCallMethod("pluto-portal-driver/supports/portlet-mode", + "addSupportedPortletMode", 0); + digester.addCallMethod("pluto-portal-driver/supports/window-state", + "addSupportedWindowState", 0); + + digester.addObjectCreate("pluto-portal-driver/portlet-app", + PortletApplicationConfig.class); + digester.addBeanPropertySetter( + "pluto-portal-driver/portlet-app/context-path", "contextPath"); + + digester.addObjectCreate( + "pluto-portal-driver/portlet-app/portlets/portlet", + PortletWindowConfig.class); + digester.addSetProperties( + "pluto-portal-driver/portlet-app/portlets/portlet", "name", + "portletName"); + digester.addSetNext("pluto-portal-driver/portlet-app/portlets/portlet", + "addPortlet"); + digester.addSetNext("pluto-portal-driver/portlet-app", "addPortletApp"); + + digester.addObjectCreate("pluto-portal-driver/render-config", + RenderConfig.class); + digester.addSetProperties("pluto-portal-driver/render-config", + "default", "defaultPageId"); + digester.addObjectCreate("pluto-portal-driver/render-config/page", + PageConfig.class); + digester.addSetProperties("pluto-portal-driver/render-config/page"); + digester.addCallMethod( + "pluto-portal-driver/render-config/page/portlet", "addPortlet", 2); + digester.addCallParam("pluto-portal-driver/render-config/page/portlet", + 0, "context"); + digester.addCallParam("pluto-portal-driver/render-config/page/portlet", + 1, "name"); + digester.addSetNext("pluto-portal-driver/render-config/page", + "addPage"); + digester.addSetNext("pluto-portal-driver/render-config", + "setRenderConfig"); + + + } + + +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PageConfig.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PageConfig.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PageConfig.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PageConfig.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,75 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * @author David H. DeWolf + */ +public class PageConfig { + + private String name; + private String uri; + private Collection portletIds; + private int orderNumber; + + public PageConfig() { + this.portletIds = new ArrayList(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public Collection getPortletIds() { + return portletIds; + } + + public void setPortletIds(Collection ids) { + this.portletIds = ids; + } + + public void addPortlet(String contextPath, String portletName) { + portletIds.add( + PortletWindowConfig.createPortletId(contextPath, portletName)); + } + + void setOrderNumber(int number) { + this.orderNumber = number; + } + + int getOrderNumber() { + return orderNumber; + } + + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletApplicationConfig.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletApplicationConfig.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletApplicationConfig.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletApplicationConfig.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,59 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +import java.util.Collection; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * @author David H. DeWolf + */ +public class PortletApplicationConfig { + private static final Log LOG = + LogFactory.getLog(PortletApplicationConfig.class); + + private String contextPath; + private Map portlets; + + public PortletApplicationConfig() { + portlets = new java.util.HashMap(); + } + + public String getContextPath() { + return contextPath; + } + + public void setContextPath(String contextPath) { + this.contextPath = contextPath; + } + + public Collection getPortlets() { + return portlets.values(); + } + + public PortletWindowConfig getPortlet(String portletName) { + return (PortletWindowConfig) portlets.get(portletName); + } + + public void addPortlet(PortletWindowConfig portlet) { + portlet.setContextPath(getContextPath()); + portlets.put(portlet.getPortletName(), portlet); + } + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletWindowConfig.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletWindowConfig.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletWindowConfig.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletWindowConfig.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,58 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +/** + * @author David H. DeWolf + */ +public class PortletWindowConfig { + + private String contextPath; + private String portletName; + + public PortletWindowConfig() { + } + + public String getId() { + return createPortletId(contextPath, portletName); + } + + public String getContextPath() { + return contextPath; + } + + /** + * Should only be set by the application upon being added. + * @param contextPath + */ + void setContextPath(String contextPath) { + this.contextPath = contextPath; + } + + public String getPortletName() { + return portletName; + } + + public void setPortletName(String portletName) { + this.portletName = portletName; + } + + public static String createPortletId(String contextPath, + String portletName) { + return contextPath + "." + portletName; + } + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfig.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfig.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfig.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfig.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,92 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.*; + +/** + * @author David H. DeWolf + */ +public class RenderConfig { + private static final Log LOG = + LogFactory.getLog(RenderConfig.class); + + private Map pages; + private String defaultPageId; + + // internally used. + private int orderNumberCounter = 0; + private Comparator pageComparator; + + public RenderConfig() { + this.pages = new java.util.HashMap(); + this.pageComparator = new Comparator() { + public int compare(Object a, Object b) { + PageConfig pa = (PageConfig)a; + PageConfig pb = (PageConfig)b; + if(pa.getOrderNumber() > pb.getOrderNumber()) { + return 1; + } + else if(pa.getOrderNumber() == pb.getOrderNumber()) { + return 0; + } + else { + return -1; + } + } + + public boolean equals(Object a) { + return false; + } + }; + } + + + public String getDefaultPageId() { + return defaultPageId; + } + + public void setDefaultPageId(String defaultPageId) { + this.defaultPageId = defaultPageId; + } + + public List getPages() { + List col = new ArrayList(pages.values()); + Collections.sort(col, pageComparator); + return col; + } + + public PageConfig getPageConfig(String pageId) { + if (pageId == null || "".equals(pageId)) { + if (LOG.isDebugEnabled()) { + LOG.debug( + "Requested page is null. Returning default: " + + defaultPageId); + } + pageId = defaultPageId; + } + return (PageConfig) pages.get(pageId); + } + + public void addPage(PageConfig config) { + config.setOrderNumber(orderNumberCounter++); + pages.put(config.getName(), config); + } + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ResourceServicesImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ResourceServicesImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ResourceServicesImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ResourceServicesImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,120 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.services.impl.resource; + +import org.apache.pluto.driver.config.DriverConfigurationException; +import org.apache.pluto.driver.config.impl.PortletRegistryService; +import org.apache.pluto.driver.config.impl.PropertyConfigService; +import org.apache.pluto.driver.config.impl.RenderConfigService; + +import javax.servlet.ServletContext; +import java.util.List; +import java.util.Set; +import java.io.InputStream; + +/** + * Default implementation of all of the portal Services. + * + * @author David H. DeWolf + * @since Aug 10, 2005 + */ +public class ResourceServicesImpl implements + PropertyConfigService, PortletRegistryService, RenderConfigService { + + private static final String CONFIG_FILE = + "/WEB-INF/pluto-portal-driver-config.xml"; + + private Configuration config; + +// +// Lifecycle Methods +// + /** + * Initialization Lifecycle Method + * @param ctx + */ + public void init(ServletContext ctx) { + // because we comprise 3 services, we must + // prevent reinitialization. + if(config != null) + return; + + try { + InputStream in = ctx.getResourceAsStream(CONFIG_FILE); + config = ConfigurationFactory.getFactory().parse(in); + } + catch(Exception e) { + throw new DriverConfigurationException(e); + } + } + + /** + * Shutdown the ResourceService. + */ + public void destroy() { + config = null; + } + + + public String getPortalName() { + return config.getPortalName(); + } + + public String getPortalVersion() { + return config.getPortalVersion(); + } + + public String getContainerName() { + return config.getContainerName(); + } + + public Set getSupportedPortletModes() { + return config.getSupportedPortletModes(); + } + + public Set getSupportedWindowStates() { + return config.getSupportedWindowStates(); + } + + public Set getPortletApplications() { + return config.getPortletApplications(); + } + + public PortletApplicationConfig getPortletApplication(String id) { + return config.getPortletApp(id); + } + + public PortletWindowConfig getPortletWindowConfig(String id) { + return config.getPortletWindowConfig(id); + } + + public PortletWindowConfig getPortlet(String id) { + return config.getPortletWindowConfig(id); + } + + public List getPages() { + return config.getRenderConfig().getPages(); + } + + public PageConfig getDefaultPage() { + return config.getRenderConfig().getPageConfig(null); + } + + public PageConfig getPage(String id) { + return config.getRenderConfig().getPageConfig(id); + } + +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html Fri Sep 2 21:23:31 2005 @@ -0,0 +1,16 @@ + + +Services required by the portal. Contains Portal Driver specific +interfaces and the following childern: + +
  • container: +The services package contains implementations of the services required +to integrate with the Pluto Container. +
  • + +
  • impl: +Default Implementations of the portal services +
  • + + + \ No newline at end of file Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletRenderTag.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletRenderTag.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletRenderTag.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletRenderTag.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,69 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.tags; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +/** + * @author David H. DeWolf + * @version 1.0 + * @since Oct 4, 2004 + */ +public class PortletRenderTag extends TagSupport { + + public int doEndTag() + throws JspException { + PortletTag parent = + (PortletTag) TagSupport + .findAncestorWithClass(this, PortletTag.class); + + if (parent == null) { + throw new JspException( + "Portlet Window Controls may only reside within a pluto:portlet tag."); + } + + if (parent.getStatus() == PortletTag.SUCCESS) { + try { + StringBuffer sb = + parent.getPortalServletResponse() + .getInternalBuffer().getBuffer(); + + pageContext.getOut().print(sb.toString()); + } catch (IOException io) { + throw new JspException(io); + } + } else { + try { + pageContext.getOut().print("Error rendering portlet."); + pageContext.getOut().print("
    ");
    +                parent.getThrowable().printStackTrace(
    +                    new PrintWriter(pageContext.getOut()));
    +                pageContext.getOut().print("
    "); + } catch (IOException io) { + throw new JspException(io); + } + } + + return SKIP_BODY; + } + + +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,139 @@ +package org.apache.pluto.driver.tags; + +import java.util.Iterator; +import java.util.Map; + +import javax.portlet.WindowState; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyTagSupport; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.pluto.PortletContainer; +import org.apache.pluto.PortletWindow; +import org.apache.pluto.driver.AttributeKeys; +import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig; +import org.apache.pluto.driver.config.DriverConfiguration; +import org.apache.pluto.driver.core.PortalEnvironment; +import org.apache.pluto.driver.core.PortalServletRequest; +import org.apache.pluto.driver.core.PortalServletResponse; +import org.apache.pluto.driver.core.PortalURL; +import org.apache.pluto.driver.core.PortletWindowImpl; +import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager; + +/** + * @author David H. DeWolf + * @version $Id$ + */ +public class PortletTag extends BodyTagSupport { + + private static final Log LOG = + LogFactory.getLog(PortletTag.class); + + public static final int FAILED = 0; + public static final int SUCCESS = 1; + + private String portletId; + private String evaluatedPortletId; + + // Cached Results! + private PortalServletResponse response; + private int status; + private Throwable throwable; + + + public int doStartTag() throws JspException { + evaluateExpressions(); + ServletContext ctx = pageContext.getServletContext(); + DriverConfiguration config = (DriverConfiguration) + ctx.getAttribute(AttributeKeys.DRIVER_CONFIG); + + PortletWindowConfig winConfig = config.getPortletWindowConfig(evaluatedPortletId); + + if (LOG.isDebugEnabled()) { + LOG.debug("Rendering Portlet Window: " + winConfig); + } + + + PortalEnvironment env = (PortalEnvironment) pageContext.getRequest() + .getAttribute(PortalEnvironment.REQUEST_PORTALENV); + + PortalURL thisURL = env.getRequestedPortalURL(); + + PortletWindow window = new PortletWindowImpl(winConfig, thisURL); + + Map states = thisURL.getWindowStates(); + Iterator it = states.keySet().iterator(); + while (it.hasNext()) { + String wdw = (String) it.next(); + WindowState state = (WindowState) states.get(wdw); + if (WindowState.MAXIMIZED.equals(state) && + !window.getId().equals(wdw)) { + // Someone else is maximized, don't show my content. + return SKIP_BODY; + } + } + + HttpServletRequest request = (HttpServletRequest) + pageContext.getRequest(); + + PortalServletRequest req = + new PortalServletRequest(request, window); + + PortalServletResponse res = + new PortalServletResponse( + (HttpServletResponse) pageContext.getResponse()); + + PortletContainer container = (PortletContainer) + ctx.getAttribute(AttributeKeys.PORTLET_CONTAINER); + + try { + container.doRender(window, req, res); + response = res; + status = SUCCESS; + } catch (Throwable e) { + status = FAILED; + throwable = e; + } + return EVAL_BODY_INCLUDE; + } + + int getStatus() { + return status; + } + + PortalServletResponse getPortalServletResponse() { + return response; + } + + Throwable getThrowable() { + return throwable; + } + + String getEvaluatedPortletId() { + return evaluatedPortletId; + } + + public String getPortletId() { + return portletId; + } + + public void setPortletId(String portletId) { + this.portletId = portletId; + } + + private void evaluateExpressions() + throws JspException { + Object obj = ExpressionEvaluatorManager.evaluate("portletId", + portletId, + String.class, this, + pageContext); + if (LOG.isDebugEnabled()) { + LOG.debug("Evaluated portletId to: " + obj); + } + evaluatedPortletId = (String) obj; + } +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTitleTag.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTitleTag.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTitleTag.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTitleTag.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,52 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.tags; + +import java.io.IOException; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +/** + * @author David H. DeWolf + * @version 1.0 + * @since Oct 4, 2004 + */ +public class PortletTitleTag extends TagSupport { + + + public int doStartTag() + throws JspException { + PortletTag parent = + (PortletTag) TagSupport + .findAncestorWithClass(this, PortletTag.class); + + if (parent == null) { + throw new JspException( + "Portlet Window Controls may only reside within a pluto:portlet tag."); + } + + try { + pageContext.getOut().print( + pageContext.getRequest().getAttribute( + "org.apache.pluto.dynamic_title")); + } catch (IOException io) { + throw new JspException(io); + } + return SKIP_BODY; + } +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletWindowControlTag.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletWindowControlTag.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletWindowControlTag.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletWindowControlTag.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,92 @@ +/* + * Copyright 2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.pluto.driver.tags; + +import java.io.IOException; + +import javax.portlet.PortletMode; +import javax.portlet.WindowState; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.BodyTagSupport; +import javax.servlet.jsp.tagext.TagSupport; + +import org.apache.pluto.driver.core.PortalURL; +import org.apache.pluto.driver.core.PortalUrlFactory; + +/** + * @author David H. DeWolf + * @version 1.0 + * @since Oct 4, 2004 + */ +public class PortletWindowControlTag extends BodyTagSupport { + + private String windowState; + private String portletMode; + + public int doStartTag() + throws JspException { + PortletTag parent = + (PortletTag) TagSupport + .findAncestorWithClass(this, PortletTag.class); + + if (parent == null) { + throw new JspException( + "Portlet Window Controls may only reside within a pluto:portlet tag."); + } + + String id = parent.getEvaluatedPortletId(); + HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); + PortalURL url = PortalUrlFactory.getFactory().createPortalUrl(req); + + if (windowState != null) { + WindowState state = new WindowState(windowState); + url.setWindowState(id, state); + } + + if (portletMode != null) { + PortletMode mode = new PortletMode(portletMode); + url.setPortletMode(id, mode); + } + + try { + pageContext.getOut().print(url.toString()); + } catch (IOException io) { + throw new JspException(io); + } + + return EVAL_BODY_INCLUDE; + } + + public String getWindowState() { + return windowState; + } + + public void setWindowState(String windowState) { + this.windowState = windowState; + } + + public String getPortletMode() { + return portletMode; + } + + public void setPortletMode(String portletMode) { + this.portletMode = portletMode; + } + + +} + Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java Fri Sep 2 21:23:31 2005 @@ -0,0 +1,96 @@ +/* + * Copyright 2003,2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + + */ + +package org.apache.pluto.driver.util; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +/** + * * Wraps around the internal Object IDs. By holding both * the string and the + * integer version of an Object ID this class * helps speed up the internal + * processing. + */ + +public class ObjectIdImpl implements org.apache.pluto.om.ObjectID, + java.io.Serializable { + + private String stringOID = null; + private int intOID; + + private ObjectIdImpl(int oid, String stringOID) { + this.stringOID = stringOID; + intOID = oid; + } + + // internal methods. + + private void readObject(ObjectInputStream stream) throws IOException { + intOID = stream.readInt(); + + stringOID = String.valueOf(intOID); + } + + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.write(intOID); + } + + + // addtional methods. + + public boolean equals(Object object) { + boolean result = false; + + if (object instanceof ObjectIdImpl) { + result = (intOID == ((ObjectIdImpl) object).intOID); + } else if (object instanceof String) { + result = stringOID.equals(object); + } else if (object instanceof Integer) { + result = (intOID == ((Integer) object).intValue()); + } + return (result); + } + + public int hashCode() { + return (intOID); + } + + public String toString() { + return (stringOID); + } + + public int intValue() { + return (intOID); + } + + static public ObjectIdImpl createFromString(String idStr) { + char[] id = idStr.toCharArray(); + int _id = 1; + for (int i = 0; i < id.length; i++) { + if ((i % 2) == 0) { + _id *= id[i]; + } else { + _id ^= id[i]; + } + _id = Math.abs(_id); + } + return new ObjectIdImpl(_id, idStr); + } +} Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/resources/pluto-portal-driver-config.xsd URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/resources/pluto-portal-driver-config.xsd?rev=267416&view=auto ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/resources/pluto-portal-driver-config.xsd (added) +++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/resources/pluto-portal-driver-config.xsd Fri Sep 2 21:23:31 2005 @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Modified: portals/pluto/branches/pluto-1.1/pluto-portal/pom.xml URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal/pom.xml?rev=267416&r1=267415&r2=267416&view=diff ============================================================================== --- portals/pluto/branches/pluto-1.1/pluto-portal/pom.xml (original) +++ portals/pluto/branches/pluto-1.1/pluto-portal/pom.xml Fri Sep 2 21:23:31 2005 @@ -13,68 +13,8 @@ org.apache.pluto - pluto-descriptor-api + pluto-portal-driver ${pom.version} - provided - - - org.apache.pluto - pluto-container - ${pom.version} - provided - - - commons-logging - commons-logging-api - 1.0.4 - provided - - - commons-logging - commons-logging - 1.0.4 - test - - - commons-digester - commons-digester - 1.7 - compile - - - junit - junit - 3.8.1 - test - - - portlet-api - portlet-api - 1.0 - provided - - - servletapi - servletapi - 2.3 - provided - - - jstl - jstl - 1.1.2 - compile - - - taglibs - standard - 1.0.4 - compile - - - spring - spring-core - 1.0.2 compile Modified: portals/pluto/branches/pluto-1.1/pom.xml URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pom.xml?rev=267416&r1=267415&r2=267416&view=diff ============================================================================== --- portals/pluto/branches/pluto-1.1/pom.xml (original) +++ portals/pluto/branches/pluto-1.1/pom.xml Fri Sep 2 21:23:31 2005 @@ -97,6 +97,7 @@ pluto-deploy pluto-container pluto-util + pluto-portal-driver pluto-portal pluto-site pluto-testsuite