Author: julien(a)jboss.com
Date: 2007-03-15 16:53:20 -0400 (Thu, 15 Mar 2007)
New Revision: 6697
Added:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistrationContext.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerAdapter.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortalContextImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletContextImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCacheInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSecurityInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSessionInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContentTypes.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/InfoBundle.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java
Removed:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerAdapter.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCacheInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCapabilities.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerMetaInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerModeInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPortletInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferencesInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSecurityInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSessionInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerWindowStateInfo.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContentTypes.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/InfoBundle.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/PortletResourceBundleManager.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/Utils.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortalContextImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletConfigImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContextImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResponseImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletSessionImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletURLImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderRequestImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java
Modified:
trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/TransactionInterceptor.java
trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java
trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java
trunk/core/src/main/org/jboss/portlet/JBossAPIFactory.java
trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java
trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java
trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java
trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationContextImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistry.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/JBossApplicationMetaDataFactory.java
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactory.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactoryImpl.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/CacheInfoSupport.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java
trunk/portlet/src/main/org/jboss/portal/test/server/ContentTypesTestCase.java
trunk/portlet/src/resources/test-sar/META-INF/jboss-service.xml
Log:
improve split between interfaces and jsr168 based implementation of portlet container
Modified: trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java
===================================================================
---
trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -23,7 +23,7 @@
package org.jboss.portal.bridge;
import org.apache.portals.bridges.common.ServletContextProvider;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import javax.portlet.GenericPortlet;
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/HeaderInterceptor.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -28,7 +28,7 @@
import org.jboss.portal.core.metadata.portlet.JBossPortletMetaData;
import org.jboss.portal.core.metadata.portlet.ElementMetaData;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
Modified:
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/TransactionInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/TransactionInterceptor.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/portlet/TransactionInterceptor.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -24,7 +24,7 @@
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
Modified: trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java 2007-03-15 20:13:17
UTC (rev 6696)
+++ trunk/core/src/main/org/jboss/portal/test/core/I18nELTestCase.java 2007-03-15 20:53:20
UTC (rev 6697)
@@ -25,8 +25,8 @@
import org.apache.cactus.JspTestCase;
import org.jboss.portal.core.servlet.jsp.PortalJsp;
import org.jboss.portal.core.servlet.jsp.taglib.PortalLib;
-import org.jboss.portal.portlet.container.info.PortletResourceBundleManager;
-import org.jboss.portal.portlet.impl.jsr168.PortletConfigImpl;
+import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletConfigImpl;
import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
import javax.portlet.PortletConfig;
Modified: trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java 2007-03-15
20:13:17 UTC (rev 6696)
+++ trunk/core/src/main/org/jboss/portal/test/core/I18nOutELTestCase.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -27,8 +27,8 @@
import org.jboss.portal.core.servlet.jsp.taglib.PortalLib;
import org.jboss.portal.core.servlet.jsp.taglib.context.Context;
import org.jboss.portal.core.servlet.jsp.taglib.context.DelegateContext;
-import org.jboss.portal.portlet.container.info.PortletResourceBundleManager;
-import org.jboss.portal.portlet.impl.jsr168.PortletConfigImpl;
+import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletConfigImpl;
import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
import javax.portlet.PortletConfig;
Modified: trunk/core/src/main/org/jboss/portlet/JBossAPIFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossAPIFactory.java 2007-03-15 20:13:17 UTC
(rev 6696)
+++ trunk/core/src/main/org/jboss/portlet/JBossAPIFactory.java 2007-03-15 20:53:20 UTC
(rev 6697)
@@ -23,10 +23,10 @@
package org.jboss.portlet;
import org.jboss.portal.portlet.impl.jsr168.APIFactory;
-import org.jboss.portal.portlet.impl.jsr168.ActionRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.ActionResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.RenderRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.RenderResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java 2007-03-15 20:13:17 UTC
(rev 6696)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionRequest.java 2007-03-15 20:53:20 UTC
(rev 6697)
@@ -27,13 +27,12 @@
import org.jboss.portal.core.controller.portlet.ControllerUserContext;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.identity.User;
-import org.jboss.portal.portlet.impl.jsr168.ActionRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portlet.util.Parameters;
import javax.portlet.PortletPreferences;
-import java.util.Map;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-03-15 20:13:17 UTC
(rev 6696)
+++ trunk/core/src/main/org/jboss/portlet/JBossActionResponse.java 2007-03-15 20:53:20 UTC
(rev 6697)
@@ -29,8 +29,8 @@
import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
import org.jboss.portal.core.controller.portlet.SignOutResponse;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.portlet.impl.jsr168.ActionResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.PortletRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
Modified: trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java 2007-03-15 20:13:17
UTC (rev 6696)
+++ trunk/core/src/main/org/jboss/portlet/JBossPortletPreferences.java 2007-03-15 20:53:20
UTC (rev 6697)
@@ -23,9 +23,9 @@
package org.jboss.portlet;
import org.jboss.portal.common.util.ProxyInfo;
-import org.jboss.portal.portlet.impl.jsr168.PortletPreferencesImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletPreferencesImpl;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
import org.jboss.portal.portlet.state.PropertyContext;
-import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
import javax.portlet.PreferencesValidator;
import java.lang.reflect.InvocationHandler;
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2007-03-15 20:13:17 UTC
(rev 6696)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderRequest.java 2007-03-15 20:53:20 UTC
(rev 6697)
@@ -27,7 +27,7 @@
import org.jboss.portal.core.controller.portlet.ControllerUserContext;
import org.jboss.portal.core.controller.ControllerContext;
import org.jboss.portal.identity.User;
-import org.jboss.portal.portlet.impl.jsr168.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portlet.util.Parameters;
Modified: trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-03-15 20:13:17 UTC
(rev 6696)
+++ trunk/core/src/main/org/jboss/portlet/JBossRenderResponse.java 2007-03-15 20:53:20 UTC
(rev 6697)
@@ -27,8 +27,8 @@
import org.jboss.portal.core.aspects.controller.node.PortalNodeURLFactory;
import org.jboss.portal.core.aspects.controller.node.PortalObjectNode;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.portlet.impl.jsr168.PortletRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.RenderResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ContextDispatcherInterceptor.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -26,7 +26,7 @@
import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.container.PortletApplication;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/aspects/portlet/ValveInterceptor.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -24,9 +24,9 @@
import org.jboss.portal.common.concurrent.Valve;
import org.jboss.portal.common.invocation.InvocationException;
-import org.jboss.portal.portlet.container.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
import org.jboss.portal.portlet.invocation.PortletInterceptor;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationContextImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationContextImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationContextImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -29,6 +29,7 @@
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
import org.jboss.portal.portlet.impl.jsr168.APIFactory;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
@@ -84,11 +85,13 @@
public void start() throws Exception
{
portletApp = new PortletApplicationImpl(portletAppMD, jbossAppMD, this);
- portletApp.setRegistry(registry);
+ PortletApplicationRegistrationContext registrationContext =
registry.registerPortletApplication(portletApp);
+
+ //
+ portletApp.setRegistrationContext(registrationContext);
portletApp.setAPIFactory(apiFactory);
portletApp.create();
portletApp.start();
- registry.registerPortletApplication(portletApp);
}
public void stop()
@@ -96,6 +99,10 @@
registry.unregisterPortletApplication(portletApp);
portletApp.stop();
portletApp.destroy();
+
+ //
+ portletApp.setRegistrationContext(null);
+ portletApp = null;
}
public PortletApplicationImpl getPortletApplication()
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,192 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.portlet.impl.jsr168.APIFactory;
-import org.jboss.portal.portlet.impl.jsr168.PortletContextImpl;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
-
-import javax.portlet.PortletContext;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletApplicationImpl extends AbstractJBossService implements
PortletApplication
-{
-
- protected LinkedHashMap portlets;
- protected PortletApplicationMetaData metaData;
- protected JBossApplicationMetaData jbossMetaData;
- protected PortletApplicationContext context;
-
- protected PortletContext portletContext;
- protected String version;
- protected Map portletModes;
- protected Map windowStates;
- protected APIFactory apiFactory;
- protected PortletApplicationRegistry registry;
-
- public PortletApplicationImpl(
- PortletApplicationMetaData metaData,
- JBossApplicationMetaData jbossMetaData,
- PortletApplicationContext context)
- {
- this.metaData = metaData;
- this.jbossMetaData = jbossMetaData;
- this.portlets = new LinkedHashMap();
- this.context = context;
- }
-
- public String getId()
- {
- return metaData.getId();
- }
-
- public PortletApplicationRegistry getRegistry()
- {
- return registry;
- }
-
- public void setRegistry(PortletApplicationRegistry registry)
- {
- this.registry = registry;
- }
-
- public APIFactory getAPIFactory()
- {
- return apiFactory;
- }
-
- public void setAPIFactory(APIFactory apiFactory)
- {
- this.apiFactory = apiFactory;
- }
-
- public PortletApplicationMetaData getMetaData()
- {
- return metaData;
- }
-
- public JBossApplicationMetaData getJBossMetaData()
- {
- return jbossMetaData;
- }
-
- public void addContainer(PortletContainer container)
- {
- portlets.put(container.getId(), container);
- registry.registerPortlet(container);
- }
-
- public void removeContainer(PortletContainer container)
- {
- registry.unregisterPortlet(container);
- portlets.remove(container.getId());
- }
-
- //
-
- public void startService() throws Exception
- {
- super.startService();
-
- //
- version = metaData.getVersion();
- portletModes = metaData.getPortletModes();
- windowStates = metaData.getWindowStates();
- portletContext = new PortletContextImpl(context.getServletContext());
- }
-
- public void stopService() throws Exception
- {
- //
- version = null;
- portletModes = null;
- windowStates = null;
- portletContext = null;
-
- //
- super.stopService();
- }
-
- public String getVersion()
- {
- return version;
- }
-
- public PortletContext getPortletContext()
- {
- return portletContext;
- }
-
- public Map getPortletModes()
- {
- return portletModes;
- }
-
- public Map getWindowStates()
- {
- return windowStates;
- }
-
- public void start(String portletName) throws Exception
- {
- context.startPortlet(portletName);
- }
-
- public void stop(String portletName) throws Exception
- {
- context.stopPortlet(portletName);
- }
-
- // WebApp implementation
********************************************************************************************
-
- public Set getPortletContainers()
- {
- return new HashSet(portlets.values());
- }
-
- public PortletContainer getPortletContainer(String name)
- {
- return (PortletContainer)portlets.get(name);
- }
-
- public PortletApplicationContext getContext()
- {
- return context;
- }
-
- // Container implementation
*****************************************************************************************
-
- public String toString()
- {
- return "PortletWebApp[" + metaData.getId() + "]";
- }
-}
Added:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistrationContext.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistrationContext.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistrationContext.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.container;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletApplicationRegistrationContext
+{
+
+ /**
+ * Register a portlet.
+ *
+ * @param portletContainer the portlet container
+ */
+ void registerPortlet(PortletContainer portletContainer);
+
+ /**
+ * Unregister a portlet.
+ *
+ * @param portletContainer the portlet container
+ */
+ void unregisterPortlet(PortletContainer portletContainer);
+
+
+}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistry.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistry.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistry.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -31,25 +31,39 @@
*/
public interface PortletApplicationRegistry
{
- /** Register a portlet application. */
- void registerPortletApplication(PortletApplication portletApplication);
+ /**
+ * Register a portlet application.
+ *
+ * @param portletApplication the portlet application to register
+ * @throws IllegalArgumentException if the portlet application is null or already
registered
+ */
+ PortletApplicationRegistrationContext registerPortletApplication(PortletApplication
portletApplication) throws IllegalArgumentException;
- /** Unregister a portlet application. */
- void unregisterPortletApplication(PortletApplication portletApplication);
+ /**
+ * Unregister a portlet application.
+ *
+ * @param portletApplication the portlet application to unregister
+ * @throws IllegalArgumentException if the portlet application is null or not
registered
+ */
+ void unregisterPortletApplication(PortletApplication portletApplication) throws
IllegalArgumentException;
- /** Register a portlet. */
- void registerPortlet(PortletContainer portlet);
-
- /** Unregister a portlet. */
- void unregisterPortlet(PortletContainer portlet);
-
/** Return an immutable list all the known portlet application in the registry. */
Collection getPortletApplications();
/** Return a portlet app using its id or null if it does not exist. */
PortletApplication getPortletApplication(String id);
+ /**
+ * Adds a portlet container registry listener.
+ *
+ * @param listener
+ */
void addListener(PortletContainerRegistryListener listener);
+ /**
+ * Removes a portlet container registry listener.
+ *
+ * @param listener
+ */
void removeListener(PortletContainerRegistryListener listener);
}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationRegistryImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -40,13 +40,16 @@
public class PortletApplicationRegistryImpl extends AbstractJBossService implements
PortletApplicationRegistry
{
+ /** . */
private Map portletApplications = new HashMap();
- private Map portlets = new HashMap();
+ /** . */
+ private Map portletContainers = new HashMap();
+ /** . */
private List listeners = new ArrayList();
- public void registerPortletApplication(PortletApplication portletApplication)
+ public PortletApplicationRegistrationContext
registerPortletApplication(PortletApplication portletApplication)
{
if (portletApplication == null)
{
@@ -58,9 +61,11 @@
{
throw new IllegalArgumentException("This portlet app is already
registered");
}
+ PortletApplicationRegistrationContext ctx = new
PortletApplicationRegistrationContextImpl(portletApplication);
Map webAppsCopy = new HashMap(portletApplications);
webAppsCopy.put(portletApplication.getId(), portletApplication);
portletApplications = webAppsCopy;
+ return ctx;
}
}
@@ -82,38 +87,6 @@
}
}
- public void registerPortlet(PortletContainer portlet)
- {
- if (portlet == null)
- {
- throw new IllegalArgumentException("No null portlet accepted");
- }
- synchronized (this)
- {
- Map componentsCopy = new HashMap(portlets);
- componentsCopy.put(new ContainerKey(portlet), portlet);
- portlets = componentsCopy;
-
- //
- raiseRegisterPortletContainerEvent(portlet);
- }
- }
-
- public void unregisterPortlet(PortletContainer portlet)
- {
- if (portlet == null)
- {
- throw new IllegalArgumentException("No null portlet accepted");
- }
- synchronized (this)
- {
- Map componentsCopy = new HashMap(portlets);
- componentsCopy.remove(portlet);
- portlets = componentsCopy;
- raiseUnregisterPortletContainerEvent(portlet);
- }
- }
-
public Collection getPortletApplications()
{
return Collections.unmodifiableCollection(portletApplications.values());
@@ -174,7 +147,6 @@
}
}
-
private static class ContainerKey
{
/** . */
@@ -208,4 +180,70 @@
return applicationId.hashCode() & containerId.hashCode();
}
}
+
+ private class PortletApplicationRegistrationContextImpl implements
PortletApplicationRegistrationContext
+ {
+
+ /** . */
+ private PortletApplication portletApplication;
+
+ /** . */
+ private boolean active;
+
+ public PortletApplicationRegistrationContextImpl(PortletApplication
portletApplication)
+ {
+ this.portletApplication = portletApplication;
+ this.active = true;
+ }
+
+ public void registerPortlet(PortletContainer portletContainer)
+ {
+ if (portletContainer == null)
+ {
+ throw new IllegalArgumentException("No null portlet accepted");
+ }
+ if (portletContainer.getApplication() != portletApplication)
+ {
+ throw new IllegalArgumentException("The container does not belong to the
application owning the registration");
+ }
+ if (!active)
+ {
+ throw new IllegalStateException("Not anymore active");
+ }
+ synchronized (this)
+ {
+ Map componentsCopy = new HashMap(portletContainers);
+ componentsCopy.put(new ContainerKey(portletContainer), portletContainer);
+ portletContainers = componentsCopy;
+
+ //
+ raiseRegisterPortletContainerEvent(portletContainer);
+ }
+ }
+
+ public void unregisterPortlet(PortletContainer portletContainer)
+ {
+ if (portletContainer == null)
+ {
+ throw new IllegalArgumentException("No null portlet accepted");
+ }
+ if (portletContainer.getApplication() != portletApplication)
+ {
+ throw new IllegalArgumentException("The container does not belong to the
application owning the registration");
+ }
+ if (!active)
+ {
+ throw new IllegalStateException("Not anymore active");
+ }
+ synchronized (this)
+ {
+ Map componentsCopy = new HashMap(portletContainers);
+ componentsCopy.remove(portletContainer);
+ portletContainers = componentsCopy;
+ raiseUnregisterPortletContainerEvent(portletContainer);
+ }
+ }
+
+ }
+
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainer.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -22,494 +22,35 @@
******************************************************************************/
package org.jboss.portal.portlet.container;
-import org.jboss.logging.Logger;
import org.jboss.portal.common.concurrent.Valve;
import org.jboss.portal.common.invocation.InvocationException;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.container.info.ContentTypes;
-import org.jboss.portal.portlet.container.info.PortletResourceBundleManager;
-import org.jboss.portal.portlet.impl.jsr168.APIConstants;
-import org.jboss.portal.portlet.impl.jsr168.APIFactory;
-import org.jboss.portal.portlet.impl.jsr168.ActionRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.ActionResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.PortletConfigImpl;
-import org.jboss.portal.portlet.impl.jsr168.RenderRequestImpl;
-import org.jboss.portal.portlet.impl.jsr168.RenderResponseImpl;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ParameterMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletPreferencesMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.SecurityRoleRefMetaData;
+import org.jboss.portal.portlet.impl.jsr168.info.ContentTypes;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.ErrorResponse;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.SecurityErrorResponse;
-import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-import javax.portlet.Portlet;
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletException;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.PreferencesValidator;
-import javax.portlet.UnavailableException;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class PortletContainer
+public interface PortletContainer
{
- /** Logger. */
- protected final Logger log;
+ PortletInfo getInfo();
- /** . */
- protected PortletApplicationImpl application;
+ String getId();
- /** . */
- protected PortletMetaData metaData;
+ JBossPortletMetaData getJBossMetaData();
- /** . */
- protected JBossPortletMetaData jbossMetaData;
+ boolean isStarted();
- /** The portlet implementation class name. */
- protected String className;
+ ContentTypes getContentTypes();
- /** The portlet config. */
- protected PortletConfig config;
+ PortletApplication getApplication();
- /** The portlet instance. */
- protected Portlet portlet;
+ Valve getValve();
- /** . */
- protected ContentTypes contentTypes;
-
- /** . */
- protected PortletResourceBundleManager bundleMgr;
-
- /** The invocation valve. */
- protected final Valve valve;
-
- /** Give the correspondance between role name and role link. */
- protected Map securityRoleRefsMap;
-
- /** Are we started or not. */
- protected boolean started;
-
- /** User data constraint. */
- protected Set userDataConstraints;
-
- /** Return info. */
- protected PortletInfo info;
-
- /**
- * The preference validator, this is not exposed as runtime meta data as it is only
used by the JSR 168 portlet
- * container implementation.
- */
- protected PreferencesValidator preferencesValidator;
-
- public PortletContainer(PortletApplicationImpl application, PortletMetaData metaData,
JBossPortletMetaData jbossMetaData)
- {
- this.application = application;
- this.metaData = metaData;
- this.jbossMetaData = jbossMetaData;
- this.valve = new Valve();
- this.log = Logger.getLogger("org.jboss.portal.portlet.container." +
metaData.getClassName().replace('.', '_'));
- this.started = false;
- }
-
- public PortletInfo getInfo()
- {
- return info;
- }
-
- public String getId()
- {
- return metaData.getName();
- }
-
- public PortletMetaData getMetaData()
- {
- return metaData;
- }
-
- public JBossPortletMetaData getJBossMetaData()
- {
- return jbossMetaData;
- }
-
- public boolean isStarted()
- {
- return valve.getState() == Valve.OPEN;
- }
-
- public void start() throws Exception, PortletInitializationException
- {
- // Set class name
- this.className = metaData.getClassName();
-
- //
- PortletPreferencesMetaData preferences = metaData.getPreferences();
- if (preferences != null)
- {
- String validatorClassName = preferences.getValidator();
- if (validatorClassName != null)
- {
- try
- {
- ClassLoader loader = application.getContext().getClassLoader();
-
- //
- if (validatorClassName != null)
- {
- // Load the class
- Class preferencesValidatorClass =
loader.loadClass(validatorClassName);
- preferencesValidator =
(PreferencesValidator)preferencesValidatorClass.newInstance();
- }
- }
- catch (ClassNotFoundException e)
- {
- log.error("Class for preference validator not found", e);
- }
- catch (InstantiationException e)
- {
- log.error("Cannot instantiate preference validator", e);
- }
- catch (IllegalAccessException e)
- {
- throw new Error();
- }
- }
- }
-
- // Security role ref
- Map securityRoleRefsMap = new HashMap();
- for (Iterator i = metaData.getSecurityRoleRefs().iterator(); i.hasNext();)
- {
- SecurityRoleRefMetaData securityRoleRefMD = (SecurityRoleRefMetaData)i.next();
- securityRoleRefsMap.put(securityRoleRefMD.getRoleName(),
securityRoleRefMD.getRoleLink());
- }
-
- // Init parameters
- Map initParameters = new HashMap();
- for (Iterator i = metaData.getParameters().values().iterator(); i.hasNext();)
- {
- ParameterMetaData parameterMD = (ParameterMetaData)i.next();
- initParameters.put(parameterMD.getName(), parameterMD.getValue());
- }
-
- // Portlet config object
- PortletResourceBundleManager bundleMgr = new
PortletResourceBundleManager(application.getContext().getClassLoader(),
metaData.getLanguages());
-
- //
- PortletConfig config = new PortletConfigImpl(
- metaData.getName(),
- application.getPortletContext(),
- initParameters,
- bundleMgr);
-
- //
- ContentTypes contentTypes = new ContentTypes();
- contentTypes.setMetadata(metaData.getContentTypes());
- contentTypes.start();
-
- //
- PortletInfo info = new ContainerPortletInfo(this, bundleMgr, contentTypes);
-
- // Finally initialize the porlet instance
- try
- {
- log.debug("Loading portlet class " + className);
- Class portletClass =
application.getContext().getClassLoader().loadClass(className);
- log.debug("Creating portlet object " + className);
- Portlet portlet = (Portlet)portletClass.newInstance();
- log.debug("Created portlet object " + className);
- initPortlet(portlet, config);
- log.debug("Initialized portlet object " + className);
-
- // We are safe, update state
- this.portlet = portlet;
- this.config = config;
- this.securityRoleRefsMap = Collections.unmodifiableMap(securityRoleRefsMap);
- this.contentTypes = contentTypes;
- this.bundleMgr = bundleMgr;
- this.info = info;
- this.started = true;
-
- // Let invocation flow in
- valve.open();
-
- // Register
- // webApp.addContainer(this);
- }
- catch (IllegalAccessException e)
- {
- throw new PortletInitializationException("Portlet class not accessible
" + className, e);
- }
- catch (ClassNotFoundException e)
- {
- throw new PortletInitializationException("Portlet class not found " +
className, e);
- }
- catch (InstantiationException e)
- {
- throw new PortletInitializationException("Portlet class cannot be
instantiated " + className, e);
- }
- catch (PortletException e)
- {
- throw new PortletInitializationException("The portlet " + getId() +
" threw a portlet exception during init", e);
- }
- catch (RuntimeException e)
- {
- throw new PortletInitializationException("The portlet " + getId() +
" threw a runtime exception during init", e);
- }
- catch (Error e)
- {
- throw new PortletInitializationException("The portlet " + getId() +
" threw an error during init", e);
- }
- }
-
- public void stop()
- {
- //
- // webApp.removeContainer(this);
-
- // Wait at most 60 seconds before all invocations are done
- log.debug("Trying to close the valve");
- boolean done = valve.closing(60000);
- if (!done)
- {
- log.warn("The valve is still holding invocations, continue anyway");
- }
-
- //
- valve.closed();
-
- //
- if (started)
- {
- //
- started = false;
-
- // Destroy the portlet object
- destroyPortlet(portlet);
-
- // Stop the plugins (static)
- contentTypes.stop();
-
- // Update state
- preferencesValidator = null;
- className = null;
- portlet = null;
- securityRoleRefsMap = null;
- config = null;
- contentTypes = null;
- userDataConstraints = null;
- info = null;
- }
- }
-
- public PortletConfig getConfig()
- {
- return config;
- }
-
- public Portlet getPortlet()
- {
- return portlet;
- }
-
- public ContentTypes getContentTypes()
- {
- return contentTypes;
- }
-
- public Map getSecurityRoleRefsMap()
- {
- return securityRoleRefsMap;
- }
-
- public PortletApplication getApplication()
- {
- return application;
- }
-
- public Valve getValve()
- {
- return valve;
- }
-
- public Set getUserDataConstraints()
- {
- return userDataConstraints;
- }
-
- public PreferencesValidator getPreferencesValidator()
- {
- return preferencesValidator;
- }
-
- public String toString()
- {
- return "PortletContainer[name=" + getId() + ",+application=" +
application.getId() + "]";
- }
-
- /** Initialize the portlet. */
- private void initPortlet(Portlet portlet, PortletConfig config) throws
PortletException
- {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- // Set the war loader for the request
- ClassLoader newLoader = application.getContext().getClassLoader();
- Thread.currentThread().setContextClassLoader(newLoader);
- portlet.init(config);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldLoader);
- }
- }
-
- /** Destroy the portlet. */
- private void destroyPortlet(Portlet portlet)
- {
- ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- // Set the war loader for the request
- ClassLoader newLoader = application.getContext().getClassLoader();
- Thread.currentThread().setContextClassLoader(newLoader);
- if (portlet != null)
- {
- portlet.destroy();
- }
- else
- {
- log.debug("Cannot call destroy, portlet was null");
- }
- }
- catch (RuntimeException e)
- {
- log.error("The portlet threw a runtime exception", e);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(oldLoader);
- }
- }
-
- public PortletInvocationResponse dispatch(PortletInvocation invocation) throws
PortletInvokerException, InvocationException
- {
- try
- {
- if (invocation instanceof ActionInvocation)
- {
- return invokeAction((ActionInvocation)invocation);
- }
- else if (invocation instanceof RenderInvocation)
- {
- return invokeRender((RenderInvocation)invocation);
- }
- else
- {
- throw new InvocationException("Unexpected invocation " +
invocation);
- }
- }
- catch (NoClassDefFoundError e)
- {
- //
- return new ErrorResponse(e);
- }
- catch (Exception e)
- {
- log.error("The portlet threw an exception", e);
-
- //
- if (e instanceof PortletSecurityException)
- {
- return new SecurityErrorResponse(e);
- }
- else if (e instanceof UnavailableException)
- {
- UnavailableException ue = (UnavailableException)e;
- if (ue.isPermanent())
- {
- return new UnavailableResponse();
- }
- else
- {
- return new UnavailableResponse(ue.getUnavailableSeconds());
- }
- }
- else
- {
- // The exception is either a PortletException, an IOException or a
RuntimeException
- return new ErrorResponse(e);
- }
- }
- }
-
- protected PortletInvocationResponse invokeAction(ActionInvocation invocation) throws
IOException, PortletException
- {
- APIFactory factory = application.getAPIFactory();
- ActionRequestImpl areq = factory.createActionRequest(invocation);
- ActionResponseImpl aresp = factory.createActionResponse(invocation, areq);
- HttpServletRequest dreq = invocation.getDispatchedRequest();
- try
- {
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, areq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, aresp);
- dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
- portlet.processAction(areq, aresp);
- }
- finally
- {
- dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
- dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
- dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
-
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
- }
-
- return aresp.getResult();
- }
-
- protected PortletInvocationResponse invokeRender(RenderInvocation invocation) throws
IOException, PortletException
- {
- APIFactory factory = application.getAPIFactory();
- RenderRequestImpl rreq = factory.createRenderRequest(invocation);
- RenderResponseImpl rresp = factory.createRenderResponse(invocation, rreq);
- HttpServletRequest dreq = invocation.getDispatchedRequest();
- try
- {
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, rreq);
- dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, rresp);
- dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
- portlet.render(rreq, rresp);
- }
- finally
- {
- dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
- dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
- dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
-
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
- }
-
- return rresp.getResult();
- }
-
-
+ PortletInvocationResponse dispatch(PortletInvocation invocation) throws
PortletInvokerException, InvocationException;
}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerAdapter.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerAdapter.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerAdapter.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container;
-
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletContainerAdapter
-{
-
- /** . */
- private PortletMetaData portletMD;
-
- /** . */
- private JBossPortletMetaData jbossPortletMD;
-
- /** . */
- private PortletApplicationContextImpl portletApplicationContext;
-
- /** . */
- private PortletContainer portletContainer;
-
- public PortletContainerAdapter(PortletMetaData portletMD, JBossPortletMetaData
jbossPortletMD)
- {
- this.portletMD = portletMD;
- this.jbossPortletMD = jbossPortletMD;
- }
-
- public PortletApplicationContextImpl getPortletApplicationContext()
- {
- return portletApplicationContext;
- }
-
- public void setPortletWebAppAdapter(PortletApplicationContextImpl
portletApplicationContext)
- {
- this.portletApplicationContext = portletApplicationContext;
- }
-
- public PortletContainer getPortletContainer()
- {
- return portletContainer;
- }
-
- public void start() throws Exception
- {
- PortletApplicationImpl portletApp =
portletApplicationContext.getPortletApplication();
- portletContainer = new PortletContainer(portletApp, portletMD, jbossPortletMD);
- portletContainer.start();
- portletApp.addContainer(portletContainer);
- }
-
- public void stop()
- {
- PortletApplicationImpl portletApp =
portletApplicationContext.getPortletApplication();
- portletApp.removeContainer(portletContainer);
- portletContainer.stop();
- portletContainer = null;
- }
-}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerInvoker.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -32,9 +32,9 @@
import org.jboss.portal.portlet.PortletContext;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
-import org.jboss.portal.portlet.container.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferenceInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCacheInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCacheInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCacheInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,86 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.portlet.impl.jsr168.metadata.CacheConfigMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.info.CacheInfo;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ContainerCacheInfo implements CacheInfo
-{
-
- /** Cache uses strong references. */
- public static int REF_STRONG = 0;
-
- /** Cache uses soft references. */
- public static int REF_SOFT = 1;
-
- /** . */
- private static Logger log = Logger.getLogger(ContainerCacheInfo.class);
-
- /** . */
- private int expirationTimeSecs;
-
- /** . */
- private int referenceType;
-
- public ContainerCacheInfo(PortletMetaData portletMD, JBossPortletMetaData
jbossPortletMD)
- {
- CacheConfigMetaData cacheConfigMD = portletMD.getCacheConfig();
- if (cacheConfigMD != null)
- {
- expirationTimeSecs = cacheConfigMD.getExpirationTime();
- if (expirationTimeSecs < 0 && expirationTimeSecs != -1)
- {
- log.warn("Seen bad caching expiration value " + expirationTimeSecs
+ " disable caching instead");
- expirationTimeSecs = 0;
- }
- }
- else
- {
- expirationTimeSecs = 0;
- }
-
- referenceType = REF_STRONG;
- if (jbossPortletMD != null)
- {
- referenceType = jbossPortletMD.getCacheRefType() == null ? REF_STRONG :
jbossPortletMD.getCacheRefType().intValue();
- }
- }
-
- public int getExpirationSecs()
- {
- return expirationTimeSecs;
- }
-
- public int getReferenceType()
- {
- return referenceType;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCapabilities.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCapabilities.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCapabilities.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,111 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.portlet.info.CapabilitiesInfo;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ContainerCapabilities implements CapabilitiesInfo
-{
- private static Set WINDOW_STATES = new HashSet(3);
-
- static
- {
- WINDOW_STATES.add(new ContainerWindowStateInfo(WindowState.MAXIMIZED));
- WINDOW_STATES.add(new ContainerWindowStateInfo(WindowState.MINIMIZED));
- WINDOW_STATES.add(new ContainerWindowStateInfo(WindowState.NORMAL));
- WINDOW_STATES = Collections.unmodifiableSet(WINDOW_STATES);
- }
-
- private Set supportedLocales;
- private ContentTypes contentTypes;
- private PortletResourceBundleManager bundleMgr;
-
- public ContainerCapabilities(Set supportedLocales, PortletResourceBundleManager
bundleMgr, ContentTypes contentTypes) throws Exception
- {
- this.supportedLocales = supportedLocales;
- this.contentTypes = contentTypes;
- this.bundleMgr = bundleMgr;
- }
-
- public Set getMimeTypes()
- {
- return new HashSet(contentTypes.getAllContentTypes());
- }
-
- public Set getAllModes()
- {
- Set infos = new HashSet();
- for (Iterator i = contentTypes.getAllModes().iterator(); i.hasNext();)
- {
- infos.add(new ContainerModeInfo((Mode)i.next()));
- }
- return infos;
- }
-
- public Set getModes(String mimeType)
- {
- Set infos = new HashSet();
- for (Iterator i = contentTypes.getSupportedModes(mimeType).iterator();
i.hasNext();)
- {
- infos.add(new ContainerModeInfo((Mode)i.next()));
- }
- return infos;
- }
-
- public Set getAllWindowStates()
- {
- return WINDOW_STATES;
- }
-
- public Set getWindowStates(String mimeType)
- {
- if (contentTypes.isContentTypeSupported(mimeType))
- {
- return getAllWindowStates();
- }
- return Collections.EMPTY_SET;
- }
-
- public Set getAllLocales()
- {
- return supportedLocales;
- }
-
- public Set getLocales(String mimeType)
- {
- return getAllLocales();
- }
-
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerMetaInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerMetaInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerMetaInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,93 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.info.MetaInfo;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ContainerMetaInfo implements MetaInfo
-{
-
- private Map values;
- private static final String JAVAX_PORTLET = "javax.portlet.";
- private static final String[] KEYS = {TITLE, SHORT_TITLE, KEYWORDS};
- private static final String[] BUNDLE_KEYS = {JAVAX_PORTLET + TITLE, JAVAX_PORTLET +
SHORT_TITLE, JAVAX_PORTLET + KEYWORDS};
-
- public ContainerMetaInfo(PortletMetaData metadata, PortletResourceBundleManager rb)
- {
- this.values = new HashMap();
-
- // Construct info from resource bundle manager
- if (rb != null)
- {
- for (int i = 0; i < KEYS.length; i++)
- {
- String key = KEYS[i];
- Map tmp = new HashMap();
- List locales = metadata.getLanguages().getSupportedLocales();
-
- // Add english locale
- locales.add(Locale.ENGLISH);
-
- for (Iterator j = locales.iterator(); j.hasNext();)
- {
- Locale locale = (Locale)j.next();
- ResourceBundle bundle = rb.getResourceBundle(locale);
- try
- {
- String value = bundle.getString(BUNDLE_KEYS[i]);
- tmp.put(locale, value);
- }
- catch (MissingResourceException ignore)
- {
- }
- }
- LocalizedString ls = new LocalizedString(tmp, Locale.ENGLISH);
- values.put(key, ls);
- }
- }
-
- // Add stuff coming from meta data
- values.put(DESCRIPTION, Utils.getLocalizedDescription(metadata.getDescription()));
- values.put(DISPLAY_NAME,
Utils.getLocalizedDescription(metadata.getDisplayName()));
- }
-
- public LocalizedString getMetaValue(String key)
- {
- return (LocalizedString)values.get(key);
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerModeInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerModeInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerModeInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.portlet.info.ModeInfo;
-
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.4
- */
-class ContainerModeInfo implements ModeInfo
-{
- private final Mode mode;
- private static final LocalizedString DEFAULT_DESCRIPTION = new
LocalizedString("Default Portlet mode description.", Locale.ENGLISH);
-
- public ContainerModeInfo(Mode mode)
- {
- this.mode = mode;
- }
-
- public LocalizedString getDescription()
- {
- return DEFAULT_DESCRIPTION; // fix-me
- }
-
- public Mode getMode()
- {
- return mode;
- }
-
- public String getModeName()
- {
- return mode.toString();
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final ContainerModeInfo modeInfo = (ContainerModeInfo)o;
-
- return mode.equals(modeInfo.mode);
-
- }
-
- public int hashCode()
- {
- return mode.hashCode();
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPortletInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPortletInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPortletInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,139 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.portlet.container.PortletApplicationImpl;
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.info.CacheInfo;
-import org.jboss.portal.portlet.info.CapabilitiesInfo;
-import org.jboss.portal.portlet.info.MetaInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.portlet.info.PreferencesInfo;
-import org.jboss.portal.portlet.info.SecurityInfo;
-import org.jboss.portal.portlet.info.SessionInfo;
-import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-
-import java.util.HashSet;
-import java.util.Locale;
-
-/**
- * For now implementation that use the portlet container directly.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ContainerPortletInfo implements PortletInfo
-{
-
- private PortletContainer container;
- private ContainerCapabilities capabilities;
- private ContainerPreferencesInfo preferences;
- private ContainerMetaInfo meta;
- private ContainerSecurityInfo security;
- private ContainerCacheInfo cache;
- private ContainerSessionInfo session;
- private Boolean remotable;
-
- public ContainerPortletInfo(
- PortletContainer container,
- PortletResourceBundleManager bundleMgr,
- ContentTypes contentTypes)
- throws Exception
- {
- PortletMetaData portletMD = container.getMetaData();
- JBossPortletMetaData jbossPortletMD = container.getJBossMetaData();
- PortletApplicationImpl pwa = (PortletApplicationImpl)container.getApplication();
- JBossApplicationMetaData jbossAppMD = pwa.getJBossMetaData();
-
- //
- this.container = container;
-
- // Add Locale.ENGLISH to supported locales if no locales was provided
- // todo: should we always include it (i.e. even when other locales are present)?
- HashSet supportedLocales = new
HashSet(container.getMetaData().getLanguages().getSupportedLocales());
- if (supportedLocales.isEmpty())
- {
- supportedLocales.add(Locale.ENGLISH);
- }
-
- this.capabilities = new ContainerCapabilities(supportedLocales, bundleMgr,
contentTypes);
- this.preferences = portletMD.getPreferences() != null ? new
ContainerPreferencesInfo(portletMD, bundleMgr) : new ContainerPreferencesInfo();
- this.meta = new ContainerMetaInfo(portletMD, bundleMgr);
- this.security = new ContainerSecurityInfo(portletMD);
- this.cache = new ContainerCacheInfo(portletMD, jbossPortletMD);
- this.session = new ContainerSessionInfo(container);
-
- if (jbossPortletMD != null)
- {
- this.remotable = jbossPortletMD.getRemotable();
- }
- if (this.remotable == null && jbossAppMD != null)
- {
- this.remotable = jbossAppMD.getRemotable();
- }
-
- }
-
- public PortletContainer getContainer()
- {
- return container;
- }
-
- public CapabilitiesInfo getCapabilities()
- {
- return capabilities;
- }
-
- public PreferencesInfo getPreferences()
- {
- return preferences;
- }
-
- public MetaInfo getMeta()
- {
- return meta;
- }
-
- public SecurityInfo getSecurity()
- {
- return security;
- }
-
- public CacheInfo getCache()
- {
- return cache;
- }
-
- public SessionInfo getSession()
- {
- return session;
- }
-
- public Boolean isRemotable()
- {
- return remotable;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,80 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.value.Value;
-import org.jboss.portal.portlet.info.PreferenceInfo;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ContainerPreferenceInfo implements PreferenceInfo
-{
-
- private String key;
- private LocalizedString displayName;
- private LocalizedString description;
- private Boolean readOnly;
- private Value value;
-
- public ContainerPreferenceInfo(String key, LocalizedString displayName,
LocalizedString description, boolean readOnly, Value value)
- {
- this.key = key;
- this.displayName = displayName;
- this.description = description;
- this.readOnly = Boolean.valueOf(readOnly);
- this.value = value;
- }
-
- public String getKey()
- {
- return key;
- }
-
- public LocalizedString getDisplayName()
- {
- return displayName;
- }
-
- public LocalizedString getDescription()
- {
- return description;
- }
-
- public Boolean isReadOnly()
- {
- return readOnly;
- }
-
- /**
- * Return the value provided by the portlet.xml deployment descriptor.
- *
- * @return the preference value associated with this preference meta data
- */
- public Value getDefaultValue()
- {
- return value;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferencesInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferencesInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferencesInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,88 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.common.value.Value;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
-import org.jboss.portal.portlet.info.PreferenceInfo;
-import org.jboss.portal.portlet.info.PreferencesInfo;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ContainerPreferencesInfo implements PreferencesInfo
-{
-
- /** The cached container preference info. */
- private Map content;
-
- public ContainerPreferencesInfo()
- {
- content = new HashMap();
- }
-
- public ContainerPreferencesInfo(PortletMetaData portletMD,
PortletResourceBundleManager bundleMgr)
- {
- content = new HashMap();
-
- for (Iterator i = portletMD.getPreferences().iterator(); i.hasNext();)
- {
- PreferenceMetaData prefMD = (PreferenceMetaData)i.next();
- Value value = new StringValue(prefMD.getValues());
- LocalizedString displayName =
bundleMgr.getLocalizedValue("javax.portlet.preference.name." + prefMD.getName(),
prefMD.getName());
- LocalizedString description =
bundleMgr.getLocalizedValue("javax.portlet.preference.description." +
prefMD.getName(), prefMD.getName());
- ContainerPreferenceInfo pref = new ContainerPreferenceInfo(prefMD.getName(),
displayName, description, prefMD.isReadOnly(), value);
- content.put(pref.getKey(), pref);
- }
- }
-
- public ContainerPreferenceInfo getContainerPreference(String key)
- {
- if (key == null)
- {
- throw new IllegalArgumentException("Preference key must not be
null");
- }
- return (ContainerPreferenceInfo)content.get(key);
- }
-
- public Set getKeys()
- {
- return Collections.unmodifiableSet(content.keySet());
- }
-
- public PreferenceInfo getPreference(String key)
- {
- return getContainerPreference(key);
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSecurityInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSecurityInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSecurityInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,75 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.portlet.TransportGuarantee;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.TransportGuaranteesMetaData;
-import org.jboss.portal.portlet.info.SecurityInfo;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ContainerSecurityInfo implements SecurityInfo
-{
-
- /** . */
- private Set tgs;
-
- public ContainerSecurityInfo(PortletMetaData portletMD)
- {
- tgs = new HashSet();
- tgs.add(TransportGuarantee.NONE);
-
- //
- TransportGuaranteesMetaData tgMD = portletMD.getTransportGuarantees();
- if (tgMD != null)
- {
- for (Iterator i = tgMD.iterator(); i.hasNext();)
- {
- TransportGuarantee tg = (TransportGuarantee)i.next();
- tgs.add(tg);
- }
- }
-
- //
- tgs = Collections.unmodifiableSet(tgs);
- }
-
-
- public boolean containsTransportGuarantee(TransportGuarantee transportGuarantee)
- {
- return tgs.contains(transportGuarantee);
- }
-
- public Set getTransportGuarantees()
- {
- return tgs;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSessionInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSessionInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSessionInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,55 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.info.SessionInfo;
-import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ContainerSessionInfo implements SessionInfo
-{
-
- private Boolean distributed;
-
- ContainerSessionInfo(PortletContainer portletContainer)
- {
- JBossPortletMetaData md = portletContainer.getJBossMetaData();
- if (md != null)
- {
- distributed = md.getDistributed();
- }
- if (distributed == null)
- {
- distributed = Boolean.FALSE;
- }
- }
-
- public Boolean getDistributed()
- {
- return distributed;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerWindowStateInfo.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerWindowStateInfo.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerWindowStateInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.WindowState;
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.portlet.info.WindowStateInfo;
-
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- * @since 2.4
- */
-class ContainerWindowStateInfo implements WindowStateInfo
-{
- private final WindowState windowState;
- private static final LocalizedString DEFAULT_DESCRIPTION = new
LocalizedString("Default window state description.", Locale.ENGLISH);
-
- public ContainerWindowStateInfo(WindowState windowState)
- {
- this.windowState = windowState;
- }
-
- public LocalizedString getDescription()
- {
- return DEFAULT_DESCRIPTION; //fix-me
- }
-
- public WindowState getWindowState()
- {
- return windowState;
- }
-
- public String getWindowStateName()
- {
- return windowState.toString();
- }
-
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- final ContainerWindowStateInfo that = (ContainerWindowStateInfo)o;
-
- return windowState.equals(that.windowState);
-
- }
-
- public int hashCode()
- {
- return windowState.hashCode();
- }
-}
Deleted: trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContentTypes.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContentTypes.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContentTypes.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,351 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypeMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypesMetaData;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This object holds the content type and mode capabilities.
- * <p/>
- * Todo : use the media type object ?
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class ContentTypes
-{
- /** Maps MIME Type (String) -> Modes (Set), excluding multiple MIME Types
("*", "* / *", "type / *"). */
- protected final Map singleTypeToPortletModes;
- /** Maps MIME Type (String) -> Modes (Set), including multiple MIME Types
("*", "* / *", "type / *"). */
- protected final Map allTypeToPortletModes;
-
- protected final Set allModes;
-
- protected ContentTypesMetaData metadata;
- protected boolean isStarted = false;
-
- private static final String ALL = "*";
- private static final String ALL_ALL = "*/*";
- private static final char SLASH = '/';
-
- // case-insensitive
- // CONTENT TYPE = TYPE / SUBTYPE
- // SUBTYPE = any char except a TSPECIALS or SPACE or CTLS (??)
- // TSPECIALS ( ) < > @ , ; : \ " / [ ] ? . =
-
- public ContentTypes()
- {
- singleTypeToPortletModes = new HashMap();
- allTypeToPortletModes = new HashMap(); // Including *
- allModes = new HashSet();
- metadata = null;
- }
-
- public ContentTypesMetaData getMetadata()
- {
- return metadata;
- }
-
- public void setMetadata(ContentTypesMetaData metadata)
- {
- isStarted = false;
- initFromMetadata(metadata);
- this.metadata = metadata;
- }
-
- public void start() throws Exception
- {
- initFromMetadata(metadata);
- }
-
- /**
- * Process all the supported content types.
- *
- * @param metadata
- */
- private void initFromMetadata(ContentTypesMetaData metadata)
- {
- if (!isStarted)
- {
- if (metadata == null)
- {
- throw new IllegalArgumentException("Must pass non-null
metadata.");
- }
-
- // Reset the collections
- singleTypeToPortletModes.clear();
- allTypeToPortletModes.clear();
- allModes.clear();
-
- // Build info from metadata
- for (Iterator i = metadata.iterator(); i.hasNext();)
- {
- ContentTypeMetaData contentTypeMD = (ContentTypeMetaData)i.next();
-
- // Get the content type
- String contentType = contentTypeMD.getContentType().toLowerCase();
-
- // Add the content type to the view mode
- // because each content type must handle this view
- add(contentType, Mode.VIEW);
-
- // Then process each mode
- Set modes = contentTypeMD.getModes();
- for (Iterator j = modes.iterator(); j.hasNext();)
- {
- Mode mode = (Mode)j.next();
- add(contentType, mode);
- }
- }
- isStarted = true;
- }
- }
-
- public void stop()
- {
-
- }
-
- private void add(String contentType, Mode mode)
- {
- // Determines which map and key to store the mode under
- String key;
- if (ALL.equals(contentType) || ALL_ALL.equals(contentType))
- {
- key = ALL;
- }
- else
- {
- int index = contentType.indexOf(SLASH);
- if (index == -1)
- {
- System.out.println("'" + contentType + "' is not a
valid MIME type: ignoring!");
- return;
- }
-
- String type = contentType.substring(0, index);
- String subtype = contentType.substring(index + 1);
-
- if (ALL.equals(subtype))
- {
- key = type;
- }
- else
- {
- key = contentType;
- // This is a single content type so we need to add it to the single mappings
in addition to all
- addMode(singleTypeToPortletModes, key, mode);
- }
- }
-
- // Store the mode in the complete mapping
- addMode(allTypeToPortletModes, key, mode);
-
- // Add the mode to the known modes
- allModes.add(mode);
- }
-
- private void addMode(Map map, String key, Mode mode)
- {
- Set modes = (Set)map.get(key);
- if (modes == null)
- {
- modes = new HashSet();
- map.put(key, modes);
- }
- modes.add(mode);
- }
-
- /** Return all modes. */
- public Collection getAllModes()
- {
- return Collections.unmodifiableCollection(allModes);
- }
-
- /** Return all content types. */
- public Collection getAllContentTypes()
- {
- return Collections.unmodifiableCollection(allTypeToPortletModes.keySet());
- }
-
- /**
- * Return true if the mode is supported
- *
- * @throws IllegalArgumentException if the mode is null
- */
- public boolean isModeSupported(Mode mode)
- {
- if (mode == null)
- {
- throw new IllegalArgumentException("Mode must not be null");
- }
- return allModes.contains(mode);
- }
-
- /**
- * Return all the supported modes for this content type.
- *
- * @throws IllegalArgumentException if the content type is null
- */
- public Set getSupportedModes(String contentType)
- {
- if (contentType == null)
- {
- throw new IllegalArgumentException("Content type must not be null");
- }
-
- int index = contentType.indexOf(SLASH);
- if (index == -1)
- {
- // Not valid content type so return empty set
- return Collections.EMPTY_SET;
- }
-
- //
- Set set = new HashSet();
-
- //
- Set contentTypeModes =
(Set)singleTypeToPortletModes.get(contentType.toLowerCase());
- if (contentTypeModes != null)
- {
- set.addAll(contentTypeModes);
- }
-
- //
- Set typeModes = (Set)allTypeToPortletModes.get(contentType.substring(0,
index).toLowerCase());
- if (typeModes != null)
- {
- set.addAll(typeModes);
- }
-
- Set wildcardModes = (Set)allTypeToPortletModes.get(ALL);
- if (wildcardModes != null)
- {
- set.addAll(wildcardModes);
- }
-
- return set;
- }
-
- /**
- * Return true if the content type is supported.
- *
- * @throws IllegalArgumentException if the content type is null
- */
- public boolean isContentTypeSupported(String contentType)
- {
- Collection allContentTypes = getAllContentTypes();
- if (contentType == null)
- {
- throw new IllegalArgumentException("Content type must not be null");
- }
-
- int index = contentType.indexOf(SLASH);
- if (index == -1)
- {
- // Not valid content type so return false
- return false;
- }
-
- // Try the content type, * or */*
- if (allContentTypes.contains(contentType) |
- allContentTypes.contains(contentType.toLowerCase()) |
- allContentTypes.contains(ALL) |
- allContentTypes.contains(ALL_ALL))
- {
- return true;
- }
-
- // Try xxx/*
- String wildcard = contentType.substring(0, index) + "/*";
- return allContentTypes.contains(wildcard) |
allContentTypes.contains(wildcard.toLowerCase());
- }
-
- /**
- * Return true if the given content type is supported for the given mode.
- *
- * @throws IllegalArgumentException if the content type or the mode is null
- */
- public boolean isSupported(Mode mode, String contentType)
- {
- if (mode == null)
- {
- throw new IllegalArgumentException("Mode must not be null");
- }
- if (contentType == null)
- {
- throw new IllegalArgumentException("Content type must not be null");
- }
-
- int index = contentType.indexOf(SLASH);
- if (index == -1)
- {
- // Not valid content type so return false
- return false;
- }
-
- // Try full name matching
- Set contentTypeModes = (Set)singleTypeToPortletModes.get(contentType);
- if (contentTypeModes != null && contentTypeModes.contains(mode))
- {
- return true;
- }
-
- // Try full name lowercase matching
- Set lowercaseContentTypeModes =
(Set)singleTypeToPortletModes.get(contentType.toLowerCase());
- if (lowercaseContentTypeModes != null &&
lowercaseContentTypeModes.contains(mode))
- {
- return true;
- }
-
- // Try type matching
- String type = contentType.substring(0, index);
- Set typeMode = (Set)allTypeToPortletModes.get(type);
- if (typeMode != null && typeMode.contains(mode))
- {
- return true;
- }
-
- // Try type matching
- Set lowercaseTypeMode = (Set)allTypeToPortletModes.get(type.toLowerCase());
- if (lowercaseTypeMode != null && lowercaseTypeMode.contains(mode))
- {
- return true;
- }
-
- // Try wildcard matching
- Set wildcardMode = (Set)allTypeToPortletModes.get(ALL);
- return wildcardMode != null && wildcardMode.contains(mode);
- }
-}
Deleted: trunk/portlet/src/main/org/jboss/portal/portlet/container/info/InfoBundle.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/InfoBundle.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/InfoBundle.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,93 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.portlet.impl.jsr168.APIConstants;
-import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListResourceBundle;
-import java.util.Locale;
-
-/**
- * A resource bundle that contains the inline information defined by the portlet
specification.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class InfoBundle extends ListResourceBundle
-{
-
- private static final Logger log = Logger.getLogger(InfoBundle.class);
-
- /** . */
- private final Object[][] content;
-
- public InfoBundle(LanguagesMetaData.InfoMetaData metaData)
- {
- log.debug("Creates the parent bundle");
-
- //
- List list = new ArrayList(3);
-
- //
- String title = metaData.getTitle();
- if (title == null)
- {
- throw new IllegalArgumentException("Title must be provided");
- }
- list.add(new Object[]{APIConstants.JAVAX_PORTLET_TITLE, title});
-
- //
- if (metaData.getShortTitle() != null)
- {
- list.add(new Object[]{APIConstants.JAVAX_PORTLET_SHORT_TITLE,
metaData.getShortTitle()});
- }
-
- //
- if (metaData.getKeywords() != null)
- {
- list.add(new Object[]{APIConstants.JAVAX_PORTLET_KEYWORDS,
metaData.getKeywords()});
- }
-
- //
- content = (Object[][])list.toArray(new Object[list.size()][]);
- }
-
- protected Object[][] getContents()
- {
- return content;
- }
-
- /**
- * This is the english locale.
- *
- * @return the english locale
- */
- public Locale getLocale()
- {
- return Locale.ENGLISH;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/PortletResourceBundleManager.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/PortletResourceBundleManager.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/PortletResourceBundleManager.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,194 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.EmptyResourceBundle;
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.util.ParentChildResourceBundle;
-import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Manage resource bundles for a portlet.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class PortletResourceBundleManager
-{
-
- private Logger log = Logger.getLogger(PortletResourceBundleManager.class);
-
- /** */
- private Map localeBundles;
-
- /** */
- private String baseName;
-
- /** */
- private ClassLoader classLoader;
-
- /** */
- private ResourceBundle infoBundle;
-
- /** */
- private Collection supportedLocales;
-
- public PortletResourceBundleManager(ClassLoader classLoader, LanguagesMetaData
metaData)
- {
- if (classLoader == null)
- {
- throw new IllegalArgumentException("Need a non null classloader");
- }
- if (metaData == null)
- {
- throw new IllegalArgumentException("Need non null meta data");
- }
- this.classLoader = classLoader;
- this.baseName = metaData.getResourceBundle();
- this.localeBundles = new HashMap();
- this.supportedLocales = metaData.getSupportedLocales();
-
- // Get the resource bundle containing the portlet info
- LanguagesMetaData.InfoMetaData infoMD = metaData.getInfo();
- if (infoMD != null)
- {
- infoBundle = new InfoBundle(infoMD);
- }
- else
- {
- infoBundle = new EmptyResourceBundle();
- }
- }
-
- /**
- * Return a localized value constructed from the various resource bundles. The
supported locales of the manager are
- * used in combination with the specified key. The default value is used if no value
is found for the
- * <code>Locale.ENGLISH</code>.
- *
- * @param key the key to lookup in the bundles
- * @param defaultValue
- * @return the localized string
- * @throws IllegalArgumentException if the key of the default value is null
- */
- public LocalizedString getLocalizedValue(String key, String defaultValue) throws
IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("No null key accepted");
- }
- if (defaultValue == null)
- {
- throw new IllegalArgumentException("No null default value accepted");
- }
- Map m = new HashMap();
- for (Iterator j = supportedLocales.iterator(); j.hasNext();)
- {
- try
- {
- Locale locale = (Locale)j.next();
- ResourceBundle bundle = getResourceBundle(locale);
- String localizedDisplayName = bundle.getString(key);
- m.put(locale, localizedDisplayName);
- }
- catch (MissingResourceException ignore)
- {
- }
- }
- if (!m.containsKey(Locale.ENGLISH))
- {
- m.put(Locale.ENGLISH, defaultValue);
- }
- return new LocalizedString(m, Locale.ENGLISH);
- }
-
- /**
- * Return a bundle for the given locale. If the complete locale (language + country +
variant) does not exist then it
- * falls back to (language + country) or (language) or the default file.
- * <p/>
- * When the resource bundle object is found and was not in the global map, it put it
in that map with a copy on
- * write.
- *
- * @throws IllegalArgumentException if the locale is null
- */
- public ResourceBundle getResourceBundle(Locale locale) throws
IllegalArgumentException
- {
- // Arg check
- if (locale == null)
- {
- throw new IllegalArgumentException("Locale cannot be null");
- }
-
- // Try to get the bundle if the map
- ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
- if (bundle != null)
- {
- return bundle;
- }
-
- //
- log.debug("Want to load bundle " + baseName + " for locale " +
locale);
-
- if (baseName == null)
- {
- bundle = infoBundle;
- }
- else
- {
- try
- {
- bundle = ResourceBundle.getBundle(baseName, locale, classLoader);
- if (infoBundle != null)
- {
- bundle = new ParentChildResourceBundle(infoBundle, bundle);
- }
- log.debug("Created bundle " + baseName + " for locale " +
locale);
- }
- catch (MissingResourceException e)
- {
- log.warn("Bundle " + baseName + " for locale " + locale +
" not found");
- bundle = infoBundle;
- }
- }
-
- // Cache the bundle
- if (bundle != null)
- {
- Map copy = new HashMap(localeBundles);
- copy.put(locale, bundle);
- localeBundles = copy;
- }
-
- //
- return bundle;
- }
-}
Deleted: trunk/portlet/src/main/org/jboss/portal/portlet/container/info/Utils.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/container/info/Utils.java 2007-03-15
20:13:17 UTC (rev 6696)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/container/info/Utils.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,57 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.container.info;
-
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedStringMetaData;
-import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedValueMetaData;
-
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class Utils
-{
-
- private static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
-
- public static LocalizedString getLocalizedDescription(LocalizedStringMetaData
describable)
- {
- Map m = new HashMap();
- for (int i = 0; i < describable.getValues().size(); i++)
- {
- LocalizedValueMetaData descriptionMD =
(LocalizedValueMetaData)describable.getValues().get(i);
- Locale locale = descriptionMD.getLocale();
- if (locale == null)
- {
- locale = DEFAULT_LOCALE;
- }
- m.put(locale, descriptionMD.getValue());
- }
- return new LocalizedString(m, DEFAULT_LOCALE);
- }
-}
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/JBossApplicationMetaDataFactory.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/JBossApplicationMetaDataFactory.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/JBossApplicationMetaDataFactory.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -23,7 +23,7 @@
package org.jboss.portal.portlet.deployment;
import org.jboss.portal.common.transaction.Transactions;
-import org.jboss.portal.portlet.container.info.ContainerCacheInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerCacheInfo;
import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
import org.jboss.portal.portlet.metadata.PolicyPermissionMetaData;
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/deployment/jboss/PortletAppDeployment.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -35,7 +35,7 @@
import org.jboss.portal.common.xml.NullEntityResolver;
import org.jboss.portal.portlet.container.PortletApplicationContextImpl;
import org.jboss.portal.portlet.container.PortletApplicationRegistry;
-import org.jboss.portal.portlet.container.PortletContainerAdapter;
+import org.jboss.portal.portlet.impl.jsr168.PortletContainerAdapter;
import org.jboss.portal.portlet.deployment.JBossApplicationMetaDataFactory;
import org.jboss.portal.portlet.deployment.PortletApplicationMetaDataFactory;
import org.jboss.portal.portlet.impl.jsr168.APIFactory;
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactory.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactory.java 2007-03-15
20:13:17 UTC (rev 6696)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactory.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -24,6 +24,10 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactoryImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactoryImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/APIFactoryImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -24,6 +24,10 @@
import org.jboss.portal.portlet.invocation.ActionInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionRequestImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionRequestImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionRequestImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,130 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.spi.ActionContext;
-
-import javax.portlet.ActionRequest;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ActionRequestImpl extends PortletRequestImpl implements ActionRequest
-{
-
- /** . */
- protected final ActionContext actionContext;
-
- public ActionRequestImpl(ActionInvocation invocation)
- {
- super(invocation);
- this.actionContext = (ActionContext)invocation.getPortletContext();
-
- // Get the possibly null interaction state
- StateString interactionState = actionContext.getInteractionState();
-
- // Take care of the interaction state if any
- if (interactionState != null)
- {
- // Unserialize the interaction state if necessary
- PortletParametersStateString parametersState = null;
- if (interactionState instanceof PortletParametersStateString)
- {
- parametersState = (PortletParametersStateString)interactionState;
- }
- else
- {
- parametersState = new
PortletParametersStateString(interactionState.getStringValue());
- }
-
- //
- parameters = parametersState.getParameters();
- }
-
- //
- PortletParameters form = actionContext.getForm();
- if (form != null)
- {
- if (parameters == null)
- {
- parameters = form;
- }
- else
- {
- parameters = new PortletParameters(parameters);
- parameters.append(form);
- }
- }
- }
-
- //
-
- public InputStream getPortletInputStream() throws IOException
- {
- if
("application/x-www-form-urlencoded".equals(actionContext.getContentType()))
- {
- throw new IllegalStateException();
- }
- return actionContext.getInputStream();
- }
-
- public void setCharacterEncoding(String s) throws UnsupportedEncodingException
- {
- // This method is frankly stupid
- throw new IllegalStateException("called after the body has been read");
- // req.setCharacterEncoding(s);
- }
-
- public BufferedReader getReader() throws UnsupportedEncodingException, IOException
- {
- if
("application/x-www-form-urlencoded".equals(actionContext.getContentType()))
- {
- throw new IllegalStateException();
- }
- return actionContext.getReader();
- }
-
- public String getCharacterEncoding()
- {
- return actionContext.getCharacterEncoding();
- }
-
- public String getContentType()
- {
- return actionContext.getContentType();
- }
-
- public int getContentLength()
- {
- return actionContext.getContentLength();
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionResponseImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionResponseImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionResponseImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,200 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.URLTools;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.invocation.ActionInvocation;
-import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RedirectionResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
-
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletModeException;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-import java.io.IOException;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class ActionResponseImpl extends PortletResponseImpl implements ActionResponse
-{
-
- private static final Logger log = Logger.getLogger(ActionResponseImpl.class);
-
- protected static final int WANT_NOTHING = 0;
- protected static final int WANT_RENDER = 1;
- protected static final int WANT_REDIRECT = 2;
-
- protected PortletInvocationResponse response;
- protected int decision;
-
- public ActionResponseImpl(ActionInvocation invocation, PortletRequestImpl preq)
- {
- super(invocation, preq);
-
- //
- RenderResponse rr = new RenderResponse();
- rr.setNavigationalState(new PortletParametersStateString());
-
- //
- this.response = rr;
- this.decision = WANT_NOTHING;
- }
-
- public PortletInvocationResponse getResult()
- {
- return response;
- }
-
- public void setWindowState(WindowState windowState) throws WindowStateException
- {
- if (decision == WANT_NOTHING || decision == WANT_RENDER)
- {
- if (!preq.isWindowStateAllowed(windowState))
- {
- throw new WindowStateException("Not supported", windowState);
- }
-
((RenderResponse)response).setWindowState(org.jboss.portal.WindowState.create(windowState.toString()));
- decision = WANT_RENDER;
- }
- else
- {
- throw new IllegalStateException("Window state cannot be set after
redirect");
- }
- }
-
- public void setPortletMode(PortletMode portletMode) throws PortletModeException
- {
- if (decision == WANT_NOTHING || decision == WANT_RENDER)
- {
- if (portletMode == null)
- {
- // The spec does not define that case
- // we just issue a warn
- log.warn("Set null portlet mode");
- }
- else
- {
- if (!preq.isPortletModeAllowed(portletMode))
- {
- throw new PortletModeException("Not supported", portletMode);
- }
- Mode mode = Mode.create(portletMode.toString());
- ((RenderResponse)response).setMode(mode);
- }
- decision = WANT_RENDER;
- }
- else
- {
- throw new IllegalStateException("Portlet mode cannot be set after
redirect");
- }
- }
-
- public void sendRedirect(String location) throws IOException
- {
- if (location == null)
- {
- // do something more clever than simply returning
- return;
- }
- URLTools.enforceAbsoluteURL(location);
- sendRedirect(new HTTPRedirectionResponse(location));
- }
-
- /**
- * Generic send redirect.
- *
- * @param redirect
- * @throws IllegalStateException implement jsr168 behavior if the portlet as already
commited stuff
- */
- protected final void sendRedirect(RedirectionResponse redirect) throws
IllegalStateException
- {
- if (decision == WANT_NOTHING || decision == WANT_REDIRECT)
- {
- response = redirect;
- decision = WANT_REDIRECT;
- }
- else
- {
- throw new IllegalStateException("sendRedirect cannot be called after "
+
- "setPortletMode/setWindowState/setRenderParameter/setRenderParameters
" +
- "has been called previously");
- }
- }
-
- public void setRenderParameters(Map map)
- {
- PortletUtils.checkPortletParameterMapValidity(map);
-
- //
- if (decision == WANT_NOTHING || decision == WANT_RENDER)
- {
-
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).replace(map);
- decision = WANT_RENDER;
- }
- else
- {
- throw new IllegalStateException("setRenderParameters cannot be called after
redirect");
- }
- }
-
- public void setRenderParameter(String name, String value)
- {
- PortletUtils.checkPortletParameterValidity(name, value);
-
- //
- if (decision == WANT_NOTHING || decision == WANT_RENDER)
- {
-
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).setValue(name,
value);
- decision = WANT_RENDER;
- }
- else
- {
- throw new IllegalStateException("setRenderParameter cannot be called after
redirect");
- }
- }
-
- public void setRenderParameter(String name, String[] values)
- {
- PortletUtils.checkPortletParameterValidity(name, values);
-
- //
- if (decision == WANT_NOTHING || decision == WANT_RENDER)
- {
-
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).setValues(name,
values);
- decision = WANT_RENDER;
- }
- else
- {
- throw new IllegalStateException("setRenderParameter cannot be called after
redirect");
- }
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortalContextImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortalContextImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortalContextImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,108 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.spi.PortalContext;
-import org.jboss.portal.server.PortalConstants;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * todo : does not provide customizable values for portlet modes and window states.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortalContextImpl implements javax.portlet.PortalContext
-{
-
- private PortalContext portal;
- private Map properties;
- private Set supportedPortletModes;
- private Set supportedWindowStates;
-
- public PortalContextImpl(PortalContext portal)
- {
- if (portal == null)
- {
- throw new IllegalArgumentException("Must provide a non-null
PortalContext!");
- }
- this.portal = portal;
- this.properties = portal.getProperties();
- }
-
- public String getPortalInfo()
- {
- return PortalConstants.VERSION.toString();
- }
-
- public String getProperty(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("Must provide a non-null property
name");
- }
- return (String)properties.get(name);
- }
-
- public Enumeration getPropertyNames()
- {
- return Tools.toEnumeration(properties.keySet().iterator());
- }
-
- public Enumeration getSupportedPortletModes()
- {
- if (supportedPortletModes == null)
- {
- Set tmp = portal.getModes();
- supportedPortletModes = new HashSet(tmp.size());
- for (Iterator i = tmp.iterator(); i.hasNext();)
- {
- Mode mode = (Mode)i.next();
- supportedPortletModes.add(PortletUtils.decodePortletMode(mode.toString()));
- }
- }
- return Tools.toEnumeration(supportedPortletModes.iterator());
- }
-
- public Enumeration getSupportedWindowStates()
- {
- if (supportedWindowStates == null)
- {
- Set tmp = portal.getWindowStates();
- supportedWindowStates = new HashSet(tmp.size());
- for (Iterator i = tmp.iterator(); i.hasNext();)
- {
- org.jboss.portal.WindowState windowState =
(org.jboss.portal.WindowState)i.next();
-
supportedWindowStates.add(PortletUtils.decodeWindowState(windowState.toString()));
- }
- }
- return Tools.toEnumeration(supportedWindowStates.iterator());
- }
-}
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletApplicationImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,214 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.portlet.impl.jsr168.APIFactory;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletContextImpl;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
+import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
+import org.jboss.portal.portlet.container.PortletApplication;
+import org.jboss.portal.portlet.container.PortletApplicationContext;
+import org.jboss.portal.portlet.container.PortletApplicationRegistrationContext;
+import org.jboss.portal.portlet.container.PortletContainer;
+
+import javax.portlet.PortletContext;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletApplicationImpl extends AbstractJBossService implements
PortletApplication
+{
+
+ /** . */
+ protected LinkedHashMap portlets;
+
+ /** . */
+ protected PortletApplicationMetaData metaData;
+
+ /** . */
+ protected JBossApplicationMetaData jbossMetaData;
+
+ /** . */
+ protected PortletApplicationContext context;
+
+ /** . */
+ protected PortletContext portletContext;
+
+ /** . */
+ protected String version;
+
+ /** . */
+ protected Map portletModes;
+
+ /** . */
+ protected Map windowStates;
+
+ /** . */
+ protected APIFactory apiFactory;
+
+ /** . */
+ protected PortletApplicationRegistrationContext registrationContext;
+
+ public PortletApplicationImpl(
+ PortletApplicationMetaData metaData,
+ JBossApplicationMetaData jbossMetaData,
+ PortletApplicationContext context)
+ {
+ this.metaData = metaData;
+ this.jbossMetaData = jbossMetaData;
+ this.portlets = new LinkedHashMap();
+ this.context = context;
+ }
+
+ public String getId()
+ {
+ return metaData.getId();
+ }
+
+ public PortletApplicationRegistrationContext getRegistrationContext()
+ {
+ return registrationContext;
+ }
+
+ public void setRegistrationContext(PortletApplicationRegistrationContext
registrationContext)
+ {
+ this.registrationContext = registrationContext;
+ }
+
+ public APIFactory getAPIFactory()
+ {
+ return apiFactory;
+ }
+
+ public void setAPIFactory(APIFactory apiFactory)
+ {
+ this.apiFactory = apiFactory;
+ }
+
+ public PortletApplicationMetaData getMetaData()
+ {
+ return metaData;
+ }
+
+ public JBossApplicationMetaData getJBossMetaData()
+ {
+ return jbossMetaData;
+ }
+
+ public void addContainer(PortletContainer container)
+ {
+ portlets.put(container.getId(), container);
+ registrationContext.registerPortlet(container);
+ }
+
+ public void removeContainer(PortletContainer container)
+ {
+ registrationContext.unregisterPortlet(container);
+ portlets.remove(container.getId());
+ }
+
+ //
+
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ //
+ version = metaData.getVersion();
+ portletModes = metaData.getPortletModes();
+ windowStates = metaData.getWindowStates();
+ portletContext = new PortletContextImpl(context.getServletContext());
+ }
+
+ public void stopService() throws Exception
+ {
+ //
+ version = null;
+ portletModes = null;
+ windowStates = null;
+ portletContext = null;
+
+ //
+ super.stopService();
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public PortletContext getPortletContext()
+ {
+ return portletContext;
+ }
+
+ public Map getPortletModes()
+ {
+ return portletModes;
+ }
+
+ public Map getWindowStates()
+ {
+ return windowStates;
+ }
+
+ public void start(String portletName) throws Exception
+ {
+ context.startPortlet(portletName);
+ }
+
+ public void stop(String portletName) throws Exception
+ {
+ context.stopPortlet(portletName);
+ }
+
+ // WebApp implementation
********************************************************************************************
+
+ public Set getPortletContainers()
+ {
+ return new HashSet(portlets.values());
+ }
+
+ public PortletContainer getPortletContainer(String name)
+ {
+ return (PortletContainer)portlets.get(name);
+ }
+
+ public PortletApplicationContext getContext()
+ {
+ return context;
+ }
+
+ // Container implementation
*****************************************************************************************
+
+ public String toString()
+ {
+ return "PortletWebApp[" + metaData.getId() + "]";
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletApplicationImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletConfigImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletConfigImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletConfigImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,87 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.container.info.PortletResourceBundleManager;
-
-import javax.portlet.PortletConfig;
-import javax.portlet.PortletContext;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletConfigImpl implements PortletConfig
-{
-
- private String portletName;
- private PortletContext portletContext;
- private Map initParameters;
- private PortletResourceBundleManager bundleMgr;
-
- public PortletConfigImpl(String portletName,
- PortletContext portletContext,
- Map initParameters,
- PortletResourceBundleManager bundleMgr)
- {
- this.portletName = portletName;
- this.portletContext = portletContext;
- this.initParameters = initParameters;
- this.bundleMgr = bundleMgr;
- }
-
- public String getPortletName()
- {
- return portletName;
- }
-
- public PortletContext getPortletContext()
- {
- return portletContext;
- }
-
- /** May return null ? the spec does not specify what happens when the bundle is not
found for the locale. */
- public ResourceBundle getResourceBundle(Locale locale)
- {
- return bundleMgr.getResourceBundle(locale);
- }
-
- public String getInitParameter(String s)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- return (String)initParameters.get(s);
- }
-
- public Enumeration getInitParameterNames()
- {
- return Collections.enumeration(initParameters.keySet());
- }
-}
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerAdapter.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/PortletContainerAdapter.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerAdapter.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerAdapter.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+import org.jboss.portal.portlet.container.PortletApplicationContextImpl;
+import org.jboss.portal.portlet.container.PortletContainer;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletContainerAdapter
+{
+
+ /** . */
+ private PortletMetaData portletMD;
+
+ /** . */
+ private JBossPortletMetaData jbossPortletMD;
+
+ /** . */
+ private PortletApplicationContextImpl portletApplicationContext;
+
+ /** . */
+ private PortletContainerImpl portletContainer;
+
+ public PortletContainerAdapter(PortletMetaData portletMD, JBossPortletMetaData
jbossPortletMD)
+ {
+ this.portletMD = portletMD;
+ this.jbossPortletMD = jbossPortletMD;
+ }
+
+ public PortletApplicationContextImpl getPortletApplicationContext()
+ {
+ return portletApplicationContext;
+ }
+
+ public void setPortletWebAppAdapter(PortletApplicationContextImpl
portletApplicationContext)
+ {
+ this.portletApplicationContext = portletApplicationContext;
+ }
+
+ public PortletContainer getPortletContainer()
+ {
+ return portletContainer;
+ }
+
+ public void start() throws Exception
+ {
+ PortletApplicationImpl portletApp =
portletApplicationContext.getPortletApplication();
+ portletContainer = new PortletContainerImpl(portletApp, portletMD,
jbossPortletMD);
+ portletContainer.start();
+ portletApp.addContainer(portletContainer);
+ }
+
+ public void stop()
+ {
+ PortletApplicationImpl portletApp =
portletApplicationContext.getPortletApplication();
+ portletApp.removeContainer(portletContainer);
+ portletContainer.stop();
+ portletContainer = null;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerAdapter.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContainerImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,517 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletConfigImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderResponseImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.api.ActionRequestImpl;
+import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+import org.jboss.portal.portlet.container.PortletInitializationException;
+import org.jboss.portal.portlet.container.PortletApplication;
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.impl.jsr168.info.ContentTypes;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletPreferencesMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.SecurityRoleRefMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.ParameterMetaData;
+import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.SecurityErrorResponse;
+import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
+import org.jboss.portal.common.concurrent.Valve;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.Portlet;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.UnavailableException;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Collections;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6365 $
+ */
+public class PortletContainerImpl implements PortletContainer
+{
+
+ /** Logger. */
+ protected final Logger log;
+
+ /** . */
+ protected PortletApplicationImpl application;
+
+ /** . */
+ protected PortletMetaData metaData;
+
+ /** . */
+ protected JBossPortletMetaData jbossMetaData;
+
+ /** The portlet implementation class name. */
+ protected String className;
+
+ /** The portlet config. */
+ protected PortletConfig config;
+
+ /** The portlet instance. */
+ protected Portlet portlet;
+
+ /** . */
+ protected ContentTypes contentTypes;
+
+ /** . */
+ protected PortletResourceBundleManager bundleMgr;
+
+ /** The invocation valve. */
+ protected final Valve valve;
+
+ /** Give the correspondance between role name and role link. */
+ protected Map securityRoleRefsMap;
+
+ /** Are we started or not. */
+ protected boolean started;
+
+ /** User data constraint. */
+ protected Set userDataConstraints;
+
+ /** Return info. */
+ protected PortletInfo info;
+
+ /**
+ * The preference validator, this is not exposed as runtime meta data as it is only
used by the JSR 168 portlet
+ * container implementation.
+ */
+ protected PreferencesValidator preferencesValidator;
+
+ public PortletContainerImpl(PortletApplicationImpl application, PortletMetaData
metaData, JBossPortletMetaData jbossMetaData)
+ {
+ this.application = application;
+ this.metaData = metaData;
+ this.jbossMetaData = jbossMetaData;
+ this.valve = new Valve();
+ this.log = Logger.getLogger("org.jboss.portal.portlet.container." +
metaData.getClassName().replace('.', '_'));
+ this.started = false;
+ }
+
+ public PortletInfo getInfo()
+ {
+ return info;
+ }
+
+ public String getId()
+ {
+ return metaData.getName();
+ }
+
+ public PortletMetaData getMetaData()
+ {
+ return metaData;
+ }
+
+ public JBossPortletMetaData getJBossMetaData()
+ {
+ return jbossMetaData;
+ }
+
+ public boolean isStarted()
+ {
+ return valve.getState() == Valve.OPEN;
+ }
+
+ public void start() throws Exception, PortletInitializationException
+ {
+ // Set class name
+ this.className = metaData.getClassName();
+
+ //
+ PortletPreferencesMetaData preferences = metaData.getPreferences();
+ if (preferences != null)
+ {
+ String validatorClassName = preferences.getValidator();
+ if (validatorClassName != null)
+ {
+ try
+ {
+ ClassLoader loader = application.getContext().getClassLoader();
+
+ //
+ if (validatorClassName != null)
+ {
+ // Load the class
+ Class preferencesValidatorClass =
loader.loadClass(validatorClassName);
+ preferencesValidator =
(PreferencesValidator)preferencesValidatorClass.newInstance();
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.error("Class for preference validator not found", e);
+ }
+ catch (InstantiationException e)
+ {
+ log.error("Cannot instantiate preference validator", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new Error();
+ }
+ }
+ }
+
+ // Security role ref
+ Map securityRoleRefsMap = new HashMap();
+ for (Iterator i = metaData.getSecurityRoleRefs().iterator(); i.hasNext();)
+ {
+ SecurityRoleRefMetaData securityRoleRefMD = (SecurityRoleRefMetaData)i.next();
+ securityRoleRefsMap.put(securityRoleRefMD.getRoleName(),
securityRoleRefMD.getRoleLink());
+ }
+
+ // Init parameters
+ Map initParameters = new HashMap();
+ for (Iterator i = metaData.getParameters().values().iterator(); i.hasNext();)
+ {
+ ParameterMetaData parameterMD = (ParameterMetaData)i.next();
+ initParameters.put(parameterMD.getName(), parameterMD.getValue());
+ }
+
+ // Portlet config object
+ PortletResourceBundleManager bundleMgr = new
PortletResourceBundleManager(application.getContext().getClassLoader(),
metaData.getLanguages());
+
+ //
+ PortletConfig config = new PortletConfigImpl(
+ metaData.getName(),
+ application.getPortletContext(),
+ initParameters,
+ bundleMgr);
+
+ //
+ ContentTypes contentTypes = new ContentTypes();
+ contentTypes.setMetadata(metaData.getContentTypes());
+ contentTypes.start();
+
+ //
+ PortletInfo info = new ContainerPortletInfo(this, bundleMgr, contentTypes);
+
+ // Finally initialize the porlet instance
+ try
+ {
+ log.debug("Loading portlet class " + className);
+ Class portletClass =
application.getContext().getClassLoader().loadClass(className);
+ log.debug("Creating portlet object " + className);
+ Portlet portlet = (Portlet)portletClass.newInstance();
+ log.debug("Created portlet object " + className);
+ initPortlet(portlet, config);
+ log.debug("Initialized portlet object " + className);
+
+ // We are safe, update state
+ this.portlet = portlet;
+ this.config = config;
+ this.securityRoleRefsMap = Collections.unmodifiableMap(securityRoleRefsMap);
+ this.contentTypes = contentTypes;
+ this.bundleMgr = bundleMgr;
+ this.info = info;
+ this.started = true;
+
+ // Let invocation flow in
+ valve.open();
+
+ // Register
+ // webApp.addContainer(this);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new PortletInitializationException("Portlet class not accessible
" + className, e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new PortletInitializationException("Portlet class not found " +
className, e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new PortletInitializationException("Portlet class cannot be
instantiated " + className, e);
+ }
+ catch (PortletException e)
+ {
+ throw new PortletInitializationException("The portlet " + getId() +
" threw a portlet exception during init", e);
+ }
+ catch (RuntimeException e)
+ {
+ throw new PortletInitializationException("The portlet " + getId() +
" threw a runtime exception during init", e);
+ }
+ catch (Error e)
+ {
+ throw new PortletInitializationException("The portlet " + getId() +
" threw an error during init", e);
+ }
+ }
+
+ public void stop()
+ {
+ //
+ // webApp.removeContainer(this);
+
+ // Wait at most 60 seconds before all invocations are done
+ log.debug("Trying to close the valve");
+ boolean done = valve.closing(60000);
+ if (!done)
+ {
+ log.warn("The valve is still holding invocations, continue anyway");
+ }
+
+ //
+ valve.closed();
+
+ //
+ if (started)
+ {
+ //
+ started = false;
+
+ // Destroy the portlet object
+ destroyPortlet(portlet);
+
+ // Stop the plugins (static)
+ contentTypes.stop();
+
+ // Update state
+ preferencesValidator = null;
+ className = null;
+ portlet = null;
+ securityRoleRefsMap = null;
+ config = null;
+ contentTypes = null;
+ userDataConstraints = null;
+ info = null;
+ }
+ }
+
+ public PortletConfig getConfig()
+ {
+ return config;
+ }
+
+ public Portlet getPortlet()
+ {
+ return portlet;
+ }
+
+ public ContentTypes getContentTypes()
+ {
+ return contentTypes;
+ }
+
+ public Map getSecurityRoleRefsMap()
+ {
+ return securityRoleRefsMap;
+ }
+
+ public PortletApplication getApplication()
+ {
+ return application;
+ }
+
+ public Valve getValve()
+ {
+ return valve;
+ }
+
+ public Set getUserDataConstraints()
+ {
+ return userDataConstraints;
+ }
+
+ public PreferencesValidator getPreferencesValidator()
+ {
+ return preferencesValidator;
+ }
+
+ public String toString()
+ {
+ return "PortletContainer[name=" + getId() + ",+application=" +
application.getId() + "]";
+ }
+
+ /** Initialize the portlet. */
+ private void initPortlet(Portlet portlet, PortletConfig config) throws
PortletException
+ {
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ // Set the war loader for the request
+ ClassLoader newLoader = application.getContext().getClassLoader();
+ Thread.currentThread().setContextClassLoader(newLoader);
+ portlet.init(config);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
+ }
+
+ /** Destroy the portlet. */
+ private void destroyPortlet(Portlet portlet)
+ {
+ ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ // Set the war loader for the request
+ ClassLoader newLoader = application.getContext().getClassLoader();
+ Thread.currentThread().setContextClassLoader(newLoader);
+ if (portlet != null)
+ {
+ portlet.destroy();
+ }
+ else
+ {
+ log.debug("Cannot call destroy, portlet was null");
+ }
+ }
+ catch (RuntimeException e)
+ {
+ log.error("The portlet threw a runtime exception", e);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(oldLoader);
+ }
+ }
+
+ public PortletInvocationResponse dispatch(PortletInvocation invocation) throws
PortletInvokerException, InvocationException
+ {
+ try
+ {
+ if (invocation instanceof ActionInvocation)
+ {
+ return invokeAction((ActionInvocation)invocation);
+ }
+ else if (invocation instanceof RenderInvocation)
+ {
+ return invokeRender((RenderInvocation)invocation);
+ }
+ else
+ {
+ throw new InvocationException("Unexpected invocation " +
invocation);
+ }
+ }
+ catch (NoClassDefFoundError e)
+ {
+ //
+ return new ErrorResponse(e);
+ }
+ catch (Exception e)
+ {
+ log.error("The portlet threw an exception", e);
+
+ //
+ if (e instanceof PortletSecurityException)
+ {
+ return new SecurityErrorResponse(e);
+ }
+ else if (e instanceof UnavailableException)
+ {
+ UnavailableException ue = (UnavailableException)e;
+ if (ue.isPermanent())
+ {
+ return new UnavailableResponse();
+ }
+ else
+ {
+ return new UnavailableResponse(ue.getUnavailableSeconds());
+ }
+ }
+ else
+ {
+ // The exception is either a PortletException, an IOException or a
RuntimeException
+ return new ErrorResponse(e);
+ }
+ }
+ }
+
+ protected PortletInvocationResponse invokeAction(ActionInvocation invocation) throws
IOException, PortletException
+ {
+ APIFactory factory = application.getAPIFactory();
+ ActionRequestImpl areq = factory.createActionRequest(invocation);
+ ActionResponseImpl aresp = factory.createActionResponse(invocation, areq);
+ HttpServletRequest dreq = invocation.getDispatchedRequest();
+ try
+ {
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, areq);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, aresp);
+ dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
+ portlet.processAction(areq, aresp);
+ }
+ finally
+ {
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
+ }
+
+ return aresp.getResult();
+ }
+
+ protected PortletInvocationResponse invokeRender(RenderInvocation invocation) throws
IOException, PortletException
+ {
+ APIFactory factory = application.getAPIFactory();
+ RenderRequestImpl rreq = factory.createRenderRequest(invocation);
+ RenderResponseImpl rresp = factory.createRenderResponse(invocation, rreq);
+ HttpServletRequest dreq = invocation.getDispatchedRequest();
+ try
+ {
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_CONFIG, config);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_REQUEST, rreq);
+ dreq.setAttribute(APIConstants.JAVAX_PORTLET_RESPONSE, rresp);
+ dreq.setAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION,
invocation);
+ portlet.render(rreq, rresp);
+ }
+ finally
+ {
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_CONFIG);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
+ dreq.removeAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+
dreq.removeAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
+ }
+
+ return rresp.getResult();
+ }
+
+
+}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContextImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContextImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContextImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,186 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.server.PortalConstants;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletRequestDispatcher;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletContextImpl implements PortletContext
-{
-
- private ServletContext servletContext;
-
- public PortletContextImpl(ServletContext servletContext)
- {
- this.servletContext = servletContext;
- }
-
- public String getServerInfo()
- {
- return "JBossPortal/" + PortalConstants.VERSION.getMajor() +
"." + PortalConstants.VERSION.getMinor();
- }
-
- public PortletRequestDispatcher getRequestDispatcher(String path)
- {
- if (path == null || !path.startsWith("/"))
- {
- return null;
- }
- RequestDispatcher rd = servletContext.getRequestDispatcher(path);
- if (rd != null)
- {
- return new PortletRequestDispatcherImpl(rd, path);
- }
- else
- {
- return null;
- }
- }
-
- public PortletRequestDispatcher getNamedDispatcher(String name)
- {
- if (name == null)
- {
- return null;
- }
- RequestDispatcher rd = servletContext.getNamedDispatcher(name);
- if (rd != null)
- {
- return new PortletRequestDispatcherImpl(rd);
- }
- else
- {
- return null;
- }
- }
-
- public InputStream getResourceAsStream(String s)
- {
- return servletContext.getResourceAsStream(s);
- }
-
- public int getMajorVersion()
- {
- return 1;
- }
-
- public int getMinorVersion()
- {
- return 0;
- }
-
- public String getMimeType(String s)
- {
- return servletContext.getMimeType(s);
- }
-
- public String getRealPath(String s)
- {
- return servletContext.getRealPath(s);
- }
-
- public Set getResourcePaths(String s)
- {
- return servletContext.getResourcePaths(s);
- }
-
- public URL getResource(String s) throws MalformedURLException
- {
- if (s == null || !s.startsWith("/"))
- {
- throw new MalformedURLException("invalid resource");
- }
- URL resource = servletContext.getResource(s);
- return resource;
- }
-
- public Object getAttribute(String s)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("attribute name must not be
null");
- }
- return servletContext.getAttribute(s);
- }
-
- public Enumeration getAttributeNames()
- {
- return servletContext.getAttributeNames();
- }
-
- public String getInitParameter(String s)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("init parameter name must not be
null");
- }
- return servletContext.getInitParameter(s);
- }
-
- public Enumeration getInitParameterNames()
- {
- return servletContext.getInitParameterNames();
- }
-
- public void log(String s)
- {
- servletContext.log(s);
- }
-
- public void log(String s, Throwable throwable)
- {
- servletContext.log(s, throwable);
- }
-
- public void removeAttribute(String s)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("attribute name must not be
null");
- }
- servletContext.removeAttribute(s);
- }
-
- public void setAttribute(String s, Object o)
- {
- servletContext.setAttribute(s, o);
- }
-
- public String getPortletContextName()
- {
- return servletContext.getServletContextName();
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,398 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.value.StringValue;
-import org.jboss.portal.common.value.Value;
-import org.jboss.portal.portlet.state.PropertyChange;
-import org.jboss.portal.portlet.state.PropertyContext;
-import org.jboss.portal.portlet.container.info.ContainerPreferenceInfo;
-import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
-
-import javax.portlet.PortletPreferences;
-import javax.portlet.PreferencesValidator;
-import javax.portlet.ReadOnlyException;
-import javax.portlet.ValidatorException;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletPreferencesImpl implements PortletPreferences
-{
-
- /** The logger. */
- protected static final Logger log = Logger.getLogger(PortletPreferencesImpl.class);
-
- /** Indicates the object is used during a action phase. */
- public static final int ACTION = 1;
-
- /** Indicates the object is used during a render phase. */
- public static final int RENDER = 0;
-
- /** . */
- protected final PropertyContext prefs;
-
- /** . */
- protected final PreferencesValidator validator;
-
- /** . */
- protected final ContainerPreferencesInfo containerPrefs;
-
- /** . */
- protected final int mode;
-
- /** Keep track of updates */
- protected final Map updates;
-
- public PortletPreferencesImpl(
- PropertyContext prefs,
- ContainerPreferencesInfo containerPrefs,
- PreferencesValidator validator,
- int mode)
- {
- this.prefs = prefs;
- this.validator = validator;
- this.containerPrefs = containerPrefs;
- this.mode = mode;
- this.updates = new HashMap();
- }
-
- public Map getMap()
- {
- return new PreferencesMap();
- }
-
- public Enumeration getNames()
- {
- // Clone the system names
- Set names = new HashSet(prefs.getPortletKeys());
-
- // Add the user
- names.addAll(prefs.getKeys());
-
- // Add the transient updates
- for (Iterator i = updates.values().iterator(); i.hasNext();)
- {
- PropertyChange change = (PropertyChange)i.next();
- if (change.getType() == PropertyChange.PREF_UPDATE)
- {
- names.add(change.getKey());
- }
- else
- {
- names.remove(change.getKey());
- }
- }
-
- // Convert to enumeration
- return Collections.enumeration(names);
- }
-
- private Value getValue(String key)
- {
- Value value = null;
- PropertyChange change = (PropertyChange)updates.get(key);
- if (change != null)
- {
- if (change.getType() == PropertyChange.PREF_UPDATE)
- {
- value = change.getValue();
- }
- else
- {
- ContainerPreferenceInfo containerPref =
containerPrefs.getContainerPreference(key);
- if (containerPref != null)
- {
- value = containerPref.getDefaultValue();
- }
- }
- }
- else
- {
- // Get user
- value = prefs.getValue(key);
-
- // If does not exist or read only use what the default one
- if (value == null || isReadOnly(key))
- {
- ContainerPreferenceInfo containerPref =
containerPrefs.getContainerPreference(key);
- if (containerPref != null)
- {
- value = containerPref.getDefaultValue();
- }
- }
- }
- return value;
- }
-
- public String getValue(String key, String def) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("key must not be null");
- }
- Value value = getValue(key);
- if (value == null || value.isEmpty())
- {
- return def;
- }
- else
- {
- return value.asString();
- }
- }
-
- public String[] getValues(String key, String[] def) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("key must not be null");
- }
- Value value = getValue(key);
- if (value != null)
- {
- return value.asStringArray();
- }
- else
- {
- return def;
- }
- }
-
- public boolean isReadOnly(String key) throws IllegalArgumentException,
IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("key must not be null");
- }
- if (mode == ACTION)
- {
- // The accurate value is to combine what the portlet developer and the consumer
specifies
- return prefs.isReadOnly() || prefs.isReadOnly(key);
- }
- else
- {
- // During render we cannot be aware of the consumer
- // intent with respect to the access mode of the current state
- return prefs.isReadOnly(key);
- }
- }
-
- public void reset(String key) throws IllegalArgumentException, ReadOnlyException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("key must not be null");
- }
- if (isReadOnly(key))
- {
- throw new ReadOnlyException("Key " + key + " cannot be
written");
- }
- updates.put(key, PropertyChange.newReset(key));
- }
-
- public void setValue(String key, String value) throws IllegalArgumentException,
ReadOnlyException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("key must not be null");
- }
- if (isReadOnly(key))
- {
- throw new ReadOnlyException("Key " + key + " cannot be
written");
- }
- Value value_ = new StringValue(value);
- updates.put(key, PropertyChange.newUpdate(key, value_));
- }
-
- public void setValues(String key, String[] values) throws IllegalArgumentException,
ReadOnlyException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("key must not be null");
- }
- if (isReadOnly(key))
- {
- throw new ReadOnlyException("Key " + key + " cannot be
written");
- }
- if (values == null)
- {
- values = new String[1];
- }
- Value value_ = new StringValue(values);
- updates.put(key, PropertyChange.newUpdate(key, value_));
- }
-
- public void store() throws IOException, ValidatorException
- {
- // Check we are in the right mode
- if (mode != ACTION)
- {
- throw new IllegalStateException("Store must be called within the scope of
an action request");
- }
-
- // Copy the transient set to the persistent set if the consumer allows it
- if (prefs.isReadOnly())
- {
- throw new IOException("Should not happen");
- }
-
- // If the optional validator is present validate
- if (validator != null)
- {
- validator.validate(this);
- }
-
- //
- PropertyChange[] changes = (PropertyChange[])updates.values().toArray(new
PropertyChange[updates.size()]);
- prefs.update(changes);
-
- // Clear the updates
- updates.clear();
- }
-
- private class PreferencesMap extends HashMap
- {
-
- /** The serialVersionUID */
- private static final long serialVersionUID = 6969583304804836926L;
-
- public PreferencesMap()
- {
- super(10);
-
- //
- for (Iterator i = containerPrefs.getKeys().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- String[] value =
containerPrefs.getContainerPreference(key).getDefaultValue().asStringArray();
- String[] clone = new String[value.length];
- System.arraycopy(value, 0, clone, 0, value.length);
- super.put(key, clone);
- }
-
- //
- for (Iterator i = prefs.getKeys().iterator(); i.hasNext();)
- {
- String key = (String)i.next();
- String[] value = prefs.getValue(key).asStringArray();
- String[] clone = new String[value.length];
- System.arraycopy(value, 0, clone, 0, value.length);
- super.put(key, clone);
- }
-
- //
- for (Iterator i = updates.values().iterator(); i.hasNext();)
- {
- PropertyChange change = (PropertyChange)i.next();
- String key = change.getKey();
-
- if (change.getType() == PropertyChange.PREF_RESET)
- {
- super.remove(key);
- }
- else
- {
- String[] value = change.getValue().asStringArray();
- String[] clone = new String[value.length];
- System.arraycopy(value, 0, clone, 0, value.length);
- super.put(key, clone);
- }
- }
- }
-
- public boolean containsValue(Object value)
- {
- if (value instanceof String[])
- {
- String[] strings = (String[])value;
- for (Iterator i = super.values().iterator(); i.hasNext();)
- {
- String[] other = (String[])i.next();
- if (Arrays.equals(strings, other))
- {
- return true;
- }
- }
- }
- return false;
- }
-
- public Object get(Object key)
- {
- return (String[])super.get(key); // Should be cloned here to ensure
immutability
- }
-
- public Collection values()
- {
- return super.values(); // String[] should be cloned here to ensure immutability
- }
-
- public Set entrySet()
- {
- return super.entrySet();
- }
-
- /**
- * Do not change state.
- *
- * @return null
- */
- public Object put(Object key, Object value)
- {
- return null;
- }
-
- /**
- * Do not change state.
- *
- * @return null
- */
- public Object remove(Object key)
- {
- return null;
- }
-
- /** Do not change state. */
- public void putAll(Map t)
- {
- }
-
- /** Do not change state. */
- public void clear()
- {
- }
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,92 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.server.servlet.FilterCommand;
-
-import javax.portlet.PortletException;
-import javax.portlet.PortletRequestDispatcher;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletRequestDispatcherImpl
- implements PortletRequestDispatcher
-{
-
- /** The servlet request dispatcher. */
- private final RequestDispatcher dispatcher;
-
- /** . */
- private final String path;
-
- PortletRequestDispatcherImpl(RequestDispatcher dispatcher)
- {
- this(dispatcher, null);
- }
-
- PortletRequestDispatcherImpl(RequestDispatcher dispatcher, String path)
- {
- this.dispatcher = dispatcher;
- this.path = path;
- }
-
- public void include(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
- {
- try
- {
- // Get the invocation that is still in the request
- PortletInvocation invocation =
(PortletInvocation)req.getAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
-
- //
- HttpServletRequest dreq = invocation.getDispatchedRequest();
- HttpServletResponse dresp = invocation.getDispatchedResponse();
-
- // It was set by the PortletContainerInvoker before diving into the portlet, so
let's just reuse them
- RenderRequest rreq =
(RenderRequest)req.getAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
- RenderResponse rresp =
(RenderResponse)req.getAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
-
- //
- DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest(rreq,
dreq, path);
- DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(rresp,
dresp);
-
- //
- dispatcher.include(direq, diresp);
- }
- catch (ServletException e)
- {
- // We must translate the servlet exception into a portlet exception for the
calling portlet
- throw new PortletException(e);
- }
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,559 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.apache.log4j.Logger;
-import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.container.PortletApplicationImpl;
-import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.info.ContainerPortletInfo;
-import org.jboss.portal.portlet.container.info.ContentTypes;
-import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
-import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.spi.InstanceContext;
-import org.jboss.portal.portlet.spi.RequestContext;
-import org.jboss.portal.portlet.spi.SecurityContext;
-import org.jboss.portal.portlet.spi.UserContext;
-import org.jboss.portal.portlet.state.PropertyContext;
-
-import javax.portlet.PortalContext;
-import javax.portlet.PortletMode;
-import javax.portlet.PortletPreferences;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSession;
-import javax.portlet.PreferencesValidator;
-import javax.portlet.RenderRequest;
-import javax.portlet.WindowState;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import java.security.Principal;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import java.util.Collection;
-
-/**
- * PortletRequest implemention. The parameter implementation is left to subclasses that
can implement it differently.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
- * @version $Revision$
- */
-public abstract class PortletRequestImpl implements PortletRequest
-{
-
- /** Constant object to mark that a request attribute is removed. */
- protected static final Object REMOVED_ATTRIBUTE = new Object();
-
- protected static final Logger log = Logger.getLogger(PortletRequestImpl.class);
-
- protected PortletInvocation invocation;
- protected UserContext userContext;
- protected SecurityContext securityContext;
- protected RequestContext requestContext;
- protected InstanceContext instanceContext;
- protected PortletPreferences preferences;
-
- protected PortletContainer container;
- protected ContentTypes contentTypes;
- protected HttpServletRequest dreq;
- protected PortalContext portalContext;
- protected PortletSessionImpl psession;
-
- protected int sessionStatus;
-
- /** . */
- protected PortletParameters parameters;
-
- /** The lazy request attributes map added or removed during the request of the
portlet. */
- protected Map attributes;
-
- public PortletRequestImpl(PortletInvocation invocation)
- {
- //
- this.invocation = invocation;
- this.userContext = invocation.getUserContext();
- this.securityContext = invocation.getSecurityContext();
- this.requestContext = invocation.getRequestContext();
- this.instanceContext = invocation.getInstanceContext();
- this.container = ((ContainerPortletInfo)invocation.getInfo()).getContainer();
- this.contentTypes = container.getContentTypes();
- this.dreq = invocation.getDispatchedRequest();
- this.portalContext = new PortalContextImpl(invocation.getPortalContext());
- this.parameters = null;
-
- //
- int mode = this instanceof RenderRequest ? PortletPreferencesImpl.RENDER :
PortletPreferencesImpl.ACTION;
- PropertyContext prefs =
(PropertyContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PropertyContext.PREFERENCES_ATTRIBUTE);
- PreferencesValidator validator = container.getPreferencesValidator();
- ContainerPreferencesInfo containerPrefs =
(ContainerPreferencesInfo)container.getInfo().getPreferences();
- this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator,
mode);
- }
-
- // PLT.11.1.1
-
- public String getParameter(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- if (parameters != null)
- {
- return parameters.getValue(name);
- }
- else
- {
- return null;
- }
- }
-
- public Enumeration getParameterNames()
- {
- if (parameters != null)
- {
- return Collections.enumeration(parameters.keySet());
- }
- else
- {
- return Tools.EMPTY_ENUMERATION;
- }
- }
-
- public String[] getParameterValues(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- if (parameters != null)
- {
- return parameters.getValues(name);
- }
- else
- {
- return null;
- }
- }
-
- public Map getParameterMap()
- {
- if (parameters != null)
- {
- return Collections.unmodifiableMap(parameters);
- }
- else
- {
- return Collections.EMPTY_MAP;
- }
- }
-
- public WindowState getWindowState()
- {
- String s = invocation.getPortletContext().getWindowState().toString();
- return PortletUtils.decodeWindowState(s);
- }
-
- public PortletMode getPortletMode()
- {
- String s = invocation.getPortletContext().getMode().toString();
- return PortletUtils.decodePortletMode(s);
- }
-
- // PLT.11.1.3
-
- public Object getAttribute(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- if (PortletRequest.USER_INFO.equals(name))
- {
- Map infos = userContext.getInformations();
-
- //
- if (infos != null)
- {
- // Get portlet application metadata
- PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
- PortletApplicationMetaData pamd = portletApp.getMetaData();
- Map uaMD = pamd.getUserAttributes();
-
- // Clone the map
- infos = new HashMap(infos);
-
- // Keep only what is of interest with respect to what the portlet app
defines
- infos.keySet().retainAll(uaMD.keySet());
-
- // Make it immutable
- infos = Collections.unmodifiableMap(infos);
- }
-
- //
- return infos;
- }
- else
- {
- Object value = null;
- if (attributes != null)
- {
- value = attributes.get(name);
- }
- if (value == null)
- {
- value = requestContext.getAttribute(name);
- }
- else if (value == REMOVED_ATTRIBUTE)
- {
- value = null;
- }
- return value;
- }
- }
-
- public Enumeration getAttributeNames()
- {
- // Copy the attribute names to avoid ConcurrentModificationException
- // one test in the TCK getPortalObjectContext the Enumeration then dispatch the
call to a
- // servlet where it use the Enumeration and it throws a CME if we don't copy
- Set names = new HashSet();
- for (Enumeration e = requestContext.getAttributeNames(); e.hasMoreElements();)
- {
- names.add(e.nextElement());
- }
- if (attributes != null)
- {
- for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
- {
- Map.Entry entry = (Map.Entry)i.next();
- String name = (String)entry.getKey();
- Object value = entry.getValue();
- if (value == REMOVED_ATTRIBUTE)
- {
- names.remove(name);
- }
- else
- {
- names.add(name);
- }
- }
- }
- names.add(PortletRequest.USER_INFO);
- return Tools.toEnumeration(names.iterator());
- }
-
- public void setAttribute(String name, Object value)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- if (!PortletRequest.USER_INFO.equals(name))
- {
- if (value == null)
- {
- value = REMOVED_ATTRIBUTE;
- }
- if (attributes == null)
- {
- attributes = new HashMap();
- }
- attributes.put(name, value);
- }
- }
-
- public void removeAttribute(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
- setAttribute(name, null);
- }
-
- // PLT.11.1.4
-
- public String getProperty(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
-
- //
- Object prop = invocation.getAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
name);
- if (prop instanceof Collection)
- {
- Iterator iterator = ((Collection)prop).iterator();
- if (iterator.hasNext())
- {
- prop = iterator.next();
- }
- }
-
- //
- if (prop == null)
- {
- // Otherwise the request header
- prop = dreq.getHeader(name);
- }
-
- return (String)prop;
- }
-
- public Enumeration getProperties(String name)
- {
- if (name == null)
- {
- throw new IllegalArgumentException("name must not be null");
- }
-
- //
- Object prop = invocation.getAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
name);
- if (prop == null)
- {
- // Otherwise the request headers
- return dreq.getHeaders(name);
- }
- else if (prop instanceof Collection)
- {
- return Collections.enumeration(((Collection)prop));
- }
- else
- {
- return Tools.toEnumeration(prop);
- }
- }
-
- public Enumeration getPropertyNames()
- {
- // First the properties
- Set names = new
HashSet(invocation.getContext().getAttributeResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE).getKeys());
-
- // Then put the headers
- for (Enumeration e = dreq.getHeaderNames();e.hasMoreElements();)
- {
- String name = (String)e.nextElement();
- names.add(name);
- }
-
- //
- return Collections.enumeration(names);
- }
-
- // PLT.11.1.5
-
- public String getContextPath()
- {
- return (String)dreq.getAttribute("javax.servlet.include.context_path");
- }
-
- // PLT.11.1.6
-
- public String getAuthType()
- {
- return securityContext.getAuthType();
- }
-
- public String getRemoteUser()
- {
- return securityContext.getRemoteUser();
- }
-
- public Principal getUserPrincipal()
- {
- return securityContext.getUserPrincipal();
- }
-
- public boolean isUserInRole(String roleName)
- {
- // Get the map role name to role link
- Map securityRoleRefsMap =
((ContainerPortletInfo)invocation.getInfo()).getContainer().getSecurityRoleRefsMap();
-
- // Process the role link
- String roleLink = (String)securityRoleRefsMap.get(roleName);
- if (roleLink == null)
- {
- if (securityRoleRefsMap.containsKey(roleName))
- {
- // The role name exist without a role link value
- return securityContext.isUserInRole(roleName);
- }
- else
- {
- // No role name is defined
- return false;
- }
- }
- else
- {
- // We have the role link value
- return securityContext.isUserInRole(roleLink);
- }
- }
-
- public boolean isSecure()
- {
- return securityContext.isSecure();
- }
-
- // PLT.11.1.7
-
- public String getResponseContentType()
- {
- return invocation.getPortletContext().getStreamInfo().getContentType().toString();
- }
-
- public Enumeration getResponseContentTypes()
- {
- Vector v = new Vector();
- v.add(getResponseContentType());
- return v.elements();
- }
-
- // PLT.11.1.8
-
- public Locale getLocale()
- {
- return userContext.getLocale();
- }
-
- // PLT.11.1.9
-
- public boolean isPortletModeAllowed(PortletMode portletMode)
- {
- if (portletMode == null)
- {
- // The spec does not give way to handle that case properly
- log.warn("Try to test a null portlet mode");
- return false;
- }
- else
- {
- return
invocation.getSupportedModes().contains(org.jboss.portal.Mode.create(portletMode.toString()));
- }
- }
-
- // PLT.11.1.10
-
- public boolean isWindowStateAllowed(WindowState windowState)
- {
- return
invocation.getSupportedWindowStates().contains(org.jboss.portal.WindowState.create(windowState.toString()));
- }
-
- //
-
- public PortletSession getPortletSession()
- {
- return getPortletSession(true);
- }
-
- public PortletSession getPortletSession(boolean create)
- {
- //
- if (create)
- {
- // Create the session with the dispatched request
- HttpSession hsession = dreq.getSession(true);
-
- // Create portlet session
- PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
- psession = new PortletSessionImpl(
- hsession,
- instanceContext.getId(),
- portletApp.getPortletContext());
- }
- else if (psession == null)
- {
- HttpSession hsession = dreq.getSession(false);
-
- //
- if (hsession != null)
- {
- // Create portlet session
- PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
- psession = new PortletSessionImpl(
- hsession,
- instanceContext.getId(),
- portletApp.getPortletContext());
- }
- }
- else if (!psession.isValid())
- {
- // If we don't create and the underlying http session is not valid we return
null
- psession = null;
- }
-
- //
- return psession;
- }
-
- public PortalContext getPortalContext()
- {
- return portalContext;
- }
-
- public String getRequestedSessionId()
- {
- return dreq.getRequestedSessionId();
- }
-
- public boolean isRequestedSessionIdValid()
- {
- return dreq.isRequestedSessionIdValid();
- }
-
- public Enumeration getLocales()
- {
- return Collections.enumeration(userContext.getLocales());
- }
-
- public String getScheme()
- {
- return requestContext.getScheme();
- }
-
- public String getServerName()
- {
- return requestContext.getServerName();
- }
-
- public int getServerPort()
- {
- return requestContext.getServerPort();
- }
-
- public PortletPreferences getPreferences()
- {
- return preferences;
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResponseImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResponseImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResponseImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,105 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.common.invocation.AttributeResolver;
-
-import javax.portlet.PortletResponse;
-import java.util.Collection;
-import java.util.ArrayList;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public abstract class PortletResponseImpl implements PortletResponse
-{
-
- /** . */
- protected final PortletInvocation invocation;
-
- /** . */
- protected final PortletRequestImpl preq;
-
- protected PortletResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
- {
- this.invocation = invocation;
- this.preq = preq;
- }
-
- public String encodeURL(String url)
- {
- if (url == null)
- {
- throw new IllegalArgumentException("URL must not be null");
- }
- return invocation.getPortletContext().encodeResourceURL(url);
- }
-
- public void addProperty(String key, String value) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
-
- //
- AttributeResolver resolver =
invocation.getContext().getAttributeResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE);
- Object prop = resolver.getAttribute(key);
- if (prop == null)
- {
- resolver.setAttribute(key, prop);
- }
- else if (prop instanceof Collection)
- {
- ((Collection)prop).add(value);
- }
- else
- {
- Collection c = new ArrayList();
- c.add(prop);
- c.add(value);
- resolver.setAttribute(key, c);
- }
- }
-
- public void setProperty(String key, String value) throws IllegalArgumentException
- {
- if (key == null)
- {
- throw new IllegalArgumentException("Name cannot be null");
- }
- if (value == null)
- {
- throw new IllegalArgumentException("Value cannot be null");
- }
-
- //
- invocation.setAttribute(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, key, value);
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletSessionImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletSessionImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletSessionImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,218 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import javax.portlet.PortletContext;
-import javax.portlet.PortletSession;
-import javax.servlet.http.HttpSession;
-import java.util.Enumeration;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletSessionImpl implements PortletSession
-{
-
- private HttpSession session;
- private String prefix;
- private PortletContext context;
-
- public PortletSessionImpl(HttpSession session, String id, PortletContext context)
- {
- this.session = session;
- this.prefix = "javax.portlet.p." + id + "?";
- this.context = context;
- }
-
- public Object getAttribute(String s)
- {
- return getAttribute(s, PORTLET_SCOPE);
- }
-
- public Object getAttribute(String s, int i)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("Name must not be null");
- }
- if (i == PORTLET_SCOPE)
- {
- s = prefix + s;
- }
- return session.getAttribute(s);
- }
-
- public Enumeration getAttributeNames()
- {
- return getAttributeNames(PORTLET_SCOPE);
- }
-
- public Enumeration getAttributeNames(int scope)
- {
- final boolean app = scope == APPLICATION_SCOPE;
- return new Enumeration()
- {
- private Enumeration e;
- private String next;
-
- {
- e = session.getAttributeNames();
- next = null;
- next();
- }
-
- public boolean hasMoreElements()
- {
- return next != null;
- }
-
- public Object nextElement()
- {
- String result = next;
- next = null;
- next();
- return result;
- }
-
- private void next()
- {
- while (e.hasMoreElements())
- {
- String attribute = (String)e.nextElement();
- if (app && !attribute.startsWith("javax.portlet."))
- {
- next = attribute;
- break;
- }
- else if (!app && attribute.startsWith(prefix))
- {
- next = attribute.substring(prefix.length());
- break;
- }
- }
- }
- };
- }
-
- public long getCreationTime()
- {
- return session.getCreationTime();
- }
-
- public String getId()
- {
- return session.getId();
- }
-
- public long getLastAccessedTime()
- {
- return session.getLastAccessedTime();
- }
-
- public int getMaxInactiveInterval()
- {
- return session.getMaxInactiveInterval();
- }
-
- public void invalidate()
- {
- // Invalidate the underlying HTTP session
- session.invalidate();
-
- // Mark the session as invalid
- // valid = false;
- }
-
- public boolean isNew()
- {
- return session.isNew();
- }
-
- public void removeAttribute(String s)
- {
- removeAttribute(s, PORTLET_SCOPE);
- }
-
- public void removeAttribute(String s, int i)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("Name must not be null");
- }
- if (i == PORTLET_SCOPE)
- {
- s = prefix + s;
- }
- session.removeAttribute(s);
- }
-
- public void setAttribute(String s, Object o)
- {
- setAttribute(s, o, PORTLET_SCOPE);
- }
-
- public void setAttribute(String s, Object o, int i)
- {
- if (s == null)
- {
- throw new IllegalArgumentException("Name must not be null");
- }
- if (i == PORTLET_SCOPE)
- {
- s = prefix + s;
- }
- session.setAttribute(s, o);
- }
-
- public void setMaxInactiveInterval(int i)
- {
- session.setMaxInactiveInterval(i);
- }
-
- public PortletContext getPortletContext()
- {
- return context;
- }
-
- /** Return the underlying session. */
- HttpSession getHttpSession()
- {
- return session;
- }
-
- /** Detect validity of the session based on the underlying session. */
- boolean isValid()
- {
- try
- {
- session.isNew();
- return true;
- }
- catch (IllegalStateException e)
- {
- return false;
- }
- }
-
-}
Deleted: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletURLImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletURLImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletURLImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,200 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.ActionURL;
-import org.jboss.portal.portlet.PortletParameters;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.RenderURL;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.spi.PortletInvocationContext;
-
-import javax.portlet.PortletMode;
-import javax.portlet.PortletModeException;
-import javax.portlet.PortletRequest;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.PortletURL;
-import javax.portlet.WindowState;
-import javax.portlet.WindowStateException;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class PortletURLImpl implements PortletURL
-{
-
- private PortletInvocation inv;
- private PortletRequest preq;
-
- //
- private Boolean secure;
- private InternalPortletURL url;
-
- public PortletURLImpl(PortletInvocation invocation, PortletRequest preq,
InternalPortletURL url)
- {
- this.inv = invocation;
- this.preq = preq;
- this.url = url;
- }
-
- public void setWindowState(WindowState windowState) throws WindowStateException
- {
- if (!preq.isWindowStateAllowed(windowState))
- {
- throw new WindowStateException("Not supported", windowState);
- }
- url.windowState = windowState;
- }
-
- public void setPortletMode(PortletMode portletMode) throws PortletModeException
- {
- if (portletMode == null)
- {
- // The spec does not say the behaviour with null argument
- // we suppose it clear the current mode
- url.portletMode = null;
- }
- else
- {
- // Check possible
- if (!preq.isPortletModeAllowed(portletMode))
- {
- throw new PortletModeException("Not supported", portletMode);
- }
-
- // Set mode
- url.portletMode = portletMode;
- }
- }
-
- /** @throws IllegalArgumentException if the name is null */
- public void setParameter(String name, String value)
- {
- PortletUtils.checkPortletParameterValidity(name, value);
-
- //
- url.getInternalParameters().setValue(name, value);
- }
-
- public void setParameter(String name, String[] values)
- {
- PortletUtils.checkPortletParameterValidity(name, values);
-
- //
- url.getInternalParameters().setValues(name, values);
- }
-
- public void setParameters(Map parameters)
- {
- PortletUtils.checkPortletParameterMapValidity(parameters);
-
- //
- url.getInternalParameters().replace(parameters);
- }
-
- public void setSecure(boolean secure) throws PortletSecurityException
- {
- this.secure = Boolean.valueOf(secure);
- }
-
- public String toString()
- {
- PortletInvocationContext responseContext = inv.getPortletContext();
- String s = responseContext.renderURL(url, secure, null, true);
- return s;
- }
-
- static abstract class InternalPortletURL implements
org.jboss.portal.portlet.PortletURL
- {
-
- /** . */
- private WindowState windowState;
-
- /** . */
- private PortletMode portletMode;
-
- public Mode getMode()
- {
- if (portletMode != null)
- {
- return Mode.create(portletMode.toString());
- }
- return null;
- }
-
- public org.jboss.portal.WindowState getWindowState()
- {
- if (windowState != null)
- {
- return org.jboss.portal.WindowState.create(windowState.toString());
- }
- return null;
- }
-
- protected abstract PortletParameters getInternalParameters();
- }
-
- static class InternalActionURL extends InternalPortletURL implements ActionURL
- {
-
- /** . */
- private PortletParametersStateString parameters = new
PortletParametersStateString();
-
- protected PortletParameters getInternalParameters()
- {
- return parameters.getParameters();
- }
-
- public StateString getInteractionState()
- {
- return parameters;
- }
-
- /** The portlet container does not need to have the navigational state provided.
*/
- public StateString getNavigationalState()
- {
- return null;
- }
- }
-
- static class InternalRenderURL extends InternalPortletURL implements RenderURL
- {
-
- /** . */
- private PortletParametersStateString navigationalState = new
PortletParametersStateString();
-
- protected PortletParameters getInternalParameters()
- {
- return navigationalState.getParameters();
- }
-
- public StateString getNavigationalState()
- {
- return navigationalState;
- }
- }
-}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletUtils.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -23,6 +23,7 @@
package org.jboss.portal.portlet.impl.jsr168;
import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.jsr168.api.PortletURLImpl;
import javax.portlet.PortletMode;
import javax.portlet.PortletRequest;
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderRequestImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderRequestImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderRequestImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,68 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.spi.RenderContext;
-
-import javax.portlet.RenderRequest;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
- * @version $Revision$
- */
-public class RenderRequestImpl extends PortletRequestImpl implements RenderRequest
-{
-
- /** . */
- protected RenderContext renderContext;
-
- public RenderRequestImpl(RenderInvocation invocation)
- {
- super(invocation);
-
- // Get the render context
- renderContext = (RenderContext)invocation.getPortletContext();
-
- // Get the possibly null navigational state
- StateString navigationalState = renderContext.getNavigationalState();
-
- //
- if (navigationalState == null)
- {
-
- }
- else if (navigationalState instanceof PortletParametersStateString)
- {
- parameters = ((PortletParametersStateString)navigationalState).getParameters();
- }
- else
- {
- PortletParametersStateString parametersState = new
PortletParametersStateString(navigationalState.getStringValue());
- parameters = parametersState.getParameters();
- }
- }
-}
Deleted:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -1,192 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.portlet.impl.jsr168;
-
-import org.jboss.portal.common.MediaType;
-import org.jboss.portal.portlet.invocation.PortletInvocation;
-import org.jboss.portal.portlet.invocation.RenderInvocation;
-import org.jboss.portal.portlet.invocation.response.FragmentResponse;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.server.util.HTTPStreamInfo;
-
-import javax.activation.MimeTypeParseException;
-import javax.portlet.PortletURL;
-import javax.portlet.RenderResponse;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision$
- */
-public class RenderResponseImpl extends PortletResponseImpl implements RenderResponse
-{
-
- /** The fragment result. */
- protected FragmentResponse result;
-
- /** The namespace. */
- protected String namespace;
-
- /** Not really used but we need it to memorize what the client set optionally. */
- protected int bufferSize;
-
- public RenderResponseImpl(RenderInvocation invocation, PortletRequestImpl preq)
- {
- super(invocation, preq);
-
- // 0 means no buffering - we say no buffering
- this.bufferSize = 0;
- this.result = new FragmentResponse();
- }
-
- public PortletInvocationResponse getResult()
- {
- return result;
- }
-
- public void setTitle(String s)
- {
- result.setTitle(s);
- }
-
- public String getContentType()
- {
- return result.getContentType();
- }
-
- public void setContentType(String contentType)
- {
- try
- {
- // Remove the unused appended charset first
- int index = contentType.indexOf(';');
- if (index != -1)
- {
- contentType = contentType.substring(0, index);
- }
-
- // Find the content type among the media type we know
- MediaType requestedMediaType = MediaType.parseMimeType(contentType);
-
- // Get the response media type
- HTTPStreamInfo info = invocation.getPortletContext().getStreamInfo();
- MediaType responseMediaType = info.getContentType();
-
- // Check if the requested media type is allowed as a subtype of the main
response
- if (!responseMediaType.isAllowedSubType(requestedMediaType))
- {
- throw new IllegalArgumentException("Content type not accepted");
- }
-
- // Set the content type
- result.setContentType(contentType);
- }
- catch (MimeTypeParseException e)
- {
- IllegalArgumentException ex = new IllegalArgumentException("Content type
not accepted");
- ex.initCause(e);
- throw ex;
- }
- }
-
- public PrintWriter getWriter() throws IOException
- {
- return result.getWriter();
- }
-
- public OutputStream getPortletOutputStream() throws IOException
- {
- return result.getOutputStream();
- }
-
- public PortletURL createRenderURL()
- {
- return PortletUtils.createRenderURL(invocation, preq);
- }
-
- public PortletURL createActionURL()
- {
- return PortletUtils.createActionURL(invocation, preq);
- }
-
- public String getNamespace()
- {
- if (namespace == null)
- {
- String windowId = invocation.getWindowContext().getId();
- namespace = PortletUtils.generateNamespaceFrom(windowId);
- }
- return namespace;
- }
-
- public String getCharacterEncoding()
- {
- return invocation.getPortletContext().getStreamInfo().getCharset();
- }
-
- public Locale getLocale()
- {
- return invocation.getUserContext().getLocale();
- }
-
- public void setBufferSize(int bufferSize)
- {
- if (bufferSize > -0)
- {
- this.bufferSize = bufferSize;
- }
- }
-
- public int getBufferSize()
- {
- return bufferSize;
- }
-
- public void flushBuffer() throws IOException
- {
- }
-
- public void resetBuffer()
- {
- // Clear the buffer
- result.resetBuffer();
- }
-
- public void reset()
- {
- // Clear the buffer
- resetBuffer();
-
- // And properties
-
invocation.getContext().getAttributeResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE).getKeys().clear();
- }
-
- public boolean isCommitted()
- {
- // Never afterCommit
- return false;
- }
-}
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionRequestImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,130 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.spi.ActionContext;
+
+import javax.portlet.ActionRequest;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ActionRequestImpl extends PortletRequestImpl implements ActionRequest
+{
+
+ /** . */
+ protected final ActionContext actionContext;
+
+ public ActionRequestImpl(ActionInvocation invocation)
+ {
+ super(invocation);
+ this.actionContext = (ActionContext)invocation.getPortletContext();
+
+ // Get the possibly null interaction state
+ StateString interactionState = actionContext.getInteractionState();
+
+ // Take care of the interaction state if any
+ if (interactionState != null)
+ {
+ // Unserialize the interaction state if necessary
+ PortletParametersStateString parametersState = null;
+ if (interactionState instanceof PortletParametersStateString)
+ {
+ parametersState = (PortletParametersStateString)interactionState;
+ }
+ else
+ {
+ parametersState = new
PortletParametersStateString(interactionState.getStringValue());
+ }
+
+ //
+ parameters = parametersState.getParameters();
+ }
+
+ //
+ PortletParameters form = actionContext.getForm();
+ if (form != null)
+ {
+ if (parameters == null)
+ {
+ parameters = form;
+ }
+ else
+ {
+ parameters = new PortletParameters(parameters);
+ parameters.append(form);
+ }
+ }
+ }
+
+ //
+
+ public InputStream getPortletInputStream() throws IOException
+ {
+ if
("application/x-www-form-urlencoded".equals(actionContext.getContentType()))
+ {
+ throw new IllegalStateException();
+ }
+ return actionContext.getInputStream();
+ }
+
+ public void setCharacterEncoding(String s) throws UnsupportedEncodingException
+ {
+ // This method is frankly stupid
+ throw new IllegalStateException("called after the body has been read");
+ // req.setCharacterEncoding(s);
+ }
+
+ public BufferedReader getReader() throws UnsupportedEncodingException, IOException
+ {
+ if
("application/x-www-form-urlencoded".equals(actionContext.getContentType()))
+ {
+ throw new IllegalStateException();
+ }
+ return actionContext.getReader();
+ }
+
+ public String getCharacterEncoding()
+ {
+ return actionContext.getCharacterEncoding();
+ }
+
+ public String getContentType()
+ {
+ return actionContext.getContentType();
+ }
+
+ public int getContentLength()
+ {
+ return actionContext.getContentLength();
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionRequestImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/ActionResponseImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,201 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.util.URLTools;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.response.HTTPRedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RedirectionResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ActionResponseImpl extends PortletResponseImpl implements ActionResponse
+{
+
+ private static final Logger log = Logger.getLogger(ActionResponseImpl.class);
+
+ protected static final int WANT_NOTHING = 0;
+ protected static final int WANT_RENDER = 1;
+ protected static final int WANT_REDIRECT = 2;
+
+ protected PortletInvocationResponse response;
+ protected int decision;
+
+ public ActionResponseImpl(ActionInvocation invocation, PortletRequestImpl preq)
+ {
+ super(invocation, preq);
+
+ //
+ RenderResponse rr = new RenderResponse();
+ rr.setNavigationalState(new PortletParametersStateString());
+
+ //
+ this.response = rr;
+ this.decision = WANT_NOTHING;
+ }
+
+ public PortletInvocationResponse getResult()
+ {
+ return response;
+ }
+
+ public void setWindowState(WindowState windowState) throws WindowStateException
+ {
+ if (decision == WANT_NOTHING || decision == WANT_RENDER)
+ {
+ if (!preq.isWindowStateAllowed(windowState))
+ {
+ throw new WindowStateException("Not supported", windowState);
+ }
+
((RenderResponse)response).setWindowState(org.jboss.portal.WindowState.create(windowState.toString()));
+ decision = WANT_RENDER;
+ }
+ else
+ {
+ throw new IllegalStateException("Window state cannot be set after
redirect");
+ }
+ }
+
+ public void setPortletMode(PortletMode portletMode) throws PortletModeException
+ {
+ if (decision == WANT_NOTHING || decision == WANT_RENDER)
+ {
+ if (portletMode == null)
+ {
+ // The spec does not define that case
+ // we just issue a warn
+ log.warn("Set null portlet mode");
+ }
+ else
+ {
+ if (!preq.isPortletModeAllowed(portletMode))
+ {
+ throw new PortletModeException("Not supported", portletMode);
+ }
+ Mode mode = Mode.create(portletMode.toString());
+ ((RenderResponse)response).setMode(mode);
+ }
+ decision = WANT_RENDER;
+ }
+ else
+ {
+ throw new IllegalStateException("Portlet mode cannot be set after
redirect");
+ }
+ }
+
+ public void sendRedirect(String location) throws IOException
+ {
+ if (location == null)
+ {
+ // do something more clever than simply returning
+ return;
+ }
+ URLTools.enforceAbsoluteURL(location);
+ sendRedirect(new HTTPRedirectionResponse(location));
+ }
+
+ /**
+ * Generic send redirect.
+ *
+ * @param redirect
+ * @throws IllegalStateException implement jsr168 behavior if the portlet as already
commited stuff
+ */
+ protected final void sendRedirect(RedirectionResponse redirect) throws
IllegalStateException
+ {
+ if (decision == WANT_NOTHING || decision == WANT_REDIRECT)
+ {
+ response = redirect;
+ decision = WANT_REDIRECT;
+ }
+ else
+ {
+ throw new IllegalStateException("sendRedirect cannot be called after "
+
+ "setPortletMode/setWindowState/setRenderParameter/setRenderParameters
" +
+ "has been called previously");
+ }
+ }
+
+ public void setRenderParameters(Map map)
+ {
+ PortletUtils.checkPortletParameterMapValidity(map);
+
+ //
+ if (decision == WANT_NOTHING || decision == WANT_RENDER)
+ {
+
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).replace(map);
+ decision = WANT_RENDER;
+ }
+ else
+ {
+ throw new IllegalStateException("setRenderParameters cannot be called after
redirect");
+ }
+ }
+
+ public void setRenderParameter(String name, String value)
+ {
+ PortletUtils.checkPortletParameterValidity(name, value);
+
+ //
+ if (decision == WANT_NOTHING || decision == WANT_RENDER)
+ {
+
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).setValue(name,
value);
+ decision = WANT_RENDER;
+ }
+ else
+ {
+ throw new IllegalStateException("setRenderParameter cannot be called after
redirect");
+ }
+ }
+
+ public void setRenderParameter(String name, String[] values)
+ {
+ PortletUtils.checkPortletParameterValidity(name, values);
+
+ //
+ if (decision == WANT_NOTHING || decision == WANT_RENDER)
+ {
+
((PortletParametersStateString)((RenderResponse)response).getNavigationalState()).setValues(name,
values);
+ decision = WANT_RENDER;
+ }
+ else
+ {
+ throw new IllegalStateException("setRenderParameter cannot be called after
redirect");
+ }
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/ActionResponseImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortalContextImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortalContextImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortalContextImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortalContextImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.server.PortalConstants;
+
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * todo : does not provide customizable values for portlet modes and window states.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortalContextImpl implements javax.portlet.PortalContext
+{
+
+ private PortalContext portal;
+ private Map properties;
+ private Set supportedPortletModes;
+ private Set supportedWindowStates;
+
+ public PortalContextImpl(PortalContext portal)
+ {
+ if (portal == null)
+ {
+ throw new IllegalArgumentException("Must provide a non-null
PortalContext!");
+ }
+ this.portal = portal;
+ this.properties = portal.getProperties();
+ }
+
+ public String getPortalInfo()
+ {
+ return PortalConstants.VERSION.toString();
+ }
+
+ public String getProperty(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Must provide a non-null property
name");
+ }
+ return (String)properties.get(name);
+ }
+
+ public Enumeration getPropertyNames()
+ {
+ return Tools.toEnumeration(properties.keySet().iterator());
+ }
+
+ public Enumeration getSupportedPortletModes()
+ {
+ if (supportedPortletModes == null)
+ {
+ Set tmp = portal.getModes();
+ supportedPortletModes = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator(); i.hasNext();)
+ {
+ Mode mode = (Mode)i.next();
+ supportedPortletModes.add(PortletUtils.decodePortletMode(mode.toString()));
+ }
+ }
+ return Tools.toEnumeration(supportedPortletModes.iterator());
+ }
+
+ public Enumeration getSupportedWindowStates()
+ {
+ if (supportedWindowStates == null)
+ {
+ Set tmp = portal.getWindowStates();
+ supportedWindowStates = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator(); i.hasNext();)
+ {
+ org.jboss.portal.WindowState windowState =
(org.jboss.portal.WindowState)i.next();
+
supportedWindowStates.add(PortletUtils.decodeWindowState(windowState.toString()));
+ }
+ }
+ return Tools.toEnumeration(supportedWindowStates.iterator());
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortalContextImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletConfigImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.impl.jsr168.info.PortletResourceBundleManager;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletConfigImpl implements PortletConfig
+{
+
+ private String portletName;
+ private PortletContext portletContext;
+ private Map initParameters;
+ private PortletResourceBundleManager bundleMgr;
+
+ public PortletConfigImpl(String portletName,
+ PortletContext portletContext,
+ Map initParameters,
+ PortletResourceBundleManager bundleMgr)
+ {
+ this.portletName = portletName;
+ this.portletContext = portletContext;
+ this.initParameters = initParameters;
+ this.bundleMgr = bundleMgr;
+ }
+
+ public String getPortletName()
+ {
+ return portletName;
+ }
+
+ public PortletContext getPortletContext()
+ {
+ return portletContext;
+ }
+
+ /** May return null ? the spec does not specify what happens when the bundle is not
found for the locale. */
+ public ResourceBundle getResourceBundle(Locale locale)
+ {
+ return bundleMgr.getResourceBundle(locale);
+ }
+
+ public String getInitParameter(String s)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ return (String)initParameters.get(s);
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ return Collections.enumeration(initParameters.keySet());
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletConfigImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletContextImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletContextImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletContextImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletContextImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,186 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.server.PortalConstants;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequestDispatcher;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletContextImpl implements PortletContext
+{
+
+ private ServletContext servletContext;
+
+ public PortletContextImpl(ServletContext servletContext)
+ {
+ this.servletContext = servletContext;
+ }
+
+ public String getServerInfo()
+ {
+ return "JBossPortal/" + PortalConstants.VERSION.getMajor() +
"." + PortalConstants.VERSION.getMinor();
+ }
+
+ public PortletRequestDispatcher getRequestDispatcher(String path)
+ {
+ if (path == null || !path.startsWith("/"))
+ {
+ return null;
+ }
+ RequestDispatcher rd = servletContext.getRequestDispatcher(path);
+ if (rd != null)
+ {
+ return new PortletRequestDispatcherImpl(rd, path);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public PortletRequestDispatcher getNamedDispatcher(String name)
+ {
+ if (name == null)
+ {
+ return null;
+ }
+ RequestDispatcher rd = servletContext.getNamedDispatcher(name);
+ if (rd != null)
+ {
+ return new PortletRequestDispatcherImpl(rd);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public InputStream getResourceAsStream(String s)
+ {
+ return servletContext.getResourceAsStream(s);
+ }
+
+ public int getMajorVersion()
+ {
+ return 1;
+ }
+
+ public int getMinorVersion()
+ {
+ return 0;
+ }
+
+ public String getMimeType(String s)
+ {
+ return servletContext.getMimeType(s);
+ }
+
+ public String getRealPath(String s)
+ {
+ return servletContext.getRealPath(s);
+ }
+
+ public Set getResourcePaths(String s)
+ {
+ return servletContext.getResourcePaths(s);
+ }
+
+ public URL getResource(String s) throws MalformedURLException
+ {
+ if (s == null || !s.startsWith("/"))
+ {
+ throw new MalformedURLException("invalid resource");
+ }
+ URL resource = servletContext.getResource(s);
+ return resource;
+ }
+
+ public Object getAttribute(String s)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("attribute name must not be
null");
+ }
+ return servletContext.getAttribute(s);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return servletContext.getAttributeNames();
+ }
+
+ public String getInitParameter(String s)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("init parameter name must not be
null");
+ }
+ return servletContext.getInitParameter(s);
+ }
+
+ public Enumeration getInitParameterNames()
+ {
+ return servletContext.getInitParameterNames();
+ }
+
+ public void log(String s)
+ {
+ servletContext.log(s);
+ }
+
+ public void log(String s, Throwable throwable)
+ {
+ servletContext.log(s, throwable);
+ }
+
+ public void removeAttribute(String s)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("attribute name must not be
null");
+ }
+ servletContext.removeAttribute(s);
+ }
+
+ public void setAttribute(String s, Object o)
+ {
+ servletContext.setAttribute(s, o);
+ }
+
+ public String getPortletContextName()
+ {
+ return servletContext.getServletContextName();
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletContextImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletPreferencesImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,398 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.state.PropertyContext;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
+
+import javax.portlet.PortletPreferences;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.ReadOnlyException;
+import javax.portlet.ValidatorException;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletPreferencesImpl implements PortletPreferences
+{
+
+ /** The logger. */
+ protected static final Logger log = Logger.getLogger(PortletPreferencesImpl.class);
+
+ /** Indicates the object is used during a action phase. */
+ public static final int ACTION = 1;
+
+ /** Indicates the object is used during a render phase. */
+ public static final int RENDER = 0;
+
+ /** . */
+ protected final PropertyContext prefs;
+
+ /** . */
+ protected final PreferencesValidator validator;
+
+ /** . */
+ protected final ContainerPreferencesInfo containerPrefs;
+
+ /** . */
+ protected final int mode;
+
+ /** Keep track of updates */
+ protected final Map updates;
+
+ public PortletPreferencesImpl(
+ PropertyContext prefs,
+ ContainerPreferencesInfo containerPrefs,
+ PreferencesValidator validator,
+ int mode)
+ {
+ this.prefs = prefs;
+ this.validator = validator;
+ this.containerPrefs = containerPrefs;
+ this.mode = mode;
+ this.updates = new HashMap();
+ }
+
+ public Map getMap()
+ {
+ return new PreferencesMap();
+ }
+
+ public Enumeration getNames()
+ {
+ // Clone the system names
+ Set names = new HashSet(prefs.getPortletKeys());
+
+ // Add the user
+ names.addAll(prefs.getKeys());
+
+ // Add the transient updates
+ for (Iterator i = updates.values().iterator(); i.hasNext();)
+ {
+ PropertyChange change = (PropertyChange)i.next();
+ if (change.getType() == PropertyChange.PREF_UPDATE)
+ {
+ names.add(change.getKey());
+ }
+ else
+ {
+ names.remove(change.getKey());
+ }
+ }
+
+ // Convert to enumeration
+ return Collections.enumeration(names);
+ }
+
+ private Value getValue(String key)
+ {
+ Value value = null;
+ PropertyChange change = (PropertyChange)updates.get(key);
+ if (change != null)
+ {
+ if (change.getType() == PropertyChange.PREF_UPDATE)
+ {
+ value = change.getValue();
+ }
+ else
+ {
+ ContainerPreferenceInfo containerPref =
containerPrefs.getContainerPreference(key);
+ if (containerPref != null)
+ {
+ value = containerPref.getDefaultValue();
+ }
+ }
+ }
+ else
+ {
+ // Get user
+ value = prefs.getValue(key);
+
+ // If does not exist or read only use what the default one
+ if (value == null || isReadOnly(key))
+ {
+ ContainerPreferenceInfo containerPref =
containerPrefs.getContainerPreference(key);
+ if (containerPref != null)
+ {
+ value = containerPref.getDefaultValue();
+ }
+ }
+ }
+ return value;
+ }
+
+ public String getValue(String key, String def) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("key must not be null");
+ }
+ Value value = getValue(key);
+ if (value == null || value.isEmpty())
+ {
+ return def;
+ }
+ else
+ {
+ return value.asString();
+ }
+ }
+
+ public String[] getValues(String key, String[] def) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("key must not be null");
+ }
+ Value value = getValue(key);
+ if (value != null)
+ {
+ return value.asStringArray();
+ }
+ else
+ {
+ return def;
+ }
+ }
+
+ public boolean isReadOnly(String key) throws IllegalArgumentException,
IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("key must not be null");
+ }
+ if (mode == ACTION)
+ {
+ // The accurate value is to combine what the portlet developer and the consumer
specifies
+ return prefs.isReadOnly() || prefs.isReadOnly(key);
+ }
+ else
+ {
+ // During render we cannot be aware of the consumer
+ // intent with respect to the access mode of the current state
+ return prefs.isReadOnly(key);
+ }
+ }
+
+ public void reset(String key) throws IllegalArgumentException, ReadOnlyException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("key must not be null");
+ }
+ if (isReadOnly(key))
+ {
+ throw new ReadOnlyException("Key " + key + " cannot be
written");
+ }
+ updates.put(key, PropertyChange.newReset(key));
+ }
+
+ public void setValue(String key, String value) throws IllegalArgumentException,
ReadOnlyException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("key must not be null");
+ }
+ if (isReadOnly(key))
+ {
+ throw new ReadOnlyException("Key " + key + " cannot be
written");
+ }
+ Value value_ = new StringValue(value);
+ updates.put(key, PropertyChange.newUpdate(key, value_));
+ }
+
+ public void setValues(String key, String[] values) throws IllegalArgumentException,
ReadOnlyException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("key must not be null");
+ }
+ if (isReadOnly(key))
+ {
+ throw new ReadOnlyException("Key " + key + " cannot be
written");
+ }
+ if (values == null)
+ {
+ values = new String[1];
+ }
+ Value value_ = new StringValue(values);
+ updates.put(key, PropertyChange.newUpdate(key, value_));
+ }
+
+ public void store() throws IOException, ValidatorException
+ {
+ // Check we are in the right mode
+ if (mode != ACTION)
+ {
+ throw new IllegalStateException("Store must be called within the scope of
an action request");
+ }
+
+ // Copy the transient set to the persistent set if the consumer allows it
+ if (prefs.isReadOnly())
+ {
+ throw new IOException("Should not happen");
+ }
+
+ // If the optional validator is present validate
+ if (validator != null)
+ {
+ validator.validate(this);
+ }
+
+ //
+ PropertyChange[] changes = (PropertyChange[])updates.values().toArray(new
PropertyChange[updates.size()]);
+ prefs.update(changes);
+
+ // Clear the updates
+ updates.clear();
+ }
+
+ private class PreferencesMap extends HashMap
+ {
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 6969583304804836926L;
+
+ public PreferencesMap()
+ {
+ super(10);
+
+ //
+ for (Iterator i = containerPrefs.getKeys().iterator(); i.hasNext();)
+ {
+ String key = (String)i.next();
+ String[] value =
containerPrefs.getContainerPreference(key).getDefaultValue().asStringArray();
+ String[] clone = new String[value.length];
+ System.arraycopy(value, 0, clone, 0, value.length);
+ super.put(key, clone);
+ }
+
+ //
+ for (Iterator i = prefs.getKeys().iterator(); i.hasNext();)
+ {
+ String key = (String)i.next();
+ String[] value = prefs.getValue(key).asStringArray();
+ String[] clone = new String[value.length];
+ System.arraycopy(value, 0, clone, 0, value.length);
+ super.put(key, clone);
+ }
+
+ //
+ for (Iterator i = updates.values().iterator(); i.hasNext();)
+ {
+ PropertyChange change = (PropertyChange)i.next();
+ String key = change.getKey();
+
+ if (change.getType() == PropertyChange.PREF_RESET)
+ {
+ super.remove(key);
+ }
+ else
+ {
+ String[] value = change.getValue().asStringArray();
+ String[] clone = new String[value.length];
+ System.arraycopy(value, 0, clone, 0, value.length);
+ super.put(key, clone);
+ }
+ }
+ }
+
+ public boolean containsValue(Object value)
+ {
+ if (value instanceof String[])
+ {
+ String[] strings = (String[])value;
+ for (Iterator i = super.values().iterator(); i.hasNext();)
+ {
+ String[] other = (String[])i.next();
+ if (Arrays.equals(strings, other))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public Object get(Object key)
+ {
+ return (String[])super.get(key); // Should be cloned here to ensure
immutability
+ }
+
+ public Collection values()
+ {
+ return super.values(); // String[] should be cloned here to ensure immutability
+ }
+
+ public Set entrySet()
+ {
+ return super.entrySet();
+ }
+
+ /**
+ * Do not change state.
+ *
+ * @return null
+ */
+ public Object put(Object key, Object value)
+ {
+ return null;
+ }
+
+ /**
+ * Do not change state.
+ *
+ * @return null
+ */
+ public Object remove(Object key)
+ {
+ return null;
+ }
+
+ /** Do not change state. */
+ public void putAll(Map t)
+ {
+ }
+
+ /** Do not change state. */
+ public void clear()
+ {
+ }
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletPreferencesImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestDispatcherImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.aspects.portlet.ContextDispatcherInterceptor;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.impl.jsr168.APIConstants;
+import org.jboss.portal.portlet.impl.jsr168.DispatchedHttpServletRequest;
+import org.jboss.portal.portlet.impl.jsr168.DispatchedHttpServletResponse;
+import org.jboss.portal.server.servlet.FilterCommand;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletRequestDispatcherImpl
+ implements PortletRequestDispatcher
+{
+
+ /** The servlet request dispatcher. */
+ private final RequestDispatcher dispatcher;
+
+ /** . */
+ private final String path;
+
+ PortletRequestDispatcherImpl(RequestDispatcher dispatcher)
+ {
+ this(dispatcher, null);
+ }
+
+ PortletRequestDispatcherImpl(RequestDispatcher dispatcher, String path)
+ {
+ this.dispatcher = dispatcher;
+ this.path = path;
+ }
+
+ public void include(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
+ {
+ try
+ {
+ // Get the invocation that is still in the request
+ PortletInvocation invocation =
(PortletInvocation)req.getAttribute(ContextDispatcherInterceptor.REQ_ATT_COMPONENT_INVOCATION);
+
+ //
+ HttpServletRequest dreq = invocation.getDispatchedRequest();
+ HttpServletResponse dresp = invocation.getDispatchedResponse();
+
+ // It was set by the PortletContainerInvoker before diving into the portlet, so
let's just reuse them
+ RenderRequest rreq =
(RenderRequest)req.getAttribute(APIConstants.JAVAX_PORTLET_REQUEST);
+ RenderResponse rresp =
(RenderResponse)req.getAttribute(APIConstants.JAVAX_PORTLET_RESPONSE);
+
+ //
+ DispatchedHttpServletRequest direq = new DispatchedHttpServletRequest(rreq,
dreq, path);
+ DispatchedHttpServletResponse diresp = new DispatchedHttpServletResponse(rresp,
dresp);
+
+ //
+ dispatcher.include(direq, diresp);
+ }
+ catch (ServletException e)
+ {
+ // We must translate the servlet exception into a portlet exception for the
calling portlet
+ throw new PortletException(e);
+ }
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestDispatcherImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
(from rev 6691,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletRequestImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,560 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPortletInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContentTypes;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletApplicationMetaData;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.spi.InstanceContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.state.PropertyContext;
+
+import javax.portlet.PortalContext;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSession;
+import javax.portlet.PreferencesValidator;
+import javax.portlet.RenderRequest;
+import javax.portlet.WindowState;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+import java.util.Collection;
+
+/**
+ * PortletRequest implemention. The parameter implementation is left to subclasses that
can implement it differently.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision$
+ */
+public abstract class PortletRequestImpl implements PortletRequest
+{
+
+ /** Constant object to mark that a request attribute is removed. */
+ protected static final Object REMOVED_ATTRIBUTE = new Object();
+
+ protected static final Logger log = Logger.getLogger(PortletRequestImpl.class);
+
+ protected PortletInvocation invocation;
+ protected UserContext userContext;
+ protected SecurityContext securityContext;
+ protected RequestContext requestContext;
+ protected InstanceContext instanceContext;
+ protected PortletPreferences preferences;
+
+ protected PortletContainerImpl container;
+ protected ContentTypes contentTypes;
+ protected HttpServletRequest dreq;
+ protected PortalContext portalContext;
+ protected PortletSessionImpl psession;
+
+ protected int sessionStatus;
+
+ /** . */
+ protected PortletParameters parameters;
+
+ /** The lazy request attributes map added or removed during the request of the
portlet. */
+ protected Map attributes;
+
+ public PortletRequestImpl(PortletInvocation invocation)
+ {
+ //
+ this.invocation = invocation;
+ this.userContext = invocation.getUserContext();
+ this.securityContext = invocation.getSecurityContext();
+ this.requestContext = invocation.getRequestContext();
+ this.instanceContext = invocation.getInstanceContext();
+ this.container =
(PortletContainerImpl)((ContainerPortletInfo)invocation.getInfo()).getContainer();
+ this.contentTypes = container.getContentTypes();
+ this.dreq = invocation.getDispatchedRequest();
+ this.portalContext = new PortalContextImpl(invocation.getPortalContext());
+ this.parameters = null;
+
+ //
+ int mode = this instanceof RenderRequest ? PortletPreferencesImpl.RENDER :
PortletPreferencesImpl.ACTION;
+ PropertyContext prefs =
(PropertyContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PropertyContext.PREFERENCES_ATTRIBUTE);
+ PreferencesValidator validator = container.getPreferencesValidator();
+ ContainerPreferencesInfo containerPrefs =
(ContainerPreferencesInfo)container.getInfo().getPreferences();
+ this.preferences = new PortletPreferencesImpl(prefs, containerPrefs, validator,
mode);
+ }
+
+ // PLT.11.1.1
+
+ public String getParameter(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ if (parameters != null)
+ {
+ return parameters.getValue(name);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Enumeration getParameterNames()
+ {
+ if (parameters != null)
+ {
+ return Collections.enumeration(parameters.keySet());
+ }
+ else
+ {
+ return Tools.EMPTY_ENUMERATION;
+ }
+ }
+
+ public String[] getParameterValues(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ if (parameters != null)
+ {
+ return parameters.getValues(name);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Map getParameterMap()
+ {
+ if (parameters != null)
+ {
+ return Collections.unmodifiableMap(parameters);
+ }
+ else
+ {
+ return Collections.EMPTY_MAP;
+ }
+ }
+
+ public WindowState getWindowState()
+ {
+ String s = invocation.getPortletContext().getWindowState().toString();
+ return PortletUtils.decodeWindowState(s);
+ }
+
+ public PortletMode getPortletMode()
+ {
+ String s = invocation.getPortletContext().getMode().toString();
+ return PortletUtils.decodePortletMode(s);
+ }
+
+ // PLT.11.1.3
+
+ public Object getAttribute(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ if (PortletRequest.USER_INFO.equals(name))
+ {
+ Map infos = userContext.getInformations();
+
+ //
+ if (infos != null)
+ {
+ // Get portlet application metadata
+ PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
+ PortletApplicationMetaData pamd = portletApp.getMetaData();
+ Map uaMD = pamd.getUserAttributes();
+
+ // Clone the map
+ infos = new HashMap(infos);
+
+ // Keep only what is of interest with respect to what the portlet app
defines
+ infos.keySet().retainAll(uaMD.keySet());
+
+ // Make it immutable
+ infos = Collections.unmodifiableMap(infos);
+ }
+
+ //
+ return infos;
+ }
+ else
+ {
+ Object value = null;
+ if (attributes != null)
+ {
+ value = attributes.get(name);
+ }
+ if (value == null)
+ {
+ value = requestContext.getAttribute(name);
+ }
+ else if (value == REMOVED_ATTRIBUTE)
+ {
+ value = null;
+ }
+ return value;
+ }
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ // Copy the attribute names to avoid ConcurrentModificationException
+ // one test in the TCK getPortalObjectContext the Enumeration then dispatch the
call to a
+ // servlet where it use the Enumeration and it throws a CME if we don't copy
+ Set names = new HashSet();
+ for (Enumeration e = requestContext.getAttributeNames(); e.hasMoreElements();)
+ {
+ names.add(e.nextElement());
+ }
+ if (attributes != null)
+ {
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ Object value = entry.getValue();
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ names.remove(name);
+ }
+ else
+ {
+ names.add(name);
+ }
+ }
+ }
+ names.add(PortletRequest.USER_INFO);
+ return Tools.toEnumeration(names.iterator());
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ if (!PortletRequest.USER_INFO.equals(name))
+ {
+ if (value == null)
+ {
+ value = REMOVED_ATTRIBUTE;
+ }
+ if (attributes == null)
+ {
+ attributes = new HashMap();
+ }
+ attributes.put(name, value);
+ }
+ }
+
+ public void removeAttribute(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+ setAttribute(name, null);
+ }
+
+ // PLT.11.1.4
+
+ public String getProperty(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+
+ //
+ Object prop = invocation.getAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
name);
+ if (prop instanceof Collection)
+ {
+ Iterator iterator = ((Collection)prop).iterator();
+ if (iterator.hasNext())
+ {
+ prop = iterator.next();
+ }
+ }
+
+ //
+ if (prop == null)
+ {
+ // Otherwise the request header
+ prop = dreq.getHeader(name);
+ }
+
+ return (String)prop;
+ }
+
+ public Enumeration getProperties(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("name must not be null");
+ }
+
+ //
+ Object prop = invocation.getAttribute(PortletInvocation.REQUEST_PROPERTIES_SCOPE,
name);
+ if (prop == null)
+ {
+ // Otherwise the request headers
+ return dreq.getHeaders(name);
+ }
+ else if (prop instanceof Collection)
+ {
+ return Collections.enumeration(((Collection)prop));
+ }
+ else
+ {
+ return Tools.toEnumeration(prop);
+ }
+ }
+
+ public Enumeration getPropertyNames()
+ {
+ // First the properties
+ Set names = new
HashSet(invocation.getContext().getAttributeResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE).getKeys());
+
+ // Then put the headers
+ for (Enumeration e = dreq.getHeaderNames();e.hasMoreElements();)
+ {
+ String name = (String)e.nextElement();
+ names.add(name);
+ }
+
+ //
+ return Collections.enumeration(names);
+ }
+
+ // PLT.11.1.5
+
+ public String getContextPath()
+ {
+ return (String)dreq.getAttribute("javax.servlet.include.context_path");
+ }
+
+ // PLT.11.1.6
+
+ public String getAuthType()
+ {
+ return securityContext.getAuthType();
+ }
+
+ public String getRemoteUser()
+ {
+ return securityContext.getRemoteUser();
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return securityContext.getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String roleName)
+ {
+ // Get the map role name to role link
+ Map securityRoleRefsMap =
((PortletContainerImpl)((ContainerPortletInfo)invocation.getInfo()).getContainer()).getSecurityRoleRefsMap();
+
+ // Process the role link
+ String roleLink = (String)securityRoleRefsMap.get(roleName);
+ if (roleLink == null)
+ {
+ if (securityRoleRefsMap.containsKey(roleName))
+ {
+ // The role name exist without a role link value
+ return securityContext.isUserInRole(roleName);
+ }
+ else
+ {
+ // No role name is defined
+ return false;
+ }
+ }
+ else
+ {
+ // We have the role link value
+ return securityContext.isUserInRole(roleLink);
+ }
+ }
+
+ public boolean isSecure()
+ {
+ return securityContext.isSecure();
+ }
+
+ // PLT.11.1.7
+
+ public String getResponseContentType()
+ {
+ return invocation.getPortletContext().getStreamInfo().getContentType().toString();
+ }
+
+ public Enumeration getResponseContentTypes()
+ {
+ Vector v = new Vector();
+ v.add(getResponseContentType());
+ return v.elements();
+ }
+
+ // PLT.11.1.8
+
+ public Locale getLocale()
+ {
+ return userContext.getLocale();
+ }
+
+ // PLT.11.1.9
+
+ public boolean isPortletModeAllowed(PortletMode portletMode)
+ {
+ if (portletMode == null)
+ {
+ // The spec does not give way to handle that case properly
+ log.warn("Try to test a null portlet mode");
+ return false;
+ }
+ else
+ {
+ return
invocation.getSupportedModes().contains(org.jboss.portal.Mode.create(portletMode.toString()));
+ }
+ }
+
+ // PLT.11.1.10
+
+ public boolean isWindowStateAllowed(WindowState windowState)
+ {
+ return
invocation.getSupportedWindowStates().contains(org.jboss.portal.WindowState.create(windowState.toString()));
+ }
+
+ //
+
+ public PortletSession getPortletSession()
+ {
+ return getPortletSession(true);
+ }
+
+ public PortletSession getPortletSession(boolean create)
+ {
+ //
+ if (create)
+ {
+ // Create the session with the dispatched request
+ HttpSession hsession = dreq.getSession(true);
+
+ // Create portlet session
+ PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
+ psession = new PortletSessionImpl(
+ hsession,
+ instanceContext.getId(),
+ portletApp.getPortletContext());
+ }
+ else if (psession == null)
+ {
+ HttpSession hsession = dreq.getSession(false);
+
+ //
+ if (hsession != null)
+ {
+ // Create portlet session
+ PortletApplicationImpl portletApp =
(PortletApplicationImpl)container.getApplication();
+ psession = new PortletSessionImpl(
+ hsession,
+ instanceContext.getId(),
+ portletApp.getPortletContext());
+ }
+ }
+ else if (!psession.isValid())
+ {
+ // If we don't create and the underlying http session is not valid we return
null
+ psession = null;
+ }
+
+ //
+ return psession;
+ }
+
+ public PortalContext getPortalContext()
+ {
+ return portalContext;
+ }
+
+ public String getRequestedSessionId()
+ {
+ return dreq.getRequestedSessionId();
+ }
+
+ public boolean isRequestedSessionIdValid()
+ {
+ return dreq.isRequestedSessionIdValid();
+ }
+
+ public Enumeration getLocales()
+ {
+ return Collections.enumeration(userContext.getLocales());
+ }
+
+ public String getScheme()
+ {
+ return requestContext.getScheme();
+ }
+
+ public String getServerName()
+ {
+ return requestContext.getServerName();
+ }
+
+ public int getServerPort()
+ {
+ return requestContext.getServerPort();
+ }
+
+ public PortletPreferences getPreferences()
+ {
+ return preferences;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletRequestImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletResponseImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import javax.portlet.PortletResponse;
+import java.util.Collection;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public abstract class PortletResponseImpl implements PortletResponse
+{
+
+ /** . */
+ protected final PortletInvocation invocation;
+
+ /** . */
+ protected final PortletRequestImpl preq;
+
+ protected PortletResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
+ {
+ this.invocation = invocation;
+ this.preq = preq;
+ }
+
+ public String encodeURL(String url)
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("URL must not be null");
+ }
+ return invocation.getPortletContext().encodeResourceURL(url);
+ }
+
+ public void addProperty(String key, String value) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Value cannot be null");
+ }
+
+ //
+ AttributeResolver resolver =
invocation.getContext().getAttributeResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE);
+ Object prop = resolver.getAttribute(key);
+ if (prop == null)
+ {
+ resolver.setAttribute(key, prop);
+ }
+ else if (prop instanceof Collection)
+ {
+ ((Collection)prop).add(value);
+ }
+ else
+ {
+ Collection c = new ArrayList();
+ c.add(prop);
+ c.add(value);
+ resolver.setAttribute(key, c);
+ }
+ }
+
+ public void setProperty(String key, String value) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Name cannot be null");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Value cannot be null");
+ }
+
+ //
+ invocation.setAttribute(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, key, value);
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletResponseImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletSessionImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,218 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletSession;
+import javax.servlet.http.HttpSession;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletSessionImpl implements PortletSession
+{
+
+ private HttpSession session;
+ private String prefix;
+ private PortletContext context;
+
+ public PortletSessionImpl(HttpSession session, String id, PortletContext context)
+ {
+ this.session = session;
+ this.prefix = "javax.portlet.p." + id + "?";
+ this.context = context;
+ }
+
+ public Object getAttribute(String s)
+ {
+ return getAttribute(s, PORTLET_SCOPE);
+ }
+
+ public Object getAttribute(String s, int i)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("Name must not be null");
+ }
+ if (i == PORTLET_SCOPE)
+ {
+ s = prefix + s;
+ }
+ return session.getAttribute(s);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ return getAttributeNames(PORTLET_SCOPE);
+ }
+
+ public Enumeration getAttributeNames(int scope)
+ {
+ final boolean app = scope == APPLICATION_SCOPE;
+ return new Enumeration()
+ {
+ private Enumeration e;
+ private String next;
+
+ {
+ e = session.getAttributeNames();
+ next = null;
+ next();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return next != null;
+ }
+
+ public Object nextElement()
+ {
+ String result = next;
+ next = null;
+ next();
+ return result;
+ }
+
+ private void next()
+ {
+ while (e.hasMoreElements())
+ {
+ String attribute = (String)e.nextElement();
+ if (app && !attribute.startsWith("javax.portlet."))
+ {
+ next = attribute;
+ break;
+ }
+ else if (!app && attribute.startsWith(prefix))
+ {
+ next = attribute.substring(prefix.length());
+ break;
+ }
+ }
+ }
+ };
+ }
+
+ public long getCreationTime()
+ {
+ return session.getCreationTime();
+ }
+
+ public String getId()
+ {
+ return session.getId();
+ }
+
+ public long getLastAccessedTime()
+ {
+ return session.getLastAccessedTime();
+ }
+
+ public int getMaxInactiveInterval()
+ {
+ return session.getMaxInactiveInterval();
+ }
+
+ public void invalidate()
+ {
+ // Invalidate the underlying HTTP session
+ session.invalidate();
+
+ // Mark the session as invalid
+ // valid = false;
+ }
+
+ public boolean isNew()
+ {
+ return session.isNew();
+ }
+
+ public void removeAttribute(String s)
+ {
+ removeAttribute(s, PORTLET_SCOPE);
+ }
+
+ public void removeAttribute(String s, int i)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("Name must not be null");
+ }
+ if (i == PORTLET_SCOPE)
+ {
+ s = prefix + s;
+ }
+ session.removeAttribute(s);
+ }
+
+ public void setAttribute(String s, Object o)
+ {
+ setAttribute(s, o, PORTLET_SCOPE);
+ }
+
+ public void setAttribute(String s, Object o, int i)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException("Name must not be null");
+ }
+ if (i == PORTLET_SCOPE)
+ {
+ s = prefix + s;
+ }
+ session.setAttribute(s, o);
+ }
+
+ public void setMaxInactiveInterval(int i)
+ {
+ session.setMaxInactiveInterval(i);
+ }
+
+ public PortletContext getPortletContext()
+ {
+ return context;
+ }
+
+ /** Return the underlying session. */
+ HttpSession getHttpSession()
+ {
+ return session;
+ }
+
+ /** Detect validity of the session based on the underlying session. */
+ boolean isValid()
+ {
+ try
+ {
+ session.isNew();
+ return true;
+ }
+ catch (IllegalStateException e)
+ {
+ return false;
+ }
+ }
+
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletSessionImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java (from
rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/PortletURLImpl.java)
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,200 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.spi.PortletInvocationContext;
+
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURL;
+import javax.portlet.WindowState;
+import javax.portlet.WindowStateException;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class PortletURLImpl implements PortletURL
+{
+
+ private PortletInvocation inv;
+ private PortletRequest preq;
+
+ //
+ private Boolean secure;
+ private InternalPortletURL url;
+
+ public PortletURLImpl(PortletInvocation invocation, PortletRequest preq,
InternalPortletURL url)
+ {
+ this.inv = invocation;
+ this.preq = preq;
+ this.url = url;
+ }
+
+ public void setWindowState(WindowState windowState) throws WindowStateException
+ {
+ if (!preq.isWindowStateAllowed(windowState))
+ {
+ throw new WindowStateException("Not supported", windowState);
+ }
+ url.windowState = windowState;
+ }
+
+ public void setPortletMode(PortletMode portletMode) throws PortletModeException
+ {
+ if (portletMode == null)
+ {
+ // The spec does not say the behaviour with null argument
+ // we suppose it clear the current mode
+ url.portletMode = null;
+ }
+ else
+ {
+ // Check possible
+ if (!preq.isPortletModeAllowed(portletMode))
+ {
+ throw new PortletModeException("Not supported", portletMode);
+ }
+
+ // Set mode
+ url.portletMode = portletMode;
+ }
+ }
+
+ /** @throws IllegalArgumentException if the name is null */
+ public void setParameter(String name, String value)
+ {
+ PortletUtils.checkPortletParameterValidity(name, value);
+
+ //
+ url.getInternalParameters().setValue(name, value);
+ }
+
+ public void setParameter(String name, String[] values)
+ {
+ PortletUtils.checkPortletParameterValidity(name, values);
+
+ //
+ url.getInternalParameters().setValues(name, values);
+ }
+
+ public void setParameters(Map parameters)
+ {
+ PortletUtils.checkPortletParameterMapValidity(parameters);
+
+ //
+ url.getInternalParameters().replace(parameters);
+ }
+
+ public void setSecure(boolean secure) throws PortletSecurityException
+ {
+ this.secure = Boolean.valueOf(secure);
+ }
+
+ public String toString()
+ {
+ PortletInvocationContext responseContext = inv.getPortletContext();
+ return responseContext.renderURL(url, secure, null, true);
+ }
+
+ public static abstract class InternalPortletURL implements
org.jboss.portal.portlet.PortletURL
+ {
+
+ /** . */
+ private WindowState windowState;
+
+ /** . */
+ private PortletMode portletMode;
+
+ public Mode getMode()
+ {
+ if (portletMode != null)
+ {
+ return Mode.create(portletMode.toString());
+ }
+ return null;
+ }
+
+ public org.jboss.portal.WindowState getWindowState()
+ {
+ if (windowState != null)
+ {
+ return org.jboss.portal.WindowState.create(windowState.toString());
+ }
+ return null;
+ }
+
+ protected abstract PortletParameters getInternalParameters();
+ }
+
+ public static class InternalActionURL extends InternalPortletURL implements ActionURL
+ {
+
+ /** . */
+ private PortletParametersStateString parameters = new
PortletParametersStateString();
+
+ protected PortletParameters getInternalParameters()
+ {
+ return parameters.getParameters();
+ }
+
+ public StateString getInteractionState()
+ {
+ return parameters;
+ }
+
+ /** The portlet container does not need to have the navigational state provided.
*/
+ public StateString getNavigationalState()
+ {
+ return null;
+ }
+ }
+
+ public static class InternalRenderURL extends InternalPortletURL implements RenderURL
+ {
+
+ /** . */
+ private PortletParametersStateString navigationalState = new
PortletParametersStateString();
+
+ protected PortletParameters getInternalParameters()
+ {
+ return navigationalState.getParameters();
+ }
+
+ public StateString getNavigationalState()
+ {
+ return navigationalState;
+ }
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/PortletURLImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderRequestImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.spi.RenderContext;
+
+import javax.portlet.RenderRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw
Dawidowicz</a>
+ * @version $Revision$
+ */
+public class RenderRequestImpl extends PortletRequestImpl implements RenderRequest
+{
+
+ /** . */
+ protected RenderContext renderContext;
+
+ public RenderRequestImpl(RenderInvocation invocation)
+ {
+ super(invocation);
+
+ // Get the render context
+ renderContext = (RenderContext)invocation.getPortletContext();
+
+ // Get the possibly null navigational state
+ StateString navigationalState = renderContext.getNavigationalState();
+
+ //
+ if (navigationalState == null)
+ {
+
+ }
+ else if (navigationalState instanceof PortletParametersStateString)
+ {
+ parameters = ((PortletParametersStateString)navigationalState).getParameters();
+ }
+ else
+ {
+ PortletParametersStateString parametersState = new
PortletParametersStateString(navigationalState.getStringValue());
+ parameters = parametersState.getParameters();
+ }
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderRequestImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/RenderResponseImpl.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,193 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.api;
+
+import org.jboss.portal.common.MediaType;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.impl.jsr168.PortletUtils;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+
+import javax.activation.MimeTypeParseException;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class RenderResponseImpl extends PortletResponseImpl implements RenderResponse
+{
+
+ /** The fragment result. */
+ protected FragmentResponse result;
+
+ /** The namespace. */
+ protected String namespace;
+
+ /** Not really used but we need it to memorize what the client set optionally. */
+ protected int bufferSize;
+
+ public RenderResponseImpl(RenderInvocation invocation, PortletRequestImpl preq)
+ {
+ super(invocation, preq);
+
+ // 0 means no buffering - we say no buffering
+ this.bufferSize = 0;
+ this.result = new FragmentResponse();
+ }
+
+ public PortletInvocationResponse getResult()
+ {
+ return result;
+ }
+
+ public void setTitle(String s)
+ {
+ result.setTitle(s);
+ }
+
+ public String getContentType()
+ {
+ return result.getContentType();
+ }
+
+ public void setContentType(String contentType)
+ {
+ try
+ {
+ // Remove the unused appended charset first
+ int index = contentType.indexOf(';');
+ if (index != -1)
+ {
+ contentType = contentType.substring(0, index);
+ }
+
+ // Find the content type among the media type we know
+ MediaType requestedMediaType = MediaType.parseMimeType(contentType);
+
+ // Get the response media type
+ HTTPStreamInfo info = invocation.getPortletContext().getStreamInfo();
+ MediaType responseMediaType = info.getContentType();
+
+ // Check if the requested media type is allowed as a subtype of the main
response
+ if (!responseMediaType.isAllowedSubType(requestedMediaType))
+ {
+ throw new IllegalArgumentException("Content type not accepted");
+ }
+
+ // Set the content type
+ result.setContentType(contentType);
+ }
+ catch (MimeTypeParseException e)
+ {
+ IllegalArgumentException ex = new IllegalArgumentException("Content type
not accepted");
+ ex.initCause(e);
+ throw ex;
+ }
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ return result.getWriter();
+ }
+
+ public OutputStream getPortletOutputStream() throws IOException
+ {
+ return result.getOutputStream();
+ }
+
+ public PortletURL createRenderURL()
+ {
+ return PortletUtils.createRenderURL(invocation, preq);
+ }
+
+ public PortletURL createActionURL()
+ {
+ return PortletUtils.createActionURL(invocation, preq);
+ }
+
+ public String getNamespace()
+ {
+ if (namespace == null)
+ {
+ String windowId = invocation.getWindowContext().getId();
+ namespace = PortletUtils.generateNamespaceFrom(windowId);
+ }
+ return namespace;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return invocation.getPortletContext().getStreamInfo().getCharset();
+ }
+
+ public Locale getLocale()
+ {
+ return invocation.getUserContext().getLocale();
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ if (bufferSize > -0)
+ {
+ this.bufferSize = bufferSize;
+ }
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+
+ public void flushBuffer() throws IOException
+ {
+ }
+
+ public void resetBuffer()
+ {
+ // Clear the buffer
+ result.resetBuffer();
+ }
+
+ public void reset()
+ {
+ // Clear the buffer
+ resetBuffer();
+
+ // And properties
+
invocation.getContext().getAttributeResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE).getKeys().clear();
+ }
+
+ public boolean isCommitted()
+ {
+ // Never afterCommit
+ return false;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/api/RenderResponseImpl.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCacheInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCacheInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCacheInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCacheInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.portlet.impl.jsr168.metadata.CacheConfigMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.info.CacheInfo;
+import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ContainerCacheInfo implements CacheInfo
+{
+
+ /** Cache uses strong references. */
+ public static int REF_STRONG = 0;
+
+ /** Cache uses soft references. */
+ public static int REF_SOFT = 1;
+
+ /** . */
+ private static Logger log = Logger.getLogger(ContainerCacheInfo.class);
+
+ /** . */
+ private int expirationTimeSecs;
+
+ /** . */
+ private int referenceType;
+
+ public ContainerCacheInfo(PortletMetaData portletMD, JBossPortletMetaData
jbossPortletMD)
+ {
+ CacheConfigMetaData cacheConfigMD = portletMD.getCacheConfig();
+ if (cacheConfigMD != null)
+ {
+ expirationTimeSecs = cacheConfigMD.getExpirationTime();
+ if (expirationTimeSecs < 0 && expirationTimeSecs != -1)
+ {
+ log.warn("Seen bad caching expiration value " + expirationTimeSecs
+ " disable caching instead");
+ expirationTimeSecs = 0;
+ }
+ }
+ else
+ {
+ expirationTimeSecs = 0;
+ }
+
+ referenceType = REF_STRONG;
+ if (jbossPortletMD != null)
+ {
+ referenceType = jbossPortletMD.getCacheRefType() == null ? REF_STRONG :
jbossPortletMD.getCacheRefType().intValue();
+ }
+ }
+
+ public int getExpirationSecs()
+ {
+ return expirationTimeSecs;
+ }
+
+ public int getReferenceType()
+ {
+ return referenceType;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCacheInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerCapabilities.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.info.CapabilitiesInfo;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ContainerCapabilities implements CapabilitiesInfo
+{
+ private static Set WINDOW_STATES = new HashSet(3);
+
+ static
+ {
+ WINDOW_STATES.add(new ContainerWindowStateInfo(WindowState.MAXIMIZED));
+ WINDOW_STATES.add(new ContainerWindowStateInfo(WindowState.MINIMIZED));
+ WINDOW_STATES.add(new ContainerWindowStateInfo(WindowState.NORMAL));
+ WINDOW_STATES = Collections.unmodifiableSet(WINDOW_STATES);
+ }
+
+ private Set supportedLocales;
+ private ContentTypes contentTypes;
+ private PortletResourceBundleManager bundleMgr;
+
+ public ContainerCapabilities(Set supportedLocales, PortletResourceBundleManager
bundleMgr, ContentTypes contentTypes) throws Exception
+ {
+ this.supportedLocales = supportedLocales;
+ this.contentTypes = contentTypes;
+ this.bundleMgr = bundleMgr;
+ }
+
+ public Set getMimeTypes()
+ {
+ return new HashSet(contentTypes.getAllContentTypes());
+ }
+
+ public Set getAllModes()
+ {
+ Set infos = new HashSet();
+ for (Iterator i = contentTypes.getAllModes().iterator(); i.hasNext();)
+ {
+ infos.add(new ContainerModeInfo((Mode)i.next()));
+ }
+ return infos;
+ }
+
+ public Set getModes(String mimeType)
+ {
+ Set infos = new HashSet();
+ for (Iterator i = contentTypes.getSupportedModes(mimeType).iterator();
i.hasNext();)
+ {
+ infos.add(new ContainerModeInfo((Mode)i.next()));
+ }
+ return infos;
+ }
+
+ public Set getAllWindowStates()
+ {
+ return WINDOW_STATES;
+ }
+
+ public Set getWindowStates(String mimeType)
+ {
+ if (contentTypes.isContentTypeSupported(mimeType))
+ {
+ return getAllWindowStates();
+ }
+ return Collections.EMPTY_SET;
+ }
+
+ public Set getAllLocales()
+ {
+ return supportedLocales;
+ }
+
+ public Set getLocales(String mimeType)
+ {
+ return getAllLocales();
+ }
+
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerCapabilities.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerMetaInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.info.MetaInfo;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ContainerMetaInfo implements MetaInfo
+{
+
+ private Map values;
+ private static final String JAVAX_PORTLET = "javax.portlet.";
+ private static final String[] KEYS = {TITLE, SHORT_TITLE, KEYWORDS};
+ private static final String[] BUNDLE_KEYS = {JAVAX_PORTLET + TITLE, JAVAX_PORTLET +
SHORT_TITLE, JAVAX_PORTLET + KEYWORDS};
+
+ public ContainerMetaInfo(PortletMetaData metadata, PortletResourceBundleManager rb)
+ {
+ this.values = new HashMap();
+
+ // Construct info from resource bundle manager
+ if (rb != null)
+ {
+ for (int i = 0; i < KEYS.length; i++)
+ {
+ String key = KEYS[i];
+ Map tmp = new HashMap();
+ List locales = metadata.getLanguages().getSupportedLocales();
+
+ // Add english locale
+ locales.add(Locale.ENGLISH);
+
+ for (Iterator j = locales.iterator(); j.hasNext();)
+ {
+ Locale locale = (Locale)j.next();
+ ResourceBundle bundle = rb.getResourceBundle(locale);
+ try
+ {
+ String value = bundle.getString(BUNDLE_KEYS[i]);
+ tmp.put(locale, value);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+ LocalizedString ls = new LocalizedString(tmp, Locale.ENGLISH);
+ values.put(key, ls);
+ }
+ }
+
+ // Add stuff coming from meta data
+ values.put(DESCRIPTION, Utils.getLocalizedDescription(metadata.getDescription()));
+ values.put(DISPLAY_NAME,
Utils.getLocalizedDescription(metadata.getDisplayName()));
+ }
+
+ public LocalizedString getMetaValue(String key)
+ {
+ return (LocalizedString)values.get(key);
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerMetaInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerModeInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.portlet.info.ModeInfo;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.4
+ */
+class ContainerModeInfo implements ModeInfo
+{
+ private final Mode mode;
+ private static final LocalizedString DEFAULT_DESCRIPTION = new
LocalizedString("Default Portlet mode description.", Locale.ENGLISH);
+
+ public ContainerModeInfo(Mode mode)
+ {
+ this.mode = mode;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return DEFAULT_DESCRIPTION; // fix-me
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public String getModeName()
+ {
+ return mode.toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ final ContainerModeInfo modeInfo = (ContainerModeInfo)o;
+
+ return mode.equals(modeInfo.mode);
+
+ }
+
+ public int hashCode()
+ {
+ return mode.hashCode();
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerModeInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPortletInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,140 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.portlet.impl.jsr168.PortletApplicationImpl;
+import org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl;
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.info.CacheInfo;
+import org.jboss.portal.portlet.info.CapabilitiesInfo;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.PreferencesInfo;
+import org.jboss.portal.portlet.info.SecurityInfo;
+import org.jboss.portal.portlet.info.SessionInfo;
+import org.jboss.portal.portlet.metadata.JBossApplicationMetaData;
+import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+
+import java.util.HashSet;
+import java.util.Locale;
+
+/**
+ * For now implementation that use the portlet container directly.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ContainerPortletInfo implements PortletInfo
+{
+
+ private PortletContainer container;
+ private ContainerCapabilities capabilities;
+ private ContainerPreferencesInfo preferences;
+ private ContainerMetaInfo meta;
+ private ContainerSecurityInfo security;
+ private ContainerCacheInfo cache;
+ private ContainerSessionInfo session;
+ private Boolean remotable;
+
+ public ContainerPortletInfo(
+ PortletContainerImpl container,
+ PortletResourceBundleManager bundleMgr,
+ ContentTypes contentTypes)
+ throws Exception
+ {
+ PortletMetaData portletMD = container.getMetaData();
+ JBossPortletMetaData jbossPortletMD = container.getJBossMetaData();
+ PortletApplicationImpl pwa = (PortletApplicationImpl)container.getApplication();
+ JBossApplicationMetaData jbossAppMD = pwa.getJBossMetaData();
+
+ //
+ this.container = container;
+
+ // Add Locale.ENGLISH to supported locales if no locales was provided
+ // todo: should we always include it (i.e. even when other locales are present)?
+ HashSet supportedLocales = new
HashSet(container.getMetaData().getLanguages().getSupportedLocales());
+ if (supportedLocales.isEmpty())
+ {
+ supportedLocales.add(Locale.ENGLISH);
+ }
+
+ this.capabilities = new ContainerCapabilities(supportedLocales, bundleMgr,
contentTypes);
+ this.preferences = portletMD.getPreferences() != null ? new
ContainerPreferencesInfo(portletMD, bundleMgr) : new ContainerPreferencesInfo();
+ this.meta = new ContainerMetaInfo(portletMD, bundleMgr);
+ this.security = new ContainerSecurityInfo(portletMD);
+ this.cache = new ContainerCacheInfo(portletMD, jbossPortletMD);
+ this.session = new ContainerSessionInfo(container);
+
+ if (jbossPortletMD != null)
+ {
+ this.remotable = jbossPortletMD.getRemotable();
+ }
+ if (this.remotable == null && jbossAppMD != null)
+ {
+ this.remotable = jbossAppMD.getRemotable();
+ }
+
+ }
+
+ public PortletContainer getContainer()
+ {
+ return container;
+ }
+
+ public CapabilitiesInfo getCapabilities()
+ {
+ return capabilities;
+ }
+
+ public PreferencesInfo getPreferences()
+ {
+ return preferences;
+ }
+
+ public MetaInfo getMeta()
+ {
+ return meta;
+ }
+
+ public SecurityInfo getSecurity()
+ {
+ return security;
+ }
+
+ public CacheInfo getCache()
+ {
+ return cache;
+ }
+
+ public SessionInfo getSession()
+ {
+ return session;
+ }
+
+ public Boolean isRemotable()
+ {
+ return remotable;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPortletInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferenceInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.portlet.info.PreferenceInfo;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ContainerPreferenceInfo implements PreferenceInfo
+{
+
+ private String key;
+ private LocalizedString displayName;
+ private LocalizedString description;
+ private Boolean readOnly;
+ private Value value;
+
+ public ContainerPreferenceInfo(String key, LocalizedString displayName,
LocalizedString description, boolean readOnly, Value value)
+ {
+ this.key = key;
+ this.displayName = displayName;
+ this.description = description;
+ this.readOnly = Boolean.valueOf(readOnly);
+ this.value = value;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return description;
+ }
+
+ public Boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ /**
+ * Return the value provided by the portlet.xml deployment descriptor.
+ *
+ * @return the preference value associated with this preference meta data
+ */
+ public Value getDefaultValue()
+ {
+ return value;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferenceInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerPreferencesInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.value.StringValue;
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PreferenceMetaData;
+import org.jboss.portal.portlet.info.PreferenceInfo;
+import org.jboss.portal.portlet.info.PreferencesInfo;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ContainerPreferencesInfo implements PreferencesInfo
+{
+
+ /** The cached container preference info. */
+ private Map content;
+
+ public ContainerPreferencesInfo()
+ {
+ content = new HashMap();
+ }
+
+ public ContainerPreferencesInfo(PortletMetaData portletMD,
PortletResourceBundleManager bundleMgr)
+ {
+ content = new HashMap();
+
+ for (Iterator i = portletMD.getPreferences().iterator(); i.hasNext();)
+ {
+ PreferenceMetaData prefMD = (PreferenceMetaData)i.next();
+ Value value = new StringValue(prefMD.getValues());
+ LocalizedString displayName =
bundleMgr.getLocalizedValue("javax.portlet.preference.name." + prefMD.getName(),
prefMD.getName());
+ LocalizedString description =
bundleMgr.getLocalizedValue("javax.portlet.preference.description." +
prefMD.getName(), prefMD.getName());
+ ContainerPreferenceInfo pref = new ContainerPreferenceInfo(prefMD.getName(),
displayName, description, prefMD.isReadOnly(), value);
+ content.put(pref.getKey(), pref);
+ }
+ }
+
+ public ContainerPreferenceInfo getContainerPreference(String key)
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("Preference key must not be
null");
+ }
+ return (ContainerPreferenceInfo)content.get(key);
+ }
+
+ public Set getKeys()
+ {
+ return Collections.unmodifiableSet(content.keySet());
+ }
+
+ public PreferenceInfo getPreference(String key)
+ {
+ return getContainerPreference(key);
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerPreferencesInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSecurityInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSecurityInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSecurityInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSecurityInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.portlet.TransportGuarantee;
+import org.jboss.portal.portlet.impl.jsr168.metadata.PortletMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.TransportGuaranteesMetaData;
+import org.jboss.portal.portlet.info.SecurityInfo;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ContainerSecurityInfo implements SecurityInfo
+{
+
+ /** . */
+ private Set tgs;
+
+ public ContainerSecurityInfo(PortletMetaData portletMD)
+ {
+ tgs = new HashSet();
+ tgs.add(TransportGuarantee.NONE);
+
+ //
+ TransportGuaranteesMetaData tgMD = portletMD.getTransportGuarantees();
+ if (tgMD != null)
+ {
+ for (Iterator i = tgMD.iterator(); i.hasNext();)
+ {
+ TransportGuarantee tg = (TransportGuarantee)i.next();
+ tgs.add(tg);
+ }
+ }
+
+ //
+ tgs = Collections.unmodifiableSet(tgs);
+ }
+
+
+ public boolean containsTransportGuarantee(TransportGuarantee transportGuarantee)
+ {
+ return tgs.contains(transportGuarantee);
+ }
+
+ public Set getTransportGuarantees()
+ {
+ return tgs;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSecurityInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSessionInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerSessionInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSessionInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSessionInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.portlet.container.PortletContainer;
+import org.jboss.portal.portlet.info.SessionInfo;
+import org.jboss.portal.portlet.metadata.JBossPortletMetaData;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class ContainerSessionInfo implements SessionInfo
+{
+
+ private Boolean distributed;
+
+ ContainerSessionInfo(PortletContainer portletContainer)
+ {
+ JBossPortletMetaData md = portletContainer.getJBossMetaData();
+ if (md != null)
+ {
+ distributed = md.getDistributed();
+ }
+ if (distributed == null)
+ {
+ distributed = Boolean.FALSE;
+ }
+ }
+
+ public Boolean getDistributed()
+ {
+ return distributed;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerSessionInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContainerWindowStateInfo.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.portlet.info.WindowStateInfo;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ * @since 2.4
+ */
+class ContainerWindowStateInfo implements WindowStateInfo
+{
+ private final WindowState windowState;
+ private static final LocalizedString DEFAULT_DESCRIPTION = new
LocalizedString("Default window state description.", Locale.ENGLISH);
+
+ public ContainerWindowStateInfo(WindowState windowState)
+ {
+ this.windowState = windowState;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return DEFAULT_DESCRIPTION; //fix-me
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public String getWindowStateName()
+ {
+ return windowState.toString();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ final ContainerWindowStateInfo that = (ContainerWindowStateInfo)o;
+
+ return windowState.equals(that.windowState);
+
+ }
+
+ public int hashCode()
+ {
+ return windowState.hashCode();
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContainerWindowStateInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContentTypes.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/ContentTypes.java)
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContentTypes.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContentTypes.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,351 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypeMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypesMetaData;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This object holds the content type and mode capabilities.
+ * <p/>
+ * Todo : use the media type object ?
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ContentTypes
+{
+ /** Maps MIME Type (String) -> Modes (Set), excluding multiple MIME Types
("*", "* / *", "type / *"). */
+ protected final Map singleTypeToPortletModes;
+ /** Maps MIME Type (String) -> Modes (Set), including multiple MIME Types
("*", "* / *", "type / *"). */
+ protected final Map allTypeToPortletModes;
+
+ protected final Set allModes;
+
+ protected ContentTypesMetaData metadata;
+ protected boolean isStarted = false;
+
+ private static final String ALL = "*";
+ private static final String ALL_ALL = "*/*";
+ private static final char SLASH = '/';
+
+ // case-insensitive
+ // CONTENT TYPE = TYPE / SUBTYPE
+ // SUBTYPE = any char except a TSPECIALS or SPACE or CTLS (??)
+ // TSPECIALS ( ) < > @ , ; : \ " / [ ] ? . =
+
+ public ContentTypes()
+ {
+ singleTypeToPortletModes = new HashMap();
+ allTypeToPortletModes = new HashMap(); // Including *
+ allModes = new HashSet();
+ metadata = null;
+ }
+
+ public ContentTypesMetaData getMetadata()
+ {
+ return metadata;
+ }
+
+ public void setMetadata(ContentTypesMetaData metadata)
+ {
+ isStarted = false;
+ initFromMetadata(metadata);
+ this.metadata = metadata;
+ }
+
+ public void start() throws Exception
+ {
+ initFromMetadata(metadata);
+ }
+
+ /**
+ * Process all the supported content types.
+ *
+ * @param metadata
+ */
+ private void initFromMetadata(ContentTypesMetaData metadata)
+ {
+ if (!isStarted)
+ {
+ if (metadata == null)
+ {
+ throw new IllegalArgumentException("Must pass non-null
metadata.");
+ }
+
+ // Reset the collections
+ singleTypeToPortletModes.clear();
+ allTypeToPortletModes.clear();
+ allModes.clear();
+
+ // Build info from metadata
+ for (Iterator i = metadata.iterator(); i.hasNext();)
+ {
+ ContentTypeMetaData contentTypeMD = (ContentTypeMetaData)i.next();
+
+ // Get the content type
+ String contentType = contentTypeMD.getContentType().toLowerCase();
+
+ // Add the content type to the view mode
+ // because each content type must handle this view
+ add(contentType, Mode.VIEW);
+
+ // Then process each mode
+ Set modes = contentTypeMD.getModes();
+ for (Iterator j = modes.iterator(); j.hasNext();)
+ {
+ Mode mode = (Mode)j.next();
+ add(contentType, mode);
+ }
+ }
+ isStarted = true;
+ }
+ }
+
+ public void stop()
+ {
+
+ }
+
+ private void add(String contentType, Mode mode)
+ {
+ // Determines which map and key to store the mode under
+ String key;
+ if (ALL.equals(contentType) || ALL_ALL.equals(contentType))
+ {
+ key = ALL;
+ }
+ else
+ {
+ int index = contentType.indexOf(SLASH);
+ if (index == -1)
+ {
+ System.out.println("'" + contentType + "' is not a
valid MIME type: ignoring!");
+ return;
+ }
+
+ String type = contentType.substring(0, index);
+ String subtype = contentType.substring(index + 1);
+
+ if (ALL.equals(subtype))
+ {
+ key = type;
+ }
+ else
+ {
+ key = contentType;
+ // This is a single content type so we need to add it to the single mappings
in addition to all
+ addMode(singleTypeToPortletModes, key, mode);
+ }
+ }
+
+ // Store the mode in the complete mapping
+ addMode(allTypeToPortletModes, key, mode);
+
+ // Add the mode to the known modes
+ allModes.add(mode);
+ }
+
+ private void addMode(Map map, String key, Mode mode)
+ {
+ Set modes = (Set)map.get(key);
+ if (modes == null)
+ {
+ modes = new HashSet();
+ map.put(key, modes);
+ }
+ modes.add(mode);
+ }
+
+ /** Return all modes. */
+ public Collection getAllModes()
+ {
+ return Collections.unmodifiableCollection(allModes);
+ }
+
+ /** Return all content types. */
+ public Collection getAllContentTypes()
+ {
+ return Collections.unmodifiableCollection(allTypeToPortletModes.keySet());
+ }
+
+ /**
+ * Return true if the mode is supported
+ *
+ * @throws IllegalArgumentException if the mode is null
+ */
+ public boolean isModeSupported(Mode mode)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("Mode must not be null");
+ }
+ return allModes.contains(mode);
+ }
+
+ /**
+ * Return all the supported modes for this content type.
+ *
+ * @throws IllegalArgumentException if the content type is null
+ */
+ public Set getSupportedModes(String contentType)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException("Content type must not be null");
+ }
+
+ int index = contentType.indexOf(SLASH);
+ if (index == -1)
+ {
+ // Not valid content type so return empty set
+ return Collections.EMPTY_SET;
+ }
+
+ //
+ Set set = new HashSet();
+
+ //
+ Set contentTypeModes =
(Set)singleTypeToPortletModes.get(contentType.toLowerCase());
+ if (contentTypeModes != null)
+ {
+ set.addAll(contentTypeModes);
+ }
+
+ //
+ Set typeModes = (Set)allTypeToPortletModes.get(contentType.substring(0,
index).toLowerCase());
+ if (typeModes != null)
+ {
+ set.addAll(typeModes);
+ }
+
+ Set wildcardModes = (Set)allTypeToPortletModes.get(ALL);
+ if (wildcardModes != null)
+ {
+ set.addAll(wildcardModes);
+ }
+
+ return set;
+ }
+
+ /**
+ * Return true if the content type is supported.
+ *
+ * @throws IllegalArgumentException if the content type is null
+ */
+ public boolean isContentTypeSupported(String contentType)
+ {
+ Collection allContentTypes = getAllContentTypes();
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException("Content type must not be null");
+ }
+
+ int index = contentType.indexOf(SLASH);
+ if (index == -1)
+ {
+ // Not valid content type so return false
+ return false;
+ }
+
+ // Try the content type, * or */*
+ if (allContentTypes.contains(contentType) |
+ allContentTypes.contains(contentType.toLowerCase()) |
+ allContentTypes.contains(ALL) |
+ allContentTypes.contains(ALL_ALL))
+ {
+ return true;
+ }
+
+ // Try xxx/*
+ String wildcard = contentType.substring(0, index) + "/*";
+ return allContentTypes.contains(wildcard) |
allContentTypes.contains(wildcard.toLowerCase());
+ }
+
+ /**
+ * Return true if the given content type is supported for the given mode.
+ *
+ * @throws IllegalArgumentException if the content type or the mode is null
+ */
+ public boolean isSupported(Mode mode, String contentType)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("Mode must not be null");
+ }
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException("Content type must not be null");
+ }
+
+ int index = contentType.indexOf(SLASH);
+ if (index == -1)
+ {
+ // Not valid content type so return false
+ return false;
+ }
+
+ // Try full name matching
+ Set contentTypeModes = (Set)singleTypeToPortletModes.get(contentType);
+ if (contentTypeModes != null && contentTypeModes.contains(mode))
+ {
+ return true;
+ }
+
+ // Try full name lowercase matching
+ Set lowercaseContentTypeModes =
(Set)singleTypeToPortletModes.get(contentType.toLowerCase());
+ if (lowercaseContentTypeModes != null &&
lowercaseContentTypeModes.contains(mode))
+ {
+ return true;
+ }
+
+ // Try type matching
+ String type = contentType.substring(0, index);
+ Set typeMode = (Set)allTypeToPortletModes.get(type);
+ if (typeMode != null && typeMode.contains(mode))
+ {
+ return true;
+ }
+
+ // Try type matching
+ Set lowercaseTypeMode = (Set)allTypeToPortletModes.get(type.toLowerCase());
+ if (lowercaseTypeMode != null && lowercaseTypeMode.contains(mode))
+ {
+ return true;
+ }
+
+ // Try wildcard matching
+ Set wildcardMode = (Set)allTypeToPortletModes.get(ALL);
+ return wildcardMode != null && wildcardMode.contains(mode);
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/ContentTypes.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/InfoBundle.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/InfoBundle.java)
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/InfoBundle.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/InfoBundle.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.portlet.impl.jsr168.APIConstants;
+import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListResourceBundle;
+import java.util.Locale;
+
+/**
+ * A resource bundle that contains the inline information defined by the portlet
specification.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class InfoBundle extends ListResourceBundle
+{
+
+ private static final Logger log = Logger.getLogger(InfoBundle.class);
+
+ /** . */
+ private final Object[][] content;
+
+ public InfoBundle(LanguagesMetaData.InfoMetaData metaData)
+ {
+ log.debug("Creates the parent bundle");
+
+ //
+ List list = new ArrayList(3);
+
+ //
+ String title = metaData.getTitle();
+ if (title == null)
+ {
+ throw new IllegalArgumentException("Title must be provided");
+ }
+ list.add(new Object[]{APIConstants.JAVAX_PORTLET_TITLE, title});
+
+ //
+ if (metaData.getShortTitle() != null)
+ {
+ list.add(new Object[]{APIConstants.JAVAX_PORTLET_SHORT_TITLE,
metaData.getShortTitle()});
+ }
+
+ //
+ if (metaData.getKeywords() != null)
+ {
+ list.add(new Object[]{APIConstants.JAVAX_PORTLET_KEYWORDS,
metaData.getKeywords()});
+ }
+
+ //
+ content = (Object[][])list.toArray(new Object[list.size()][]);
+ }
+
+ protected Object[][] getContents()
+ {
+ return content;
+ }
+
+ /**
+ * This is the english locale.
+ *
+ * @return the english locale
+ */
+ public Locale getLocale()
+ {
+ return Locale.ENGLISH;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/InfoBundle.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java
(from rev 6689,
trunk/portlet/src/main/org/jboss/portal/portlet/container/info/PortletResourceBundleManager.java)
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java
(rev 0)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,194 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.EmptyResourceBundle;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.util.ParentChildResourceBundle;
+import org.jboss.portal.portlet.impl.jsr168.metadata.LanguagesMetaData;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * Manage resource bundles for a portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletResourceBundleManager
+{
+
+ private Logger log = Logger.getLogger(PortletResourceBundleManager.class);
+
+ /** */
+ private Map localeBundles;
+
+ /** */
+ private String baseName;
+
+ /** */
+ private ClassLoader classLoader;
+
+ /** */
+ private ResourceBundle infoBundle;
+
+ /** */
+ private Collection supportedLocales;
+
+ public PortletResourceBundleManager(ClassLoader classLoader, LanguagesMetaData
metaData)
+ {
+ if (classLoader == null)
+ {
+ throw new IllegalArgumentException("Need a non null classloader");
+ }
+ if (metaData == null)
+ {
+ throw new IllegalArgumentException("Need non null meta data");
+ }
+ this.classLoader = classLoader;
+ this.baseName = metaData.getResourceBundle();
+ this.localeBundles = new HashMap();
+ this.supportedLocales = metaData.getSupportedLocales();
+
+ // Get the resource bundle containing the portlet info
+ LanguagesMetaData.InfoMetaData infoMD = metaData.getInfo();
+ if (infoMD != null)
+ {
+ infoBundle = new InfoBundle(infoMD);
+ }
+ else
+ {
+ infoBundle = new EmptyResourceBundle();
+ }
+ }
+
+ /**
+ * Return a localized value constructed from the various resource bundles. The
supported locales of the manager are
+ * used in combination with the specified key. The default value is used if no value
is found for the
+ * <code>Locale.ENGLISH</code>.
+ *
+ * @param key the key to lookup in the bundles
+ * @param defaultValue
+ * @return the localized string
+ * @throws IllegalArgumentException if the key of the default value is null
+ */
+ public LocalizedString getLocalizedValue(String key, String defaultValue) throws
IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value accepted");
+ }
+ Map m = new HashMap();
+ for (Iterator j = supportedLocales.iterator(); j.hasNext();)
+ {
+ try
+ {
+ Locale locale = (Locale)j.next();
+ ResourceBundle bundle = getResourceBundle(locale);
+ String localizedDisplayName = bundle.getString(key);
+ m.put(locale, localizedDisplayName);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+ if (!m.containsKey(Locale.ENGLISH))
+ {
+ m.put(Locale.ENGLISH, defaultValue);
+ }
+ return new LocalizedString(m, Locale.ENGLISH);
+ }
+
+ /**
+ * Return a bundle for the given locale. If the complete locale (language + country +
variant) does not exist then it
+ * falls back to (language + country) or (language) or the default file.
+ * <p/>
+ * When the resource bundle object is found and was not in the global map, it put it
in that map with a copy on
+ * write.
+ *
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public ResourceBundle getResourceBundle(Locale locale) throws
IllegalArgumentException
+ {
+ // Arg check
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+
+ // Try to get the bundle if the map
+ ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+
+ //
+ log.debug("Want to load bundle " + baseName + " for locale " +
locale);
+
+ if (baseName == null)
+ {
+ bundle = infoBundle;
+ }
+ else
+ {
+ try
+ {
+ bundle = ResourceBundle.getBundle(baseName, locale, classLoader);
+ if (infoBundle != null)
+ {
+ bundle = new ParentChildResourceBundle(infoBundle, bundle);
+ }
+ log.debug("Created bundle " + baseName + " for locale " +
locale);
+ }
+ catch (MissingResourceException e)
+ {
+ log.warn("Bundle " + baseName + " for locale " + locale +
" not found");
+ bundle = infoBundle;
+ }
+ }
+
+ // Cache the bundle
+ if (bundle != null)
+ {
+ Map copy = new HashMap(localeBundles);
+ copy.put(locale, bundle);
+ localeBundles = copy;
+ }
+
+ //
+ return bundle;
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/PortletResourceBundleManager.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java (from
rev 6689, trunk/portlet/src/main/org/jboss/portal/portlet/container/info/Utils.java)
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java
(rev 0)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.portlet.impl.jsr168.info;
+
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedStringMetaData;
+import org.jboss.portal.portlet.impl.jsr168.metadata.LocalizedValueMetaData;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision$
+ */
+public class Utils
+{
+
+ private static final Locale DEFAULT_LOCALE = Locale.ENGLISH;
+
+ public static LocalizedString getLocalizedDescription(LocalizedStringMetaData
describable)
+ {
+ Map m = new HashMap();
+ for (int i = 0; i < describable.getValues().size(); i++)
+ {
+ LocalizedValueMetaData descriptionMD =
(LocalizedValueMetaData)describable.getValues().get(i);
+ Locale locale = descriptionMD.getLocale();
+ if (locale == null)
+ {
+ locale = DEFAULT_LOCALE;
+ }
+ m.put(locale, descriptionMD.getValue());
+ }
+ return new LocalizedString(m, DEFAULT_LOCALE);
+ }
+}
Property changes on:
trunk/portlet/src/main/org/jboss/portal/portlet/impl/jsr168/info/Utils.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/CacheInfoSupport.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/CacheInfoSupport.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/portlet/support/info/CacheInfoSupport.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -22,7 +22,7 @@
******************************************************************************/
package org.jboss.portal.portlet.support.info;
-import org.jboss.portal.portlet.container.info.ContainerCacheInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerCacheInfo;
import org.jboss.portal.portlet.info.CacheInfo;
/**
Modified:
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/test/portlet/info/PreferenceInfoTest.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -23,8 +23,8 @@
package org.jboss.portal.test.portlet.info;
import org.jboss.portal.portlet.container.PortletContainer;
-import org.jboss.portal.portlet.container.info.ContainerPreferencesInfo;
-import org.jboss.portal.portlet.container.info.ContainerPreferenceInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferencesInfo;
+import org.jboss.portal.portlet.impl.jsr168.info.ContainerPreferenceInfo;
import org.jboss.portal.portlet.info.PortletInfo;
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.common.test.driver.response.EndTestResponse;
Modified: trunk/portlet/src/main/org/jboss/portal/test/server/ContentTypesTestCase.java
===================================================================
---
trunk/portlet/src/main/org/jboss/portal/test/server/ContentTypesTestCase.java 2007-03-15
20:13:17 UTC (rev 6696)
+++
trunk/portlet/src/main/org/jboss/portal/test/server/ContentTypesTestCase.java 2007-03-15
20:53:20 UTC (rev 6697)
@@ -25,7 +25,7 @@
import junit.framework.TestCase;
import org.jboss.portal.Mode;
-import org.jboss.portal.portlet.container.info.ContentTypes;
+import org.jboss.portal.portlet.impl.jsr168.info.ContentTypes;
import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypeMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.ContentTypesMetaData;
Modified: trunk/portlet/src/resources/test-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/portlet/src/resources/test-sar/META-INF/jboss-service.xml 2007-03-15 20:13:17
UTC (rev 6696)
+++ trunk/portlet/src/resources/test-sar/META-INF/jboss-service.xml 2007-03-15 20:53:20
UTC (rev 6697)
@@ -76,7 +76,6 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<depends-list optional-attribute-name="InterceptorNames">
-
<depends-list-element>portal:service=Interceptor,type=Server,name=User</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Server,name=Locale</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Server,name=ContentType</depends-list-element>
</depends-list>