Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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.net.URL;
 import java.util.List;
 
 import  javax.portlet.GenericPortlet;
 import  javax.portlet.PortletException;
 import  javax.portlet.PortletPreferences;
 import  javax.portlet.RenderRequest;
 import  javax.portlet.RenderResponse;
 import  javax.portlet.PortletRequestDispatcher;
 import  javax.portlet.ResourceRequest;
 import  javax.portlet.ResourceResponse;
 
 import  com.sun.syndication.io.FeedException;

Author(s):
Viliam Rockai
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";
     private static final Logger log = LoggerFactory.getLogger(CommunityPortlet.class);
 
     @Override
     protected void doView(RenderRequest request, RenderResponse responsethrows PortletException, IOException {
         PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/community.jsp");
         prd.include(requestresponse);
     }
 
     private RssReaderBean makeReaderBean(String urlRssString urlContentint headString pfxBlogAuthor) {
         RssReaderBean rssReaderBean = new RssReaderBean();
         rssReaderBean.setSourceIO(urlRss);
 
         try {
             URL rssSourceUrl = new URL(urlRss);
             rssReaderBean.setFeedTitles(RomeRssControllerBean.getFeedTitles(rssSourceUrlhead));
             rssReaderBean.setContentSource(new URL(urlContent));
             rssReaderBean.setAuthorUrlPrefix(pfxBlogAuthor);
         } catch (IOException e) {
             rssReaderBean.setValid(false);
             .debug("Unable to open RSS feed url: " + e);
         }   catch (FeedException e) {
             rssReaderBean.setValid(false);
             .debug("Problem with RSS feed: " + e);
         }
 
         return rssReaderBean;
     }
 
     @Override
     public void serveResource(ResourceRequest request, ResourceResponse responsethrows PortletException, IOException {
 
         PortletPreferences portletPreferences = request.getPreferences();
 
         String contentType = request.getParameter("type");
 
         if ("blog".equals(contentType)){
             String urlRssBlog = portletPreferences.getValue();
             String urlContentBlog = portletPreferences.getValue();
             String pfxBlogAuthor = portletPreferences.getValue("");
 
             RssReaderBean gateInBlogRssReader = makeReaderBean(urlRssBlogurlContentBlog, 2, pfxBlogAuthor);
             request.setAttribute("blogRSSBean"gateInBlogRssReader);
 
             PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/feedBlog.jsp");
             prd.include(requestresponse);
         } else if ("twitter".equals(contentType)) {
            String urlRssTwitter = portletPreferences.getValue();
            String urlContentTwitter = portletPreferences.getValue();
            RssReaderBean gateInTwitterRssReader = makeReaderBean(urlRssTwitterurlContentTwitter, 2, null);
            request.setAttribute("twitterRSSBean"gateInTwitterRssReader);
            PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/feedTwitter.jsp");
            prd.include(requestresponse);
        }
    }
New to GrepCode? Check out our FAQ X