Permalink
Browse files

Fixed ENCUESTAME-424

  • Loading branch information...
1 parent 14f8169 commit a37680a10a575ec9a17b3823ca742f4a29affa9b Juan Picado committed Apr 22, 2012
@@ -16,10 +16,13 @@
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.collections.ListUtils;
+import org.apache.log4j.Logger;
+import org.encuestame.core.util.EnMeUtils;
import org.encuestame.core.util.FeedUtils;
import org.encuestame.core.util.InternetUtils;
import org.encuestame.mvc.controller.AbstractBaseOperations;
import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
+import org.encuestame.persistence.exception.EnMeSearchException;
import org.encuestame.utils.json.TweetPollBean;
import org.encuestame.utils.web.PollBean;
import com.sun.syndication.feed.atom.Entry;
@@ -33,6 +36,11 @@
*/
public abstract class AbstractFeedController extends AbstractBaseOperations{
+ /**
+ * Log.
+ */
+ private Logger log = Logger.getLogger(this.getClass());
+
/**
* Get TweetPolls.
* @param username
@@ -68,6 +76,9 @@
final String itemType,
final Integer limits) throws EnMeNoResultsFoundException{
List<Item> item = new ArrayList<Item>();
+ log.debug("getItemRssFeed username "+username);
+ log.debug("getItemRssFeed itemType "+itemType);
+ log.debug("getItemRssFeed limits "+limits);
if (itemType.equals("tweetPolls")) {
item = FeedUtils.convertTweetPollBeanToItemRSS(
getTweetPolls(username), InternetUtils.getDomain(request));
@@ -85,8 +96,17 @@
} else if (itemType.equals("projects")) {
item = ListUtils.EMPTY_LIST;
} else if (itemType.equals("frontend")) {
- item = ListUtils.EMPTY_LIST;
+ try {
+ item = FeedUtils.convertHomeBeanToItemRSS(
+ getFrontService().getFrontEndItems("all",
+ EnMeUtils.DEFAULT_START, limits, request),
+ InternetUtils.getDomain(request));
+ } catch (EnMeSearchException e) {
+ log.error("Error on retrieve RSS home items ", e);
+ item = ListUtils.EMPTY_LIST;
+ }
}
+ log.debug("getItemRssFeed item "+item.size());
return item;
}
@@ -97,8 +117,11 @@
* @return
* @throws EnMeNoResultsFoundException
*/
- public List<Entry> getEntryAtomFeed(final String username,
- final HttpServletRequest request, final String entryType ) throws EnMeNoResultsFoundException{
+ public List<Entry> getEntryAtomFeed(
+ final String username,
+ final HttpServletRequest request,
+ final String entryType,
+ final Integer limits) throws EnMeNoResultsFoundException{
List<Entry> entry = new ArrayList<Entry>();
if (entryType.equals("tweetPolls")){
entry = FeedUtils.convertTweetPollBeanToEntryAtom(
@@ -125,9 +148,10 @@ else if(entryType.equals("projects")){
InternetUtils.getDomain(request));
}
else if(entryType.equals("frontend")){
- entry = FeedUtils.convertTweetPollBeanToEntryAtom(
- getTweetPolls(username),
- InternetUtils.getDomain(request));
+// entry = FeedUtils.convertHomeBeanToItemRSS(
+// getFrontService().getFrontEndItems("all",
+// EnMeUtils.DEFAULT_START, limits, request),
+// InternetUtils.getDomain(request));
}
return entry;
}
@@ -79,7 +79,7 @@ public String tweetPollAtom(@PathVariable String username, Model model, HttpServ
final UserAccount secUserSecondary = findByUsername(username);
if(secUserSecondary != null){
try {
- model.addAttribute("items", this.getEntryAtomFeed(username, request, "tweetPolls"));
+ model.addAttribute("items", this.getEntryAtomFeed(username, request, "tweetPolls", rssDisplayItems));
} catch (EnMeExpcetion e) {
log.error(e);
}
@@ -165,7 +165,7 @@ public String profileAtom(@PathVariable String username, Model model, HttpServle
final UserAccount secUserSecondary = findByUsername(username);
if(secUserSecondary != null){
try {
- model.addAttribute("items", this.getEntryAtomFeed(username, request, "profiles"));
+ model.addAttribute("items", this.getEntryAtomFeed(username, request, "profiles", rssDisplayItems));
this.buildTweetPollFeedBody(username, model, request, secUserSecondary);
} catch (EnMeExpcetion e) {
log.error(e);
@@ -186,7 +186,7 @@ public String surveyAtom(@PathVariable String username, Model model, HttpServlet
final UserAccount secUserSecondary = findByUsername(username);
if(secUserSecondary != null){
try {
- model.addAttribute("items", this.getEntryAtomFeed(username, request, "surveys"));
+ model.addAttribute("items", this.getEntryAtomFeed(username, request, "surveys", rssDisplayItems));
} catch (EnMeExpcetion e) {
log.error(e);
}
@@ -250,7 +250,7 @@ public String pollAtom(@PathVariable String username, Model model, HttpServletRe
final UserAccount secUserSecondary = findByUsername(username);
if(secUserSecondary != null){
try {
- model.addAttribute("items", this.getEntryAtomFeed(username, request, "polls"));
+ model.addAttribute("items", this.getEntryAtomFeed(username, request, "polls", rssDisplayItems));
} catch (EnMeExpcetion e) {
log.error(e);
}
@@ -265,7 +265,7 @@ public String pollAtom(@PathVariable String username, Model model, HttpServletRe
* @param request
* @return
*/
- @RequestMapping(value = "/feed/polls.atom", method = RequestMethod.GET)
+ @RequestMapping(value = "/feed/poll.atom", method = RequestMethod.GET)
public String pollAtom(Model model, HttpServletRequest request) {
model.addAttribute("items", ListUtils.EMPTY_LIST); //TODO: without filter.
return "pollAtomFeedView";
@@ -316,7 +316,7 @@ public String projectAtom(@PathVariable String username, Model model, HttpServle
final UserAccount secUserSecondary = findByUsername(username);
if(secUserSecondary != null){
try {
- model.addAttribute("items", this.getEntryAtomFeed(username, request, "projects"));
+ model.addAttribute("items", this.getEntryAtomFeed(username, request, "projects", rssDisplayItems));
} catch (EnMeExpcetion e) {
log.error(e);
}
@@ -379,15 +379,12 @@ public String projectRss(Model model, HttpServletRequest request) {
@RequestMapping(value = "/feed/home.atom", method = RequestMethod.GET)
public String frontendAtom(
Model model,
- HttpServletRequest request) {
- final UserAccount secUserSecondary = findByUsername("");//TODO: remove
- if(secUserSecondary != null){
+ HttpServletRequest request) {
try {
- model.addAttribute("items", this.getEntryAtomFeed("", request, "frontend"));
+ model.addAttribute("items", this.getEntryAtomFeed("", request, "frontend", rssDisplayItems));
} catch (EnMeExpcetion e) {
log.error(e);
}
- }
return "frontEndAtomFeedView";
}
@@ -403,14 +400,11 @@ public String frontendAtom(
public String frontendRss(
Model model,
HttpServletRequest request) {
- final UserAccount secUserSecondary = findByUsername(""); //TODO: remove
- if(secUserSecondary != null){
try {
- model.addAttribute("items", this.getItemRssFeed("", request, "frontend", rssDisplayItems)); //TODO: remove
+ model.addAttribute("items", this.getItemRssFeed(null, request, "frontend", rssDisplayItems));
} catch (EnMeNoResultsFoundException e) {
log.error(e);
}
- }
return "frontEndRssFeedView";
}
@@ -174,7 +174,6 @@ public void testGetTopRatedComments() throws ServletException, IOException {
setParameter("start", "0");
final JSONObject response = callJsonService();
final JSONObject success = getSucess(response);
- System.out.println(success);
final JSONArray comments = (JSONArray) success.get("topComments");
//System.out.println("COMMENTS JSON TEST-->" + comments.size());
Assert.assertEquals(comments.size(), 4);
@@ -15,6 +15,7 @@
<!-- All JavaScript at the bottom, except for Modernizr / Respond.
Modernizr enables HTML5 elements & feature detects; Respond is a polyfill for min/max-width CSS3 Media Queries-->
<script src="<%=request.getContextPath()%>/resources/js/req/modernizr-2.0.6.js"></script>
+ <tiles:insertAttribute name="rss" ignore="true" />
</head>
<body class="claro enme-web-context">
<header id="header">
@@ -80,6 +80,15 @@ setup.oauth.des = use your platform with third party app
setup.social = Social Network's' more popular
setup.social.des = Facebook, Google Buzz, Twitter, IdentCa, Yahoo and more.
+################
+# RSS / ATOM
+################
+syndicate.tweetpoll = Last TweetPoll published
+syndicate.poll = Last Poll published
+syndicate.profiles = The last item published by this user
+syndicate.survey = Last Survey published
+syndicate.project = Last Project published
+syndicate.home = The more recent items published
################
# Sign In
@@ -86,6 +86,16 @@ setup.oauth.des = usala con aplicaciones a terceros o crea las tuyas propias
setup.social = Integrado con las Redes Sociales más Popúlares
setup.social.des = Facebook, Google, Twitter, Identi.ca, Yahoo y muchas más.
+################
+# RSS / ATOM
+################
+syndicate.tweetpoll = Últimos tweetpoll publicados
+syndicate.poll = Últimos sondeos publicados
+syndicate.profiles = Los Últimos elementos publicados por este usuario
+syndicate.survey = Últimas encuestas publicados
+syndicate.project = Últimos projects publicados
+syndicate.home = Los mas recientes elementos publicados
+
################
# Sign In
################
@@ -0,0 +1,11 @@
+<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp"%>
+<link href="<%=request.getContextPath()%>/feed/home.rss" rel="alternate" type="application/rss+xml" title="<spring:message code="syndicate.home" />" />
+<link href="<%=request.getContextPath()%>/feed/home.atom" rel="alternate" type="application/atom+xml" title="<spring:message code="syndicate.home" />" />
+<link href="<%=request.getContextPath()%>/feed/poll.atom" rel="alternate" type="application/atom+xml" title="<spring:message code="syndicate.poll" />" />
+<link href="<%=request.getContextPath()%>/feed/poll.rss" rel="alternate" type="application/rss+xml" title="<spring:message code="syndicate.poll" />" />
+<link href="<%=request.getContextPath()%>/feed/projects.atom" rel="alternate" type="application/atom+xml" title="<spring:message code="syndicate.project" />" />
+<link href="<%=request.getContextPath()%>/feed/projects.rss" rel="alternate" type="application/rss+xml" title="<spring:message code="syndicate.project" />" />
+<link href="<%=request.getContextPath()%>/feed/survey.rss" rel="alternate" type="application/rss+xml" title="<spring:message code="syndicate.survey" />" />
+<link href="<%=request.getContextPath()%>/feed/survey.atom" rel="alternate" type="application/atom+xml" title="<spring:message code="syndicate.survey" />" />
+<link href="<%=request.getContextPath()%>/feed/tweetpoll.atom" rel="alternate" type="application/atom+xml" title="<spring:message code="syndicate.tweetpoll" />" />
+<link href="<%=request.getContextPath()%>/feed/tweetpoll.rss" rel="alternate" type="application/rss+xml" title="<spring:message code="syndicate.tweetpoll" />" />
@@ -7,6 +7,7 @@
<put-attribute name="title" value="Home | encuestame" />
<put-attribute name="content" expression="/WEB-INF/views/home/${currentDevice.mobile ? 'mobile/' : 'web/'}home.jsp" />
<put-attribute name="extra-js" expression="/WEB-INF/views/home/js.jsp" />
+ <put-attribute name="rss" value="/WEB-INF/views/home/rss.jsp" />
</definition>
<definition name="menu" extends="page">

0 comments on commit a37680a

Please sign in to comment.