Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
GTNPORTAL-2843 Responsive community portlet
Browse files Browse the repository at this point in the history
  • Loading branch information
vrockai authored and nscavell committed Mar 27, 2013
1 parent 8b30441 commit d2af2aa
Show file tree
Hide file tree
Showing 23 changed files with 1,015 additions and 0 deletions.
Expand Up @@ -60,6 +60,17 @@
<show-application-state>false</show-application-state>
<show-application-mode>false</show-application-mode>
</portlet-application>
<portlet-application>
<portlet>
<application-ref>responsive-community-portlet</application-ref>
<portlet-ref>ResponsiveCommunityPortlet</portlet-ref>
</portlet>
<title>Community portlet</title>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
<show-application-state>false</show-application-state>
<show-application-mode>false</show-application-mode>
</portlet-application>
</page>

<page>
Expand Down
Expand Up @@ -60,6 +60,17 @@
<show-application-state>false</show-application-state>
<show-application-mode>false</show-application-mode>
</portlet-application>
<portlet-application>
<portlet>
<application-ref>responsive-community-portlet</application-ref>
<portlet-ref>ResponsiveCommunityPortlet</portlet-ref>
</portlet>
<title>Community portlet</title>
<access-permissions>Everyone</access-permissions>
<show-info-bar>false</show-info-bar>
<show-application-state>false</show-application-state>
<show-application-mode>false</show-application-mode>
</portlet-application>
</page>

<page>
Expand Down
12 changes: 12 additions & 0 deletions mobile-integration/extension-ear/pom.xml
Expand Up @@ -41,6 +41,11 @@
<artifactId>portlet.responsive.banner</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.gatein.portal</groupId>
<artifactId>portlet.responsive.community</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.gatein.portal</groupId>
<artifactId>portlet.responsive.features</artifactId>
Expand Down Expand Up @@ -112,6 +117,13 @@
<bundleFileName>responsive-banner-portlet.war</bundleFileName>
<unpack>true</unpack>
</webModule>
<webModule>
<groupId>org.gatein.portal</groupId>
<artifactId>portlet.responsive.community</artifactId>
<contextRoot>/responsive-community-portlet</contextRoot>
<bundleFileName>responsive-community-portlet.war</bundleFileName>
<unpack>true</unpack>
</webModule>
<webModule>
<groupId>org.gatein.portal</groupId>
<artifactId>portlet.responsive.footer</artifactId>
Expand Down
63 changes: 63 additions & 0 deletions mobile-integration/portlets/community/pom.xml
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.gatein.portal</groupId>
<artifactId>responsive-portlets</artifactId>
<version>3.6.0.MO1-SNAPSHOT</version>
</parent>

<groupId>org.gatein.portal</groupId>
<artifactId>portlet.responsive.community</artifactId>
<packaging>war</packaging>
<name>GateIn Portal Responsive Community Portlet</name>
<description />

<build>
<finalName>responsive-community-portlet</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>rome</groupId>
<artifactId>rome</artifactId>
</dependency>
<dependency>
<groupId>org.gatein.common</groupId>
<artifactId>common-logging</artifactId>
<type>jar</type>
</dependency>
</dependencies>

<repositories>
<repository>
<id>JBoss repository</id>
<url>http://repository.jboss.com/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

</project>
@@ -0,0 +1,79 @@
/******************************************************************************
* JBoss, a division of Red Hat *
* Copyright 2012, 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.portlet.responsive.community;

import java.io.IOException;
import java.net.URL;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletPreferences;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.PortletRequestDispatcher;

/**
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
* @version $Revision$
*/
public class CommunityPortlet extends GenericPortlet {

private String DEFAULT_URL = "/#";
private String URL_RSS_BLOG = "url.rss.blog";
private String URL_RSS_TWITTER = "url.rss.twitter";
private String URL_CONTENT_BLOG = "url.blog";
private String URL_CONTENT_TWITTER = "url.twitter";
private String PFX_BLOG_AUTHOR = "pfx.url.author";

@Override
protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {

PortletPreferences portletPreferences = request.getPreferences();

String urlRssBlog = portletPreferences.getValue(URL_RSS_BLOG, DEFAULT_URL);
String urlRssTwitter = portletPreferences.getValue(URL_RSS_TWITTER, DEFAULT_URL);
String urlContentBlog = portletPreferences.getValue(URL_CONTENT_BLOG, DEFAULT_URL);
String urlContentTwitter = portletPreferences.getValue(URL_CONTENT_TWITTER, DEFAULT_URL);
String pfxBlogAuthor = portletPreferences.getValue(PFX_BLOG_AUTHOR, "");

RomeRssControllerBean romeRssControllerBean = new RomeRssControllerBean();

URL gateInBlog = new URL(urlRssBlog);

RssReaderBean gateInBlogRssReader = new RssReaderBean();
gateInBlogRssReader.setFeedTitles(romeRssControllerBean.getFeedTitles(gateInBlog, 2));
gateInBlogRssReader.setAuthorUrlPrefix(pfxBlogAuthor);
gateInBlogRssReader.setContentSource(new URL(urlContentBlog));

URL gateInTwitter = new URL(urlRssTwitter);

RssReaderBean gateInTwitterRssReader = new RssReaderBean();
gateInTwitterRssReader.setFeedTitles(romeRssControllerBean.getFeedTitles(gateInTwitter, 2));
gateInTwitterRssReader.setContentSource(new URL(urlContentTwitter));

request.setAttribute("blogRSSBean", gateInBlogRssReader);
request.setAttribute("twitterRSSBean", gateInTwitterRssReader);

PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/community.jsp");
prd.include(request, response);
}
}
@@ -0,0 +1,92 @@
/******************************************************************************
* JBoss, a division of Red Hat *
* Copyright 2012, 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.portlet.responsive.community;

import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndPerson;
import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.gatein.common.logging.Logger;
import org.gatein.common.logging.LoggerFactory;

/**
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
* @version $Revision$
*/
public class RomeRssControllerBean {

private static final Logger log = LoggerFactory.getLogger(RomeRssControllerBean.class);

public List<RssTitleBean> getFeedTitles(URL source, int headsize) {
List<RssTitleBean> rssTitleBeanList = new ArrayList<RssTitleBean>();
XmlReader reader = null;

try {
try {
reader = new XmlReader(source);
SyndFeed feed = new SyndFeedInput().build(reader);

for (Iterator i = feed.getEntries().iterator(); i.hasNext() && (headsize-- > 0);) {
SyndEntry entry = (SyndEntry) i.next();

RssTitleBean rssTitleBean = new RssTitleBean();
rssTitleBean.setTitle(entry.getTitle());
rssTitleBean.setLink(entry.getLink());
rssTitleBean.setPublishedDate(entry.getPublishedDate());

List<RssAuthorBean> rssAuthors = new ArrayList<RssAuthorBean>();

for (SyndPerson author : (List<SyndPerson>) entry.getAuthors()) {
RssAuthorBean rssAuthorBean = new RssAuthorBean();
rssAuthorBean.setName(author.getName());
rssAuthorBean.setUri(author.getUri());

rssAuthors.add(rssAuthorBean);
}

rssTitleBean.setAuthors(rssAuthors);

rssTitleBeanList.add(rssTitleBean);
}
} catch (FeedException e) {
log.error("RSS Feed related exception: " + e);

} finally {
if (reader != null) {
reader.close();
}
}
} catch (IOException e) {
log.error("Unable to open RSS feed url: " + e);
}

return rssTitleBeanList;
}
}
@@ -0,0 +1,49 @@
/******************************************************************************
* JBoss, a division of Red Hat *
* Copyright 2012, 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.portlet.responsive.community;

/**
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
* @version $Revision$
*/
public class RssAuthorBean {

private String name;
private String uri;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getUri() {
return uri;
}

public void setUri(String uri) {
this.uri = uri;
}
}

0 comments on commit d2af2aa

Please sign in to comment.