You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by dd...@apache.org on 2005/09/03 06:23:52 UTC
svn commit: r267416 [1/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/...
Author: ddewolf
Date: Fri Sep 2 21:23:31 2005
New Revision: 267416
URL: http://svn.apache.org/viewcvs?rev=267416&view=rev
Log:
Seperating pluto-portal from pluto-portal-driver.
Added:
portals/pluto/branches/pluto-1.1/pluto-portal-driver/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/pom.xml
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/assemble/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/assemble/bin.xml
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/AttributeKeys.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationService.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PortletRegistryService.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PropertyConfigService.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/RenderConfigService.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalURL.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlFactory.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParameter.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/ContainerServicesImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/DynamicInformationProviderImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalCallbackProviderImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortalContextImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferenceImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletPreferencesProviderImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PortletURLProviderImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/container/PropertyManagerProviderImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/Configuration.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ConfigurationFactory.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PageConfig.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletApplicationConfig.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/PortletWindowConfig.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/RenderConfig.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/resource/ResourceServicesImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletRenderTag.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTag.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletTitleTag.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletWindowControlTag.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/util/ObjectIdImpl.java
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/resources/
portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/resources/pluto-portal-driver-config.xsd
Removed:
portals/pluto/branches/pluto-1.1/pluto-portal/src/main/java/
portals/pluto/branches/pluto-1.1/pluto-portal/src/main/resources/pluto-portal-driver-config.xsd
Modified:
portals/pluto/branches/pluto-1.1/pluto-portal/pom.xml
portals/pluto/branches/pluto-1.1/pom.xml
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/pom.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/pom.xml?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/pom.xml (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/pom.xml Fri Sep 2 21:23:31 2005
@@ -0,0 +1,88 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto-portal-driver</artifactId>
+ <packaging>jar</packaging>
+ <name>Pluto Portal Driver</name>
+ <url>http://portals.apache.org/pluto</url>
+ <parent>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>pluto-container</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>1.0.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.7</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>portlet-api</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>servletapi</groupId>
+ <artifactId>servletapi</artifactId>
+ <version>2.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jstl</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.1.2</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.0.4</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>spring</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>1.0.2</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>pluto-portal</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptor>src/assemble/bin.xml</descriptor>
+ <finalName>pluto-portal-${pom.version}</finalName>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+</project>
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/assemble/bin.xml
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/assemble/bin.xml?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/assemble/bin.xml (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/assemble/bin.xml Fri Sep 2 21:23:31 2005
@@ -0,0 +1,28 @@
+<assembly>
+ <id>bin</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>tar.bz2</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <includes>
+ <include>README*</include>
+ <include>LICENSE*</include>
+ <include>NOTICE*</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+ <dependencySets>
+
+ </dependencySets>
+</assembly>
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/AttributeKeys.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/AttributeKeys.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/AttributeKeys.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/AttributeKeys.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,50 @@
+/*
+ * 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;
+
+/**
+ * Constants used as attribute keys.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 25, 2004
+ */
+public class AttributeKeys {
+
+ private AttributeKeys() {
+ }
+
+ /**
+ * Attribute Key used to bind the applications driver config to the
+ * ServletContext.
+ */
+ public static final String DRIVER_CONFIG = "driverConfig";
+
+ /**
+ * Attribute Key used to bind the application's portlet container to the
+ * ServletContext.
+ */
+ public static final String PORTLET_CONTAINER = "portletContainer";
+
+
+ /**
+ * Attribute Key used to bind the current page to the request.
+ */
+ public static final String CURRENT_PAGE = "currentPage";
+
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalDriverServlet.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,145 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.core.PortalEnvironment;
+import org.apache.pluto.driver.core.PortalURL;
+import org.apache.pluto.driver.core.PortletWindowImpl;
+import org.apache.pluto.driver.services.impl.resource.PageConfig;
+import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig;
+
+import javax.portlet.PortletException;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * The controller servlet used to drive the Portal Driver. All requests mapped
+ * to this servlet will be processed as Portal Requests.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 22, 2004
+ */
+public class PortalDriverServlet extends HttpServlet {
+
+ /** Internal Logger. */
+ private static final Log LOG = LogFactory.getLog(PortalDriverServlet.class);
+
+ /**
+ * The portlet container to which we will forward all portlet requests.
+ */
+ protected PortletContainer container;
+
+ /**
+ * The driver configuration defining our configuraiton.
+ */
+ protected DriverConfiguration driverConfig;
+
+ /**
+ * Initialize the Portal Driver. Initialization completes the following
+ * tasks: <ul><li>Retrieve and Cache the <code>PortletContainer</code></li>
+ * <li>Retrieve and Cache the <code>DriverConfigurationImpl</code></li>
+ * @see PortletContainer
+ * @see org.apache.pluto.driver.config.impl.DriverConfigurationImpl
+ */
+ public void init() {
+ ServletContext ctx = getServletContext();
+
+ String key = AttributeKeys.PORTLET_CONTAINER;
+ container = (PortletContainer) ctx.getAttribute(key);
+
+ key = AttributeKeys.DRIVER_CONFIG;
+ driverConfig = (DriverConfiguration) ctx.getAttribute(key);
+ }
+
+ /**
+ * Handle all requests.
+ * @param req the HttpServletRequest
+ * @param res the HttpServletResponse
+ * @throws ServletException if an internal error occurs.
+ * @throws IOException if an error occurs writing to the response.
+ */
+ public void doGet(HttpServletRequest req,
+ HttpServletResponse res)
+ throws ServletException, IOException {
+
+ PortalEnvironment env = new PortalEnvironment(req, res);
+
+ PortalURL currentURL = env.getRequestedPortalURL();
+
+ String actionWindowId = currentURL.getActionWindow();
+ PortletWindowConfig winConfig =
+ driverConfig.getPortletWindowConfig(actionWindowId);
+
+ // Window will only exist if there's an action;
+ if (winConfig != null) {
+ PortletWindowImpl window = new PortletWindowImpl(winConfig,
+ currentURL);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Window Found: " + window.getId());
+ }
+ try {
+ container.doAction(window, req, res);
+
+ } catch (PortletContainerException exc) {
+ throw new ServletException(exc);
+ } catch (PortletException exc) {
+ throw new ServletException(exc);
+ }
+ } else {
+ PageConfig page = getPageConfig(currentURL);
+ req.setAttribute(AttributeKeys.CURRENT_PAGE, page);
+ String uri = page.getUri();
+ RequestDispatcher disp = req.getRequestDispatcher(uri);
+ disp.forward(req, res);
+ }
+ }
+
+ protected PageConfig getPageConfig(PortalURL currentURL) {
+ String currentPage = currentURL.getRenderPath();
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Rendering Portal: Requested Page: " + currentPage);
+ }
+
+ return driverConfig.getPageConfig(currentPage);
+ }
+
+
+ /**
+ * Pass all requests on to {@link #doPost(HttpServletRequest, HttpServletResponse)}.
+ * @param req the request
+ * @param res the response
+ * @throws ServletException if an exception occurs.
+ * @throws IOException if an exception occurs writing to the response.
+ */
+ public void doPost(HttpServletRequest req,
+ HttpServletResponse res)
+ throws ServletException, IOException {
+ doGet(req, res);
+ }
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/PortalStartupListener.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,153 @@
+/*
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.PortletContainerFactory;
+import org.apache.pluto.driver.config.DriverConfigurationException;
+import org.apache.pluto.driver.config.DriverConfigurationFactory;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.services.container.ContainerServicesImpl;
+import org.apache.pluto.driver.services.container.PortalContextImpl;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * Listener used to start up the Pluto Portal Driver upon
+ * startup of the servlet context in which it resides.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 22, 2004
+ */
+public class PortalStartupListener implements ServletContextListener {
+ /** Internal Logger. */
+ private static final Log LOG =
+ LogFactory.getLog(PortalStartupListener.class);
+
+ /** The location of the portal driver configuration. */
+
+ /** The KEY with which the container is bound to the context. */
+ private static final String CONTAINER_KEY = AttributeKeys.PORTLET_CONTAINER;
+
+ /** The KEY with which the configuration is bound to the context. */
+ private static final String CONFIG_KEY = AttributeKeys.DRIVER_CONFIG;
+
+
+ /**
+ * Receive the startup notification and subsequently start up
+ * the portal driver. The following are done in this order:
+ * <ol><li>Retrieve the Configuration File</li>
+ * <li>Parse the Configuration File into Configuration Objects</li>
+ * <li>Create a Portal Context</li>
+ * <li>Create the ContainerServices implementation</li>
+ * <li>Create the Portlet Container</li>
+ * <li>Initialize the Container</li>
+ * <li>Bind the configuration to the ServletContext</li>
+ * <li>Bind the container to the ServletContext</li><ul>
+ *
+ * @param event the servlet context event.
+ */
+ public void contextInitialized(ServletContextEvent event) {
+ ServletContext ctx = event.getServletContext();
+ try {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Starting Pluto Portal Driver . . .");
+ LOG.debug(" - Retreaving Driver Configuration . . .");
+ }
+
+ DriverConfiguration config =
+ DriverConfigurationFactory.getFactory().getConfig(ctx);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(
+ " - Creating Portal Context [" + config.getPortalName() +
+ "/" +
+ config.getPortalVersion() +
+ "]. . .");
+ }
+
+ PortalContextImpl context = new PortalContextImpl(config);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" - Creating Container Services. . .");
+ }
+
+ ContainerServicesImpl impl = new ContainerServicesImpl(context);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" - Creating Portlet Container. . .");
+ }
+
+ PortletContainerFactory factory = PortletContainerFactory.getInstance();
+ PortletContainer container =
+ factory.createContainer(
+ config.getContainerName(),
+ impl
+ );
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" - Starting Portlet Container");
+ }
+
+ container.init(ctx);
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" Pluto Portal Driver Started.");
+ }
+
+ ctx.setAttribute(CONFIG_KEY, config);
+ ctx.setAttribute(CONTAINER_KEY, container);
+
+ } catch (DriverConfigurationException exception) {
+ LOG.error(
+ "Unable to retrieve driver configuration due to configuration error.",
+ exception
+ );
+ } catch (PortletContainerException exception) {
+ LOG.error(
+ "Unable to start portlet container due to configuration error.",
+ exception
+ );
+ }
+ }
+
+ /**
+ * Recieve notification that the context is being shut down
+ * and subsequently destroy the container.
+ *
+ * @param event the destrubtion even.t
+ */
+ public void contextDestroyed(ServletContextEvent event) {
+ ServletContext ctx = event.getServletContext();
+ PortletContainer container =
+ (PortletContainer) ctx.getAttribute(CONTAINER_KEY);
+
+ try {
+ container.destroy();
+ } catch (PortletContainerException exc) {
+ LOG.error("Unable to shutdown portlet container. ", exc);
+ } finally {
+ ctx.removeAttribute(CONTAINER_KEY);
+ }
+ }
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfiguration.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.config;
+
+import org.apache.pluto.driver.services.impl.resource.PortletApplicationConfig;
+import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig;
+import org.apache.pluto.driver.services.impl.resource.PageConfig;
+
+import javax.servlet.ServletContext;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @todo Document
+ * @since Sep 2, 2005
+ */
+public interface DriverConfiguration {
+
+ /**
+ * Initialization method used to place the driver
+ * configuration into service.
+ *
+ * @param context
+ */
+ void init(ServletContext context);
+
+ String getPortalName();
+
+ String getPortalVersion();
+
+ String getContainerName();
+
+ Collection getSupportedPortletModes();
+
+ Collection getSupportedWindowStates();
+
+ Collection getPortletApplications();
+
+ PortletApplicationConfig getPortletApp(String id);
+
+ PortletWindowConfig getPortletWindowConfig(String id);
+
+ Collection getPages();
+
+ PageConfig getPageConfig(String pageId);
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,39 @@
+/*
+ * 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.config;
+
+/**
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @todo Document
+ * @since Aug 10, 2005
+ */
+public class DriverConfigurationException extends RuntimeException {
+
+ public DriverConfigurationException() {
+ }
+
+ public DriverConfigurationException(String message) {
+ super(message);
+ }
+
+ public DriverConfigurationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public DriverConfigurationException(Throwable cause) {
+ super(cause);
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationFactory.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,78 @@
+/*
+ * 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.config;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+
+import javax.servlet.ServletContext;
+import java.io.InputStream;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 23, 2004
+ */
+public class DriverConfigurationFactory {
+
+ private static final Log LOG =
+ LogFactory.getLog(DriverConfigurationFactory.class);
+
+ private static final String DRIVER_CONFIG =
+ "/WEB-INF/pluto-portal-driver-services-config.xml";
+
+
+ private static DriverConfigurationFactory factory;
+
+ public static DriverConfigurationFactory getFactory() {
+ if (factory == null) {
+ factory = new DriverConfigurationFactory();
+ }
+ return factory;
+ }
+
+ private DriverConfigurationFactory() {
+
+ }
+
+ public DriverConfiguration getConfig(ServletContext context) {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Retrieving driver configuration from: "+DRIVER_CONFIG);
+ }
+
+ InputStream in =
+ context.getResourceAsStream(DRIVER_CONFIG);
+
+ XmlBeanFactory beanFactory = new XmlBeanFactory(in);
+
+ DriverConfiguration configuration = (DriverConfiguration)
+ beanFactory.getBean("DriverConfiguration");
+
+ configuration.init(context);
+
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug(
+ "Driver Configuration of type "+configuration.getClass() +
+ " Initialized and Ready For Service"
+ );
+ }
+
+ return configuration;
+ }
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationImpl.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,131 @@
+/*
+ * 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.config.impl;
+
+import org.apache.pluto.driver.services.impl.resource.PortletApplicationConfig;
+import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig;
+import org.apache.pluto.driver.services.impl.resource.PageConfig;
+import org.apache.pluto.driver.config.DriverConfiguration;
+
+import javax.servlet.ServletContext;
+import java.util.Collection;
+
+/**
+ * Encapsulation of the Pluto Driver Configuration.
+ *
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 23, 2004
+ */
+public class DriverConfigurationImpl implements DriverConfiguration {
+
+ private PropertyConfigService propertyService;
+ private PortletRegistryService registryService;
+ private RenderConfigService renderService;
+
+ public DriverConfigurationImpl(PropertyConfigService propertyService,
+ PortletRegistryService registryService,
+ RenderConfigService renderService) {
+ this.propertyService = propertyService;
+ this.registryService = registryService;
+ this.renderService = renderService;
+ }
+
+ /**
+ * Standard Getter.
+ * @return the name of the portal.
+ */
+ public String getPortalName() {
+ return propertyService.getPortalName();
+ }
+
+ /**
+ * Standard Getter.
+ * @return the portal version.
+ */
+ public String getPortalVersion() {
+ return propertyService.getPortalVersion();
+ }
+
+ /**
+ * Standard Getter.
+ * @return the name of the container.
+ */
+ public String getContainerName() {
+ return propertyService.getContainerName();
+ }
+
+ /**
+ * Standard Getter.
+ * @return the names of the supported portlet modes.
+ */
+ public Collection getSupportedPortletModes() {
+ return propertyService.getSupportedPortletModes();
+ }
+
+ /**
+ * Standard Getter.
+ * @return the names of the supported window states.
+ */
+ public Collection getSupportedWindowStates() {
+ return propertyService.getSupportedWindowStates();
+ }
+
+ /**
+ * Standard Getter.
+ * @return the configuration data of all configured portlet applications.
+ */
+ public Collection getPortletApplications() {
+ return registryService.getPortletApplications();
+ }
+
+ /**
+ * 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 registryService.getPortletApplication(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) {
+ return registryService.getPortlet(id);
+ }
+
+ /**
+ * Standard Getter.
+ * @return the render configuration.
+ */
+ public Collection getPages() {
+ return renderService.getPages();
+ }
+
+ public PageConfig getPageConfig(String pageId) {
+ return renderService.getPage(pageId);
+ }
+
+ public void init(ServletContext context) {
+ this.propertyService.init(context);
+ this.registryService.init(context);
+ this.renderService.init(context);
+ }
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationService.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationService.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationService.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/DriverConfigurationService.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,47 @@
+/*
+ * 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.config.impl;
+
+import org.apache.pluto.driver.config.DriverConfigurationException;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Abstract interface defining lifecycle methods for
+ * Driver configuration services.
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @since Aug 10, 2005
+ */
+public interface DriverConfigurationService {
+
+ /**
+ * Initialize the service for use by the driver.
+ * This method allows the service to retrieve required
+ * resources from the context and instantiate any required
+ * services.
+ *
+ * @param ctx the Portal's servlet context in which the
+ * service will be executing.
+ *
+ */
+ void init(ServletContext ctx) throws DriverConfigurationException;
+
+ /**
+ * Destroy the service, notifying it of shutdown.
+ */
+ void destroy() throws DriverConfigurationException;
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PortletRegistryService.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PortletRegistryService.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PortletRegistryService.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PortletRegistryService.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,55 @@
+/*
+ * 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.config.impl;
+
+import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig;
+import org.apache.pluto.driver.services.impl.resource.PortletApplicationConfig;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @since Aug 10, 2005
+ */
+public interface PortletRegistryService extends DriverConfigurationService {
+
+ /**
+ * A set of all Portlet Applications
+ * @return a set of uniqe PortletAppConfig instances.
+ */
+ Set getPortletApplications();
+
+ /**
+ * Retrieves the PortletAppConfig associated
+ * with the specified id.
+ * @param id the unique id of the portlet application config
+ * @return the PortletAppConfig instance for the specified id.
+ */
+ PortletApplicationConfig getPortletApplication(String id);
+
+ /**
+ * Utility method used to retrieve a portlet
+ * directly from the service to prevent the driver
+ * from needing to navigate the portlet application
+ * object graph.
+ *
+ * @param id the unique id of the portlet being requested.
+ * @return PortletWindowConfig for the specified id.
+ */
+ PortletWindowConfig getPortlet(String id);
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PropertyConfigService.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PropertyConfigService.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PropertyConfigService.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/PropertyConfigService.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,68 @@
+/*
+ * 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.config.impl;
+
+import java.util.Set;
+
+/**
+ * Service interface which defines the methods required
+ * for a provider wishing to provide property management.
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @since Aug 10, 2005
+ */
+public interface PropertyConfigService extends DriverConfigurationService {
+
+ /**
+ * Name of the portal driver.
+ * @return the name of this portal implementation
+ */
+ String getPortalName();
+
+ /**
+ * Portal driver version.
+ * @return version information
+ */
+ String getPortalVersion();
+
+ /**
+ * Unique name of the Portlet Container
+ * used to service this portal instance.
+ * @return container name
+ */
+ String getContainerName();
+
+ /**
+ * Set of unique Portlet Modes.
+ * The set must include
+ * {@link javax.portlet.PortletMode#VIEW},
+ * {@link javax.portlet.PortletMode#EDIT}, and
+ * {@link javax.portlet.PortletMode#HELP}
+ * @return set of unique portlet modes.
+ */
+ Set getSupportedPortletModes();
+
+ /**
+ * Set of unique Window States.
+ * The set must include:
+ * {@link javax.portlet.WindowState#NORMAL},
+ * {@link javax.portlet.WindowState#MAXIMIZED}, and
+ * {@link javax.portlet.WindowState#MINIMIZED}
+ * @return set of unique window states.
+ */
+ Set getSupportedWindowStates();
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/RenderConfigService.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/RenderConfigService.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/RenderConfigService.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/impl/RenderConfigService.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,53 @@
+/*
+ * 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.config.impl;
+
+import org.apache.pluto.driver.services.impl.resource.PageConfig;
+
+import java.util.List;
+
+/**
+ * Service interface defining methods necessary for
+ * a provider wishing to manage page administration.
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @since Aug 10, 2005
+ */
+public interface RenderConfigService extends DriverConfigurationService {
+
+ /**
+ * Retrieve an ordered list of all PageConfig instances.
+ * @return list of all PageConfig instances.
+ */
+ List getPages();
+
+ /**
+ * Retrieve the PageConfig for the default
+ * page.
+ * @return PageConfig instance of the default page.
+ */
+ PageConfig getDefaultPage();
+
+ /**
+ * Retrieve the PageConfig for the given
+ * page id.
+ *
+ * @param id
+ * @return PageConfig instance for the specified id.
+ */
+ PageConfig getPage(String id);
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalEnvironment.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,80 @@
+/*
+ * 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.core;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.pluto.driver.config.DriverConfiguration;
+
+public class PortalEnvironment {
+
+ public final static String REQUEST_PORTALENV = "org.apache.pluto.driver.core.PortalEnvironment";
+
+ private HttpServletRequest request;
+ private HttpServletResponse response;
+ private DriverConfiguration driverConfig;
+
+
+ private PortalURL requestedPortalURL;
+
+ public PortalEnvironment(HttpServletRequest request,
+ HttpServletResponse response) {
+ this.request = request;
+ this.response = response;
+ init();
+
+
+ }
+
+ private void init() {
+
+ requestedPortalURL =
+ PortalUrlFactory.getFactory().createPortalUrl(request);
+
+
+ // set Environment in Request for later use
+ this.request.setAttribute(REQUEST_PORTALENV, this);
+ }
+
+
+ public static PortalEnvironment getPortalEnvironment(
+ HttpServletRequest request) {
+ return (PortalEnvironment) request.getAttribute(REQUEST_PORTALENV);
+ }
+
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+
+ public HttpServletResponse getResponse() {
+ return response;
+ }
+
+/*
+ public List getNavigationalInformation()
+ {
+ return navigationalInformation;
+ }
+*/
+ public PortalURL getRequestedPortalURL() {
+ return requestedPortalURL;
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,130 @@
+/*
+ * 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.core;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.pluto.PortletWindow;
+
+public class PortalServletRequest extends HttpServletRequestWrapper {
+
+ private PortletWindow portletWindow = null;
+
+ private PortalURL url;
+ private Map portletParameters;
+
+ public PortalServletRequest(HttpServletRequest request,
+ PortletWindow window) {
+ super(request);
+ this.portletWindow = window;
+
+ url =
+ PortalEnvironment.getPortalEnvironment(request).getRequestedPortalURL();
+ }
+
+
+// HttpServletRequestWrapper overlay
+
+ public java.lang.String getContentType() {
+ String contentType = super.getContentType();
+ return contentType;
+ }
+
+// ServletRequestWrapper overlay
+
+ public String getParameter(String name) {
+ String[] values = (String[]) this.getParameterMap().get(name);
+ if (values != null) {
+ return values[0];
+ }
+ return null;
+ }
+
+ /**
+ * Retreive the Parameters.
+ * @return Map of parameters targeted to the window associated with this
+ * request.
+ */
+ public Map getParameterMap() {
+ if (portletParameters == null) {
+ initParameterMap();
+ }
+ return Collections.unmodifiableMap(portletParameters);
+ }
+
+ /**
+ * Initialize parameters for this request. We must be careful to make sure
+ * that render parameters are only made available if they were targeted for
+ * this specific window.
+ */
+ private void initParameterMap() {
+ portletParameters = new HashMap();
+
+ Iterator iterator = url.getParameters().iterator();
+ while (iterator.hasNext()) {
+ PortalUrlParameter param = (PortalUrlParameter) iterator.next();
+ String name = param.getName();
+ String[] values = param.getValues();
+ if (param.getWindowId().equals(portletWindow.getId().toString())) {
+ portletParameters.put(name, values);
+ }
+ }
+
+ String id = portletWindow.getId().toString();
+ if (portletWindow.getId().toString().equals(id)) {
+ Enumeration params = super.getParameterNames();
+ while (params.hasMoreElements()) {
+ String name = params.nextElement().toString();
+ String[] values = super.getParameterValues(name);
+ if (portletParameters.containsKey(name)) {
+ String[] temp = (String[]) portletParameters.get(name);
+ String[] all = new String[values.length + temp.length];
+ System.arraycopy(values, 0, all, 0, values.length);
+ System.arraycopy(temp, 0, all, values.length, temp.length);
+ }
+ portletParameters.put(name, values);
+ }
+ }
+ }
+
+ /**
+ * Get an enumeration which contains each of the names for which parameters
+ * exist.
+ * @return an enumeration of all names bound as parameters.
+ */
+ public Enumeration getParameterNames() {
+ return Collections.enumeration(getParameterMap().keySet());
+ }
+
+ /**
+ * Get the values associated with the given parameter key.
+ * @param name the Parameter name used to key the parameter.
+ * @return a String[] of all values bound to the given name as a parameter.
+ */
+ public String[] getParameterValues(String name) {
+ return (String[]) getParameterMap().get(name);
+ }
+
+}
+
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,59 @@
+/*
+ * 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.core;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.servlet.http.HttpServletResponse;
+
+public class PortalServletResponse
+ extends javax.servlet.http.HttpServletResponseWrapper {
+
+ private StringWriter buffer = null;
+ private PrintWriter writer = null;
+ private String contentType = "text/html";
+
+ public PortalServletResponse(HttpServletResponse response) {
+ super(response);
+ buffer = new StringWriter();
+ writer = new PrintWriter(buffer);
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public PrintWriter getWriter() {
+ return writer;
+ }
+
+ public StringWriter getInternalBuffer() {
+ return buffer;
+ }
+
+ public PrintWriter getInternalResponseWriter()
+ throws IOException {
+ return super.getWriter();
+ }
+
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalURL.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalURL.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalURL.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalURL.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,176 @@
+/*
+ * 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.core;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import java.util.*;
+
+public class PortalURL implements Cloneable {
+
+ private static final Log LOG = LogFactory.getLog(PortalURL.class);
+
+ /**
+ * The baseURL consists of the URI up to the servlet path. The dynamic
+ * portion of the PortalURL is the pathInfo;
+ */
+ private StringBuffer server;
+ private StringBuffer servletPath;
+ private String renderPath;
+ private String actionWindow;
+
+ private Map windowStates;
+ private Map portletModes;
+ private Map parameters;
+
+ public PortalURL(String protocol, String server) {
+ this.server = new StringBuffer();
+ this.server.append(protocol).append(server);
+ this.parameters = new java.util.HashMap();
+ this.windowStates = new java.util.HashMap();
+ this.portletModes = new java.util.HashMap();
+ }
+
+ private PortalURL() {
+
+ }
+
+ public PortalURL(String protocol, String server, int port) {
+ this(protocol, server);
+ this.server.append(":").append(port);
+ }
+
+ public PortalURL(String protocol, String server, String contextPath,
+ String servletPath) {
+ this(protocol, server);
+ setControllerPath(contextPath, servletPath);
+ }
+
+ public PortalURL(String protocol, String server, int port,
+ String contextPath, String servletPath) {
+ this(protocol, server, port);
+ setControllerPath(contextPath, servletPath);
+ }
+
+ public void setControllerPath(String context, String servletPath) {
+ this.servletPath = new StringBuffer();
+ this.servletPath = this.servletPath.append(context).append(servletPath);
+ }
+
+ // BasePortalURL
+ public void setRenderPath(String renderPath) {
+ this.renderPath = renderPath;
+ }
+
+ public String getRenderPath() {
+ return renderPath;
+ }
+
+ public void addParameter(PortalUrlParameter param) {
+ parameters.put(param.getWindowId() + param.getName(), param);
+ }
+
+ public Collection getParameters() {
+ return parameters.values();
+ }
+
+ public void setActionWindow(String window) {
+ this.actionWindow = window;
+ }
+
+ public String getActionWindow() {
+ return actionWindow;
+ }
+
+ public Map getPortletModes() {
+ return Collections.unmodifiableMap(portletModes);
+ }
+
+ public PortletMode getPortletMode(String windowId) {
+ PortletMode mode = (PortletMode) portletModes.get(windowId);
+ if (mode == null) {
+ mode = PortletMode.VIEW;
+ }
+ return mode;
+ }
+
+ public void setPortletMode(String windowId, PortletMode portletMode) {
+ this.portletModes.put(windowId, portletMode);
+ }
+
+ public Map getWindowStates() {
+ return Collections.unmodifiableMap(windowStates);
+ }
+
+ public WindowState getWindowState(String windowId) {
+ WindowState state = (WindowState) windowStates.get(windowId);
+ if (state == null) {
+ state = WindowState.NORMAL;
+ }
+ return state;
+ }
+
+ public void setWindowState(String windowId, WindowState windowState) {
+ this.windowStates.put(windowId, windowState);
+ }
+
+ public void clearParameters(String window) {
+ Iterator it = parameters.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry) it.next();
+ if (((PortalUrlParameter) entry.getValue()).getWindowId().equals(
+ window)) {
+ it.remove();
+ }
+ }
+ }
+
+ public String toString() {
+ return PortalUrlParser.getParser().toString(this);
+ }
+
+
+ /**
+ * Retrieve the server uri, (protocol, name, port).
+ * @return the server uri portion of the url.
+ */
+ public String getServerUri() {
+ return server.toString();
+ }
+
+ public String getControllerPath() {
+ return servletPath.toString();
+ }
+
+ public Object clone() {
+ PortalURL url = new PortalURL();
+ url.portletModes = new HashMap(portletModes);
+ url.windowStates = new HashMap(windowStates);
+ url.parameters = new HashMap(parameters);
+ url.server = new StringBuffer(server.toString());
+ url.servletPath = new StringBuffer(servletPath.toString());
+ url.renderPath = renderPath;
+ url.actionWindow = actionWindow;
+ return url;
+ }
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlFactory.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlFactory.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlFactory.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlFactory.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,31 @@
+package org.apache.pluto.driver.core;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ */
+public class PortalUrlFactory {
+
+ private static final String KEY = PortalURL.class.getName();
+
+ private static PortalUrlFactory factory;
+
+ public static PortalUrlFactory getFactory() {
+ if (factory == null) {
+ factory = new PortalUrlFactory();
+ }
+ return factory;
+ }
+
+ public PortalURL createPortalUrl(HttpServletRequest req) {
+ if (req.getAttribute(KEY) == null) {
+ PortalURL gnew = PortalUrlParser.getParser().parse(req);
+ req.setAttribute(KEY, gnew);
+ }
+
+ PortalURL url = (PortalURL) req.getAttribute(KEY);
+ return (PortalURL) url.clone();
+ }
+
+}
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParameter.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParameter.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParameter.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParameter.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,63 @@
+/*
+ * 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.core;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 30, 2004
+ */
+public class PortalUrlParameter {
+
+
+ private String window;
+ private String name;
+ private String[] values;
+
+ public PortalUrlParameter(String window, String name, String value) {
+ this.window = window;
+ this.name = name;
+ this.values = new String[]{value};
+ }
+
+ public PortalUrlParameter(String window, String name, String[] values) {
+ this.window = window;
+ this.name = name;
+ this.values = values;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String[] getValues() {
+ return values;
+ }
+
+ public void setValues(String[] values) {
+ this.values = values;
+ }
+
+ public String getWindowId() {
+ return window;
+ }
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalUrlParser.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,262 @@
+/*
+ * 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.core;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.pluto.util.StringUtils;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ * @version 1.0
+ * @since Sep 30, 2004
+ */
+class PortalUrlParser {
+
+ private static PortalUrlParser parser;
+
+
+ public static PortalUrlParser getParser() {
+ if (parser == null) {
+ parser = new PortalUrlParser();
+ }
+ return parser;
+ }
+
+ public PortalURL parse(HttpServletRequest req) {
+
+ String protocol = req.isSecure() ? "https://" : "http://";
+ String server = req.getServerName();
+ int port = req.getServerPort();
+
+ PortalURL url;
+ if ((req.isSecure() && port != 443) ||
+ (!req.isSecure() && port != 80)) {
+ url = new PortalURL(protocol, server, port);
+ } else {
+ url = new PortalURL(protocol, server);
+ }
+
+ url.setControllerPath(req.getContextPath(), req.getServletPath());
+
+ StringBuffer renderPath = new StringBuffer();
+ if (req.getPathInfo() == null) {
+ return url;
+ }
+ StringTokenizer st = new StringTokenizer(req.getPathInfo(), "/", false);
+
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+
+ // render path
+ if (!token.startsWith(PREFIX)) {
+ renderPath.append(token);
+ } else if (token.startsWith(PREFIX + ACTION)) {
+ url.setActionWindow(decode(token)[0]);
+ } else if (token.startsWith(PREFIX + WINDOW_STATE)) {
+ String[] decoded = decode(token);
+ url.setWindowState(decoded[0], new WindowState(decoded[1]));
+ } else if (token.startsWith(PREFIX + PORTLET_MODE)) {
+ String[] decoded = decode(token);
+ url.setPortletMode(decoded[0], new PortletMode(decoded[1]));
+ } else {
+ String value = null;
+ if (st.hasMoreTokens()) {
+ value = st.nextToken();
+ }
+ url.addParameter(decode(token, value));
+ }
+ }
+
+ if (renderPath.length() > 0) {
+ url.setRenderPath(renderPath.toString());
+ }
+
+ return url;
+ }
+
+ public String toString(PortalURL url) {
+ StringBuffer sb = new StringBuffer();
+ // 1) The Servlet Path
+ sb.append(url.getServerUri()).append(url.getControllerPath());
+
+ // 2) Start the PathInfo with the Path to the Render URL (Page).
+ if (url.getRenderPath() != null) {
+ sb.append("/");
+ sb.append(url.getRenderPath());
+ }
+
+ // 3) Add the action window, if it exists
+ if (url.getActionWindow() != null) {
+ sb.append("/");
+ sb.append(PREFIX).append(ACTION).append(encode(url.getActionWindow()));
+ }
+
+ Iterator it = url.getPortletModes().entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry) it.next();
+ sb.append("/").append(
+ encode(PORTLET_MODE, entry.getKey().toString(),
+ entry.getValue().toString()));
+ }
+
+
+ it = url.getWindowStates().entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry) it.next();
+ sb.append("/").append(
+ encode(WINDOW_STATE, entry.getKey().toString(),
+ entry.getValue().toString()));
+ }
+
+ // 4) Add parameters
+ StringBuffer query = new StringBuffer("?");
+
+ it = url.getParameters().iterator();
+ while (it.hasNext()) {
+ PortalUrlParameter param = (PortalUrlParameter) it.next();
+ if (url.getActionWindow() != null &&
+ url.getActionWindow().equals(param.getWindowId())) {
+ query.append("&").append(param.getName()).append("=").append(
+ convert(param.getValues()));
+ } else if (param.getValues() != null &&
+ param.getValues().length > 0) {
+ String valueString = encode(param.getValues());
+ if (valueString.length() > 0) {
+ sb.append("/").append(
+ encode(RENDER_PARAM, param.getWindowId(),
+ param.getName()));
+ sb.append("/").append(valueString);
+ }
+ }
+ }
+
+ // 5) Add local nav
+
+ return sb.append(query).toString();
+ }
+
+ private static final String PREFIX = "__";
+ private static final String DELIM = "_";
+ private static final String PORTLET_ID = "pd";
+ private static final String ACTION = "ac";
+ private static final String RENDER_PARAM = "rp";
+ private static final String WINDOW_STATE = "ws";
+ private static final String PORTLET_MODE = "pm";
+
+ private static final String[][] ENCODINGS =
+ new String[][]{
+ new String[]{"_", "0x1"},
+ new String[]{".", "0x2"},
+ new String[]{"/", "0x3"},
+ new String[]{"\r", "0x4"},
+ new String[]{"\n", "0x5"},
+ new String[]{"<", "0x6"},
+ new String[]{">", "0x7"},
+ new String[]{" ", "0x8"}
+ };
+
+ private String encode(String type, String windowId, String name) {
+ return PREFIX + type + encode(windowId) + DELIM + name;
+ }
+
+ private String encode(String[] values) {
+ String value = "";
+ for (int i = 0; i < values.length; i++) {
+ value += values[i]==null?"":values[i];
+ if (i + 1 != values.length) {
+ value += ",";
+ }
+ }
+ for (int i = 0; i < ENCODINGS.length; i++) {
+ value =
+ StringUtils.replace(value, ENCODINGS[i][0], ENCODINGS[i][1]);
+ }
+ return value;
+ }
+
+ /**
+ * Parse a control parameter into the porlet which it effects and it's
+ * original value.
+ * @param ctl
+ * @return
+ */
+ private String[] decode(String ctl) {
+ int length = (PREFIX + PORTLET_ID).length();
+ ctl = ctl.substring(length);
+ String[] vals = new String[2];
+ if (ctl.indexOf(DELIM) > -1) {
+ vals[0] = ctl.substring(0, ctl.indexOf(DELIM));
+ vals[1] = ctl.substring(ctl.indexOf(DELIM) + 1);
+ for (int i = 0; i < ENCODINGS.length; i++) {
+ vals[0] =
+ StringUtils.replace(vals[0], ENCODINGS[i][1], ENCODINGS[i][0]);
+ vals[1] =
+ StringUtils.replace(vals[1], ENCODINGS[i][1], ENCODINGS[i][0]);
+ }
+ } else {
+ vals[0] = ctl;
+ for (int i = 0; i < ENCODINGS.length; i++) {
+ vals[0] =
+ StringUtils.replace(vals[0], ENCODINGS[i][1], ENCODINGS[i][0]);
+ }
+ }
+ return vals;
+ }
+
+ private PortalUrlParameter decode(String name, String value) {
+ String nopre = name.substring((PREFIX + PORTLET_ID).length());
+ String windowId = nopre.substring(0, nopre.indexOf(DELIM));
+ String param = nopre.substring(nopre.indexOf(DELIM) + 1);
+
+ for (int i = 0; i < ENCODINGS.length; i++) {
+ windowId =
+ StringUtils.replace(windowId, ENCODINGS[i][1], ENCODINGS[i][0]);
+ if (value != null) {
+ value =
+ StringUtils.replace(value, ENCODINGS[i][1], ENCODINGS[i][0]);
+ }
+ }
+ return new PortalUrlParameter(windowId, param, value);
+ }
+
+ private String encode(String string) {
+ for (int i = 0; i < ENCODINGS.length; i++) {
+ string =
+ StringUtils.replace(string, ENCODINGS[i][0], ENCODINGS[i][1]);
+ }
+ return string;
+ }
+
+ private String convert(String[] strings) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < strings.length; i++) {
+ sb.append(strings[i]);
+ if (i + 1 != strings.length) {
+ sb.append(",");
+ }
+ }
+ return sb.toString();
+ }
+
+}
+
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,63 @@
+/*
+ * 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.core;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.driver.services.impl.resource.PortletWindowConfig;
+import org.apache.pluto.driver.util.ObjectIdImpl;
+import org.apache.pluto.om.ObjectID;
+
+public class PortletWindowImpl implements PortletWindow {
+
+ private PortletWindowConfig config;
+ private PortalURL url;
+ private ObjectIdImpl objectIdImpl;
+
+ public PortletWindowImpl(PortletWindowConfig config, PortalURL url) {
+ this.config = config;
+ this.url = url;
+ }
+
+ public String getContextPath() {
+ return config.getContextPath();
+ }
+
+ public String getPortletName() {
+ return config.getPortletName();
+ }
+
+ public WindowState getWindowState() {
+ return url.getWindowState(getId().toString());
+ }
+
+ public PortletMode getPortletMode() {
+ return url.getPortletMode(getId().toString());
+ }
+
+ public ObjectID getId() {
+ if (objectIdImpl == null) {
+ objectIdImpl = ObjectIdImpl.createFromString(config.getId());
+ }
+ return objectIdImpl;
+ }
+}
\ No newline at end of file
Added: portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java
URL: http://svn.apache.org/viewcvs/portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java?rev=267416&view=auto
==============================================================================
--- portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java (added)
+++ portals/pluto/branches/pluto-1.1/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java Fri Sep 2 21:23:31 2005
@@ -0,0 +1,69 @@
+/*
+ * 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.core;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+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.services.ResourceURLProvider;
+
+public class ResourceURLProviderImpl implements ResourceURLProvider {
+
+ private static final Log LOG =
+ LogFactory.getLog(ResourceURLProviderImpl.class);
+
+ private String stringUrl = "";
+ private String base = "";
+
+ public ResourceURLProviderImpl(HttpServletRequest req,
+ PortletWindow internalPortletWindow) {
+ this.base =
+ PortalUrlFactory.getFactory().createPortalUrl(req).getServerUri();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Resource URL Created with base: " + base);
+ }
+ }
+
+ public void setAbsoluteURL(String path) {
+ stringUrl = path;
+ }
+
+ public void setFullPath(String path) {
+ stringUrl = base + path;
+ }
+
+ public String toString() {
+ URL url = null;
+
+ if (!"".equals(stringUrl)) {
+ try {
+ url = new URL(stringUrl);
+ } catch (MalformedURLException e) {
+ throw new java.lang.IllegalArgumentException(
+ "A malformed URL has occured");
+ }
+ }
+
+ return ((url == null) ? "" : url.toString());
+
+ }
+}