Author: julien(a)jboss.com
Date: 2007-03-23 12:29:59 -0400 (Fri, 23 Mar 2007)
New Revision: 6806
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentProviderRegistry.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/portlet/
trunk/core/src/main/org/jboss/portal/core/model/content/spi/portlet/ContentPortlet.java
trunk/core/src/main/org/jboss/portal/core/ui/
trunk/core/src/main/org/jboss/portal/core/ui/content/
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContent.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentRenderer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContentHandler.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/content/
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java
Modified:
trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java
trunk/build/ide/intellij/idea60/modules/identity/identity.iml
trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererRegistry.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml
trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml
trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml
trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java
trunk/testsuite/build.xml
Log:
improved content provider stuff : less registries
Modified: trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java
===================================================================
---
trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/api/src/main/org/jboss/portal/spi/runtime/NavigationalStateContext.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -57,7 +57,7 @@
*
* @param window the window from which the mode is returned
* @return the mode
- * @throws IllegalArgumentException
+ * @thrpows IllegalArgumentException
*/
Mode getMode(PortalNode window) throws IllegalArgumentException;
Modified: trunk/build/ide/intellij/idea60/modules/identity/identity.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/identity/identity.iml 2007-03-23 13:58:47 UTC
(rev 6805)
+++ trunk/build/ide/intellij/idea60/modules/identity/identity.iml 2007-03-23 16:29:59 UTC
(rev 6806)
@@ -130,6 +130,15 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/sun-servlet/lib/servlet-api.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java
===================================================================
--- trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -80,7 +80,7 @@
* @return true if the unregistration was made
* @throws IllegalArgumentException if the key is null
*/
- public synchronized boolean unregister(Object key) throws IllegalArgumentException
+ public synchronized Object unregister(Object key) throws IllegalArgumentException
{
if (key == null)
{
@@ -89,11 +89,11 @@
if (content.containsKey(key))
{
Map tmp = new HashMap(content);
- tmp.remove(key);
+ Object registration = tmp.remove(key);
content = tmp;
- return true;
+ return registration;
}
- return false;
+ return null;
}
/**
Modified:
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
===================================================================
---
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/common/src/main/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -120,7 +120,7 @@
public void testUnregisterNonRegistered()
{
- assertFalse(registry.unregister(key));
+ assertNull(registry.unregister(key));
}
public void testNormal()
@@ -131,7 +131,7 @@
assertEquals(Collections.singleton(key), registry.getKeys());
assertEquals(Collections.singletonList(registered1), new
ArrayList(registry.getRegistrations()));
assertEquals(registered1, registry.getRegistration(key));
- assertTrue(registry.unregister(key));
+ assertEquals(registered1, registry.unregister(key));
assertEquals(null, registry.getRegistration(key));
assertEquals(Collections.EMPTY_SET, registry.getKeys());
assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
@@ -150,7 +150,7 @@
registrations = new ArrayList(registry.getRegistrations());
assertEquals(Collections.singleton(key), keys);
assertEquals(Collections.singletonList(registered1), registrations);
- assertTrue(registry.unregister(key));
+ assertEquals(registered1, registry.unregister(key));
assertEquals(Collections.singleton(key), keys);
assertEquals(Collections.singletonList(registered1), registrations);
keys = registry.getKeys();
Modified:
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeployment.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -33,7 +33,8 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.server.deployment.PortalWebApp;
import org.jboss.portal.server.deployment.jboss.Deployment;
import org.w3c.dom.Document;
@@ -170,7 +171,7 @@
}
if (metaDataElt != null)
{
- metaData =
PortalObjectMetaData.buildMetaData(factory.contentHandlerRegistry, metaDataElt);
+ metaData =
PortalObjectMetaData.buildMetaData(factory.contentProviderRegistry, metaDataElt);
}
else
{
@@ -192,9 +193,10 @@
{
return factory.portalObjectContainer;
}
- public ContentHandler getHandler(ContentType contentType)
+ public ContentHandler getContentHandler(ContentType contentType)
{
- return factory.contentHandlerRegistry.getHandler(contentType);
+ ContentProvider contentProvider =
factory.contentProviderRegistry.getContentProvider(contentType);
+ return contentProvider != null ? contentProvider.getHandler() : null;
}
};
Modified:
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/deployment/jboss/ObjectDeploymentFactory.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -25,7 +25,7 @@
import org.jboss.deployment.DeploymentException;
import org.jboss.portal.common.transaction.TransactionManagerProvider;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.jboss.portal.server.deployment.PortalWebApp;
import org.jboss.portal.server.deployment.jboss.AbstractDeploymentFactory;
import org.jboss.portal.server.deployment.jboss.Deployment;
@@ -53,7 +53,7 @@
protected PortalObjectContainer portalObjectContainer;
/** . */
- protected ContentHandlerRegistry contentHandlerRegistry;
+ protected ContentProviderRegistry contentProviderRegistry;
/** . */
protected EntityResolver portalObjectEntityResolver;
@@ -98,13 +98,13 @@
this.portalObjectContainer = portalObjectContainer;
}
- public ContentHandlerRegistry getContentHandlerRegistry()
+ public ContentProviderRegistry getContentProviderRegistry()
{
- return contentHandlerRegistry;
+ return contentProviderRegistry;
}
- public void setContentHandlerRegistry(ContentHandlerRegistry contentHandlerRegistry)
+ public void setContentProviderRegistry(ContentProviderRegistry
contentProviderRegistry)
{
- this.contentHandlerRegistry = contentHandlerRegistry;
+ this.contentProviderRegistry = contentProviderRegistry;
}
}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/CustomizationManagerService.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -166,6 +166,8 @@
//
Content content = window.getContent();
+
+ //
String instanceId = ((PortletContent)content).getInstanceRef();
if (instanceId == null)
{
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/AbstractContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,95 +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.core.impl.model.content;
-
-import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentHandler;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
-import org.jboss.portal.core.model.content.spi.ContentState;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public abstract class AbstractContentHandler extends AbstractJBossService implements
ContentHandler
-{
-
- /** . */
- private ContentHandlerRegistry registry;
-
- /** . */
- private String contentType;
-
- /** . */
- private ContentType registeredContentType;
-
- public String getContentType()
- {
- return contentType;
- }
-
- public void setContentType(String contentType)
- {
- this.contentType = contentType;
- }
-
- public ContentHandlerRegistry getRegistry()
- {
- return registry;
- }
-
- public ContentType getRegisteredContentType()
- {
- return registeredContentType;
- }
-
- public void setRegistry(ContentHandlerRegistry registry)
- {
- this.registry = registry;
- }
-
- protected void startService() throws Exception
- {
- registeredContentType = ContentType.create(contentType);
-
- //
- registry.registerHandler(registeredContentType, this);
- }
-
- protected void stopService() throws Exception
- {
- if (registeredContentType != null)
- {
- registry.unregisterHandler(registeredContentType);
- }
- }
-
- public void contentCreated(String contextId, ContentState state)
- {
- }
-
- public void contentDestroyed(String contextId, ContentState state)
- {
- }
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,69 +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.core.impl.model.content;
-
-import org.jboss.portal.common.util.CopyOnWriteRegistry;
-import org.jboss.portal.core.model.content.ContentType;
-
-import java.util.Collection;
-
-/**
- * A simple registry to track the instance that provides content facilities.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentEditorRegistry
-{
-
- /** The singleton instance. */
- private static final ContentEditorRegistry instance = new ContentEditorRegistry();
-
- /** . */
- private final CopyOnWriteRegistry editors = new CopyOnWriteRegistry();
-
- public static ContentEditorRegistry getInstance()
- {
- return instance;
- }
-
- public void registerEditor(ContentType contentType, String instanceName)
- {
- editors.register(contentType, instanceName);
- }
-
- public void unregisterEditor(ContentType contentType)
- {
- editors.unregister(contentType);
- }
-
- public String getEditor(ContentType contentType)
- {
- return (String)editors.getRegistration(contentType);
- }
-
- public Collection getContentTypes()
- {
- return editors.getKeys();
- }
-}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentProviderRegistryService.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * 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.core.impl.model.content;
+
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.portal.content.ContentRenderer;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+
+import java.util.Collection;
+
+/**
+ * A simple registry to track the instance that provides content facilities.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentProviderRegistryService implements InternalContentProviderRegistry
+{
+
+ /** . */
+ private static volatile ContentProviderRegistryService instance;
+
+ public static ContentProviderRegistryService getInstance()
+ {
+ return instance;
+ }
+
+ /** . */
+ private final CopyOnWriteRegistry registry = new CopyOnWriteRegistry();
+
+ public void registerContentProvider(InternalContentProvider contentProvider)
+ {
+ registry.register(contentProvider.registeredContentType, contentProvider);
+ }
+
+ public void unregisterContentProvider(ContentType contentType)
+ {
+ registry.unregister(contentType);
+ }
+
+ public void start()
+ {
+ synchronized(ContentProviderRegistryService.class)
+ {
+ if (instance != null)
+ {
+ throw new IllegalStateException("An instance of the content type
registry service already exists");
+ }
+ instance = this;
+ }
+ }
+
+ public void stop()
+ {
+ synchronized(ContentProviderRegistryService.class)
+ {
+ instance = null;
+ }
+ }
+
+ //
+
+ public Collection getContentTypes()
+ {
+ return registry.getKeys();
+ }
+
+ public ContentProvider getContentProvider(ContentType contentType)
+ {
+ InternalContentProvider acp =
(InternalContentProvider)registry.getRegistration(contentType);
+ return acp != null ? acp.contentProvider : null;
+ }
+
+ public ContentRenderer getRenderer(ContentType contentType)
+ {
+ return (InternalContentProvider)registry.getRegistration(contentType);
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProvider.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,432 @@
+/******************************************************************************
+ * 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.core.impl.model.content;
+
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
+import org.jboss.portal.core.model.portal.command.response.PortletWindowResponse;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.Portal;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.content.ContentRenderer;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.ResourceNotFoundException;
+import org.jboss.portal.core.controller.ControllerException;
+import org.jboss.portal.core.controller.ResourceAccessDeniedException;
+import org.jboss.portal.core.controller.portlet.PortletInvocationFactory;
+import org.jboss.portal.server.config.ServerConfig;
+import org.jboss.portal.server.ServerInvocationContext;
+import org.jboss.portal.server.request.URLContext;
+import org.jboss.portal.server.request.URLFormat;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.Properties;
+import org.jboss.portal.portlet.info.WindowStateInfo;
+import org.jboss.portal.portlet.info.ModeInfo;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.portlet.invocation.response.ErrorResponse;
+import org.jboss.portal.portlet.invocation.response.UnavailableResponse;
+import org.jboss.portal.portlet.invocation.response.InsufficientPrivilegesResponse;
+import org.jboss.portal.theme.navigation.WindowNavigationalState;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.util.Exceptions;
+import org.jboss.logging.Logger;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class InternalContentProvider implements ContentRenderer
+{
+
+ /** . */
+ private final Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private InternalContentProviderRegistry registry;
+
+ /** . */
+ private String contentType;
+
+ /** . */
+ ContentType registeredContentType;
+
+ /** . */
+ ContentProvider contentProvider;
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ public void setContentType(String contentType)
+ {
+ this.contentType = contentType;
+ }
+
+ public ContentType getRegisteredContentType()
+ {
+ return registeredContentType;
+ }
+
+ public InternalContentProviderRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(InternalContentProviderRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public void start() throws Exception
+ {
+ registeredContentType = ContentType.create(contentType);
+
+ //
+ contentProvider = createProvider();
+
+ //
+ registry.registerContentProvider(this);
+ }
+
+ protected abstract ContentProvider createProvider();
+
+ public void stop()
+ {
+ if (registeredContentType != null)
+ {
+ registry.unregisterContentProvider(registeredContentType);
+ }
+ }
+
+ /**
+ * Returns the portlet instance to render view mode.
+ *
+ * @param command
+ * @return the portlet instance for the view mode
+ */
+ protected abstract Instance getViewModePortletInstance(RenderWindowCommand command);
+
+ public Object renderWindow(RenderWindowCommand cmd) throws Exception
+ {
+ Window window = cmd.getWindow();
+ Portal portal = cmd.getPortal();
+ ControllerContext context = cmd.getControllerContext();
+ ServerConfig cfg =
context.getServerInvocation().getRequest().getServer().getConfig();
+ PortalObjectId windowId = window.getId();
+ StateString navigationalState =
(StateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
windowId);
+ String navStateKey = windowId + "_window";
+ WindowNavigationalState windowNavState =
(WindowNavigationalState)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
navStateKey);
+
+ //
+ if (windowNavState == null)
+ {
+ windowNavState = new WindowNavigationalState();
+ context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, navStateKey,
windowNavState);
+ }
+
+ //
+ Mode mode = windowNavState.getMode();
+ WindowState windowState = windowNavState.getWindowState();
+
+ //
+ String windowTitle;
+ String contentChars;
+ String headerChars = null;
+ Map actionMap = new HashMap();
+ Map windowProps = window.getDeclaredProperties();
+
+ //
+ try
+ {
+ // Obtain instance
+ Instance instance = getViewModePortletInstance(cmd);
+
+ // No instance means we can't continue
+ if (instance == null)
+ {
+ String ref = null;
+ Content content = window.getContent();
+ if (content != null)
+ {
+ ref = content.getURI();
+ }
+ if (ref == null)
+ {
+ ref = window.getId().toString();
+ }
+ throw new ResourceNotFoundException(ref);
+ }
+
+ // Create invocation
+ RenderInvocation invocation = PortletInvocationFactory.createRender(
+ context,
+ mode,
+ windowState,
+ navigationalState,
+ window,
+ portal);
+
+ //
+ PortletInvocationResponse response;
+ try
+ {
+ response = invoke(instance, invocation);
+ }
+ catch (PortletInvokerException e)
+ {
+ log.error("Portlet invoker exception during portlet window
rendering", e);
+
+ //
+ if (e instanceof NoSuchPortletException)
+ {
+
+ throw new
ResourceNotFoundException(((NoSuchPortletException)e).getPortletId());
+ }
+ else
+ {
+ throw new ControllerException(e);
+ }
+ }
+
+ //
+ if (response instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)response;
+ windowTitle = fragment.getTitle();
+ if (windowTitle == null)
+ {
+ windowTitle = window.getName();
+ }
+ headerChars = fragment.getHeader();
+
+ //
+ List supportedWindowStates = new ArrayList();
+ for (Iterator i =
instance.getPortlet().getInfo().getCapabilities().getAllWindowStates().iterator();
i.hasNext();)
+ {
+ WindowStateInfo windowStateInfo = (WindowStateInfo)i.next();
+ WindowState tmp = windowStateInfo.getWindowState();
+ if (portal.getSupportedWindowStates().contains(tmp))
+ {
+ supportedWindowStates.add(tmp);
+ }
+ }
+
+ //
+ List supportedModes = new ArrayList();
+ for (Iterator i =
instance.getPortlet().getInfo().getCapabilities().getAllModes().iterator(); i.hasNext();)
+ {
+ ModeInfo modeInfo = (ModeInfo)i.next();
+ Mode tmp = modeInfo.getMode();
+ if (portal.getSupportedModes().contains(tmp))
+ {
+ supportedModes.add(tmp);
+ }
+ }
+
+ // Remove edit mode if the user is not logged it
+ if
(context.getServerInvocation().getServerContext().getClientRequest().getUserPrincipal() ==
null)
+ {
+ supportedModes.remove(Mode.EDIT);
+ }
+
+ //
+ addModeActions(context, window, actionMap, windowNavState.getMode(),
supportedModes);
+
+ //
+ addStateActions(context, window, actionMap, windowNavState.getWindowState(),
supportedWindowStates);
+
+ //
+ contentChars = fragment.getContent();
+
+ //
+ return new WindowResult(
+ windowTitle,
+ contentChars,
+ actionMap,
+ windowProps,
+ new Properties(),
+ headerChars,
+ windowNavState.getWindowState(),
+ windowNavState.getMode());
+ }
+ else if (response instanceof ErrorResponse)
+ {
+ ErrorResponse errorResult = (ErrorResponse)response;
+ String logMessage = "Rendering portlet window " + windowId + "
triggered the following error :";
+ errorResult.logErrorTo(log, logMessage);
+ String property = cfg.getProperty(RenderWindowCommand.WINDOW_ERROR);
+ if (!RenderWindowCommand.HIDE.equals(property))
+ {
+ windowTitle = "An error occured while rendering window '" +
windowId + "'";
+ contentChars = errorResult.getMessage();
+ Throwable t = errorResult.getThrowable();
+ if (t != null && RenderWindowCommand.SHOW.equals(property))
+ {
+ contentChars = Exceptions.toHTML(t, true);
+ }
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ }
+ }
+ else if (response instanceof UnavailableResponse)
+ {
+ if
(RenderWindowCommand.SHOW.equals(cfg.getProperty(RenderWindowCommand.WINDOW_UNAVAILABLE)))
+ {
+ windowTitle = "Portlet unavailable";
+ contentChars = "Portlet unavailable";
+ actionMap = new HashMap();
+ actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ }
+ }
+ else if (response instanceof InsufficientPrivilegesResponse)
+ {
+ // Julien : go to the section below, I know it is very ugly
+ throw new ResourceAccessDeniedException(windowId.toString());
+ }
+ else
+ {
+ return new PortletWindowResponse(windowId, response);
+ }
+ }
+ catch (ResourceAccessDeniedException e)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Window access denied", e);
+ }
+ if
(RenderWindowCommand.SHOW.equals(cfg.getProperty(RenderWindowCommand.WINDOW_ACCESS_DENIED)))
+ {
+ actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ windowTitle = "Access denied";
+ contentChars = "Access denied";
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ }
+ }
+ catch (ResourceNotFoundException e)
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Window not found", e);
+ }
+ if
(RenderWindowCommand.SHOW.equals(cfg.getProperty(RenderWindowCommand.WINDOW_NOT_FOUND)))
+ {
+ actionMap.put(WindowResult.MODES_KEY, Collections.EMPTY_LIST);
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, Collections.EMPTY_LIST);
+ windowTitle = "Cannot render";
+ contentChars = "Object not found " + e.getRef();
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ }
+ }
+ catch (ControllerException e)
+ {
+ // It's a CommandException that we rethrow
+ throw e;
+ }
+ catch (Exception e)
+ {
+ log.error("Rendering portlet window " + windowId + " produced an
internal error", e);
+ String property = cfg.getProperty(RenderWindowCommand.WINDOW_INTERNAL_ERROR);
+ if (RenderWindowCommand.SHOW.equals(property))
+ {
+ windowTitle = "An internal error occured while rendering window
'" + window + "'";
+ contentChars = Exceptions.toHTML(e, true);
+ return new WindowResult(windowTitle, contentChars, actionMap, windowProps,
new Properties(), headerChars, windowNavState.getWindowState(),
windowNavState.getMode());
+ }
+ }
+
+ //
+ return null;
+ }
+
+ protected PortletInvocationResponse invoke(Instance instance, PortletInvocation
invocation) throws PortletInvokerException
+ {
+ return instance.invoke(invocation);
+ }
+
+ /**
+ * Create the action URLs for the allowed window states of the rendered portlet window
and add them to the provided
+ * actionMap.
+ */
+ private void addStateActions(ControllerContext context, Window window, Map actionMap,
WindowState currentWindowState, List supportedWindowStates)
+ {
+ List windowStates = new ArrayList(supportedWindowStates.size());
+ for (Iterator j = supportedWindowStates.iterator(); j.hasNext();)
+ {
+ WindowState windowState = (WindowState)j.next();
+ String url = createUpdateNavigationalStateURL(context, window, null,
windowState);
+ boolean disabled = windowState.equals(currentWindowState);
+ WindowResult.Action action = new WindowResult.Action(windowState, url,
!disabled);
+ windowStates.add(action);
+ }
+ actionMap.put(WindowResult.WINDOWSTATES_KEY, windowStates);
+ }
+
+ /**
+ * Create the action URLs for the allowed portlet modes of the rendered portlet window
and add them to the provided
+ * actionMap.
+ */
+ private void addModeActions(ControllerContext context, Window window, Map actionMap,
Mode currentMode, List supportedModes)
+ {
+ List modes = new ArrayList(supportedModes.size());
+ for (Iterator j = supportedModes.iterator(); j.hasNext();)
+ {
+ Mode mode = (Mode)j.next();
+ String url = createUpdateNavigationalStateURL(context, window, mode, null);
+ boolean disabled = mode.equals(currentMode);
+ WindowResult.Action action = new WindowResult.Action(mode, url, !disabled);
+ modes.add(action);
+ }
+ actionMap.put(WindowResult.MODES_KEY, modes);
+ }
+
+ private String createUpdateNavigationalStateURL(ControllerContext context, Window
window, Mode mode, WindowState windowState)
+ {
+ InvokePortletWindowRenderCommand cmd = new
InvokePortletWindowRenderCommand(window.getId(), mode, windowState);
+ ServerInvocationContext serverContext =
context.getServerInvocation().getServerContext();
+ boolean secure = serverContext.getURLContext().isSecure();
+ boolean authenticated = serverContext.getURLContext().isAuthenticated();
+ URLContext urlContext = URLContext.newInstance(secure, authenticated);
+ return context.renderURL(cmd, urlContext, URLFormat.newInstance(true, true));
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/InternalContentProviderRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -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.core.impl.model.content;
+
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
+import org.jboss.portal.core.model.portal.content.ContentRendererRegistry;
+
+/**
+ * A simple registry to track the instance that provides content facilities.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface InternalContentProviderRegistry extends ContentProviderRegistry,
ContentRendererRegistry
+{
+
+ /**
+ *
+ */
+ void registerContentProvider(InternalContentProvider registration);
+
+ /**
+ *
+ */
+ void unregisterContentProvider(ContentType contentType);
+}
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,40 +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.core.impl.model.content.generic;
-
-import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
-import org.jboss.portal.core.model.content.spi.ContentHandler;
-import org.jboss.portal.core.model.content.spi.ContentState;
-import org.jboss.portal.core.model.content.Content;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class GenericContentHandler extends AbstractContentHandler implements
ContentHandler
-{
- public Content newContent(String contextId, ContentState state)
- {
- return new GenericContent(state);
- }
-}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentProviderRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentProviderRegistry.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/GenericContentProviderRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * 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.core.impl.model.content.generic;
+
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.CustomizationManager;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.impl.model.content.InternalContentProviderRegistry;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class GenericContentProviderRegistry
+{
+
+ /** . */
+ private static GenericContentProviderRegistry instance;
+
+ public static GenericContentProviderRegistry getInstance()
+ {
+ return instance;
+ }
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ /** . */
+ private CustomizationManager customizationManager;
+
+ /** . */
+ private InternalContentProviderRegistry registry;
+
+ /** . */
+ private CopyOnWriteRegistry registrations = new CopyOnWriteRegistry();
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public CustomizationManager getCustomizationManager()
+ {
+ return customizationManager;
+ }
+
+ public void setCustomizationManager(CustomizationManager customizationManager)
+ {
+ this.customizationManager = customizationManager;
+ }
+
+ public InternalContentProviderRegistry getRegistry()
+ {
+ return registry;
+ }
+
+ public void setRegistry(InternalContentProviderRegistry registry)
+ {
+ this.registry = registry;
+ }
+
+ public void register(
+ ContentType contentType,
+ ContentPortlet contentPortlet)
+ {
+ InternalGenericContentProvider provider = new InternalGenericContentProvider();
+ provider.setContentType(contentType.toString());
+ provider.setInstanceContainer(instanceContainer);
+ provider.setDecorateContent(true);
+ provider.setContentPortletInfo(contentPortlet);
+ provider.setRegistry(registry);
+
+ // Keep track
+ registrations.register(contentType, provider);
+
+ //
+ try
+ {
+ provider.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void unregister(ContentType contentType)
+ {
+ InternalGenericContentProvider provider =
(InternalGenericContentProvider)registrations.unregister(contentType);
+ if (provider != null)
+ {
+ provider.stop();
+ }
+ }
+
+ public void start() throws Exception
+ {
+ synchronized(GenericContentProviderRegistry.class)
+ {
+ if (instance != null)
+ {
+ throw new IllegalStateException("Already an existing instance of the
generic content provider registry");
+ }
+ instance = this;
+ }
+ }
+
+ public void stop() throws Exception
+ {
+ synchronized(GenericContentProviderRegistry.class)
+ {
+ instance = null;
+ }
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/generic/InternalGenericContentProvider.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,210 @@
+/******************************************************************************
+ * 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.core.impl.model.content.generic;
+
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.impl.model.content.InternalContentProvider;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.util.LocalizedString;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class InternalGenericContentProvider extends InternalContentProvider implements
ContentHandler
+{
+
+ /** . */
+ protected InstanceContainer instanceContainer;
+
+ /** . */
+ protected boolean decorateContent;
+
+ /** . */
+ protected ContentPortlet contentPortlet;
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public ContentPortlet getContentPortletInfo()
+ {
+ return contentPortlet;
+ }
+
+ public void setContentPortletInfo(ContentPortlet contentPortlet)
+ {
+ this.contentPortlet = contentPortlet;
+ }
+
+ public boolean getDecorateContent()
+ {
+ return decorateContent;
+ }
+
+ public void setDecorateContent(boolean decorateContent)
+ {
+ this.decorateContent = decorateContent;
+ }
+
+ protected ContentProvider createProvider()
+ {
+ return new ContentProvider()
+ {
+ public ContentType getContentType()
+ {
+ return getRegisteredContentType();
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return null;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return null;
+ }
+
+ public ContentHandler getHandler()
+ {
+ return InternalGenericContentProvider.this;
+ }
+
+ public ContentPortlet getPortletInfo()
+ {
+ return contentPortlet;
+ }
+ };
+ }
+
+ public Content newContent(String contextId, ContentState state)
+ {
+ return new GenericContent(state);
+ }
+
+ protected Instance getViewModePortletInstance(RenderWindowCommand command)
+ {
+ String id = contentPortlet.getPortletName(Mode.VIEW);
+
+ //
+ if (id != null)
+ {
+ ControllerContext context = command.getControllerContext();
+ InstanceContainer container = context.getController().getInstanceContainer();
+ return container.getDefinition(id);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void contentCreated(String contextId, ContentState state)
+ {
+ }
+
+ public void contentDestroyed(String contextId, ContentState state)
+ {
+ }
+
+ public Object renderWindow(RenderWindowCommand cmd) throws Exception
+ {
+ ControllerContext context = cmd.getControllerContext();
+ Window window = cmd.getWindow();
+ PortalObjectId windowId = window.getId();
+
+ // No content
+ Content content = window.getContent();
+ if (content == null)
+ {
+ return null;
+ }
+
+ // Initialize the navigational state with the URI when needed
+ PortletParametersStateString navigationalState =
(PortletParametersStateString)context.getAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE,
windowId);
+ if (navigationalState == null)
+ {
+ navigationalState = new PortletParametersStateString();
+
+ //
+ for (Iterator i = content.getParameterNames();i.hasNext();)
+ {
+ String paramName = (String)i.next();
+ String paramValue = content.getParameter(paramName);
+ navigationalState.setValue(paramName, paramValue);
+ }
+
+ //
+ String uri = content.getURI();
+ navigationalState.setValue("uri", uri);
+
+ //
+ context.setAttribute(RenderWindowCommand.NAVIGATIONAL_STATE_SCOPE, windowId,
navigationalState);
+ }
+
+ //
+ Object o = super.renderWindow(cmd);
+
+ //
+ if (o instanceof WindowResult && getDecorateContent() == false)
+ {
+ WindowResult result = (WindowResult)o;
+
+ //
+ Map props = new HashMap(result.getWindowProperties());
+ props.put("theme.windowRendererId", "emptyRenderer");
+ props.put("theme.decorationRendererId", "emptyRenderer");
+ props.put("theme.portletRendererId", "emptyRenderer");
+
+ //
+ result.setWindowProperties(props);
+ }
+
+ //
+ return o;
+ }
+}
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/InternalPortletContentProvider.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,163 @@
+/******************************************************************************
+ * 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.core.impl.model.content.portlet;
+
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.ContentProvider;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.ContentState;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.Window;
+import org.jboss.portal.core.model.CustomizationManager;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.impl.model.content.InternalContentProvider;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.Mode;
+import org.jboss.portal.common.util.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class InternalPortletContentProvider extends InternalContentProvider implements
ContentHandler
+{
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ /** . */
+ private CustomizationManager customizationManager;
+
+ public InstanceContainer getInstanceContainer()
+ {
+ return instanceContainer;
+ }
+
+ public void setInstanceContainer(InstanceContainer instanceContainer)
+ {
+ this.instanceContainer = instanceContainer;
+ }
+
+ public CustomizationManager getCustomizationManager()
+ {
+ return customizationManager;
+ }
+
+ public void setCustomizationManager(CustomizationManager customizationManager)
+ {
+ this.customizationManager = customizationManager;
+ }
+
+ protected ContentProvider createProvider()
+ {
+ return new ContentProvider()
+ {
+ public ContentType getContentType()
+ {
+ return getRegisteredContentType();
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return null;
+ }
+
+ public LocalizedString getDescription()
+ {
+ return null;
+ }
+
+ public ContentHandler getHandler()
+ {
+ return InternalPortletContentProvider.this;
+ }
+
+ public ContentPortlet getPortletInfo()
+ {
+ return new ContentPortlet()
+ {
+ public String getPortletName(Mode mode)
+ {
+ if (EDIT_CONTENT_MODE.equals(mode))
+ {
+ return "PortletContentEditorInstance";
+ }
+ else
+ {
+ return null;
+ }
+ }
+ };
+ }
+ };
+ }
+
+ // ContentHandler implementation
************************************************************************************
+
+ public Content newContent(String contextId, ContentState state)
+ {
+ return new PortletContent(this, contextId, state);
+ }
+
+ public void contentDestroyed(String contextId, ContentState state)
+ {
+ String instanceRef = state.getURI();
+
+ // Do we have a related instance ?
+ if (instanceRef != null)
+ {
+ Instance instance = instanceContainer.getDefinition(instanceRef);
+
+ // Destroy related instance customization if possible
+ if (instance != null)
+ {
+ instance.destroyCustomization(contextId);
+ }
+ }
+ }
+
+ public void contentCreated(String contextId, ContentState state)
+ {
+ }
+
+ // ContentRenderer implementation
***********************************************************************************
+
+ protected Instance getViewModePortletInstance(RenderWindowCommand command)
+ {
+ ControllerContext context = command.getControllerContext();
+
+ // The window
+ Window window = command.getWindow();
+
+ // We need the user id
+ User user = context.getUser();
+
+ // Get instance
+ return customizationManager.getInstance(window, user);
+ }
+
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContent.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -39,13 +39,13 @@
private final String contextId;
/** . */
- private final PortletContentHandler handler;
+ private final InternalPortletContentProvider provider;
- public PortletContent(PortletContentHandler handler, String contextId, ContentState
state)
+ public PortletContent(InternalPortletContentProvider handler, String contextId,
ContentState state)
{
super(state);
this.contextId = contextId;
- this.handler = handler;
+ this.provider = handler;
}
public LocalizedString getDisplayName()
@@ -60,7 +60,7 @@
//
if (currentInstanceRef != null && currentInstanceRef.equals(uri) == false)
{
- handler.contentDestroyed(contextId, state);
+ provider.contentDestroyed(contextId, state);
}
//
Deleted:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContentHandler.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/portlet/PortletContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,73 +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.core.impl.model.content.portlet;
-
-import org.jboss.portal.core.model.content.spi.ContentHandler;
-import org.jboss.portal.core.model.content.spi.ContentState;
-import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
-import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.Instance;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletContentHandler extends AbstractContentHandler implements
ContentHandler
-{
-
- /** . */
- private InstanceContainer instanceContainer;
-
- public InstanceContainer getInstanceContainer()
- {
- return instanceContainer;
- }
-
- public void setInstanceContainer(InstanceContainer instanceContainer)
- {
- this.instanceContainer = instanceContainer;
- }
-
- public Content newContent(String contextId, ContentState state)
- {
- return new PortletContent(this, contextId, state);
- }
-
- public void contentDestroyed(String contextId, ContentState state)
- {
- String instanceRef = state.getURI();
-
- // Do we have a related instance ?
- if (instanceRef != null)
- {
- Instance instance = instanceContainer.getDefinition(instanceRef);
-
- // Destroy related instance customization if possible
- if (instance != null)
- {
- instance.destroyCustomization(contextId);
- }
- }
- }
-}
Modified:
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPortalObjectContainer.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -27,9 +27,9 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
-import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.jems.as.system.AbstractJBossService;
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.security.PortalPermissionCollection;
@@ -40,7 +40,6 @@
import org.jboss.portal.security.spi.provider.PermissionFactory;
import org.jboss.portal.security.spi.provider.PermissionRepository;
import org.jboss.portal.security.spi.provider.SecurityConfigurationException;
-import org.jboss.portal.common.util.CopyOnWriteRegistry;
import java.util.Collection;
import java.util.HashSet;
@@ -51,7 +50,7 @@
* @version $Revision$
*/
public abstract class AbstractPortalObjectContainer extends AbstractJBossService
- implements PortalObjectContainer, PermissionFactory, AuthorizationDomain,
DomainConfigurator, PermissionRepository, ContentHandlerRegistry
+ implements PortalObjectContainer, PermissionFactory, AuthorizationDomain,
DomainConfigurator, PermissionRepository
{
/** . */
@@ -61,11 +60,10 @@
private InstanceContainer instanceContainer;
/** . */
- private CopyOnWriteRegistry contentHandlerRegistrations;
+ private ContentProviderRegistry contentProviderRegistry;
protected AbstractPortalObjectContainer()
{
- contentHandlerRegistrations = new CopyOnWriteRegistry();
}
public InstanceContainer getInstanceContainer()
@@ -78,26 +76,16 @@
this.instanceContainer = instanceContainer;
}
- public void registerHandler(ContentType contentType, ContentHandler handler) throws
IllegalArgumentException
+ public ContentProviderRegistry getContentProviderRegistry()
{
- contentHandlerRegistrations.register(contentType, handler);
+ return contentProviderRegistry;
}
- public ContentHandler getHandler(ContentType contentType)
+ public void setContentProviderRegistry(ContentProviderRegistry
contentProviderRegistry)
{
- return (ContentHandler)contentHandlerRegistrations.getRegistration(contentType);
+ this.contentProviderRegistry = contentProviderRegistry;
}
- public void unregisterHandler(ContentType contentType)
- {
- contentHandlerRegistrations.unregister(contentType);
- }
-
- public Collection getContentTypes()
- {
- return contentHandlerRegistrations.getKeys();
- }
-
public PortalObject getRootObject()
{
return getObject(rootId);
@@ -248,7 +236,7 @@
*/
public ContentHandler getContentHandler(ContentType contentType)
{
- return
(ContentHandler)contentHandlerRegistrations.getRegistration(contentType);
+ return contentProviderRegistry.getContentProvider(contentType).getHandler();
}
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/WindowImpl.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -27,14 +27,11 @@
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.spi.ContentState;
-import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
import org.jboss.portal.jems.hibernate.ContextObject;
import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
import java.util.Iterator;
-import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -215,12 +212,6 @@
ContentHandler handler = context.getContentHandler(contentType);
//
- if (handler == null)
- {
- handler = context.getContentHandler(ContentType.GENERIC);
- }
-
- //
return handler;
}
Added: trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProvider.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.core.model.content;
+
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.common.util.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentProvider
+{
+
+ /**
+ * Return the content type value.
+ *
+ * @return the content type
+ */
+ ContentType getContentType();
+
+ /**
+ * Returns the display name.
+ *
+ * @return the display name
+ */
+ LocalizedString getDisplayName();
+
+ /**
+ * Returns the description.
+ *
+ * @return the description
+ */
+ LocalizedString getDescription();
+
+ /**
+ * Returns the handler.
+ *
+ * @return the handler
+ */
+ ContentHandler getHandler();
+
+ /**
+ * Returns the portlet info
+ *
+ * @return the portlet info
+ */
+ ContentPortlet getPortletInfo();
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/ContentProviderRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * 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.core.model.content;
+
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentProviderRegistry
+{
+ /**
+ *
+ */
+ Collection getContentTypes();
+
+ /**
+ *
+ */
+ ContentProvider getContentProvider(ContentType contentType);
+}
Modified: trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core/src/main/org/jboss/portal/core/model/content/ContentType.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -43,9 +43,6 @@
public static final ContentType PORTLET = new ContentType("portlet");
/** . */
- public static final ContentType GENERIC = new ContentType("generic");
-
- /** . */
private final String value;
private ContentType(String value)
@@ -94,10 +91,6 @@
{
return PORTLET;
}
- else if ("generic".equals(value))
- {
- return GENERIC;
- }
else if ("cms".equals(value))
{
return CMS;
Deleted: trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,63 +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.core.model.content.spi;
-
-import org.jboss.portal.core.model.content.Content;
-
-/**
- * The content handler act as a factory for <code>Content</code> objects from
their state. The interface
- * receives also callbacks of the content lifecycle in order to be able to manage
additional resources
- * related to the content.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentHandler
-{
- /**
- * Factory method that creates an instance of content object. This method is called
- * whenever the frameworks needs a runtime representation of the content state which
- * can be used at runtime by content clients.
- *
- * @param contextId the context id in which the state is used
- * @param state the state
- * @return the content interface implementation
- */
- Content newContent(String contextId, ContentState state);
-
- /**
- * Life cycle method to signal state creation.
- *
- * @param contextId the context id in which the state is created
- * @param state the state
- */
- void contentCreated(String contextId, ContentState state);
-
- /**
- * Life cycle method to signal state destruction.
- *
- * @param contextId the context id in which the state is destroyed
- * @param state the state
- */
- void contentDestroyed(String contextId, ContentState state);
-}
Deleted:
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandlerRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,70 +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.core.model.content.spi;
-
-import org.jboss.portal.core.model.content.ContentType;
-
-import java.util.Collection;
-
-/**
- * A registry for content handlers.
- *
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public interface ContentHandlerRegistry
-{
-
- /**
- * Return the set of known content types by the registry.
- *
- * @return the set of content types
- */
- Collection getContentTypes();
-
- /**
- * Register an handler
- *
- * @param contentType the content type the handler will handle
- * @param handler the handler
- * @throws IllegalArgumentException if the content type or the handler is null
- */
- void registerHandler(ContentType contentType, ContentHandler handler) throws
IllegalArgumentException;
-
- /**
- * Return an handler for the specified content type or null if it is not found
- *
- * @param contentType the content type
- * @return the handler
- * @throws IllegalArgumentException if the content type is null
- */
- ContentHandler getHandler(ContentType contentType) throws IllegalArgumentException;
-
- /**
- * Unregister the handler for the specified content type.
- *
- * @param contentType the content type of the handler to unregister.
- * @throws IllegalArgumentException if the content type is null
- */
- void unregisterHandler(ContentType contentType) throws IllegalArgumentException;
-}
Copied:
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java
(from rev 6798,
trunk/core/src/main/org/jboss/portal/core/model/content/spi/ContentHandler.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/handler/ContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * 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.core.model.content.spi.handler;
+
+import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.ContentState;
+
+/**
+ * The content handler act as a factory for <code>Content</code> objects from
their state. The interface
+ * receives also callbacks of the content lifecycle in order to be able to manage
additional resources
+ * related to the content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentHandler
+{
+ /**
+ * Factory method that creates an instance of content object. This method is called
+ * whenever the frameworks needs a runtime representation of the content state which
+ * can be used at runtime by content clients.
+ *
+ * @param contextId the context id in which the state is used
+ * @param state the state
+ * @return the content interface implementation
+ */
+ Content newContent(String contextId, ContentState state);
+
+ /**
+ * Life cycle method to signal state creation.
+ *
+ * @param contextId the context id in which the state is created
+ * @param state the state
+ */
+ void contentCreated(String contextId, ContentState state);
+
+ /**
+ * Life cycle method to signal state destruction.
+ *
+ * @param contextId the context id in which the state is destroyed
+ * @param state the state
+ */
+ void contentDestroyed(String contextId, ContentState state);
+}
Added:
trunk/core/src/main/org/jboss/portal/core/model/content/spi/portlet/ContentPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/content/spi/portlet/ContentPortlet.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/model/content/spi/portlet/ContentPortlet.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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.core.model.content.spi.portlet;
+
+import org.jboss.portal.Mode;
+
+/**
+ * Content portlet meta data.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ContentPortlet
+{
+
+ /**
+ * The edit content mode.
+ */
+ Mode EDIT_CONTENT_MODE = Mode.create("edit_content");
+
+ /**
+ * Return the portlet name to use for handling the specified mode.
+ *
+ * @param mode the mode
+ * @return the portlet name
+ */
+ String getPortletName(Mode mode);
+
+}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/command/RenderWindowCommand.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -78,12 +78,6 @@
ContentType contentType = window.getContentType();
ContentRenderer renderer = registry.getRenderer(contentType);
- // Try generic renderer
- if (renderer == null)
- {
- renderer = registry.getRenderer(ContentType.GENERIC);
- }
-
//
if (renderer == null)
{
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRenderer.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -22,9 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.model.portal.content;
-import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
-import org.jboss.portal.core.controller.ControllerContext;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererRegistry.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererRegistry.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/content/ContentRendererRegistry.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -42,19 +42,6 @@
/**
*
* @param contentType
- * @param renderer
- */
- void registerRenderer(ContentType contentType, ContentRenderer renderer);
-
- /**
- *
- * @param contentType
- */
- void unregisterRenderer(ContentType contentType);
-
- /**
- *
- * @param contentType
* @return
*/
ContentRenderer getRenderer(ContentType contentType);
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/BuildContext.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -24,7 +24,7 @@
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentHandler;
+import org.jboss.portal.core.model.content.spi.handler.ContentHandler;
/**
* Defines the callbacks for creating a portal object.
@@ -36,5 +36,5 @@
{
PortalObjectContainer getContainer();
- ContentHandler getHandler(ContentType contentType);
+ ContentHandler getContentHandler(ContentType contentType);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/ContextMetaData.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -24,9 +24,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalContainer;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
-import org.jboss.portal.core.model.portal.metadata.PortalObjectMetaData;
-import org.jboss.portal.core.model.portal.metadata.PortalMetaData;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.jboss.portal.common.util.XML;
import org.w3c.dom.Element;
@@ -51,7 +49,7 @@
}
/** Parse the following XML elements : context-name. */
- public static ContextMetaData buildContextMetaData(ContentHandlerRegistry
contentHandlerRegistry, Element contextElt) throws Exception
+ public static ContextMetaData buildContextMetaData(ContentProviderRegistry
contentProviderRegistry, Element contextElt) throws Exception
{
ContextMetaData contextMD = new ContextMetaData();
@@ -72,7 +70,7 @@
for (int i = 0; i < pageElts.size(); i++)
{
Element portalElt = (Element)pageElts.get(i);
- PortalMetaData pageMD =
(PortalMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, portalElt);
+ PortalMetaData pageMD =
(PortalMetaData)PortalObjectMetaData.buildMetaData(contentProviderRegistry, portalElt);
contextMD.getChildren().put(pageMD.getName(), pageMD);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PageMetaData.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -25,7 +25,7 @@
import org.jboss.portal.common.util.XML;
import org.jboss.portal.core.model.portal.PageContainer;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.w3c.dom.Element;
import java.util.List;
@@ -52,7 +52,7 @@
return ((PageContainer)parent).createPage(getName());
}
- public static PageMetaData buildPageMetaData(ContentHandlerRegistry
contentHandlerRegistry, Element pageElt)
+ public static PageMetaData buildPageMetaData(ContentProviderRegistry
contentProviderRegistry, Element pageElt)
{
PageMetaData pageMD = new PageMetaData();
@@ -67,7 +67,7 @@
Element windowElt = (Element)windowElts.get(j);
try
{
- WindowMetaData windowMD =
(WindowMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, windowElt);
+ WindowMetaData windowMD =
(WindowMetaData)PortalObjectMetaData.buildMetaData(contentProviderRegistry, windowElt);
pageMD.getChildren().put(windowMD.getName(), windowMD);
}
catch (Exception e)
@@ -83,7 +83,7 @@
Element childPageElt = (Element)pageElts.get(j);
try
{
- PageMetaData childPageMD =
(PageMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, childPageElt);
+ PageMetaData childPageMD =
(PageMetaData)PortalObjectMetaData.buildMetaData(contentProviderRegistry, childPageElt);
pageMD.getChildren().put(childPageMD.getName(), childPageMD);
}
catch (Exception e)
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalMetaData.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -28,7 +28,7 @@
import org.jboss.portal.core.model.portal.PortalContainer;
import org.jboss.portal.core.model.portal.Portal;
import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.jboss.portal.portlet.impl.jsr168.metadata.ModesMetaData;
import org.jboss.portal.portlet.impl.jsr168.metadata.WindowStatesMetaData;
import org.w3c.dom.Element;
@@ -110,7 +110,7 @@
}
/** Parse the following XML elements : portal-name, supported-modes,
supported-window-states. */
- public static PortalMetaData buildPortalMetaData(ContentHandlerRegistry
contentHandlerRegistry, Element portalElt) throws Exception
+ public static PortalMetaData buildPortalMetaData(ContentProviderRegistry
contentProviderRegistry, Element portalElt) throws Exception
{
PortalMetaData portalMD = new PortalMetaData();
@@ -145,7 +145,7 @@
for (int i = 0; i < pageElts.size(); i++)
{
Element pageElt = (Element)pageElts.get(i);
- PageMetaData pageMD =
(PageMetaData)PortalObjectMetaData.buildMetaData(contentHandlerRegistry, pageElt);
+ PageMetaData pageMD =
(PageMetaData)PortalObjectMetaData.buildMetaData(contentProviderRegistry, pageElt);
portalMD.getChildren().put(pageMD.getName(), pageMD);
}
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/PortalObjectMetaData.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -25,7 +25,7 @@
import org.jboss.logging.Logger;
import org.jboss.portal.common.util.Tools;
import org.jboss.portal.common.util.XML;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectContainer;
import org.jboss.portal.core.model.portal.PortalObjectId;
@@ -196,25 +196,25 @@
}
}
- public static PortalObjectMetaData buildMetaData(ContentHandlerRegistry
contentHandlerRegistry, Element portalObjectElt) throws Exception
+ public static PortalObjectMetaData buildMetaData(ContentProviderRegistry
contentProviderRegistry, Element portalObjectElt) throws Exception
{
String type = portalObjectElt.getTagName();
PortalObjectMetaData portalObjectMD = null;
if ("portal".equals(type))
{
- portalObjectMD = PortalMetaData.buildPortalMetaData(contentHandlerRegistry,
portalObjectElt);
+ portalObjectMD = PortalMetaData.buildPortalMetaData(contentProviderRegistry,
portalObjectElt);
}
else if ("page".equals(type))
{
- portalObjectMD = PageMetaData.buildPageMetaData(contentHandlerRegistry,
portalObjectElt);
+ portalObjectMD = PageMetaData.buildPageMetaData(contentProviderRegistry,
portalObjectElt);
}
else if ("window".equals(type))
{
- portalObjectMD =
WindowMetaData.buildPortletWindowMetaData(contentHandlerRegistry, portalObjectElt);
+ portalObjectMD =
WindowMetaData.buildPortletWindowMetaData(contentProviderRegistry, portalObjectElt);
}
else if ("context".equals(type))
{
- portalObjectMD = ContextMetaData.buildContextMetaData(contentHandlerRegistry,
portalObjectElt);
+ portalObjectMD = ContextMetaData.buildContextMetaData(contentProviderRegistry,
portalObjectElt);
}
// Parse common XML stuff
Modified:
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/core/model/portal/metadata/WindowMetaData.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -26,7 +26,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.Window;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.model.content.spi.ContentHandlerRegistry;
+import org.jboss.portal.core.model.content.ContentProviderRegistry;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.common.util.XML;
import org.w3c.dom.Element;
@@ -108,7 +108,7 @@
return window;
}
- public static WindowMetaData buildPortletWindowMetaData(ContentHandlerRegistry
registry, Element windowElt) throws Exception
+ public static WindowMetaData buildPortletWindowMetaData(ContentProviderRegistry
contentProviderRegistry, Element windowElt) throws Exception
{
WindowMetaData windowMD = new WindowMetaData();
Added:
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/ui/content/portlet/PortletContentEditorPortlet.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * 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.core.ui.content.portlet;
+
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.MetaInfo;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContentEditorPortlet extends GenericPortlet
+{
+
+ /** . */
+ private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ public void init() throws PortletException
+ {
+ instanceContainer =
(InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
+ }
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ if (req.getPortletMode().equals(EDIT_CONTENT))
+ {
+ String uri = req.getParameter("content.uri");
+ if (uri != null)
+ {
+ resp.setRenderParameter("content.uri", uri);
+ }
+ }
+ }
+
+ protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ if (EDIT_CONTENT.equals(req.getPortletMode()))
+ {
+ doEditContent(req, resp);
+ }
+ else
+ {
+ super.doDispatch(req, resp);
+ }
+ }
+
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ String selectedURI = req.getParameter("content.uri");
+
+ //
+ PortletURL actionURL = resp.createActionURL();
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ // load insances this user has access to.
+ List available_instances = (List)instanceContainer.getDefinitions();
+ Instance selectedInstance = null;
+ writer.print("<form action=\"");
+ writer.print(actionURL);
+ writer.print("\" method=\"post\">\n");
+ writer.println("<select
name=\"content.uri\"size=\"20\">\n");
+ for (int i = 0; i < available_instances.size(); i++)
+ {
+ Instance instance = (Instance)available_instances.get(i);
+
+ //
+ writer.print("<option value=\"");
+ writer.print(instance.getId());
+ writer.print("\"");
+
+ //
+ if (instance.getId().equals(selectedURI))
+ {
+ selectedInstance = instance;
+ writer.print(" selected=\"selected\"");
+ }
+
+ //
+ writer.print(">");
+ writer.print(instance.getId());
+ writer.println("</option>\n");
+ }
+ writer.println("</select>");
+ writer.println("<input type=\"submit\"
name=\"content.action.select\" value=\"Select\"/>");
+ writer.println("<input type=\"submit\"
value=\"Info\"/>");
+ writer.print("</form>");
+
+ //
+ if (selectedInstance != null)
+ {
+ writer.print("<div class=\"portlet-font\"
style=\"float:left\">");
+ writer.print("<div><span
class=\"portlet-form-field-label\">Portlet instance:</span>" +
selectedURI + "</div>");
+ try
+ {
+ Portlet portlet = selectedInstance.getPortlet();
+ if (portlet != null)
+ {
+ MetaInfo metaInfo = portlet.getInfo().getMeta();
+ writer.print("<div><span
class=\"portlet-form-field-label\">Portlet name:</span>" +
metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() +
"</div>");
+ writer.print("<div><span
class=\"portlet-form-field-label\">Portlet description:</span>" +
metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() +
"</div>");
+ writer.print("<div><span
class=\"portlet-form-field-label\">Portlet title:</span>" +
metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() + "</div>");
+ writer.print("<div><span
class=\"portlet-form-field-label\">Portlet keywords:</span>" +
metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() + "</div>");
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ writer.close();
+ }
+}
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/content/NullContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -24,13 +24,12 @@
import org.jboss.portal.core.model.content.spi.ContentState;
import org.jboss.portal.core.model.content.Content;
-import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class NullContentHandler extends AbstractContentHandler
+public class NullContentHandler
{
public Content newContent(String contextId, ContentState state)
{
Modified:
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core/src/main/org/jboss/portal/test/core/model/portal/PortalObjectContainerTestCase.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -105,20 +105,20 @@
//
handler = new NullContentHandler();
- handler.setContentType(ContentType.PORTLET.toString());
- handler.setRegistry(container);
+// handler.setContentType(ContentType.PORTLET.toString());
+// handler.setRegistry(container);
//
registry.start();
factory.start();
container.start();
- handler.start();
+// handler.start();
}
public void tearDown() throws Exception
{
super.tearDown();
- handler.destroy();
+// handler.destroy();
container.destroy();
factory.destroy();
registry.destroy();
Modified: trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java
===================================================================
--- trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core/src/main/org/jboss/portlet/content/ContentTypeRegistration.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -22,8 +22,10 @@
******************************************************************************/
package org.jboss.portlet.content;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.impl.model.content.generic.GenericContentProviderRegistry;
import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.Mode;
import org.apache.log4j.Logger;
import javax.servlet.ServletContextListener;
@@ -60,18 +62,24 @@
contentType = ContentType.create(tmp);
//
- String portletInstance =
event.getServletContext().getInitParameter("org.jboss.portal.portlet_instance");
- if (portletInstance == null)
+ final String portletInstanceName =
event.getServletContext().getInitParameter("org.jboss.portal.portlet_instance");
+ if (portletInstanceName == null)
{
- log.warn("The portlet instance of the content registration is not defined,
please define the init parameter org.jboss.portal.portlet_instance in web.xml");
+ log.warn("The portlet instance name of the content registration is not
defined, please define the init parameter org.jboss.portal.portlet_instance in
web.xml");
return;
}
//
- log.debug("About to register content type "+ contentType + " with
portlet instance " + portletInstance);
- ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
- registry.registerEditor(contentType, portletInstance);
- log.debug("Registered content type "+ contentType + " with portlet
instance " + portletInstance);
+ log.debug("About to register content type "+ contentType + " with
portlet instance " + portletInstanceName);
+ GenericContentProviderRegistry providerRegistry =
GenericContentProviderRegistry.getInstance();
+ providerRegistry.register(contentType, new ContentPortlet()
+ {
+ public String getPortletName(Mode mode)
+ {
+ return portletInstanceName;
+ }
+ });
+ log.debug("Registered content type "+ contentType + " with portlet
instance " + portletInstanceName);
}
public void contextDestroyed(ServletContextEvent event)
@@ -79,8 +87,8 @@
if (contentType != null)
{
log.debug("About to unregister content type "+ contentType);
- ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
- registry.unregisterEditor(contentType);
+ GenericContentProviderRegistry providerRegistry =
GenericContentProviderRegistry.getInstance();
+ providerRegistry.unregister(contentType);
log.debug("Content type "+ contentType + " has been
unregistered");
}
}
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-03-23
16:29:59 UTC (rev 6806)
@@ -568,53 +568,73 @@
<depends
optional-attribute-name="InstanceContainer"
proxy-type="attribute">portal:container=Instance</depends>
+ <depends
+ optional-attribute-name="ContentProviderRegistry"
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
<attribute
name="SessionFactoryJNDIName">java:/portal/PortalObjectSessionFactory</attribute>
<attribute name="CacheNaturalId">true</attribute>
</mbean>
+
+ <!-- Customization manager -->
<mbean
-
code="org.jboss.portal.core.impl.model.content.portlet.PortletContentHandler"
- name="portal:service=ContentHandler,type=portlet"
+ code="org.jboss.portal.core.impl.model.CustomizationManagerService"
+ name="portal:service=CustomizationManager"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ <depends
+ optional-attribute-name="PortalAuthorizationManagerFactory"
+
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
<depends
- optional-attribute-name="Registry"
-
proxy-type="attribute">portal:container=PortalObject</depends>
- <depends
optional-attribute-name="InstanceContainer"
proxy-type="attribute">portal:container=Instance</depends>
- <attribute name="ContentType">portlet</attribute>
+ <depends
+ optional-attribute-name="PortalObjectContainer"
+
proxy-type="attribute">portal:container=PortalObject</depends>
+
<depends>portal:service=Module,type=IdentityServiceController</depends>
+ <attribute name="DashboardContextId">dashboard</attribute>
</mbean>
+
+ <!-- The content provider framework -->
<mbean
-
code="org.jboss.portal.core.impl.model.content.generic.GenericContentHandler"
- name="portal:service=ContentHandler,type=generic"
+
code="org.jboss.portal.core.impl.model.content.ContentProviderRegistryService"
+ name="portal:service=ContentProviderRegistry"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
+ </mbean>
+ <mbean
+
code="org.jboss.portal.core.impl.model.content.portlet.InternalPortletContentProvider"
+ name="portal:service=ContentRenderer,type=portlet"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="ContentType">portlet</attribute>
<depends
optional-attribute-name="Registry"
-
proxy-type="attribute">portal:container=PortalObject</depends>
- <attribute name="ContentType">generic</attribute>
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
+ <depends
+ optional-attribute-name="CustomizationManager"
+
proxy-type="attribute">portal:service=CustomizationManager</depends>
+ <depends
+ optional-attribute-name="InstanceContainer"
+ proxy-type="attribute">portal:container=Instance</depends>
</mbean>
-
- <!-- Customization manager -->
<mbean
- code="org.jboss.portal.core.impl.model.CustomizationManagerService"
- name="portal:service=CustomizationManager"
+
code="org.jboss.portal.core.impl.model.content.generic.GenericContentProviderRegistry"
+ name="portal:service=GenericContentProviderRegistry"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <depends
- optional-attribute-name="PortalAuthorizationManagerFactory"
-
proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
<depends
+ optional-attribute-name="Registry"
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
+ <depends
+ optional-attribute-name="CustomizationManager"
+
proxy-type="attribute">portal:service=CustomizationManager</depends>
+ <depends
optional-attribute-name="InstanceContainer"
proxy-type="attribute">portal:container=Instance</depends>
- <depends
- optional-attribute-name="PortalObjectContainer"
-
proxy-type="attribute">portal:container=PortalObject</depends>
-
<depends>portal:service=Module,type=IdentityServiceController</depends>
- <attribute name="DashboardContextId">dashboard</attribute>
</mbean>
<!-- Integrate identity -->
@@ -863,44 +883,6 @@
proxy-type="attribute">portal:service=PortletInvoker,type=Federating</depends>
</mbean>
- <!-- The content renderer registry -->
- <mbean
-
code="org.jboss.portal.core.impl.model.portal.content.ContentRendererRegistryService"
- name="portal:service=ContentRendererRegistry"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- </mbean>
- <mbean
-
code="org.jboss.portal.core.impl.model.portal.content.PortletContentRenderer"
- name="portal:service=ContentRenderer,type=portlet"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- <attribute name="ContentType">portlet</attribute>
- <depends
- optional-attribute-name="Registry"
-
proxy-type="attribute">portal:service=ContentRendererRegistry</depends>
- <depends
- optional-attribute-name="CustomizationManager"
-
proxy-type="attribute">portal:service=CustomizationManager</depends>
- </mbean>
- <mbean
-
code="org.jboss.portal.core.impl.model.portal.content.GenericPortletContentRenderer"
- name="portal:service=ContentRenderer,type=generic"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
- <attribute name="ContentType">generic</attribute>
- <attribute name="DecorateContent">true</attribute>
- <depends
- optional-attribute-name="Registry"
-
proxy-type="attribute">portal:service=ContentRendererRegistry</depends>
- <depends
- optional-attribute-name="CustomizationManager"
-
proxy-type="attribute">portal:service=CustomizationManager</depends>
- </mbean>
-
<!-- The core controller -->
<mbean
code="org.jboss.portal.core.controller.classic.ClassicController"
@@ -934,7 +916,7 @@
proxy-type="attribute">portal:service=CustomizationManager</depends>
<depends
optional-attribute-name="ContentRendererRegistry"
-
proxy-type="attribute">portal:service=ContentRendererRegistry</depends>
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
</mbean>
<!-- The ajax controller -->
@@ -1026,8 +1008,8 @@
optional-attribute-name="PortalObjectContainer"
proxy-type="attribute">portal:container=PortalObject</depends>
<depends
- optional-attribute-name="ContentHandlerRegistry"
-
proxy-type="attribute">portal:container=PortalObject</depends>
+ optional-attribute-name="ContentProviderRegistry"
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
<depends
optional-attribute-name="PortalObjectEntityResolver"
proxy-type="attribute">portal:service=EntityResolver</depends>
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml 2007-03-23 13:58:47
UTC (rev 6805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jboss-portlet.xml 2007-03-23 16:29:59
UTC (rev 6806)
@@ -57,6 +57,17 @@
<trans-attribute>Required</trans-attribute>
</transaction>
</portlet>
+ <portlet>
+ <portlet-name>PortletContentEditorPortlet</portlet-name>
+ <transaction>
+ <trans-attribute>RequiresNew</trans-attribute>
+ </transaction>
+<!--
+ <header-content>
+ <link rel="stylesheet" type="text/css"
href="/style.css" title="" media="screen"/>
+ </header-content>
+-->
+ </portlet>
<!-- Service injected in the portlet context. -->
<service>
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/portlet-instances.xml 2007-03-23
16:29:59 UTC (rev 6806)
@@ -45,4 +45,16 @@
<portlet-ref>CatalogPortlet</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>PortletContentEditorInstance</instance-id>
+ <portlet-ref>PortletContentEditorPortlet</portlet-ref>
+ <security-constraint>
+ <policy-permission>
+ <role-name>Admin</role-name>
+ <action-name>view</action-name>
+ </policy-permission>
+ </security-constraint>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml 2007-03-23 13:58:47 UTC
(rev 6805)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/portlet.xml 2007-03-23 16:29:59 UTC
(rev 6806)
@@ -110,6 +110,20 @@
<title>Catalog</title>
</portlet-info>
</portlet>
+ <portlet>
+ <description>Portlet Content Editor</description>
+ <portlet-name>PortletContentEditorPortlet</portlet-name>
+ <display-name>Portlet Content Editor</display-name>
+
<portlet-class>org.jboss.portal.core.ui.content.portlet.PortletContentEditorPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Portlet Content Portlet</title>
+ <keywords>management,admin</keywords>
+ </portlet-info>
+ </portlet>
<user-attribute>
<name>user.name.nickName</name>
</user-attribute>
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -40,7 +40,8 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.impl.model.content.ContentProviderRegistryService;
import org.jboss.portal.security.AuthorizationDomainRegistry;
import org.jboss.portal.security.spi.provider.AuthorizationDomain;
import org.jboss.portal.theme.LayoutService;
@@ -252,12 +253,12 @@
registerDecorator(PortalObject.class, portalObjectDecorator);
//
- registerDecorator(ContentEditorRegistry.class, new AbstractBeanDecorator()
+ registerDecorator(ContentProviderRegistryService.class, new
AbstractBeanDecorator()
{
protected PropertyDecorator getProperty(Object propertyName)
{
ContentType contentType = ContentType.create((String)propertyName);
- final String instanceName =
ContentEditorRegistry.getInstance().getEditor(contentType);
+ final String instanceName =
ContentProviderRegistryService.getInstance().getContentProvider(contentType).getPortletInfo().getPortletName(ContentPortlet.EDIT_CONTENT_MODE);
return instanceName == null ? null : new
AbstractPropertyDecorator(String.class)
{
public Object getValue(Object bean) throws IllegalArgumentException
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -48,10 +48,11 @@
import org.jboss.portal.core.model.portal.PortalObjectPermission;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.admin.ui.portlet.PortletDefinitionInvoker;
import org.jboss.portal.core.admin.ui.common.PageManagerBean;
import org.jboss.portal.core.admin.ui.actions.AddPageAction;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.impl.model.content.ContentProviderRegistryService;
import org.jboss.portal.faces.component.portlet.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.security.RoleSecurityBinding;
@@ -139,7 +140,9 @@
public List getAvailableContentTypes()
{
LinkedList types = new LinkedList();
- for (Iterator i =
ContentEditorRegistry.getInstance().getContentTypes().iterator();i.hasNext();)
+
+ //
+ for (Iterator i =
ContentProviderRegistryService.getInstance().getContentTypes().iterator();i.hasNext();)
{
ContentType contentType = (ContentType)i.next();
SelectItem item = new SelectItem();
@@ -157,16 +160,16 @@
return types;
}
- public ContentEditorRegistry getContentEditors()
- {
- return ContentEditorRegistry.getInstance();
- }
+// public ContentEditorRegistry getContentEditors()
+// {
+// return ContentEditorRegistry.getInstance();
+// }
public String getSelectedContentEditorInstance()
{
if (selectedContentType != null)
{
- return ContentEditorRegistry.getInstance().getEditor(selectedContentType);
+ return
ContentProviderRegistryService.getInstance().getContentProvider(selectedContentType).getPortletInfo().getPortletName(ContentPortlet.EDIT_CONTENT_MODE);
}
return null;
}
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -29,8 +29,9 @@
import org.jboss.portal.core.model.portal.NoSuchPortalObjectException;
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
import org.jboss.portal.core.admin.ui.actions.WindowComparator;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.impl.model.content.ContentProviderRegistryService;
import org.jboss.portal.theme.ThemeConstants;
import org.jboss.portal.theme.PortalLayout;
import org.jboss.portal.theme.LayoutService;
@@ -108,7 +109,7 @@
public List getContentTypeItems()
{
LinkedList types = new LinkedList();
- for (Iterator i =
ContentEditorRegistry.getInstance().getContentTypes().iterator();i.hasNext();)
+ for (Iterator i =
ContentProviderRegistryService.getInstance().getContentTypes().iterator();i.hasNext();)
{
ContentType contentType = (ContentType)i.next();
SelectItem item = new SelectItem();
@@ -130,7 +131,7 @@
{
if (selectedContentType != null)
{
- return ContentEditorRegistry.getInstance().getEditor(selectedContentType);
+ return
ContentProviderRegistryService.getInstance().getContentProvider(selectedContentType).getPortletInfo().getPortletName(ContentPortlet.EDIT_CONTENT_MODE);
}
else
{
Deleted:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,159 +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.core.admin.ui.portlet;
-
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.MetaInfo;
-
-import javax.portlet.GenericPortlet;
-import javax.portlet.PortletException;
-import javax.portlet.RenderRequest;
-import javax.portlet.RenderResponse;
-import javax.portlet.PortletSecurityException;
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletURL;
-import javax.portlet.PortletMode;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.List;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class PortletContentEditorPortlet extends GenericPortlet
-{
-
- /** . */
- private final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
-
- /** . */
- private InstanceContainer instanceContainer;
-
- public void init() throws PortletException
- {
- instanceContainer =
(InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
- ContentEditorRegistry.getInstance().registerEditor(ContentType.PORTLET,
"PortletContentEditorInstance");
- }
-
- public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- if (req.getPortletMode().equals(EDIT_CONTENT))
- {
- String uri = req.getParameter("content.uri");
- if (uri != null)
- {
- resp.setRenderParameter("content.uri", uri);
- }
- }
- }
-
- protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- if (EDIT_CONTENT.equals(req.getPortletMode()))
- {
- doEditContent(req, resp);
- }
- else
- {
- super.doDispatch(req, resp);
- }
- }
-
- protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
- {
- String selectedURI = req.getParameter("content.uri");
-
- //
- PortletURL actionURL = resp.createActionURL();
-
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
-
- // load insances this user has access to.
- List available_instances = (List)instanceContainer.getDefinitions();
- Instance selectedInstance = null;
- writer.print("<form action=\"");
- writer.print(actionURL);
- writer.print("\" method=\"post\">\n");
- writer.println("<select
name=\"content.uri\"size=\"20\">\n");
- for (int i = 0; i < available_instances.size(); i++)
- {
- Instance instance = (Instance)available_instances.get(i);
-
- //
- writer.print("<option value=\"");
- writer.print(instance.getId());
- writer.print("\"");
-
- //
- if (instance.getId().equals(selectedURI))
- {
- selectedInstance = instance;
- writer.print(" selected=\"selected\"");
- }
-
- //
- writer.print(">");
- writer.print(instance.getId());
- writer.println("</option>\n");
- }
- writer.println("</select>");
- writer.println("<input type=\"submit\"
name=\"content.action.select\" value=\"Select\"/>");
- writer.println("<input type=\"submit\"
value=\"Info\"/>");
- writer.print("</form>");
-
- //
- if (selectedInstance != null)
- {
- writer.print("<div class=\"portlet-font\"
style=\"float:left\">");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet instance:</span>" +
selectedURI + "</div>");
- try
- {
- Portlet portlet = selectedInstance.getPortlet();
- if (portlet != null)
- {
- MetaInfo metaInfo = portlet.getInfo().getMeta();
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet name:</span>" +
metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() +
"</div>");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet description:</span>" +
metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() +
"</div>");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet title:</span>" +
metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() + "</div>");
- writer.print("<div><span
class=\"portlet-form-field-label\">Portlet keywords:</span>" +
metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() + "</div>");
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
-
- //
- writer.close();
- }
-}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-03-23
16:29:59 UTC (rev 6806)
@@ -36,15 +36,6 @@
</header-content>
</portlet>
<portlet>
- <portlet-name>PortletContentEditorPortlet</portlet-name>
- <transaction>
- <trans-attribute>RequiresNew</trans-attribute>
- </transaction>
- <header-content>
- <link rel="stylesheet" type="text/css"
href="/style.css" title="" media="screen"/>
- </header-content>
- </portlet>
- <portlet>
<portlet-name>DashboardConfigPortlet</portlet-name>
<transaction>
<trans-attribute>Required</trans-attribute>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml
===================================================================
---
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml 2007-03-23
16:29:59 UTC (rev 6806)
@@ -45,16 +45,4 @@
<portlet-ref>DashboardConfigPortlet</portlet-ref>
</instance>
</deployment>
- <deployment>
- <instance>
- <instance-id>PortletContentEditorInstance</instance-id>
- <portlet-ref>PortletContentEditorPortlet</portlet-ref>
- <security-constraint>
- <policy-permission>
- <role-name>Admin</role-name>
- <action-name>view</action-name>
- </policy-permission>
- </security-constraint>
- </instance>
- </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml 2007-03-23
16:29:59 UTC (rev 6806)
@@ -65,18 +65,4 @@
<keywords>management,admin</keywords>
</portlet-info>
</portlet>
- <portlet>
- <description>Portlet Content Editor</description>
- <portlet-name>PortletContentEditorPortlet</portlet-name>
- <display-name>Portlet Content Editor</display-name>
-
<portlet-class>org.jboss.portal.core.admin.ui.portlet.PortletContentEditorPortlet</portlet-class>
- <supports>
- <mime-type>text/html</mime-type>
- <portlet-mode>VIEW</portlet-mode>
- </supports>
- <portlet-info>
- <title>Portlet Content Portlet</title>
- <keywords>management,admin</keywords>
- </portlet-info>
- </portlet>
</portlet-app>
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactory.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -22,167 +22,15 @@
******************************************************************************/
package org.jboss.portal.core.cms;
-import org.jboss.portal.Mode;
-import org.jboss.portal.cms.CMS;
-import org.jboss.portal.cms.CMSException;
-import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.model.Content;
-import org.jboss.portal.cms.model.File;
-import org.jboss.portal.core.controller.ControllerCommand;
-import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
-import org.jboss.portal.core.cms.command.StreamContentCommand;
-import org.jboss.portal.core.cms.ui.CMSPortlet;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.server.ServerInvocation;
-import org.jboss.portal.server.config.ServerConfig;
+import org.jboss.portal.core.controller.command.mapper.CommandFactory;
-import java.util.Locale;
-
/**
* This command mapper is used to map urls to cms content objects
*
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
*/
-public class CMSObjectCommandFactory extends AbstractCommandFactory
+public interface CMSObjectCommandFactory extends CommandFactory
{
-
- /** . */
- protected CMS CMSService;
-
- /** . */
- protected String targetWindowRef;
-
- /** . */
- protected PortalObjectId targetWindowId;
-
- /** . */
- protected ServerConfig serverConfig;
-
- public PortalObjectId getTargetWindowId()
- {
- return targetWindowId;
- }
-
- public CMS getCMSService()
- {
- return CMSService;
- }
-
- public void setCMSService(CMS CMSService)
- {
- this.CMSService = CMSService;
- }
-
- public String getTargetWindowRef()
- {
- return targetWindowRef;
- }
-
- public void setTargetWindowRef(String targetWindowRef)
- {
- this.targetWindowRef = targetWindowRef;
- }
-
- public ServerConfig getServerConfig()
- {
- return serverConfig;
- }
-
- public void setServerConfig(ServerConfig serverConfig)
- {
- this.serverConfig = serverConfig;
- }
-
- protected void startService() throws Exception
- {
- targetWindowId = PortalObjectId.parse(targetWindowRef,
PortalObjectId.LEGACY_FORMAT);
-
- //
- super.startService();
- }
-
-
- protected void stopService() throws Exception
- {
- super.stopService();
-
- //
- targetWindowId = null;
- }
-
- private File getFile(String requestPath, Locale locale)
- {
- Command getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath,
locale);
- File file = (File)CMSService.execute(getCMD);
- if (file == null)
- {
- getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath, new
Locale(CMSService.getDefaultLocale()));
- file = (File)CMSService.execute(getCMD);
- }
- return file;
- }
-
- public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
- {
- try
- {
- String path = requestPath;
- Locale requestLocale = invocation.getRequest().getLocale();
- File file = getFile(requestPath, requestLocale);
-
- // Redirect to default content if nothing found (and WTF the content is prefixed
by /default ???)
- if (file == null && "/default/index.html".equals(path) ==
false)
- {
- path = "/default/index.html";
- file = getFile(path, requestLocale);
- }
-
- //
- if (file != null)
- {
- Content content = file.getContent();
-
- if (content != null)
- {
- boolean isStreamable = false;
- if (!"text/html".equalsIgnoreCase(content.getMimeType())
&& !"text/plain".equalsIgnoreCase(content.getMimeType()))
- {
- isStreamable = true;
- }
-
- if (isStreamable)
- {
- return new StreamContentCommand(requestPath);
- }
- else
- {
- // Set the content as a render parameter
- PortletParametersStateString parameters = new
PortletParametersStateString();
- parameters.setValue(CMSPortlet.RENDER_PARAMETER_PATH, path);
- parameters.setValue(CMSPortlet.REQUEST_PROPERTY_USE_GLOBAL_URLS,
"true");
-
- // Perform a render URL on the target window
- return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
- }
- }
- }
- }
- catch (CMSException e)
- {
- if(e.toString().indexOf("Access to this resource is denied")!=-1)
- {
- PortletParametersStateString parameters = new
PortletParametersStateString();
- parameters.setValue("path", requestPath);
- return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
- }
- else
- {
- log.error("CMS error", e);
- }
- }
-
- return null; // TODO: 404?
- }
+ PortalObjectId getTargetWindowId();
}
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java
(rev 0)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/CMSObjectCommandFactoryService.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -0,0 +1,188 @@
+/******************************************************************************
+ * 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.core.cms;
+
+import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.command.InvokePortletWindowRenderCommand;
+import org.jboss.portal.core.cms.command.StreamContentCommand;
+import org.jboss.portal.core.cms.ui.CMSPortlet;
+import org.jboss.portal.cms.CMS;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.CMSException;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.server.config.ServerConfig;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.Mode;
+
+import java.util.Locale;
+
+/**
+ * This command mapper is used to map urls to cms content objects
+ *
+ * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
+ */
+public class CMSObjectCommandFactoryService extends AbstractCommandFactory
+{
+
+ /** . */
+ protected CMS CMSService;
+
+ /** . */
+ protected String targetWindowRef;
+
+ /** . */
+ protected PortalObjectId targetWindowId;
+
+ /** . */
+ protected ServerConfig serverConfig;
+
+ public PortalObjectId getTargetWindowId()
+ {
+ return targetWindowId;
+ }
+
+ public CMS getCMSService()
+ {
+ return CMSService;
+ }
+
+ public void setCMSService(CMS CMSService)
+ {
+ this.CMSService = CMSService;
+ }
+
+ public String getTargetWindowRef()
+ {
+ return targetWindowRef;
+ }
+
+ public void setTargetWindowRef(String targetWindowRef)
+ {
+ this.targetWindowRef = targetWindowRef;
+ }
+
+ public ServerConfig getServerConfig()
+ {
+ return serverConfig;
+ }
+
+ public void setServerConfig(ServerConfig serverConfig)
+ {
+ this.serverConfig = serverConfig;
+ }
+
+ protected void startService() throws Exception
+ {
+ targetWindowId = PortalObjectId.parse(targetWindowRef,
PortalObjectId.LEGACY_FORMAT);
+
+ //
+ super.startService();
+ }
+
+
+ protected void stopService() throws Exception
+ {
+ super.stopService();
+
+ //
+ targetWindowId = null;
+ }
+
+ private File getFile(String requestPath, Locale locale)
+ {
+ Command getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath,
locale);
+ File file = (File)CMSService.execute(getCMD);
+ if (file == null)
+ {
+ getCMD = CMSService.getCommandFactory().createFileGetCommand(requestPath, new
Locale(CMSService.getDefaultLocale()));
+ file = (File)CMSService.execute(getCMD);
+ }
+ return file;
+ }
+
+ public ControllerCommand doMapping(ServerInvocation invocation, String host, String
contextPath, String requestPath)
+ {
+ try
+ {
+ String path = requestPath;
+ Locale requestLocale = invocation.getRequest().getLocale();
+ File file = getFile(requestPath, requestLocale);
+
+ // Redirect to default content if nothing found (and WTF the content is prefixed
by /default ???)
+ if (file == null && "/default/index.html".equals(path) ==
false)
+ {
+ path = "/default/index.html";
+ file = getFile(path, requestLocale);
+ }
+
+ //
+ if (file != null)
+ {
+ Content content = file.getContent();
+
+ if (content != null)
+ {
+ boolean isStreamable = false;
+ if (!"text/html".equalsIgnoreCase(content.getMimeType())
&& !"text/plain".equalsIgnoreCase(content.getMimeType()))
+ {
+ isStreamable = true;
+ }
+
+ if (isStreamable)
+ {
+ return new StreamContentCommand(requestPath);
+ }
+ else
+ {
+ // Set the content as a render parameter
+ PortletParametersStateString parameters = new
PortletParametersStateString();
+ parameters.setValue(CMSPortlet.RENDER_PARAMETER_PATH, path);
+ parameters.setValue(CMSPortlet.REQUEST_PROPERTY_USE_GLOBAL_URLS,
"true");
+
+ // Perform a render URL on the target window
+ return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
+ }
+ }
+ }
+ }
+ catch (CMSException e)
+ {
+ if(e.toString().indexOf("Access to this resource is denied")!=-1)
+ {
+ PortletParametersStateString parameters = new
PortletParametersStateString();
+ parameters.setValue("path", requestPath);
+ return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW,
null, parameters);
+ }
+ else
+ {
+ log.error("CMS error", e);
+ }
+ }
+
+ return null; // TODO: 404?
+ }
+}
Deleted: trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContent.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContent.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContent.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,47 +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.core.cms.content;
-
-import org.jboss.portal.core.model.content.spi.ContentState;
-import org.jboss.portal.core.impl.model.content.AbstractContent;
-import org.jboss.portal.common.util.LocalizedString;
-
-import java.util.Locale;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CMSContent extends AbstractContent
-{
-
- public CMSContent(ContentState state)
- {
- super(state);
- }
-
- public LocalizedString getDisplayName()
- {
- return new LocalizedString(state.getURI() + " cms", Locale.ENGLISH);
- }
-}
Deleted: trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentHandler.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,40 +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.core.cms.content;
-
-import org.jboss.portal.core.model.content.spi.ContentHandler;
-import org.jboss.portal.core.model.content.spi.ContentState;
-import org.jboss.portal.core.impl.model.content.AbstractContentHandler;
-import org.jboss.portal.core.model.content.Content;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CMSContentHandler extends AbstractContentHandler implements ContentHandler
-{
- public Content newContent(String contextId, ContentState state)
- {
- return new CMSContent(state);
- }
-}
Deleted:
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentRenderer.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentRenderer.java 2007-03-23
13:58:47 UTC (rev 6805)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentRenderer.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -1,90 +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.core.cms.content;
-
-import org.jboss.portal.core.impl.model.portal.content.GenericPortletContentRenderer;
-import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-
-import javax.management.ObjectName;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class CMSContentRenderer extends GenericPortletContentRenderer
-{
-
- /** . */
- private static final ThreadLocal useGlobalURLLocal = new ThreadLocal();
-
- public static boolean useGlobalURL()
- {
- return Boolean.TRUE.equals(useGlobalURLLocal.get());
- }
-
- /** . */
- private PortalObjectId targetWindowId;
-
- /** . */
- private ObjectName commandFactory;
-
- public ObjectName getCommandFactory()
- {
- return commandFactory;
- }
-
- public void setCommandFactory(ObjectName commandFactory)
- {
- this.commandFactory = commandFactory;
- }
-
- protected void startService() throws Exception
- {
- targetWindowId = (PortalObjectId)server.getAttribute(commandFactory,
"TargetWindowId");
-
- //
- super.startService();
- }
-
- public Object renderWindow(RenderWindowCommand cmd) throws Exception
- {
- try
- {
- PortalObjectId windowId = cmd.getWindow().getId();
-
- //
- if (windowId.equals(targetWindowId))
- {
- useGlobalURLLocal.set(Boolean.TRUE);
- }
-
- //
- return super.renderWindow(cmd);
- }
- finally
- {
- useGlobalURLLocal.set(null);
- }
- }
-}
Copied:
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
(from rev 6798,
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/CMSContentRenderer.java)
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java
(rev 0)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/content/InternalCMSContentProvider.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -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.core.cms.content;
+
+import org.jboss.portal.core.impl.model.content.generic.InternalGenericContentProvider;
+import org.jboss.portal.core.model.portal.command.RenderWindowCommand;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.spi.portlet.ContentPortlet;
+import org.jboss.portal.core.cms.CMSObjectCommandFactory;
+import org.jboss.portal.Mode;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class InternalCMSContentProvider extends InternalGenericContentProvider
+{
+
+ /** . */
+ private static final ThreadLocal useGlobalURLLocal = new ThreadLocal();
+
+ public static boolean useGlobalURL()
+ {
+ return Boolean.TRUE.equals(useGlobalURLLocal.get());
+ }
+
+ /** . */
+ private PortalObjectId targetWindowId;
+
+ /** . */
+ private CMSObjectCommandFactory commandFactory;
+
+ /** . */
+ private String portletInstanceName;
+
+ public String getPortletInstanceName()
+ {
+ return portletInstanceName;
+ }
+
+ public void setPortletInstanceName(String portletInstanceName)
+ {
+ this.portletInstanceName = portletInstanceName;
+ }
+
+ public CMSObjectCommandFactory getCommandFactory()
+ {
+ return commandFactory;
+ }
+
+ public void setCommandFactory(CMSObjectCommandFactory commandFactory)
+ {
+ this.commandFactory = commandFactory;
+ }
+
+ public void start() throws Exception
+ {
+ targetWindowId = commandFactory.getTargetWindowId();
+ contentPortlet = new ContentPortlet()
+ {
+ public String getPortletName(Mode mode)
+ {
+ return portletInstanceName;
+ }
+ };
+
+ //
+ super.start();
+ }
+
+ public Object renderWindow(RenderWindowCommand cmd) throws Exception
+ {
+ try
+ {
+ PortalObjectId windowId = cmd.getWindow().getId();
+
+ //
+ if (windowId.equals(targetWindowId))
+ {
+ useGlobalURLLocal.set(Boolean.TRUE);
+ }
+
+ //
+ return super.renderWindow(cmd);
+ }
+ finally
+ {
+ useGlobalURLLocal.set(null);
+ }
+ }
+}
Modified: trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
===================================================================
--- trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -53,8 +53,6 @@
import org.jboss.portal.core.cms.ui.admin.CMSContentEditorPortlet;
import org.jboss.portal.core.cms.command.StreamContentCommand;
import org.jboss.portal.core.controller.ControllerContext;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
-import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.search.federation.SearchFederation;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
@@ -130,7 +128,7 @@
static final String DEFAULT_IMAGES_PATH = "/images/cms";
/** The render parameter name of the path of the file the portlet will show. */
- public static final String RENDER_PARAMETER_PATH = "path";
+ public static final String RENDER_PARAMETER_PATH = "uri";
/** The request property which tells the portlet to use global URLs instead of portlet
URLs. */
public static final String REQUEST_PROPERTY_USE_GLOBAL_URLS =
"cms.use_global_urls";
@@ -159,9 +157,6 @@
super.destroy();
//
- ContentEditorRegistry.getInstance().unregisterEditor(ContentType.CMS);
-
- //
hack.destroy();
}
@@ -173,9 +168,6 @@
throw new PortletException("Cannot start CMS portlet due to service
unavailability");
}
- //
- ContentEditorRegistry.getInstance().registerEditor(ContentType.CMS,
"CMSPortletInstance");
-
try
{
SearchFederation searchFederationService =
(SearchFederation)getPortletContext().getAttribute("SearchFederationService");
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-03-23
16:29:59 UTC (rev 6806)
@@ -220,7 +220,7 @@
-->
<mbean
- code="org.jboss.portal.core.cms.CMSObjectCommandFactory"
+ code="org.jboss.portal.core.cms.CMSObjectCommandFactoryService"
name="portal:commandFactory=CMSObject"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
@@ -664,29 +664,19 @@
<!-- Content renderer integration -->
<mbean
- code="org.jboss.portal.core.cms.content.CMSContentRenderer"
+ code="org.jboss.portal.core.cms.content.InternalCMSContentProvider"
name="portal:service=ContentRenderer,type=cms"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="ContentType">cms</attribute>
<attribute name="DecorateContent">false</attribute>
+ <attribute
name="PortletInstanceName">CMSPortletInstance</attribute>
<depends
optional-attribute-name="Registry"
-
proxy-type="attribute">portal:service=ContentRendererRegistry</depends>
- <depends
optional-attribute-name="CommandFactory">portal:commandFactory=CMSObject</depends>
- </mbean>
-
- <!-- Content handler integration -->
- <mbean
- code="org.jboss.portal.core.cms.content.CMSContentHandler"
- name="portal:service=ContentHandler,type=cms"
- xmbean-dd=""
- xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
- <xmbean/>
+
proxy-type="attribute">portal:service=ContentProviderRegistry</depends>
<depends
- optional-attribute-name="Registry"
-
proxy-type="attribute">portal:container=PortalObject</depends>
- <attribute name="ContentType">cms</attribute>
+ optional-attribute-name="CommandFactory"
+
proxy-type="attribute">portal:commandFactory=CMSObject</depends>
</mbean>
</server>
Modified: trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java
===================================================================
--- trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java 2007-03-23
13:58:47 UTC (rev 6805)
+++ trunk/identity/src/main/org/jboss/portal/identity/IdentityContextImpl.java 2007-03-23
16:29:59 UTC (rev 6806)
@@ -53,7 +53,7 @@
public void unregister(String name)
{
- if (!registry.unregister(name))
+ if (registry.unregister(name) == null)
{
log.error("Cannot unregister object from IdentityContext with name: "
+ name);
}
Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml 2007-03-23 13:58:47 UTC (rev 6805)
+++ trunk/testsuite/build.xml 2007-03-23 16:29:59 UTC (rev 6806)
@@ -125,6 +125,9 @@
<param name="module" value="cms"/>
</antcall>
<antcall target="internal-test-module">
+ <param name="module" value="faces"/>
+ </antcall>
+ <antcall target="internal-test-module">
<param name="module" value="format"/>
</antcall>
<antcall target="internal-test-module">
@@ -143,6 +146,9 @@
<param name="module" value="portlet-server"/>
</antcall>
<antcall target="internal-test-module">
+ <param name="module" value="portlet-federation"/>
+ </antcall>
+ <antcall target="internal-test-module">
<param name="module" value="wsrp"/>
</antcall>
<antcall target="internal-test-module">
@@ -178,10 +184,16 @@
<fileset dir="../common"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
<fileset dir="../format" includes="*.log"/>
<fileset dir="../format"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
+ <fileset dir="../faces" includes="*.log"/>
+ <fileset dir="../faces"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
<fileset dir="../server" includes="*.log"/>
<fileset dir="../server"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
<fileset dir="../portlet" includes="*.log"/>
<fileset dir="../portlet"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
+ <fileset dir="../portlet-federation"
includes="*.log"/>
+ <fileset dir="../portlet-federation"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
+ <fileset dir="../portlet-server" includes="*.log"/>
+ <fileset dir="../portlet-server"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
<fileset dir="../security" includes="*.log"/>
<fileset dir="../security"
includes="output/tests/TEST-*.xml,output/tests/TEST-*.txt"/>
<fileset dir="../identity" includes="*.log"/>