Author: julien(a)jboss.com
Date: 2007-03-06 18:08:36 -0500 (Tue, 06 Mar 2007)
New Revision: 6568
Added:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.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/portlet/PortletContentEditorPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml
Log:
- hack to merge cms content viewer and content editor
- moved ContentTypeRegistry into core
Copied:
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java
(from rev 6566,
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/impl/model/content/ContentEditorRegistry.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * 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/servlet/jsp/ContentTypeRegistration.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java
(rev 0)
+++
trunk/core/src/main/org/jboss/portal/core/servlet/jsp/ContentTypeRegistration.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.servlet.jsp;
+
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.core.model.content.ContentType;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContext;
+
+/**
+ * Provide registration of a content type with a portlet instance. This listener can be
used
+ * in war files to register content driven portlet.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentTypeRegistration implements ServletContextListener
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(ContentTypeRegistration.class);
+
+ /** . */
+ private ContentType contentType;
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ ServletContext ctx = event.getServletContext();
+
+ //
+ String tmp = ctx.getInitParameter("org.jboss.portal.content_type");
+ if (tmp == null)
+ {
+ log.warn("The content type of the content registration is not defined,
please define the init parameter org.jboss.portal.content_type in web.xml");
+ return;
+ }
+ contentType = ContentType.create(tmp);
+
+ //
+ String portletInstance =
event.getServletContext().getInitParameter("org.jboss.portal.portlet_instance");
+ if (portletInstance == 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");
+ 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);
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ if (contentType != null)
+ {
+ log.debug("About to unregister content type "+ contentType);
+ ContentEditorRegistry registry = ContentEditorRegistry.getInstance();
+ registry.unregisterEditor(contentType);
+ log.debug("Content type "+ contentType + " has been
unregistered");
+ }
+ }
+}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-06
22:53:50 UTC (rev 6567)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -38,7 +38,7 @@
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.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
import javax.faces.context.FacesContext;
import java.util.Set;
@@ -223,12 +223,12 @@
DelegatingPropertyResolver.registerDecorator(PortalObject.class,
portalObjectDecorator);
//
- DelegatingPropertyResolver.registerDecorator(ContentEditors.class, new
AbstractBeanDecorator()
+ DelegatingPropertyResolver.registerDecorator(ContentEditorRegistry.class, new
AbstractBeanDecorator()
{
protected PropertyDecorator getProperty(Object propertyName)
{
ContentType contentType = ContentType.create((String)propertyName);
- final String instanceName =
ContentEditors.getInstance().getEditor(contentType);
+ final String instanceName =
ContentEditorRegistry.getInstance().getEditor(contentType);
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-06
22:53:50 UTC (rev 6567)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -52,7 +52,7 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.admin.ui.actions.WindowComparator;
-import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
import org.jboss.portal.core.faces.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.security.AuthorizationDomainRegistry;
@@ -145,7 +145,7 @@
public List getAvailableContentTypes()
{
LinkedList types = new LinkedList();
- for (Iterator i =
ContentEditors.getInstance().getContentTypes().iterator();i.hasNext();)
+ for (Iterator i =
ContentEditorRegistry.getInstance().getContentTypes().iterator();i.hasNext();)
{
ContentType contentType = (ContentType)i.next();
SelectItem item = new SelectItem();
@@ -163,16 +163,16 @@
return types;
}
- public ContentEditors getContentEditors()
+ public ContentEditorRegistry getContentEditors()
{
- return ContentEditors.getInstance();
+ return ContentEditorRegistry.getInstance();
}
public String getSelectedContentEditorInstance()
{
if (selectedContentType != null)
{
- return ContentEditors.getInstance().getEditor(selectedContentType);
+ return ContentEditorRegistry.getInstance().getEditor(selectedContentType);
}
return null;
}
Deleted:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06
22:53:50 UTC (rev 6567)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -1,67 +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.content;
-
-import org.jboss.portal.common.util.CopyOnWriteRegistry;
-import org.jboss.portal.core.model.content.ContentType;
-
-import java.util.Collection;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class ContentEditors
-{
-
- /** . */
- private static final ContentEditors instance = new ContentEditors();
-
- /** . */
- private final CopyOnWriteRegistry editors = new CopyOnWriteRegistry();
-
- public static ContentEditors 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();
- }
-}
Modified:
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-06
22:53:50 UTC (rev 6567)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -25,7 +25,7 @@
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.admin.ui.content.ContentEditors;
+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;
@@ -59,7 +59,7 @@
public void init() throws PortletException
{
instanceContainer =
(InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
- ContentEditors.getInstance().registerEditor(ContentType.PORTLET,
"PortletContentEditorInstance");
+ ContentEditorRegistry.getInstance().registerEditor(ContentType.PORTLET,
"PortletContentEditorInstance");
}
public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
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-06
22:53:50 UTC (rev 6567)
+++ trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -38,6 +38,9 @@
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletMode;
+import javax.portlet.PortletConfig;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
import org.apache.log4j.Logger;
import org.jboss.portal.cms.CMS;
@@ -47,8 +50,11 @@
import org.jboss.portal.cms.search.CMSFederatedSearch;
import org.jboss.portal.cms.util.FileUtil;
import org.jboss.portal.core.cms.CMSConstants;
+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;
@@ -132,15 +138,41 @@
/** . */
private CMS CMSService;
+ /** . */
+ private CMSContentEditorPortlet hack = new CMSContentEditorPortlet();
+
+
+ public void init(PortletConfig config) throws PortletException
+ {
+ super.init(config);
+
+ //
+ hack.init(config);
+ }
+
+
+ public void destroy()
+ {
+ super.destroy();
+
+ //
+ ContentEditorRegistry.getInstance().unregisterEditor(ContentType.CMS);
+
+ //
+ hack.destroy();
+ }
+
public void init() throws PortletException
{
CMSService = (CMS)getPortletContext().getAttribute("CMS");
-
if (CMSService == null)
{
throw new PortletException("Cannot start CMS portlet due to service
unavailability");
}
-
+
+ //
+ ContentEditorRegistry.getInstance().registerEditor(ContentType.CMS,
"CMSPortletInstance");
+
try
{
SearchFederation searchFederationService =
(SearchFederation)getPortletContext().getAttribute("SearchFederationService");
@@ -158,6 +190,12 @@
}
+ public void processAction(ActionRequest request, ActionResponse response) throws
PortletException, PortletSecurityException, IOException
+ {
+ // Only the editor uses it for now, so just forward
+ hack.processAction(request, response);
+ }
+
protected void doDispatch(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
{
PortletMode portletMode = req.getPortletMode();
@@ -165,6 +203,10 @@
{
doViewContent(req, resp);
}
+ else if ("edit_content".equals(portletMode.toString()))
+ {
+ hack.render(req, resp);
+ }
else
{
super.doDispatch(req, resp);
@@ -184,6 +226,11 @@
}
}
+ protected void doEditContent(RenderRequest req, RenderResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ hack.render(req, resp);
+ }
+
protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
{
PortletPreferences prefs = req.getPreferences();
Modified:
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06
22:53:50 UTC (rev 6567)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSContentEditorPortlet.java 2007-03-06
23:08:36 UTC (rev 6568)
@@ -37,8 +37,6 @@
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.core.admin.ui.content.ContentEditors;
-import org.jboss.portal.core.model.content.ContentType;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -54,7 +52,6 @@
public void init() throws PortletException
{
cmsService = (CMS)getPortletContext().getAttribute("CMS");
- ContentEditors.getInstance().registerEditor(ContentType.CMS,
"CMSContentEditorInstance");
}
public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
Modified: trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml 2007-03-06
22:53:50 UTC (rev 6567)
+++ trunk/core-cms/src/resources/portal-cms-war/WEB-INF/portlet-instances.xml 2007-03-06
23:08:36 UTC (rev 6568)
@@ -47,10 +47,4 @@
</instance>
</deployment>
- <deployment>
- <instance>
- <instance-id>CMSContentEditorInstance</instance-id>
- <portlet-ref>CMSContentEditorPortlet</portlet-ref>
- </instance>
- </deployment>
</deployments>
\ No newline at end of file