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 cd...@apache.org on 2007/08/04 16:41:49 UTC
svn commit: r562725 [18/33] - in
/portals/pluto/branches/1.1-286-trunk-merge: ./ assembly/ assembly/src/
assembly/src/main/ assembly/src/main/assembly/ assembly/src/main/resources/
maven-pluto-plugin/ maven-pluto-plugin/src/ maven-pluto-plugin/src/main...
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/DriverConfigurationException.java Sat Aug 4 07:41:23 2007
@@ -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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/config/package.html Sat Aug 4 07:41:23 2007
@@ -0,0 +1,22 @@
+<!--
+Copyright 2005-2006 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.
+-->
+<html>
+<body>
+ Provides a single interface for retrieving configuration
+ and instantiating services.
+</body>
+</html>
\ No newline at end of file
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalRequestContext.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,136 @@
+/*
+ * 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 javax.servlet.ServletContext;
+
+import org.apache.pluto.driver.url.PortalURL;
+import org.apache.pluto.driver.url.PortalURLParser;
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.config.DriverConfiguration;
+
+/**
+ * Defines the context of the currentl portal request.
+ * Allows for the retrieval of the original request
+ * and response throughout the lifetime of the request.
+ *
+ * Provides a consistent interface for parsing/creating
+ * PortalURLs to the outside world.
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortalRequestContext {
+
+ /**
+ * The attribute key to bind the portal environment instance to servlet
+ * request.
+ */
+ public final static String REQUEST_KEY =
+ PortalRequestContext.class.getName();
+
+ /** The servletContext of execution. **/
+ private ServletContext servletContext = null;
+
+ /** The incoming servlet request. */
+ private HttpServletRequest request = null;
+
+ /** The incoming servlet response. */
+ private HttpServletResponse response = null;
+
+ /** The requested portal URL. */
+ private PortalURL requestedPortalURL = null;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Creates a PortalRequestContext instance.
+ * @param request the incoming servlet request.
+ * @param response the incoming servlet response.
+ */
+ public PortalRequestContext(ServletContext servletContext,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+ this.servletContext = servletContext;
+ this.request = request;
+ this.response = response;
+
+ // Bind the instance to servlet request for later use.
+ request.setAttribute(REQUEST_KEY, this);
+ }
+
+ /**
+ * Returns the portal environment from the servlet request. The portal
+ * envirionment instance is saved in the request scope.
+ * @param request the servlet request.
+ * @return the portal environment.
+ */
+ public static PortalRequestContext getContext(
+ HttpServletRequest request) {
+ return (PortalRequestContext) request.getAttribute(REQUEST_KEY);
+ }
+
+ /**
+ * Returns the servlet request.
+ * @return the servlet request.
+ */
+ public HttpServletRequest getRequest() {
+ return request;
+ }
+
+ /**
+ * Returns the servlet response.
+ * @return the servlet response.
+ */
+ public HttpServletResponse getResponse() {
+ return response;
+ }
+
+ /**
+ * Returns the requested portal URL.
+ * @return the requested portal URL.
+ */
+ public PortalURL getRequestedPortalURL() {
+ if(requestedPortalURL == null) {
+ DriverConfiguration config = (DriverConfiguration)
+ servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
+ PortalURLParser parser = config.getPortalUrlParser();
+ requestedPortalURL = parser.parse(request);
+ }
+ return requestedPortalURL;
+ }
+
+ public PortalURL createPortalURL() {
+ return (PortalURL)getRequestedPortalURL().clone();
+ }
+
+ public void setPortalURL(PortalURL portalURL){
+ requestedPortalURL = portalURL;
+ }
+
+ public static String getREQUEST_KEY() {
+ return REQUEST_KEY;
+ }
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletRequest.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,117 @@
+/*
+ * 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;
+import org.apache.pluto.driver.url.PortalURLParameter;
+import org.apache.pluto.driver.url.PortalURL;
+
+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 =
+ PortalRequestContext.getContext(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().getStringId())) {
+ 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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortalServletResponse.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,55 @@
+/*
+ * 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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowIDImpl.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,116 @@
+/*
+ * 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.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.apache.pluto.PortletWindowID;
+
+/**
+ * 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.
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortletWindowIDImpl implements PortletWindowID, Serializable {
+
+ // Private Member Variables ------------------------------------------------
+
+ private String stringId = null;
+ private int intId;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Private constructor that prevents external instantiation.
+ * @param intId the integer ID.
+ * @param stringId the string ID.
+ */
+ private PortletWindowIDImpl(int intId, String stringId) {
+ this.stringId = stringId;
+ this.intId = intId;
+ }
+
+
+ // PortletWindowID Impl ----------------------------------------------------
+
+ public String getStringId() {
+ return stringId;
+ }
+
+ // Internal Methods --------------------------------------------------------
+
+ private void readObject(ObjectInputStream stream) throws IOException {
+ intId = stream.readInt();
+ stringId = String.valueOf(intId);
+ }
+
+ private void writeObject(ObjectOutputStream stream) throws IOException {
+ stream.write(intId);
+ }
+
+ // Common Object Methods ---------------------------------------------------
+
+ /**
+ public boolean equals(Object object) {
+ boolean result = false;
+ if (object instanceof PortletWindowIDImpl) {
+ result = (intId == ((PortletWindowIDImpl) object).intId);
+ } else if (object instanceof String) {
+ result = stringId.equals(object);
+ } else if (object instanceof Integer) {
+ result = (intId == ((Integer) object).intValue());
+ }
+ return (result);
+ }
+ **/
+
+ public int hashCode() {
+ return intId;
+ }
+
+
+ // Additional Methods ------------------------------------------------------
+
+ public int intValue() {
+ return intId;
+ }
+
+ /**
+ * Creates a portlet window ID instance from a string.
+ * @param stringId the string ID from which the instance is created.
+ * @return a portlet window ID instance created from the string ID.
+ */
+ static public PortletWindowIDImpl createFromString(String stringId) {
+ char[] id = stringId.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 PortletWindowIDImpl(_id, stringId);
+ }
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/PortletWindowImpl.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,77 @@
+/*
+ * 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.PortletWindowID;
+import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+import org.apache.pluto.driver.url.PortalURL;
+
+/**
+ * Implementation of <code>PortletWindow</code> interface.
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ */
+public class PortletWindowImpl implements PortletWindow {
+
+ // Private Member Variables ------------------------------------------------
+
+ private PortletWindowConfig config = null;
+ private PortalURL portalURL = null;
+ private PortletWindowIDImpl objectIdImpl = null;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Constructs an instance.
+ * @param config the portlet window configuration.
+ * @param portalURL the portal URL.
+ */
+ public PortletWindowImpl(PortletWindowConfig config, PortalURL portalURL) {
+ this.config = config;
+ this.portalURL = portalURL;
+ }
+
+
+ // PortletWindow Impl ------------------------------------------------------
+
+ public String getContextPath() {
+ return config.getContextPath();
+ }
+
+ public String getPortletName() {
+ return config.getPortletName();
+ }
+
+ public WindowState getWindowState() {
+ return portalURL.getWindowState(getId().getStringId());
+ }
+
+ public PortletMode getPortletMode() {
+ return portalURL.getPortletMode(getId().getStringId());
+ }
+
+ public PortletWindowID getId() {
+ if (objectIdImpl == null) {
+ objectIdImpl = PortletWindowIDImpl.createFromString(config.getId());
+ }
+ return objectIdImpl;
+ }
+}
\ No newline at end of file
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/core/ResourceURLProviderImpl.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.spi.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) {
+ PortalRequestContext ctx = (PortalRequestContext)
+ req.getAttribute(PortalRequestContext.REQUEST_KEY);
+
+ this.base = ctx.createPortalURL().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());
+
+ }
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AboutPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AboutPortlet.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AboutPortlet.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AboutPortlet.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.portlets;
+
+import java.io.IOException;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+
+/**
+ * The pluto portal driver about portlet.
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @since 2006-02-09
+ */
+public class AboutPortlet extends GenericPortlet {
+
+ private static final String VIEW_PAGE = "/WEB-INF/fragments/about/view.jsp";
+ private static final String EDIT_PAGE = "/WEB-INF/fragments/about/edit.jsp";
+ private static final String HELP_PAGE = "/WEB-INF/fragments/about/help.jsp";
+
+ // GenericPortlet Impl -----------------------------------------------------
+
+ public void doView(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException {
+ PortletContext context = getPortletContext();
+ PortletRequestDispatcher requestDispatcher =
+ context.getRequestDispatcher(VIEW_PAGE);
+ requestDispatcher.include(request, response);
+ }
+
+ protected void doEdit(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException {
+ PortletContext context = getPortletContext();
+ PortletRequestDispatcher requestDispatcher =
+ context.getRequestDispatcher(EDIT_PAGE);
+ requestDispatcher.include(request, response);
+ }
+
+ protected void doHelp(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException {
+ PortletContext context = getPortletContext();
+ PortletRequestDispatcher requestDispatcher =
+ context.getRequestDispatcher(HELP_PAGE);
+ requestDispatcher.include(request, response);
+ }
+
+ public void serveResource(ResourceRequest arg0, ResourceResponse arg1) throws PortletException, IOException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("This method needs to be implemented.");
+
+ }
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminPortlet.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminPortlet.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminPortlet.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/portlets/AdminPortlet.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.portlets;
+
+import java.io.IOException;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+
+public class AdminPortlet extends GenericPortlet {
+
+ private static final String VIEW_PAGE = "/WEB-INF/fragments/admin/view.jsp";
+ private static final String EDIT_PAGE = "/WEB-INF/fragments/admin/edit.jsp";
+ private static final String HELP_PAGE = "/WEB-INF/fragments/admin/help.jsp";
+
+ // GenericPortlet Impl -----------------------------------------------------
+
+ public void doView(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException {
+ PortletContext context = getPortletContext();
+ PortletRequestDispatcher requestDispatcher =
+ context.getRequestDispatcher(VIEW_PAGE);
+ requestDispatcher.include(request, response);
+ }
+
+ protected void doEdit(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException {
+ PortletContext context = getPortletContext();
+ PortletRequestDispatcher requestDispatcher =
+ context.getRequestDispatcher(EDIT_PAGE);
+ requestDispatcher.include(request, response);
+ }
+
+ protected void doHelp(RenderRequest request, RenderResponse response)
+ throws PortletException, IOException {
+ PortletContext context = getPortletContext();
+ PortletRequestDispatcher requestDispatcher =
+ context.getRequestDispatcher(HELP_PAGE);
+ requestDispatcher.include(request, response);
+ }
+
+ public void serveResource(ResourceRequest arg0, ResourceResponse arg1) throws PortletException, IOException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("This method needs to be implemented.");
+ }
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/impl/package.html Sat Aug 4 07:41:23 2007
@@ -0,0 +1,30 @@
+<!--
+Copyright 2005-2006 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.
+-->
+<HTML>
+<BODY>
+Service implementations of the driver configuration services.
+
+<li><b>rdbms</b>:
+ Relational Database Management System implementations.
+</li>
+
+<li><b>resource</b>:
+ Classpath Resources (file) based implementations.
+</li>
+
+</BODY>
+</HTML>
\ No newline at end of file
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/package.html Sat Aug 4 07:41:23 2007
@@ -0,0 +1,32 @@
+<!--
+Copyright 2005-2006 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.
+-->
+<HTML>
+<BODY>
+Services required by the portal. Contains Portal Driver specific
+interfaces and the following childern:
+
+<li><b>container</b>:
+The services package contains implementations of the services required
+to integrate with the Pluto Container.
+</li>
+
+<li><b>impl</b>:
+Default Implementations of the portal services
+</li>
+
+</BODY>
+</HTML>
\ No newline at end of file
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/DriverConfigurationService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/DriverConfigurationService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/DriverConfigurationService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/DriverConfigurationService.java Sat Aug 4 07:41:23 2007
@@ -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.services.portal;
+
+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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageConfig.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageConfig.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PageConfig.java Sat Aug 4 07:41:23 2007
@@ -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.portal;
+
+import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ */
+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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletApplicationConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletApplicationConfig.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletApplicationConfig.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletApplicationConfig.java Sat Aug 4 07:41:23 2007
@@ -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.services.portal;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortletApplicationConfig {
+
+ 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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletRegistryService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletRegistryService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletRegistryService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletRegistryService.java Sat Aug 4 07:41:23 2007
@@ -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.services.portal;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @since Aug 10, 2005
+ */
+public interface PortletRegistryService extends DriverConfigurationService {
+
+ /**
+ * A set of all Portlet Applications
+ * @return a set of uniqe PortletAppConfig instances.
+ */
+ public 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.
+ */
+ public 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.
+ */
+ public PortletWindowConfig getPortlet(String id);
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PortletWindowConfig.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,142 @@
+/*
+ * 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.portal;
+
+/**
+ * Configuration of a portlet window on the portal page.
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ */
+public class PortletWindowConfig {
+
+ // Private Member Variables ------------------------------------------------
+
+ /** The context path of the associated portlet. */
+ private String contextPath = null;
+
+ /** The portlet name. */
+ private String portletName = null;
+
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * No-arg constructor.
+ */
+ public PortletWindowConfig() {
+ // Do nothing.
+ }
+
+
+ // Public Methods ----------------------------------------------------------
+
+ public String getId() {
+ return createPortletId(contextPath, portletName);
+ }
+
+ public String getContextPath() {
+ return contextPath;
+ }
+
+ public void setContextPath(String contextPath) {
+ this.contextPath = contextPath;
+ }
+
+ public String getPortletName() {
+ return portletName;
+ }
+
+ public void setPortletName(String portletName) {
+ this.portletName = portletName;
+ }
+
+
+ // Public Static Methods ---------------------------------------------------
+
+ /**
+ * Creates the portlet ID from context path and portlet name. The portlet ID
+ * is constructed by concatinating the context path and the portlet name
+ * using a dot ('.').
+ *
+ * The method checks that the portlet name parameter does not have a dot. This check
+ * is not done for the portlet ID.
+ *
+ * @param contextPath the portlet context path.
+ * @param portletName the portlet name.
+ * @throws IllegalArgumentException if the portletName has a dot
+ * @throws NullPointerException if the portlet Name or context path is null.
+ */
+ public static String createPortletId(String contextPath, String portletName)
+ throws NullPointerException, IllegalArgumentException {
+
+ if (contextPath == null) {
+ throw new NullPointerException("Context path must not be null.");
+ }
+ if (portletName == null) {
+ throw new NullPointerException("Portlet name must not be null.");
+ }
+ if (portletName.indexOf('.') != -1) {
+ throw new IllegalArgumentException("Portlet name must not have a dot(period). Please remove the dot from the value of the portlet-name element ("+ portletName + ") in portlet.xml");
+ }
+ return contextPath + "." + portletName;
+ }
+
+ /**
+ * Parses out the portlet context path from the portlet ID.
+ * @param portletId the portlet ID to parse.
+ * @return the portlet context path.
+ */
+ public static String parseContextPath(String portletId) {
+ int index = getSeparatorIndex(portletId);
+ return portletId.substring(0, index);
+ }
+
+ /**
+ * Parses out the portlet context path from the portlet ID.
+ * @param portletId the portlet ID to parse.
+ * @return the portlet context path.
+ * @throws IllegalArgumentException if portlet ID is invalid.
+ */
+ public static String parsePortletName(String portletId) {
+ int index = getSeparatorIndex(portletId);
+ return portletId.substring(index + 1);
+ }
+
+
+ // Private Static Method ---------------------------------------------------
+
+ /**
+ * Parses the portlet ID and returns the separator (".") index. The portlet
+ * ID passed in should be a valid ID: not null, not starts with ".",
+ * not ends with ".", and contains ".".
+ * @param portletId the portlet ID to parse.
+ * @return the separator index.
+ * @throws IllegalArgumentException if portlet ID is null or invalid.
+ */
+ private static int getSeparatorIndex(String portletId)
+ throws IllegalArgumentException {
+ if (portletId == null) {
+ throw new IllegalArgumentException("Invalid portlet ID: null");
+ }
+ int index = portletId.indexOf(".");
+ if (index <= 0 || index == portletId.length() - 1) {
+ throw new IllegalArgumentException("Invalid portlet ID: " + portletId);
+ }
+ return index;
+ }
+
+}
+
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PropertyConfigService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PropertyConfigService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PropertyConfigService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/PropertyConfigService.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.portal;
+
+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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfig.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,123 @@
+/*
+ * 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.portal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.driver.services.portal.PageConfig;
+
+import java.util.*;
+
+/**
+ * @author <a href="ddewolf@apache.org">David H. DeWolf</a>
+ */
+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);
+
+ // TODO: Make sure this is needed.
+ //This is the PLUTO-251 fix submitted by Charles Severence. Thank you!!!
+ // Sometimes pages come with a prefix of a slash - if the page is not
+ // found, and the first character of the pageId is a slash we attempt
+ // to look up the page without the slash.
+
+ PageConfig retval = (PageConfig) pages.get(pageId);
+
+ if ( retval == null && pageId.startsWith("/") && pageId.length() > 2 ) {
+ retval = (PageConfig) pages.get(pageId.substring(1));
+ }
+
+
+ if (retval == null)
+ {
+ LOG.warn("Couldn't find a PageConfig for page ID: [" + pageId + "]");
+ if ((retval = (PageConfig)pages.get(defaultPageId)) != null)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Returning default page ID: [" + defaultPageId + "]");
+ }
+ }
+ else
+ {
+ LOG.error("Could not find default page Id for render config!");
+ }
+ }
+ return retval;
+ }
+
+ public void addPage(PageConfig config) {
+ config.setOrderNumber(orderNumberCounter++);
+ pages.put(config.getName(), config);
+ }
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/RenderConfigService.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.portal;
+
+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/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/SupportedModesService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/SupportedModesService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/SupportedModesService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/SupportedModesService.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 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.portal;
+
+/**
+ * Allows clients to determine if a particular PortletMode is supported
+ * by the portal, a particular portlet, or both.
+ *
+ * @author <a href="mailto:esm@apache.org">Elliot Metsger</a>
+ * @version $Id: SupportedModesService.java 442414 2006-09-12 01:59:56Z esm $
+ * @since September 9, 2006
+ * @see PortletMode
+ */
+public interface SupportedModesService extends DriverConfigurationService {
+
+ /**
+ * Returns true if the portlet and the portal support the supplied mode.
+ * @param portletId the id uniquely identifiying the portlet
+ * @param mode the portlet mode
+ * @return true if the portlet and portal both support the supplied mode
+ */
+ boolean isPortletModeSupported(String portletId, String mode);
+
+ /**
+ * Returns true if the portal supports the supplied mode.
+ * @param mode the portlet mode
+ * @return true if the portal supports the supplied mode
+ */
+ boolean isPortletModeSupportedByPortal(String mode);
+
+ /**
+ * Returns true if the portlet supports the supplied mode.
+ * @param portletId the id uniquely identifying the portlet
+ * @param mode the portlet mode
+ * @return true if the portlet supports the supplied mode.
+ */
+ boolean isPortletModeSupportedByPortlet(String portletId, String mode);
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DriverAdministrationException.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DriverAdministrationException.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DriverAdministrationException.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/DriverAdministrationException.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,41 @@
+/*
+ * 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.portal.admin;
+
+import javax.servlet.ServletException;
+
+/**
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>:
+ * @version 1.0
+ * @since Nov 23, 2005
+ */
+public class DriverAdministrationException extends ServletException {
+
+ public DriverAdministrationException(String string) {
+ super(string);
+ }
+
+ public DriverAdministrationException(String string, Throwable throwable) {
+ super(string, throwable);
+ }
+
+ public DriverAdministrationException(Throwable cause) {
+ super(cause);
+ }
+
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/PortletRegistryAdminService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/PortletRegistryAdminService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/PortletRegistryAdminService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/PortletRegistryAdminService.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2005-2006 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.portal.admin;
+
+/**
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @version 1.0
+ * @since Nov 30, 2005
+ */
+public interface PortletRegistryAdminService {
+
+ public void addPortletApplication(String portletContext)
+ throws DriverAdministrationException;
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/services/portal/admin/RenderConfigAdminService.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2005-2006 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.portal.admin;
+
+import org.apache.pluto.driver.services.portal.PageConfig;
+import org.apache.pluto.driver.config.DriverConfigurationException;
+
+/**
+ *
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>:
+ * @version 1.0
+ * @since Nov 30, 2005
+ */
+public interface RenderConfigAdminService {
+
+ public void addPage(PageConfig config)
+ throws DriverConfigurationException;
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/IsMaximizedTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/IsMaximizedTag.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/IsMaximizedTag.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/IsMaximizedTag.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,50 @@
+package org.apache.pluto.driver.tags;
+
+import org.apache.pluto.driver.core.PortalRequestContext;
+import org.apache.pluto.driver.url.PortalURL;
+
+import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.jsp.JspException;
+import javax.servlet.http.HttpServletRequest;
+import javax.portlet.WindowState;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: ddewolf
+ * Date: Sep 4, 2006
+ * Time: 9:27:35 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class IsMaximizedTag extends TagSupport {
+
+ private String var;
+
+ public int doStartTag() throws JspException {
+ PortalRequestContext portalEnv = PortalRequestContext.getContext(
+ (HttpServletRequest) pageContext.getRequest());
+
+ PortalURL portalURL = portalEnv.getRequestedPortalURL();
+
+ // Check if someone else is maximized. If yes, don't show content.
+ Map windowStates = portalURL.getWindowStates();
+ for (Iterator it = windowStates.values().iterator(); it.hasNext();) {
+ WindowState windowState = (WindowState) it.next();
+ if (WindowState.MAXIMIZED.equals(windowState)) {
+ pageContext.setAttribute(var, Boolean.TRUE);
+ break;
+ }
+ }
+ return SKIP_BODY;
+ }
+
+ public String getVar() {
+ return var;
+ }
+
+ public void setVar(String var) {
+ this.var = var;
+ }
+
+}
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletModeAnchorTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletModeAnchorTag.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletModeAnchorTag.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletModeAnchorTag.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2006 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.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.driver.AttributeKeys;
+import org.apache.pluto.driver.config.DriverConfiguration;
+import org.apache.pluto.driver.core.PortalRequestContext;
+import org.apache.pluto.driver.services.portal.PortletWindowConfig;
+import org.apache.pluto.driver.url.PortalURL;
+import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
+
+/**
+ * The tag is used to render a portlet mode anchor specified by the portlet ID and mode.
+ * This is designed to live inside of a <pluto:portlet/> tag.
+ *
+ * <pluto:modeAnchor portletId="" portletMode="edit"/>
+ *
+ * @author <a href="mailto:esm@apache.org">Elliot Metsger</a>
+ * @author <a href="mailto:cdoremus@apache.org">Craig Doremus</a>
+ * @todo Test supported Window States using a version of ActionResponseImpl.isWindowStateAllowed()
+ */
+public class PortletModeAnchorTag extends BodyTagSupport {
+
+ /** Logger. */
+ private static final Log LOG = LogFactory.getLog(PortletModeAnchorTag.class);
+
+
+ // Private Member Variables ------------------------------------------------
+ private String portletMode = null;
+
+ /** The portlet ID attribute obtained from parent tag. */
+ private String portletId = null;
+
+ /** The evaluated value of the portlet ID attribute. */
+ private String evaluatedPortletId = null;
+
+ // BodyTagSupport Impl -----------------------------------------------------
+
+ /**
+ * Method invoked when the start tag is encountered.
+ * @throws JspException if an error occurs.
+ */
+ public int doStartTag() throws JspException {
+
+ // Ensure that the modeAnchor tag resides within a portlet tag.
+ PortletTag parentTag = (PortletTag) TagSupport.findAncestorWithClass(
+ this, PortletTag.class);
+ if (parentTag == null) {
+ throw new JspException("Portlet window controls may only reside "
+ + "within a pluto:portlet tag.");
+ }
+
+ portletId = parentTag.getPortletId();
+ // Evaluate portlet ID attribute.
+ evaluatePortletId();
+
+ // Retrieve the portlet window config for the evaluated portlet ID.
+ ServletContext servletContext = pageContext.getServletContext();
+ DriverConfiguration driverConfig = (DriverConfiguration)
+ servletContext.getAttribute(AttributeKeys.DRIVER_CONFIG);
+ PortletWindowConfig windowConfig = driverConfig
+ .getPortletWindowConfig(evaluatedPortletId);
+
+ if (isPortletModeAllowed(driverConfig, windowConfig, portletMode)) {
+ // Retrieve the portal environment.
+ PortalRequestContext portalEnv = PortalRequestContext.getContext(
+ (HttpServletRequest) pageContext.getRequest());
+
+ PortalURL portalUrl = portalEnv.createPortalURL();
+ portalUrl.setPortletMode(evaluatedPortletId, new PortletMode(portletMode));
+
+ // Print the mode anchor tag.
+ try {
+ JspWriter out = pageContext.getOut();
+ out.print("<a href=\"");
+ out.print(portalUrl.toString());
+ out.print("\">");
+ out.print("<span class=\"");
+ out.print(portletMode);
+ out.print("\"></span></a>");
+ } catch (IOException ex) {
+ throw new JspException(ex);
+ }
+ }
+
+
+ // Continue to evaluate the tag body.
+ return EVAL_BODY_INCLUDE;
+ }
+
+
+ // Package Methods ---------------------------------------------------------
+
+ /**
+ * Returns the evaluated portlet ID.
+ * @return the evaluated portlet ID.
+ */
+ String getEvaluatedPortletId() {
+ return evaluatedPortletId;
+ }
+
+
+
+ // Private Methods ---------------------------------------------------------
+
+ /**
+ * Evaluates the portlet ID attribute passed into this tag. This method
+ * evaluates the member variable <code>portletId</code> and saves the
+ * evaluated result to <code>evaluatedPortletId</code>
+ * @throws JspException if an error occurs.
+ */
+ private void evaluatePortletId() throws JspException {
+ Object obj = ExpressionEvaluatorManager.evaluate(
+ "portletId", portletId, String.class, this, pageContext);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Evaluated portletId to: " + obj);
+ }
+ evaluatedPortletId = (String) obj;
+ }
+
+ /**
+ * @return the portletMode
+ */
+ public String getPortletMode() {
+ return portletMode;
+ }
+
+ /**
+ * @param portletMode the portletMode to set
+ */
+ public void setPortletMode(String portletMode) {
+ this.portletMode = portletMode;
+ }
+
+ private boolean isPortletModeAllowed(DriverConfiguration config, PortletWindowConfig window, String mode) {
+ LOG.debug("Testing if PortletWindowConfig [" + Integer.toHexString(window.hashCode()) + "] supports mode [" + mode + "]");
+ return config.isPortletModeSupported(getEvaluatedPortletId(), mode);
+ }
+
+
+}
\ No newline at end of file
Added: portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletPortalURLTag.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletPortalURLTag.java?view=auto&rev=562725
==============================================================================
--- portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletPortalURLTag.java (added)
+++ portals/pluto/branches/1.1-286-trunk-merge/pluto-portal-driver/src/main/java/org/apache/pluto/driver/tags/PortletPortalURLTag.java Sat Aug 4 07:41:23 2007
@@ -0,0 +1,119 @@
+/*
+ * 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.url.PortalURL;
+import org.apache.pluto.driver.core.PortalRequestContext;
+
+/**
+ * The portlet URL tag is used to generate portal URL pointing to the current
+ * portlet with specified portlet mode and window state.
+ *
+ * @author <a href="mailto:ddewolf@apache.org">David H. DeWolf</a>
+ * @author <a href="mailto:zheng@apache.org">ZHENG Zhong</a>
+ * @version 1.0
+ * @since Oct 4, 2004
+ */
+public class PortletPortalURLTag extends BodyTagSupport {
+
+ // Private Member Variables ------------------------------------------------
+
+ /** The window state to be encoded in the portal URL. */
+ private String windowState = null;
+
+ /** The portlet mode to be encoded in the portal URL. */
+ private String portletMode = null;
+
+
+ // Tag Attribute Accessors -------------------------------------------------
+
+ 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;
+ }
+
+
+ // BodyTagSupport Impl -----------------------------------------------------
+
+ /**
+ * Creates the portal URL pointing to the current portlet with specified
+ * portlet mode and window state, and print the URL to the page.
+ * @see PortletTag
+ */
+ public int doStartTag() throws JspException {
+
+ // Ensure that the portlet render tag resides within a portlet tag.
+ PortletTag parentTag = (PortletTag) TagSupport.findAncestorWithClass(
+ this, PortletTag.class);
+ if (parentTag == null) {
+ throw new JspException("Portlet window controls may only reside "
+ + "within a pluto:portlet tag.");
+ }
+
+ // Create portal URL.
+ HttpServletRequest request = (HttpServletRequest)
+ pageContext.getRequest();
+
+ PortalRequestContext ctx = (PortalRequestContext)
+ request.getAttribute(PortalRequestContext.REQUEST_KEY);
+
+ PortalURL portalUrl = ctx.createPortalURL();
+
+ // Encode window state of the current portlet in the portal URL.
+ String portletId = parentTag.getEvaluatedPortletId();
+ if (windowState != null) {
+ portalUrl.setWindowState(portletId, new WindowState(windowState));
+ }
+
+ // Encode portlet mode of the current portlet in the portal URL.
+ if (portletMode != null) {
+ portalUrl.setPortletMode(portletId, new PortletMode(portletMode));
+ }
+
+ // Print the portal URL as a string to the page.
+ try {
+ pageContext.getOut().print(portalUrl.toString());
+ } catch (IOException ex) {
+ throw new JspException(ex);
+ }
+
+ // Skip the tag body.
+ return SKIP_BODY;
+ }
+
+
+}
+