[gatein-commits] gatein SVN: r6986 - in portal/branches/api/examples/portlets/api/src/main: webapp/WEB-INF and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 2 17:52:08 EDT 2011


Author: chris.laprun at jboss.com
Date: 2011-08-02 17:52:08 -0400 (Tue, 02 Aug 2011)
New Revision: 6986

Added:
   portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
Modified:
   portal/branches/api/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
Log:
- Added portlet to show how to interact with the ContentRegistry API.

Added: portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java
===================================================================
--- portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java	                        (rev 0)
+++ portal/branches/api/examples/portlets/api/src/main/java/org/gatein/portal/samples/api/ContentRegistryPortlet.java	2011-08-02 21:52:08 UTC (rev 6986)
@@ -0,0 +1,64 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2008, 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.gatein.portal.samples.api;
+
+import org.gatein.api.GateIn;
+import org.gatein.api.content.Category;
+import org.gatein.api.util.IterableIdentifiableCollection;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
+public class ContentRegistryPortlet extends GenericPortlet
+{
+   private GateIn gateIn;
+
+   @Override
+   public void init(PortletConfig config) throws PortletException
+   {
+      super.init(config);
+      gateIn = (GateIn)config.getPortletContext().getAttribute(GateIn.GATEIN_API);
+   }
+
+   @Override
+   protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+   {
+      PrintWriter writer = response.getWriter();
+
+      writer.println("<h1>Categories</h1>");
+
+      writer.println("<ul>");
+      IterableIdentifiableCollection<Category> categories = gateIn.getDefaultPortal().getContentRegistry().getAllCategories();
+      for (Category category : categories)
+      {
+         writer.println("<li>" + category + "</li>");
+      }
+      writer.println("</ul>");
+   }
+}

Modified: portal/branches/api/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- portal/branches/api/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml	2011-08-02 21:50:32 UTC (rev 6985)
+++ portal/branches/api/examples/portlets/api/src/main/webapp/WEB-INF/portlet.xml	2011-08-02 21:52:08 UTC (rev 6986)
@@ -74,6 +74,23 @@
       </portlet-info>
    </portlet>
 
+   <portlet>
+      <description xml:lang="EN">Content Registry Portlet Example using GateIn's public API</description>
+      <portlet-name>ContentRegistryAPIPortlet</portlet-name>
+      <display-name xml:lang="EN">API Content Registry Portlet</display-name>
+      <portlet-class>org.gatein.portal.samples.api.ContentRegistryPortlet</portlet-class>
+
+      <supports>
+         <mime-type>text/html</mime-type>
+      </supports>
+
+      <portlet-info>
+         <title>API Content Registry Portlet</title>
+         <short-title>Content Registry Portlet</short-title>
+         <keywords>Sample</keywords>
+      </portlet-info>
+   </portlet>
+
    <public-render-parameter>
       <identifier>navigation_uri</identifier>
       <qname xmlns:prp='http://www.gatein.org/xml/ns/prp_1_0'>prp:navigation_uri</qname>



More information about the gatein-commits mailing list