This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GTNPORTAL-2843 Responsive community portlet
- Loading branch information
Showing
23 changed files
with
1,015 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
79 changes: 79 additions & 0 deletions
79
...ets/community/src/main/java/org/gatein/portlet/responsive/community/CommunityPortlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
...ommunity/src/main/java/org/gatein/portlet/responsive/community/RomeRssControllerBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...rtlets/community/src/main/java/org/gatein/portlet/responsive/community/RssAuthorBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Oops, something went wrong.