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 ms...@apache.org on 2016/01/18 13:41:27 UTC
[25/35] portals-pluto git commit: Initial integration of bean
processor code
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
index c4e0354..8f34ce5 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletAppDescriptorServiceImpl.java
@@ -19,41 +19,15 @@ package org.apache.pluto.container.impl;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.regex.Pattern;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.helpers.DefaultValidationEventHandler;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.XMLEvent;
-import javax.xml.stream.util.StreamReaderDelegate;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
import org.apache.pluto.container.PortletAppDescriptorService;
import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
-import org.apache.pluto.container.om.portlet.PortletDefinition;
import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
/**
* Service that reads the portlet deployment descriptor.
@@ -63,6 +37,7 @@ public class PortletAppDescriptorServiceImpl implements PortletAppDescriptorServ
/** Logger. */
private static final Logger LOG = LoggerFactory.getLogger(PortletAppDescriptorServiceImpl.class);
+ @SuppressWarnings("unused")
private static final boolean isDebug = LOG.isDebugEnabled();
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
index 43a1539..8548fc3 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletContextImpl.java
@@ -1,190 +1,187 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.container.impl;
-
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Set;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletRequestDispatcher;
-import javax.servlet.ServletContext;
-
-import org.apache.pluto.container.ContainerInfo;
-import org.apache.pluto.container.RequestDispatcherService;
-import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
-
-/**
- * Default Portlet Context Implementation.
- *
- * @version $Id$
- */
-public class PortletContextImpl implements PortletContext
-{
- // Private Member Variables ------------------------------------------------
-
- protected ServletContext servletContext;
- protected PortletApplicationDefinition portletApp;
- protected ContainerInfo containerInfo;
- protected List<String> supportedContainerRuntimeOptions;
- protected RequestDispatcherService rdService;
-
- // Constructor -------------------------------------------------------------
-
- /**
- * Constructs an instance.
- * @param servletContext the servlet context in which we are contained.
- * @param portletApp the portlet application descriptor.
- */
- public PortletContextImpl(ServletContext servletContext,
- PortletApplicationDefinition portletApp,
- ContainerInfo containerInfo,
- List<String> supportedContainerRuntimeOptions,
- RequestDispatcherService rdService)
- {
- this.servletContext = servletContext;
- this.portletApp = portletApp;
- this.containerInfo = containerInfo;
- this.supportedContainerRuntimeOptions = supportedContainerRuntimeOptions;
- this.rdService = rdService;
- }
-
- // PortletContext Impl -----------------------------------------------------
-
- /**
- * Retrieve the PortletContainer's server info.
- * @return the server info in the form of <i>Server/Version</i>
- */
- public String getServerInfo() {
- return containerInfo.getServerInfo();
- }
-
- public PortletRequestDispatcher getRequestDispatcher(String path)
- {
- return rdService.getRequestDispatcher(servletContext, portletApp, path);
- }
-
- public PortletRequestDispatcher getNamedDispatcher(String name)
- {
- return rdService.getNamedDispatcher(servletContext, portletApp, name);
- }
-
- public InputStream getResourceAsStream(String path) {
- return servletContext.getResourceAsStream(path);
- }
-
- public int getMajorVersion() {
- return containerInfo.getMajorSpecificationVersion();
- }
-
- public int getMinorVersion() {
- return containerInfo.getMinorSpecificationVersion();
- }
-
- public String getMimeType(String file) {
- return servletContext.getMimeType(file);
- }
-
- public String getRealPath(String path) {
- return servletContext.getRealPath(path);
- }
-
- @SuppressWarnings("unchecked")
- public Set<String> getResourcePaths(String path) {
- return servletContext.getResourcePaths(path);
- }
-
- public URL getResource(String path)
- throws java.net.MalformedURLException {
- if (path == null || !path.startsWith("/")) {
- throw new MalformedURLException("path must start with a '/'");
- }
- return servletContext.getResource(path);
- }
-
- public Object getAttribute(java.lang.String name) {
- if (name == null) {
- throw new IllegalArgumentException("Attribute name == null");
- }
-
- return servletContext.getAttribute(name);
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration<String> getAttributeNames() {
- return servletContext.getAttributeNames();
- }
-
- public String getInitParameter(java.lang.String name) {
- if (name == null) {
- throw new IllegalArgumentException("Parameter name == null");
- }
-
- return servletContext.getInitParameter(name);
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration<String> getInitParameterNames() {
- return servletContext.getInitParameterNames();
- }
-
- public void log(java.lang.String msg) {
- servletContext.log(msg);
- }
-
- public void log(java.lang.String message, Throwable throwable) {
- servletContext.log(message, throwable);
- }
-
- public void removeAttribute(String name) {
- if (name == null) {
- throw new IllegalArgumentException("Attribute name == null");
- }
-
- servletContext.removeAttribute(name);
- }
-
- public void setAttribute(String name, Object object) {
- if (name == null) {
- throw new IllegalArgumentException("Attribute name == null");
- }
-
- servletContext.setAttribute(name, object);
- }
-
- public String getPortletContextName() {
- return servletContext.getServletContextName();
- }
-
-
- public ServletContext getServletContext() {
- return servletContext;
- }
-
- public PortletApplicationDefinition getPortletApplicationDefinition() {
- return portletApp;
- }
-
- public Enumeration<String> getContainerRuntimeOptions() {
- return Collections.enumeration(supportedContainerRuntimeOptions);
- }
-}
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.container.impl;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.ServletContext;
+
+import org.apache.pluto.container.ContainerInfo;
+import org.apache.pluto.container.RequestDispatcherService;
+import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+
+/**
+ * Default Portlet Context Implementation.
+ *
+ * @version $Id$
+ */
+public class PortletContextImpl implements PortletContext
+{
+ // Private Member Variables ------------------------------------------------
+
+ protected ServletContext servletContext;
+ protected PortletApplicationDefinition portletApp;
+ protected ContainerInfo containerInfo;
+ protected List<String> supportedContainerRuntimeOptions;
+ protected RequestDispatcherService rdService;
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Constructs an instance.
+ * @param servletContext the servlet context in which we are contained.
+ * @param portletApp the portlet application descriptor.
+ */
+ public PortletContextImpl(ServletContext servletContext,
+ PortletApplicationDefinition portletApp,
+ ContainerInfo containerInfo,
+ List<String> supportedContainerRuntimeOptions,
+ RequestDispatcherService rdService)
+ {
+ this.servletContext = servletContext;
+ this.portletApp = portletApp;
+ this.containerInfo = containerInfo;
+ this.supportedContainerRuntimeOptions = supportedContainerRuntimeOptions;
+ this.rdService = rdService;
+ }
+
+ // PortletContext Impl -----------------------------------------------------
+
+ /**
+ * Retrieve the PortletContainer's server info.
+ * @return the server info in the form of <i>Server/Version</i>
+ */
+ public String getServerInfo() {
+ return containerInfo.getServerInfo();
+ }
+
+ public PortletRequestDispatcher getRequestDispatcher(String path)
+ {
+ return rdService.getRequestDispatcher(servletContext, portletApp, path);
+ }
+
+ public PortletRequestDispatcher getNamedDispatcher(String name)
+ {
+ return rdService.getNamedDispatcher(servletContext, portletApp, name);
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ return servletContext.getResourceAsStream(path);
+ }
+
+ public int getMajorVersion() {
+ return containerInfo.getMajorSpecificationVersion();
+ }
+
+ public int getMinorVersion() {
+ return containerInfo.getMinorSpecificationVersion();
+ }
+
+ public String getMimeType(String file) {
+ return servletContext.getMimeType(file);
+ }
+
+ public String getRealPath(String path) {
+ return servletContext.getRealPath(path);
+ }
+
+ public Set<String> getResourcePaths(String path) {
+ return servletContext.getResourcePaths(path);
+ }
+
+ public URL getResource(String path)
+ throws java.net.MalformedURLException {
+ if (path == null || !path.startsWith("/")) {
+ throw new MalformedURLException("path must start with a '/'");
+ }
+ return servletContext.getResource(path);
+ }
+
+ public Object getAttribute(java.lang.String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Attribute name == null");
+ }
+
+ return servletContext.getAttribute(name);
+ }
+
+ public Enumeration<String> getAttributeNames() {
+ return servletContext.getAttributeNames();
+ }
+
+ public String getInitParameter(java.lang.String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Parameter name == null");
+ }
+
+ return servletContext.getInitParameter(name);
+ }
+
+ public Enumeration<String> getInitParameterNames() {
+ return servletContext.getInitParameterNames();
+ }
+
+ public void log(java.lang.String msg) {
+ servletContext.log(msg);
+ }
+
+ public void log(java.lang.String message, Throwable throwable) {
+ servletContext.log(message, throwable);
+ }
+
+ public void removeAttribute(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Attribute name == null");
+ }
+
+ servletContext.removeAttribute(name);
+ }
+
+ public void setAttribute(String name, Object object) {
+ if (name == null) {
+ throw new IllegalArgumentException("Attribute name == null");
+ }
+
+ servletContext.setAttribute(name, object);
+ }
+
+ public String getPortletContextName() {
+ return servletContext.getServletContextName();
+ }
+
+
+ public ServletContext getServletContext() {
+ return servletContext;
+ }
+
+ public PortletApplicationDefinition getPortletApplicationDefinition() {
+ return portletApp;
+ }
+
+ public Enumeration<String> getContainerRuntimeOptions() {
+ return Collections.enumeration(supportedContainerRuntimeOptions);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletParametersImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletParametersImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletParametersImpl.java
index b50a8cd..938a4a5 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletParametersImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletParametersImpl.java
@@ -39,7 +39,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class PortletParametersImpl implements PortletParameters {
private static final Logger LOGGER = LoggerFactory.getLogger(PortletParametersImpl.class);
- private static final boolean isDebug = LOGGER.isDebugEnabled();
+ //private static final boolean isDebug = LOGGER.isDebugEnabled();
private static final boolean isTrace = LOGGER.isTraceEnabled();
protected final PortletURLProvider urlProvider;
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletPreferencesImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletPreferencesImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletPreferencesImpl.java
index a634b4d..65cf0c9 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletPreferencesImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletPreferencesImpl.java
@@ -1,322 +1,322 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.container.impl;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-import javax.portlet.PreferencesValidator;
-import javax.portlet.ReadOnlyException;
-import javax.portlet.ValidatorException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.pluto.container.PortletPreference;
-import org.apache.pluto.container.PortletContainer;
-import org.apache.pluto.container.PortletContainerException;
-import org.apache.pluto.container.PortletPreferencesService;
-import org.apache.pluto.container.PortletWindow;
-import org.apache.pluto.container.om.portlet.PortletDefinition;
-import org.apache.pluto.container.util.StringManager;
-
-/**
- * Implementation of the <code>javax.portlet.PortletPreferences</code>
- * interface.
- *
- * @see PortletPreferences
- * @see PortletPreferenceImpl
- */
-public class PortletPreferencesImpl implements PortletPreferences {
-
- /** Logger. */
- private static final Logger LOG = LoggerFactory.getLogger(PortletPreferencesImpl.class);
-
- private static final StringManager EXCEPTIONS = StringManager.getManager(
- PortletPreferencesImpl.class.getPackage().getName());
-
-
- // Private Member Variables ------------------------------------------------
-
- /** The portlet preferences service provided by the portal. */
- private PortletPreferencesService preferencesService;
-
- private PortletWindow window;
-
- private PortletRequest request;
-
- /**
- * Default portlet preferences retrieved from portlet.xml, and used for
- * resetting portlet preferences.
- */
- private Map<String,PortletPreference> defaultPreferences;
-
- /**
- * Current portlet preferences: key is the preference name as a string,
- * value is the PortletPreference instance.
- */
- private final Map<String, PortletPreference> preferences = new HashMap<String, PortletPreference>();
-
- // Constructor -------------------------------------------------------------
-
- /**
- * Constructs an instance.
- * @param container the portlet container.
- * @param window the internal portlet window.
- * @param request the internal portlet request.
- */
- public PortletPreferencesImpl(PortletContainer container,
- PortletWindow window,
- PortletRequest request)
- {
- this.window = window;
- this.request = request;
-
- // Get the portlet preferences service from container.
- preferencesService = container.getContainerServices()
- .getPortletPreferencesService();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Using PortletPreferencesService: "
- + preferencesService.getClass().getName());
- }
-
- try {
- // Put default portlet preferences into preferences map.
- defaultPreferences = preferencesService.getDefaultPreferences(window, request);
- if (defaultPreferences != null) {
- for (PortletPreference p : defaultPreferences.values()) {
- preferences.put(p.getName(), p.clone());
- }
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Loaded default preferences: " + toString());
- }
-
- // Merge stored portlet preferences into preferences map.
-
- Map<String,PortletPreference> storedPreferences = preferencesService
- .getStoredPreferences(window, request);
- preferences.putAll(storedPreferences);
-
- } catch (PortletContainerException ex) {
- LOG.error("Error retrieving preferences.", ex);
- //TODO: Rethrow up the stack????
- }
- if (LOG.isDebugEnabled()) {
- LOG.debug("Merged stored preferences: " + toString());
- }
- }
-
-
- // PortletPreferences Impl -------------------------------------------------
-
- public boolean isReadOnly(String key) {
- if (key == null) {
- throw new IllegalArgumentException(
- EXCEPTIONS.getString("error.null", "Preference key "));
- }
- PortletPreference pref = preferences.get(key);
- return (pref != null && pref.isReadOnly());
- }
-
- public String getValue(String key, String defaultValue) {
- String[] values = getValues(key, new String[] { defaultValue });
- String value = defaultValue;
- if (values != null) {
- if (values.length == 0) {
- value = null;
- }
- else if (values[0] != null) {
- value = values[0];
- }
- }
- return value;
- }
-
- public String[] getValues(String key, String[] defaultValues) {
- if (key == null) {
- throw new IllegalArgumentException(
- EXCEPTIONS.getString("error.null", "Preference key "));
- }
- String[] values = null;
- PortletPreference pref = preferences.get(key);
- if (pref != null) {
- values = pref.getValues();
- }
- if (values == null) {
- values = defaultValues;
- }
- return values;
- }
-
- public void setValue(String key, String value) throws ReadOnlyException {
- if (isReadOnly(key)) {
- throw new ReadOnlyException(EXCEPTIONS.getString(
- "error.preference.readonly", key));
- }
- PortletPreference pref = preferences.get(key);
- String[] values = value == null ? new String[0] : new String[] { value };
- if (pref != null) {
- pref.setValues(values);
- } else {
- pref = new PortletPreferenceImpl(key, values);
- preferences.put(key, pref);
- }
- }
-
- public void setValues(String key, String[] values) throws ReadOnlyException {
- if (isReadOnly(key)) {
- throw new ReadOnlyException(EXCEPTIONS.getString(
- "error.preference.readonly", key));
- }
- if (values == null) {
- values = new String[0];
- }
- PortletPreference pref = preferences.get(key);
- if (pref != null) {
- pref.setValues(values);
- } else {
- pref = new PortletPreferenceImpl(key, values);
- preferences.put(key, pref);
- }
- }
-
- public Enumeration<String> getNames() {
- return Collections.enumeration(preferences.keySet());
- }
-
- public Map<String,String[]> getMap() {
- Map<String,String[]> map = new HashMap<String,String[]>();
- for (PortletPreference pref : preferences.values()) {
- map.put(pref.getName(),
- pref.getValues() != null ? pref.getValues().clone() : null);
- }
- return Collections.unmodifiableMap(map);
- }
-
- public void reset(String key) throws ReadOnlyException {
- // Read-only preferences cannot be reset.
- if (isReadOnly(key)) {
- throw new ReadOnlyException(EXCEPTIONS.getString(
- "error.preference.readonly", key));
- }
- // Try to reset preference to the default values.
- PortletPreference p = defaultPreferences.get(key);
- if (p != null) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Resetting preference for key: " + key);
- }
- preferences.put(key,p.clone());
- }
- // Remove preference if default values are not defined (PLT.14.1).
- else {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Resetting preference to null for key: " + key);
- }
- preferences.remove(key);
- }
- }
-
- /**
- * Stores the portlet preferences to a persistent storage. This method
- * should only be invoked within <code>processAction()</code> method.
- *
- * @see #internalStore()
- *
- * @throws IllegalStateException if this method is not invoked within
- * <code>processAction()</code> method.
- * @throws ValidatorException if the portlet preferences are not valid.
- * @throws IOException if an error occurs with the persistence mechanism.
- */
- public void store() throws IOException, ValidatorException {
- if (PortletRequest.RENDER_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
- throw new IllegalStateException(
- "store is not allowed during RENDER phase.");
- }
- internalStore();
- }
-
-
- // Private Methods ---------------------------------------------------------
-
- /**
- * Stores the portlet preferences to a persistent storage. If a preferences
- * validator is defined for this portlet, this method firstly validates the
- * portlet preferences.
- * <p>
- * This method is invoked internally, thus it does not check the portlet
- * request method ID (METHOD_RENDER or METHOD_ACTION).
- * </p>
- * @throws ValidatorException if the portlet preferences are not valid.
- * @throws IOException if an error occurs with the persistence mechanism.
- */
- protected final void internalStore() throws IOException, ValidatorException {
- // Validate the preferences before storing, if a validator is defined.
- // If the preferences cannot pass the validation,
- // an ValidatorException will be thrown out.
- PortletDefinition portletD = window.getPortletDefinition();
- PreferencesValidator validator = preferencesService.getPreferencesValidator(portletD);
- if (validator != null)
- {
- validator.validate(this);
- }
- // Store the portlet preferences.
- try {
- preferencesService.store(window, request, preferences);
- } catch (PortletContainerException ex) {
- LOG.error("Error storing preferences.", ex);
- throw new IOException("Error storing perferences: " + ex.getMessage());
- }
- }
-
-
- // Object Methods ----------------------------------------------------------
-
- /**
- * Returns the string representation of this object. Preferences are
- * separated by ';' character, while values in one preference are separated
- * by ',' character.
- * @return the string representation of this object.
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getClass().getName()).append("[");
- for (PortletPreference p : preferences.values()) {
- buffer.append(p.getName());
- buffer.append("(readOnly:").append(p.isReadOnly()).append(")=");
- String[] values = p.getValues();
- if (values != null) {
- for (int i = 0; i < values.length; i++) {
- buffer.append(values[i]);
- if (i < values.length - 1) {
- buffer.append(",");
- }
- }
- } else {
- buffer.append("NULL");
- }
- buffer.append(";");
- }
- buffer.append("]");
- return buffer.toString();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.container.impl;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ReadOnlyException;
+import javax.portlet.ValidatorException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.pluto.container.PortletPreference;
+import org.apache.pluto.container.PortletContainer;
+import org.apache.pluto.container.PortletContainerException;
+import org.apache.pluto.container.PortletPreferencesService;
+import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
+import org.apache.pluto.container.util.StringManager;
+
+/**
+ * Implementation of the <code>javax.portlet.PortletPreferences</code>
+ * interface.
+ *
+ * @see PortletPreferences
+ * @see PortletPreferenceImpl
+ */
+public class PortletPreferencesImpl implements PortletPreferences {
+
+ /** Logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(PortletPreferencesImpl.class);
+
+ private static final StringManager EXCEPTIONS = StringManager.getManager(
+ PortletPreferencesImpl.class.getPackage().getName());
+
+
+ // Private Member Variables ------------------------------------------------
+
+ /** The portlet preferences service provided by the portal. */
+ private PortletPreferencesService preferencesService;
+
+ private PortletWindow window;
+
+ private PortletRequest request;
+
+ /**
+ * Default portlet preferences retrieved from portlet.xml, and used for
+ * resetting portlet preferences.
+ */
+ private Map<String,PortletPreference> defaultPreferences;
+
+ /**
+ * Current portlet preferences: key is the preference name as a string,
+ * value is the PortletPreference instance.
+ */
+ private final Map<String, PortletPreference> preferences = new HashMap<String, PortletPreference>();
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Constructs an instance.
+ * @param container the portlet container.
+ * @param window the internal portlet window.
+ * @param request the internal portlet request.
+ */
+ public PortletPreferencesImpl(PortletContainer container,
+ PortletWindow window,
+ PortletRequest request)
+ {
+ this.window = window;
+ this.request = request;
+
+ // Get the portlet preferences service from container.
+ preferencesService = container.getContainerServices()
+ .getPortletPreferencesService();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Using PortletPreferencesService: "
+ + preferencesService.getClass().getName());
+ }
+
+ try {
+ // Put default portlet preferences into preferences map.
+ defaultPreferences = preferencesService.getDefaultPreferences(window, request);
+ if (defaultPreferences != null) {
+ for (PortletPreference p : defaultPreferences.values()) {
+ preferences.put(p.getName(), p.clone());
+ }
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Loaded default preferences: " + toString());
+ }
+
+ // Merge stored portlet preferences into preferences map.
+
+ Map<String,PortletPreference> storedPreferences = preferencesService
+ .getStoredPreferences(window, request);
+ preferences.putAll(storedPreferences);
+
+ } catch (PortletContainerException ex) {
+ LOG.error("Error retrieving preferences.", ex);
+ //TODO: Rethrow up the stack????
+ }
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Merged stored preferences: " + toString());
+ }
+ }
+
+
+ // PortletPreferences Impl -------------------------------------------------
+
+ public boolean isReadOnly(String key) {
+ if (key == null) {
+ throw new IllegalArgumentException(
+ EXCEPTIONS.getString("error.null", "Preference key "));
+ }
+ PortletPreference pref = preferences.get(key);
+ return (pref != null && pref.isReadOnly());
+ }
+
+ public String getValue(String key, String defaultValue) {
+ String[] values = getValues(key, new String[] { defaultValue });
+ String value = defaultValue;
+ if (values != null) {
+ if (values.length == 0) {
+ value = null;
+ }
+ else if (values[0] != null) {
+ value = values[0];
+ }
+ }
+ return value;
+ }
+
+ public String[] getValues(String key, String[] defaultValues) {
+ if (key == null) {
+ throw new IllegalArgumentException(
+ EXCEPTIONS.getString("error.null", "Preference key "));
+ }
+ String[] values = null;
+ PortletPreference pref = preferences.get(key);
+ if (pref != null) {
+ values = pref.getValues();
+ }
+ if (values == null) {
+ values = defaultValues;
+ }
+ return values;
+ }
+
+ public void setValue(String key, String value) throws ReadOnlyException {
+ if (isReadOnly(key)) {
+ throw new ReadOnlyException(EXCEPTIONS.getString(
+ "error.preference.readonly", key));
+ }
+ PortletPreference pref = preferences.get(key);
+ String[] values = value == null ? new String[0] : new String[] { value };
+ if (pref != null) {
+ pref.setValues(values);
+ } else {
+ pref = new PortletPreferenceImpl(key, values);
+ preferences.put(key, pref);
+ }
+ }
+
+ public void setValues(String key, String... values) throws ReadOnlyException {
+ if (isReadOnly(key)) {
+ throw new ReadOnlyException(EXCEPTIONS.getString(
+ "error.preference.readonly", key));
+ }
+ if (values == null) {
+ values = new String[0];
+ }
+ PortletPreference pref = preferences.get(key);
+ if (pref != null) {
+ pref.setValues(values);
+ } else {
+ pref = new PortletPreferenceImpl(key, values);
+ preferences.put(key, pref);
+ }
+ }
+
+ public Enumeration<String> getNames() {
+ return Collections.enumeration(preferences.keySet());
+ }
+
+ public Map<String,String[]> getMap() {
+ Map<String,String[]> map = new HashMap<String,String[]>();
+ for (PortletPreference pref : preferences.values()) {
+ map.put(pref.getName(),
+ pref.getValues() != null ? pref.getValues().clone() : null);
+ }
+ return Collections.unmodifiableMap(map);
+ }
+
+ public void reset(String key) throws ReadOnlyException {
+ // Read-only preferences cannot be reset.
+ if (isReadOnly(key)) {
+ throw new ReadOnlyException(EXCEPTIONS.getString(
+ "error.preference.readonly", key));
+ }
+ // Try to reset preference to the default values.
+ PortletPreference p = defaultPreferences.get(key);
+ if (p != null) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Resetting preference for key: " + key);
+ }
+ preferences.put(key,p.clone());
+ }
+ // Remove preference if default values are not defined (PLT.14.1).
+ else {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Resetting preference to null for key: " + key);
+ }
+ preferences.remove(key);
+ }
+ }
+
+ /**
+ * Stores the portlet preferences to a persistent storage. This method
+ * should only be invoked within <code>processAction()</code> method.
+ *
+ * @see #internalStore()
+ *
+ * @throws IllegalStateException if this method is not invoked within
+ * <code>processAction()</code> method.
+ * @throws ValidatorException if the portlet preferences are not valid.
+ * @throws IOException if an error occurs with the persistence mechanism.
+ */
+ public void store() throws IOException, ValidatorException {
+ if (PortletRequest.RENDER_PHASE.equals(request.getAttribute(PortletRequest.LIFECYCLE_PHASE))) {
+ throw new IllegalStateException(
+ "store is not allowed during RENDER phase.");
+ }
+ internalStore();
+ }
+
+
+ // Private Methods ---------------------------------------------------------
+
+ /**
+ * Stores the portlet preferences to a persistent storage. If a preferences
+ * validator is defined for this portlet, this method firstly validates the
+ * portlet preferences.
+ * <p>
+ * This method is invoked internally, thus it does not check the portlet
+ * request method ID (METHOD_RENDER or METHOD_ACTION).
+ * </p>
+ * @throws ValidatorException if the portlet preferences are not valid.
+ * @throws IOException if an error occurs with the persistence mechanism.
+ */
+ protected final void internalStore() throws IOException, ValidatorException {
+ // Validate the preferences before storing, if a validator is defined.
+ // If the preferences cannot pass the validation,
+ // an ValidatorException will be thrown out.
+ PortletDefinition portletD = window.getPortletDefinition();
+ PreferencesValidator validator = preferencesService.getPreferencesValidator(portletD);
+ if (validator != null)
+ {
+ validator.validate(this);
+ }
+ // Store the portlet preferences.
+ try {
+ preferencesService.store(window, request, preferences);
+ } catch (PortletContainerException ex) {
+ LOG.error("Error storing preferences.", ex);
+ throw new IOException("Error storing perferences: " + ex.getMessage());
+ }
+ }
+
+
+ // Object Methods ----------------------------------------------------------
+
+ /**
+ * Returns the string representation of this object. Preferences are
+ * separated by ';' character, while values in one preference are separated
+ * by ',' character.
+ * @return the string representation of this object.
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(getClass().getName()).append("[");
+ for (PortletPreference p : preferences.values()) {
+ buffer.append(p.getName());
+ buffer.append("(readOnly:").append(p.isReadOnly()).append(")=");
+ String[] values = p.getValues();
+ if (values != null) {
+ for (int i = 0; i < values.length; i++) {
+ buffer.append(values[i]);
+ if (i < values.length - 1) {
+ buffer.append(",");
+ }
+ }
+ } else {
+ buffer.append("NULL");
+ }
+ buffer.append(";");
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
index a7f7e36..79e9281 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletResponseImpl.java
@@ -18,7 +18,6 @@ package org.apache.pluto.container.impl;
import java.util.Enumeration;
-import javax.portlet.MimeResponse;
import javax.portlet.PortalContext;
import javax.portlet.PortletMode;
import javax.portlet.PortletResponse;
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletSessionImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletSessionImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletSessionImpl.java
index 0257dd4..d8fdf60 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletSessionImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/PortletSessionImpl.java
@@ -1,329 +1,328 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.container.impl;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletSession;
-import javax.portlet.PortletSessionUtil;
-import javax.servlet.http.HttpSession;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.pluto.container.PortletWindow;
-import org.apache.pluto.container.util.ArgumentUtility;
-
-/**
- * Implementation of the <code>javax.portlet.PortletSession</code> interface.
- *
- */
-public class PortletSessionImpl implements PortletSession {
-
- /** Logger. */
- private static final Logger LOG = LoggerFactory.getLogger(PortletSessionImpl.class);
-
- /** The default scope (<code>PORTLET_SCOPE</code>) for storing objects. */
- protected static final int DEFAULT_SCOPE = PortletSession.PORTLET_SCOPE;
-
- /** The portlet scope namespace as defined in PLT. 15.3. */
- protected static final String PORTLET_SCOPE_NAMESPACE = "javax.portlet.p.";
-
- /** The portlet window ID / attribute name separator as defined in PLT. 15.3. */
- protected static final char ID_NAME_SEPARATOR = '?';
-
-
- // Private Member Variables ------------------------------------------------
-
- /** The wrapped HttpSession object. */
- private HttpSession httpSession;
-
- /** The portlet context. */
- private PortletContext portletContext;
-
- /** The portlet window. */
- private PortletWindow portletWindow;
-
- // Constructor -------------------------------------------------------------
-
- /**
- * Constructs an instance.
- */
- public PortletSessionImpl(PortletContext portletContext,
- PortletWindow portletWindow,
- HttpSession httpSession) {
- this.portletContext = portletContext;
- this.portletWindow = portletWindow;
- this.httpSession = httpSession;
- }
-
- // InternalPortletSession Impl -----------------------------------------
-
- public HttpSession getHttpSession()
- {
- return httpSession;
- }
-
- // PortletSession Impl: Attributes -----------------------------------------
-
- public Object getAttribute(String name) {
- return getAttribute(name, DEFAULT_SCOPE);
- }
-
- /**
- * Returns the attribute of the specified name under the given scope.
- *
- * @param name the attribute name.
- * @param scope the scope under which the attribute object is stored.
- * @return the attribute object.
- */
- public Object getAttribute(String name, int scope) {
- ArgumentUtility.validateNotNull("attributeName", name);
- String key = (scope == PortletSession.APPLICATION_SCOPE)
- ? name : createPortletScopedId(name);
- return httpSession.getAttribute(key);
- }
-
- public Enumeration<String> getAttributeNames() {
- return getAttributeNames(DEFAULT_SCOPE);
- }
-
- @SuppressWarnings("unchecked")
- public Enumeration<String> getAttributeNames(int scope) {
- // Return all attribute names in the nested HttpSession object.
- if (scope == PortletSession.APPLICATION_SCOPE) {
- return httpSession.getAttributeNames();
- }
- // Return attribute names with the portlet-scoped prefix.
- Vector<String> portletScopedNames = new Vector<String>();
- for (Enumeration<String> en = httpSession.getAttributeNames();
- en.hasMoreElements(); ) {
- String name = en.nextElement();
- if (isInCurrentPortletScope(name)) {
- portletScopedNames.add(
- PortletSessionUtil.decodeAttributeName(name));
- }
- }
- return portletScopedNames.elements();
-
- }
-
- public void removeAttribute(String name) {
- removeAttribute(name, DEFAULT_SCOPE);
- }
-
- public void removeAttribute(String name, int scope) {
- ArgumentUtility.validateNotNull("attributeName", name);
- if (scope == PortletSession.APPLICATION_SCOPE) {
- httpSession.removeAttribute(name);
- } else {
- httpSession.removeAttribute(createPortletScopedId(name));
- }
- }
-
- public void setAttribute(String name, Object value) {
- setAttribute(name, value, DEFAULT_SCOPE);
- }
-
- public void setAttribute(String name, Object value, int scope) {
- ArgumentUtility.validateNotNull("attributeName", name);
- if (scope == PortletSession.APPLICATION_SCOPE) {
- httpSession.setAttribute(name, value);
- } else {
- httpSession.setAttribute(createPortletScopedId(name), value);
- }
- }
-
-
- // PortletSession Impl: Other Methods --------------------------------------
-
- public PortletContext getPortletContext() {
- return portletContext;
- }
-
- public long getCreationTime() {
- return httpSession.getCreationTime();
- }
-
- public String getId() {
- return httpSession.getId();
- }
-
- public long getLastAccessedTime() {
- return httpSession.getLastAccessedTime();
- }
-
- public int getMaxInactiveInterval() {
- return httpSession.getMaxInactiveInterval();
- }
-
- public void invalidate(){
- httpSession.invalidate();
- }
-
- public boolean isNew(){
- return httpSession.isNew();
- }
-
- /**
- * Specifies the time, in seconds, between client requests, before the
- * portlet container invalidates this session. A negative time indicates
- * the session should never timeout.
- * <p>
- * [Portlet Spec. PLT. 15.4.] If the PortletSession object is invalidated
- * by a portlet, the portlet container must invalidate the associated
- * HttpSession object.
- * </p>
- * @param interval an integer specifying the number of seconds.
- */
- public void setMaxInactiveInterval(int interval) {
- httpSession.setMaxInactiveInterval(interval);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Session timeout set to: " + interval);
- }
- }
-
-
- // Private Methods ---------------------------------------------------------
-
- /**
- * Creates portlet-scoped ID for the specified attribute name.
- * Portlet-scoped ID for a given attribute name has the following form:
- * <code>javax.portlet.p.<ID>?<name></code>
- * where <code>ID</code> is a unique identification for the portlet window
- * (assigned by the portal/portlet-container) that must not contain a '?'
- * character. <code>name</code> is the attribute name.
- * <p>
- * Refer to Portlet Specification PLT. 15.3 for more details.
- * </p>
- * @param name the attribute name.
- * @return portlet-scoped ID for the attribute name.
- */
- protected String createPortletScopedId(String name) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(PORTLET_SCOPE_NAMESPACE);
- buffer.append(portletWindow.getId().getStringId());
- buffer.append(ID_NAME_SEPARATOR);
- buffer.append(name);
- return buffer.toString();
- }
-
- /**
- * Checks if the attribute name in APPLICATION_SCOPE is in the current
- * portlet scope.
- * @param name the attribute name to check.
- * @return true if the attribute name is in the current portlet scope.
- * @see #createPortletScopedId(String)
- */
- protected boolean isInCurrentPortletScope(String name) {
- // Portlet-scoped attribute names MUST start with "javax.portlet.p.",
- // and contain the ID-name separator '?'.
- if (name.startsWith(PORTLET_SCOPE_NAMESPACE)
- && name.indexOf(ID_NAME_SEPARATOR) > -1) {
- String id = name.substring(PORTLET_SCOPE_NAMESPACE.length(),
- name.indexOf(ID_NAME_SEPARATOR));
- return (id.equals(portletWindow.getId().getStringId()));
- }
- // Application-scoped attribute names are not in portlet scope.
- return false;
- }
-
-
- // HttpSession Impl --------------------------------------------------------
-
- public Map<String, Object> getMap() {
- List<String> paramNames = getAttributeNamesAsList(DEFAULT_SCOPE);
- return fillMap(paramNames, DEFAULT_SCOPE);
- }
-
- public Map<String, Object> getMap(int scope) {
- List<String> paramNames = getAttributeNamesAsList(scope);
- return fillMap(paramNames, scope);
- }
-
-// ***** private methods *****
-
- /**
- * transforms the getAttributeNames enumeration to a list
- * @return list of getAttributeNames
- */
- private List<String> getAttributeNamesAsList(int scope) {
- //transform Enum to List
- List<String> paramNames = new ArrayList<String>();
- Enumeration<String> e = getAttributeNames(scope);
- while (e.hasMoreElements()){
- paramNames.add(e.nextElement());
- }
- return paramNames;
- }
-
- /**
- * @param paramNames list of the attribute names to be filled in the map
- * @return the filled map
- */
- private Map<String, Object> fillMap(List<String> paramNames, int scope) {
- Map<String, Object> resultMap = new HashMap<String, Object>();
- for (String string : paramNames) {
- resultMap.put(string, getAttribute(string,scope));
- }
- return resultMap;
- }
-
- /**
- * Returns a <code>Map</code> of the session attributes in
- * the portlet session scope.
- * <p>
- * The keys are of type <code>String</code> and the values in the
- * returned <code>Map</code> are from type <code>Object</code>.
- * <p>
- * If no session attributes exist this method returns an empty <code>Map</code>.
- *
- * @return an immutable <code>Map</code> containing the session attributes in the
- * portlet session scope as keys and attribute values as map values, or an empty <code>Map</code>
- * if no session attributes exist. The keys in the
- * map are of type String, the values of type
- * Object.
- * @since 2.0
- */
- public Map<String, Object> getAttributeMap(int scope){
- return getMap(scope);
- }
- /**
- * Returns a <code>Map</code> of the session attributes in
- * the portlet session scope.
- * <p>
- * The keys are of type <code>String</code> and the values in the
- * returned <code>Map</code> are from type <code>Object</code>.
- * <p>
- * If no session attributes exist this method returns an empty <code>Map</code>.
- *
- * @return an immutable <code>Map</code> containing the session attributes in the
- * portlet session scope as keys and attribute values as map values, or an empty <code>Map</code>
- * if no session attributes exist. The keys in the
- * map are of type String, the values of type
- * Object.
- * @since 2.0
- */
- public Map<String, Object> getAttributeMap(){
- return getMap();
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.container.impl;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletSessionUtil;
+import javax.servlet.http.HttpSession;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.pluto.container.PortletWindow;
+import org.apache.pluto.container.util.ArgumentUtility;
+
+/**
+ * Implementation of the <code>javax.portlet.PortletSession</code> interface.
+ *
+ */
+public class PortletSessionImpl implements PortletSession {
+
+ /** Logger. */
+ private static final Logger LOG = LoggerFactory.getLogger(PortletSessionImpl.class);
+
+ /** The default scope (<code>PORTLET_SCOPE</code>) for storing objects. */
+ protected static final int DEFAULT_SCOPE = PortletSession.PORTLET_SCOPE;
+
+ /** The portlet scope namespace as defined in PLT. 15.3. */
+ protected static final String PORTLET_SCOPE_NAMESPACE = "javax.portlet.p.";
+
+ /** The portlet window ID / attribute name separator as defined in PLT. 15.3. */
+ protected static final char ID_NAME_SEPARATOR = '?';
+
+
+ // Private Member Variables ------------------------------------------------
+
+ /** The wrapped HttpSession object. */
+ private HttpSession httpSession;
+
+ /** The portlet context. */
+ private PortletContext portletContext;
+
+ /** The portlet window. */
+ private PortletWindow portletWindow;
+
+ // Constructor -------------------------------------------------------------
+
+ /**
+ * Constructs an instance.
+ */
+ public PortletSessionImpl(PortletContext portletContext,
+ PortletWindow portletWindow,
+ HttpSession httpSession) {
+ this.portletContext = portletContext;
+ this.portletWindow = portletWindow;
+ this.httpSession = httpSession;
+ }
+
+ // InternalPortletSession Impl -----------------------------------------
+
+ public HttpSession getHttpSession()
+ {
+ return httpSession;
+ }
+
+ // PortletSession Impl: Attributes -----------------------------------------
+
+ public Object getAttribute(String name) {
+ return getAttribute(name, DEFAULT_SCOPE);
+ }
+
+ /**
+ * Returns the attribute of the specified name under the given scope.
+ *
+ * @param name the attribute name.
+ * @param scope the scope under which the attribute object is stored.
+ * @return the attribute object.
+ */
+ public Object getAttribute(String name, int scope) {
+ ArgumentUtility.validateNotNull("attributeName", name);
+ String key = (scope == PortletSession.APPLICATION_SCOPE)
+ ? name : createPortletScopedId(name);
+ return httpSession.getAttribute(key);
+ }
+
+ public Enumeration<String> getAttributeNames() {
+ return getAttributeNames(DEFAULT_SCOPE);
+ }
+
+ public Enumeration<String> getAttributeNames(int scope) {
+ // Return all attribute names in the nested HttpSession object.
+ if (scope == PortletSession.APPLICATION_SCOPE) {
+ return httpSession.getAttributeNames();
+ }
+ // Return attribute names with the portlet-scoped prefix.
+ Vector<String> portletScopedNames = new Vector<String>();
+ for (Enumeration<String> en = httpSession.getAttributeNames();
+ en.hasMoreElements(); ) {
+ String name = en.nextElement();
+ if (isInCurrentPortletScope(name)) {
+ portletScopedNames.add(
+ PortletSessionUtil.decodeAttributeName(name));
+ }
+ }
+ return portletScopedNames.elements();
+
+ }
+
+ public void removeAttribute(String name) {
+ removeAttribute(name, DEFAULT_SCOPE);
+ }
+
+ public void removeAttribute(String name, int scope) {
+ ArgumentUtility.validateNotNull("attributeName", name);
+ if (scope == PortletSession.APPLICATION_SCOPE) {
+ httpSession.removeAttribute(name);
+ } else {
+ httpSession.removeAttribute(createPortletScopedId(name));
+ }
+ }
+
+ public void setAttribute(String name, Object value) {
+ setAttribute(name, value, DEFAULT_SCOPE);
+ }
+
+ public void setAttribute(String name, Object value, int scope) {
+ ArgumentUtility.validateNotNull("attributeName", name);
+ if (scope == PortletSession.APPLICATION_SCOPE) {
+ httpSession.setAttribute(name, value);
+ } else {
+ httpSession.setAttribute(createPortletScopedId(name), value);
+ }
+ }
+
+
+ // PortletSession Impl: Other Methods --------------------------------------
+
+ public PortletContext getPortletContext() {
+ return portletContext;
+ }
+
+ public long getCreationTime() {
+ return httpSession.getCreationTime();
+ }
+
+ public String getId() {
+ return httpSession.getId();
+ }
+
+ public long getLastAccessedTime() {
+ return httpSession.getLastAccessedTime();
+ }
+
+ public int getMaxInactiveInterval() {
+ return httpSession.getMaxInactiveInterval();
+ }
+
+ public void invalidate(){
+ httpSession.invalidate();
+ }
+
+ public boolean isNew(){
+ return httpSession.isNew();
+ }
+
+ /**
+ * Specifies the time, in seconds, between client requests, before the
+ * portlet container invalidates this session. A negative time indicates
+ * the session should never timeout.
+ * <p>
+ * [Portlet Spec. PLT. 15.4.] If the PortletSession object is invalidated
+ * by a portlet, the portlet container must invalidate the associated
+ * HttpSession object.
+ * </p>
+ * @param interval an integer specifying the number of seconds.
+ */
+ public void setMaxInactiveInterval(int interval) {
+ httpSession.setMaxInactiveInterval(interval);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Session timeout set to: " + interval);
+ }
+ }
+
+
+ // Private Methods ---------------------------------------------------------
+
+ /**
+ * Creates portlet-scoped ID for the specified attribute name.
+ * Portlet-scoped ID for a given attribute name has the following form:
+ * <code>javax.portlet.p.<ID>?<name></code>
+ * where <code>ID</code> is a unique identification for the portlet window
+ * (assigned by the portal/portlet-container) that must not contain a '?'
+ * character. <code>name</code> is the attribute name.
+ * <p>
+ * Refer to Portlet Specification PLT. 15.3 for more details.
+ * </p>
+ * @param name the attribute name.
+ * @return portlet-scoped ID for the attribute name.
+ */
+ protected String createPortletScopedId(String name) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(PORTLET_SCOPE_NAMESPACE);
+ buffer.append(portletWindow.getId().getStringId());
+ buffer.append(ID_NAME_SEPARATOR);
+ buffer.append(name);
+ return buffer.toString();
+ }
+
+ /**
+ * Checks if the attribute name in APPLICATION_SCOPE is in the current
+ * portlet scope.
+ * @param name the attribute name to check.
+ * @return true if the attribute name is in the current portlet scope.
+ * @see #createPortletScopedId(String)
+ */
+ protected boolean isInCurrentPortletScope(String name) {
+ // Portlet-scoped attribute names MUST start with "javax.portlet.p.",
+ // and contain the ID-name separator '?'.
+ if (name.startsWith(PORTLET_SCOPE_NAMESPACE)
+ && name.indexOf(ID_NAME_SEPARATOR) > -1) {
+ String id = name.substring(PORTLET_SCOPE_NAMESPACE.length(),
+ name.indexOf(ID_NAME_SEPARATOR));
+ return (id.equals(portletWindow.getId().getStringId()));
+ }
+ // Application-scoped attribute names are not in portlet scope.
+ return false;
+ }
+
+
+ // HttpSession Impl --------------------------------------------------------
+
+ public Map<String, Object> getMap() {
+ List<String> paramNames = getAttributeNamesAsList(DEFAULT_SCOPE);
+ return fillMap(paramNames, DEFAULT_SCOPE);
+ }
+
+ public Map<String, Object> getMap(int scope) {
+ List<String> paramNames = getAttributeNamesAsList(scope);
+ return fillMap(paramNames, scope);
+ }
+
+// ***** private methods *****
+
+ /**
+ * transforms the getAttributeNames enumeration to a list
+ * @return list of getAttributeNames
+ */
+ private List<String> getAttributeNamesAsList(int scope) {
+ //transform Enum to List
+ List<String> paramNames = new ArrayList<String>();
+ Enumeration<String> e = getAttributeNames(scope);
+ while (e.hasMoreElements()){
+ paramNames.add(e.nextElement());
+ }
+ return paramNames;
+ }
+
+ /**
+ * @param paramNames list of the attribute names to be filled in the map
+ * @return the filled map
+ */
+ private Map<String, Object> fillMap(List<String> paramNames, int scope) {
+ Map<String, Object> resultMap = new HashMap<String, Object>();
+ for (String string : paramNames) {
+ resultMap.put(string, getAttribute(string,scope));
+ }
+ return resultMap;
+ }
+
+ /**
+ * Returns a <code>Map</code> of the session attributes in
+ * the portlet session scope.
+ * <p>
+ * The keys are of type <code>String</code> and the values in the
+ * returned <code>Map</code> are from type <code>Object</code>.
+ * <p>
+ * If no session attributes exist this method returns an empty <code>Map</code>.
+ *
+ * @return an immutable <code>Map</code> containing the session attributes in the
+ * portlet session scope as keys and attribute values as map values, or an empty <code>Map</code>
+ * if no session attributes exist. The keys in the
+ * map are of type String, the values of type
+ * Object.
+ * @since 2.0
+ */
+ public Map<String, Object> getAttributeMap(int scope){
+ return getMap(scope);
+ }
+ /**
+ * Returns a <code>Map</code> of the session attributes in
+ * the portlet session scope.
+ * <p>
+ * The keys are of type <code>String</code> and the values in the
+ * returned <code>Map</code> are from type <code>Object</code>.
+ * <p>
+ * If no session attributes exist this method returns an empty <code>Map</code>.
+ *
+ * @return an immutable <code>Map</code> containing the session attributes in the
+ * portlet session scope as keys and attribute values as map values, or an empty <code>Map</code>
+ * if no session attributes exist. The keys in the
+ * map are of type String, the values of type
+ * Object.
+ * @since 2.0
+ */
+ public Map<String, Object> getAttributeMap(){
+ return getMap();
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/impl/ServletPortletSessionProxy.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/ServletPortletSessionProxy.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/ServletPortletSessionProxy.java
index a520f24..5470ee5 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/ServletPortletSessionProxy.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/ServletPortletSessionProxy.java
@@ -1,134 +1,132 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.container.impl;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import org.apache.pluto.container.util.NamespacedNamesEnumeration;
-
-/**
- * Proxy for a Servlet HttpSession to attach to a PortletSession, providing only access to PORTLET_SCOPE session attributes
- * and hiding the APPLICATION_SCOPE attributes from the Servlet.
- * <br/>
- * This Proxy can be used to isolate two instances of the same Portlet dispatching to Servlets so they don't overwrite or read
- * each others session attributes.
- *
- * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
- * @version $Id$
- */
-public class ServletPortletSessionProxy implements InvocationHandler
-{
- HttpSession servletSession;
- String portletWindowId;
- String portletScopeAttrNamePrefix;
-
- public static HttpSession createProxy(HttpServletRequest request, String portletWindowId)
- {
- HttpSession servletSession = request.getSession();
- HashSet<Class<? extends Object>> interfaces = new HashSet<Class<? extends Object>>();
- interfaces.add(HttpSession.class);
- Class<? extends Object> current = servletSession.getClass();
- while (current != null)
- {
- try
- {
- @SuppressWarnings("unchecked")
- Class<? extends Object>[] currentInterfaces = current.getInterfaces();
- for (int i = 0; i < currentInterfaces.length; i++)
- {
- interfaces.add(currentInterfaces[i]);
- }
- current = current.getSuperclass();
- }
- catch (Exception e)
- {
- current = null;
- }
- }
- Object proxy = Proxy.newProxyInstance(servletSession.getClass().getClassLoader(),
- interfaces.toArray(new Class[interfaces.size()]),
- new ServletPortletSessionProxy(request.getSession(), portletWindowId));
- return (HttpSession)proxy;
- }
-
- private ServletPortletSessionProxy(HttpSession servletSession, String portletWindowId)
- {
- this.servletSession = servletSession;
- this.portletWindowId = portletWindowId;
- this.portletScopeAttrNamePrefix = PortletSessionImpl.PORTLET_SCOPE_NAMESPACE + this.portletWindowId + PortletSessionImpl.ID_NAME_SEPARATOR;
- }
-
- /**
- * (non-Javadoc)
- *
- * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,
- * java.lang.reflect.Method, java.lang.Object[])
- */
- @SuppressWarnings("unchecked")
- public Object invoke(Object proxy, Method m, Object[] args) throws Throwable
- {
- Object retval = null;
- if (("getAttribute".equals(m.getName()) || "getValue".equals(m.getName())) && args.length == 1 && args[0] instanceof String)
- {
- retval = servletSession.getAttribute(this.portletScopeAttrNamePrefix + (String) args[0]);
- }
- else if (("setAttribute".equals(m.getName()) || "putValue".equals(m.getName())) && args.length == 2 && args[0] instanceof String)
- {
- servletSession.setAttribute(this.portletScopeAttrNamePrefix + (String) args[0], args[1]);
- }
- else if (("removeAttribute".equals(m.getName()) || "removeValue".equals(m.getName())) && args.length == 1 && args[0] instanceof String)
- {
- servletSession.removeAttribute(this.portletScopeAttrNamePrefix + (String) args[0]);
- }
- else if ("getAttributeNames".equals(m.getName()) && args == null)
- {
- retval = new NamespacedNamesEnumeration(servletSession.getAttributeNames(), this.portletScopeAttrNamePrefix);
- }
- else if ("getValueNames".equals(m.getName()) && args == null)
- {
- final List<String> list = new ArrayList<String>();
- Enumeration<String> e = new NamespacedNamesEnumeration(servletSession.getAttributeNames(), this.portletScopeAttrNamePrefix);
- while (e.hasMoreElements())
- {
- list.add(e.nextElement());
- }
- retval = list.toArray(new String[list.size()]);
- }
- else
- {
- try
- {
- retval = m.invoke(servletSession, args);
- }
- catch (InvocationTargetException ite)
- {
- throw ite.getTargetException();
- }
- }
- return retval;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.container.impl;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.pluto.container.util.NamespacedNamesEnumeration;
+
+/**
+ * Proxy for a Servlet HttpSession to attach to a PortletSession, providing only access to PORTLET_SCOPE session attributes
+ * and hiding the APPLICATION_SCOPE attributes from the Servlet.
+ * <br/>
+ * This Proxy can be used to isolate two instances of the same Portlet dispatching to Servlets so they don't overwrite or read
+ * each others session attributes.
+ *
+ * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
+ * @version $Id$
+ */
+public class ServletPortletSessionProxy implements InvocationHandler
+{
+ HttpSession servletSession;
+ String portletWindowId;
+ String portletScopeAttrNamePrefix;
+
+ public static HttpSession createProxy(HttpServletRequest request, String portletWindowId)
+ {
+ HttpSession servletSession = request.getSession();
+ HashSet<Class<? extends Object>> interfaces = new HashSet<Class<? extends Object>>();
+ interfaces.add(HttpSession.class);
+ Class<? extends Object> current = servletSession.getClass();
+ while (current != null)
+ {
+ try
+ {
+ Class<? extends Object>[] currentInterfaces = current.getInterfaces();
+ for (int i = 0; i < currentInterfaces.length; i++)
+ {
+ interfaces.add(currentInterfaces[i]);
+ }
+ current = current.getSuperclass();
+ }
+ catch (Exception e)
+ {
+ current = null;
+ }
+ }
+ Object proxy = Proxy.newProxyInstance(servletSession.getClass().getClassLoader(),
+ interfaces.toArray(new Class[interfaces.size()]),
+ new ServletPortletSessionProxy(request.getSession(), portletWindowId));
+ return (HttpSession)proxy;
+ }
+
+ private ServletPortletSessionProxy(HttpSession servletSession, String portletWindowId)
+ {
+ this.servletSession = servletSession;
+ this.portletWindowId = portletWindowId;
+ this.portletScopeAttrNamePrefix = PortletSessionImpl.PORTLET_SCOPE_NAMESPACE + this.portletWindowId + PortletSessionImpl.ID_NAME_SEPARATOR;
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,
+ * java.lang.reflect.Method, java.lang.Object[])
+ */
+ public Object invoke(Object proxy, Method m, Object[] args) throws Throwable
+ {
+ Object retval = null;
+ if (("getAttribute".equals(m.getName()) || "getValue".equals(m.getName())) && args.length == 1 && args[0] instanceof String)
+ {
+ retval = servletSession.getAttribute(this.portletScopeAttrNamePrefix + (String) args[0]);
+ }
+ else if (("setAttribute".equals(m.getName()) || "putValue".equals(m.getName())) && args.length == 2 && args[0] instanceof String)
+ {
+ servletSession.setAttribute(this.portletScopeAttrNamePrefix + (String) args[0], args[1]);
+ }
+ else if (("removeAttribute".equals(m.getName()) || "removeValue".equals(m.getName())) && args.length == 1 && args[0] instanceof String)
+ {
+ servletSession.removeAttribute(this.portletScopeAttrNamePrefix + (String) args[0]);
+ }
+ else if ("getAttributeNames".equals(m.getName()) && args == null)
+ {
+ retval = new NamespacedNamesEnumeration(servletSession.getAttributeNames(), this.portletScopeAttrNamePrefix);
+ }
+ else if ("getValueNames".equals(m.getName()) && args == null)
+ {
+ final List<String> list = new ArrayList<String>();
+ Enumeration<String> e = new NamespacedNamesEnumeration(servletSession.getAttributeNames(), this.portletScopeAttrNamePrefix);
+ while (e.hasMoreElements())
+ {
+ list.add(e.nextElement());
+ }
+ retval = list.toArray(new String[list.size()]);
+ }
+ else
+ {
+ try
+ {
+ retval = m.invoke(servletSession, args);
+ }
+ catch (InvocationTargetException ite)
+ {
+ throw ite.getTargetException();
+ }
+ }
+ return retval;
+ }
+}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationHolder.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationHolder.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationHolder.java
index 9e3a18e..46ba537 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationHolder.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationHolder.java
@@ -36,6 +36,7 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import org.apache.pluto.container.bean.processor.AnnotatedMethodStore;
import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
import org.apache.pluto.container.om.portlet.PortletDefinition;
import org.slf4j.Logger;
@@ -70,6 +71,14 @@ public class ConfigurationHolder {
}
/**
+ * Constructor taking existing portlet app definition - for testing purposes
+ * @param pad
+ */
+ public ConfigurationHolder(PortletApplicationDefinition pad) {
+ this.pad = pad;
+ }
+
+ /**
* returns the finished portlet application definition
*
* @return the portlet application definition
@@ -235,9 +244,20 @@ public class ConfigurationHolder {
* validates the configuration. To be called after the configuration has been completely read.
*/
public void validate() {
- if (jcp != null) {
- jcp.validate();
+ if (jcp == null) {
+ jcp = new JSR362ConfigurationProcessor(pad);
+ }
+ jcp.validate();
+ }
+
+ /**
+ * Reconciles the bean configuration with the config from annotations & portlet DD.
+ */
+ public void reconcileBeanConfig(AnnotatedMethodStore ams) {
+ if (jcp == null) {
+ jcp = new JSR362ConfigurationProcessor(pad);
}
+ jcp.reconcileBeanConfig(ams);
}
}
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
index e3932d3..5460a10 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
@@ -16,6 +16,7 @@ import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;
+import org.apache.pluto.container.bean.processor.AnnotatedMethodStore;
import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,6 +71,24 @@ public abstract class ConfigurationProcessor {
* If there is a validation error.
*/
public abstract void validate() throws IllegalArgumentException;
+
+ /**
+ * reconciles the given annotated method store containing the bean configuration
+ * with the configuration as read from the portlet deployment descriptor and
+ * the corresponding type annotations.
+ * <p>
+ * Portlets that are defined in the bean config are added to the portlet application
+ * definition if not already present. Event reference information from the
+ * annotations is verified and added to the corresponding portlet definition.
+ * <p>
+ * Methods from portlet classes definied in the portlet definitions are
+ * added to the annotated method store.
+ *
+ * @param ams
+ */
+ public void reconcileBeanConfig(AnnotatedMethodStore ams) {
+ // do nothing for JSR 168 & JSR 286 portlets
+ }
/**
* Handle the locale the old-fashioned way (v1 & v2)
@@ -101,6 +120,9 @@ public abstract class ConfigurationProcessor {
* @return
*/
protected boolean isValidIdentifier(String id) {
+ if (id == null || id.length() == 0) {
+ return false;
+ }
char[] chars = id.toCharArray();
if (!Character.isJavaIdentifierStart(chars[0])) {
return false;
http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/2e60a313/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionImpl.java
index a4a70bd..ad0cc63 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/EventDefinitionImpl.java
@@ -40,7 +40,7 @@ public class EventDefinitionImpl implements EventDefinition {
private final ArrayList<QName> aliases = new ArrayList<QName>();
private final List<Description> descs = new ArrayList<Description>();
private final List<DisplayName> dispNames = new ArrayList<DisplayName>();
- private String valType = "";
+ private String valType;
/**
* Copy constructor