From 0a2e024f7c856cf126f6d52f38b2543e39789465 Mon Sep 17 00:00:00 2001 From: Misagh Moayyed Date: Tue, 3 Apr 2012 15:46:03 -0700 Subject: [PATCH] NEWSREADER-1: Fixed a bug with the single newsfeed renderer JSP where empty feeds caused an exception. Also allowed the portlet to administer its own preferences, allowing the user to enter the feed title, url and class name. Also updated the schema declarations to Spring 3.0 and updated the single news feed UI to display the message for misbehaving feeds that could be loaded/parsed. --- .classpath | 16 +++-- .gitignore | 58 +++++++++++++++++++ .project | 25 ++++++++ .../jasig/portlet/newsreader/Preference.java | 9 ++- .../mvc/portlet/reader/HelpController.java | 2 +- .../EditSingleFeedPreferencesController.java | 21 ++++++- .../portlet/singlefeed/HelpController.java | 34 +++++++++++ .../WEB-INF/context/applicationContext.xml | 8 +-- .../WEB-INF/context/importExportContext.xml | 4 +- .../webapp/WEB-INF/context/portlet/news.xml | 8 ++- .../WEB-INF/context/portlet/single-feed.xml | 9 +-- .../servlet/ajaxResponseServletContext.xml | 4 +- .../webapp/WEB-INF/jsp/editSingleFeed.jsp | 41 +++++++++++-- .../webapp/WEB-INF/jsp/helpSingleFeed.jsp | 41 +++++++++++++ .../webapp/WEB-INF/jsp/viewSingleFeed.jsp | 12 +++- 15 files changed, 259 insertions(+), 33 deletions(-) create mode 100644 .gitignore create mode 100644 src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/HelpController.java create mode 100644 src/main/webapp/WEB-INF/jsp/helpSingleFeed.jsp diff --git a/.classpath b/.classpath index 6c79bc87..e56b1e8b 100644 --- a/.classpath +++ b/.classpath @@ -1,9 +1,15 @@ - - - - + + + + + + + + + + - + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..58e1e061 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# Project Files # +.cvsignore +.project +*.project +.settings +*.classpath + +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +target +bin + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +ehthumbs.db +Icon? +Thumbs.db +======= +.classpath +!/.project +.project +.settings +target +*.ipr +*.iml +*.iws +*.class +.idea/ +.DS_Store +.idea +overlays/ +pom.xml.versionsBackup \ No newline at end of file diff --git a/.project b/.project index c3dea684..92b92f13 100644 --- a/.project +++ b/.project @@ -5,6 +5,16 @@ + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.common.project.facet.core.builder + + + org.maven.ide.eclipse.maven2Builder @@ -15,9 +25,24 @@ + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature org.maven.ide.eclipse.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.jsdt.core.jsNature diff --git a/src/main/java/org/jasig/portlet/newsreader/Preference.java b/src/main/java/org/jasig/portlet/newsreader/Preference.java index b9f0b3c9..abd7138d 100644 --- a/src/main/java/org/jasig/portlet/newsreader/Preference.java +++ b/src/main/java/org/jasig/portlet/newsreader/Preference.java @@ -20,9 +20,12 @@ package org.jasig.portlet.newsreader; public class Preference { - public static final String MAX_STORIES = "maxStories"; - public static final String SUMMARY_VIEW_STYLE = "summaryView"; - public static final String NEW_WINDOW = "newWindow"; + public static final String MAX_STORIES = "maxStories"; + public static final String SUMMARY_VIEW_STYLE = "summaryView"; + public static final String NEW_WINDOW = "newWindow"; + public static final String CLASS_NAME = "className"; + public static final String FFED_NAME = "name"; + public static final String FEED_URL = "url"; private String value; private Object options; diff --git a/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/reader/HelpController.java b/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/reader/HelpController.java index 86c67825..aa4bd3ab 100644 --- a/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/reader/HelpController.java +++ b/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/reader/HelpController.java @@ -26,7 +26,7 @@ @RequestMapping("HELP") public class HelpController { - @RequestMapping + @RequestMapping public String getHelpView() { return "help"; } diff --git a/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/EditSingleFeedPreferencesController.java b/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/EditSingleFeedPreferencesController.java index 46e23eb1..56318307 100644 --- a/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/EditSingleFeedPreferencesController.java +++ b/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/EditSingleFeedPreferencesController.java @@ -40,6 +40,8 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.portlet.ModelAndView; +import org.springframework.web.portlet.bind.annotation.ActionMapping; +import org.springframework.web.portlet.bind.annotation.RenderMapping; @Controller @RequestMapping("EDIT") @@ -63,7 +65,7 @@ public void afterPropertiesSet() throws Exception { } - @RequestMapping + @RenderMapping protected ModelAndView showForm(RenderRequest request, RenderResponse response) throws Exception { log.trace("handleRenderRequestInternal"); @@ -72,6 +74,21 @@ protected ModelAndView showForm(RenderRequest request, RenderResponse response) PortletPreferences preferences = request.getPreferences(); Map model = new HashMap(); + Preference name = new Preference(); + name.setValue(preferences.getValue(Preference.FFED_NAME, "")); + name.setReadOnly(preferences.isReadOnly(Preference.FFED_NAME)); + model.put("name", name); + + Preference url = new Preference(); + url.setValue(preferences.getValue(Preference.FEED_URL, "")); + url.setReadOnly(preferences.isReadOnly(Preference.FEED_URL)); + model.put("url", url); + + Preference className = new Preference(); + className.setValue(preferences.getValue(Preference.CLASS_NAME, "")); + className.setReadOnly(preferences.isReadOnly(Preference.CLASS_NAME)); + model.put("className", className); + Preference max = new Preference(); max.setOptions(optionsMaxStories); max.setValue(preferences.getValue(Preference.MAX_STORIES, "")); @@ -94,7 +111,7 @@ protected ModelAndView showForm(RenderRequest request, RenderResponse response) } - @RequestMapping + @ActionMapping public Map savePreference(ActionRequest request, ActionResponse response) throws Exception { diff --git a/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/HelpController.java b/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/HelpController.java new file mode 100644 index 00000000..75da6a1c --- /dev/null +++ b/src/main/java/org/jasig/portlet/newsreader/mvc/portlet/singlefeed/HelpController.java @@ -0,0 +1,34 @@ +/** + * Licensed to Jasig under one or more contributor license + * agreements. See the NOTICE file distributed with this work + * for additional information regarding copyright ownership. + * Jasig licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a + * copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.jasig.portlet.newsreader.mvc.portlet.singlefeed; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("HELP") +public class HelpController { + + @RequestMapping + public String getHelpView() { + return "helpSingleFeed"; + } + +} diff --git a/src/main/webapp/WEB-INF/context/applicationContext.xml b/src/main/webapp/WEB-INF/context/applicationContext.xml index 5883d5e0..06524d50 100644 --- a/src/main/webapp/WEB-INF/context/applicationContext.xml +++ b/src/main/webapp/WEB-INF/context/applicationContext.xml @@ -27,10 +27,10 @@ xmlns:util="http://www.springframework.org/schema/util" xmlns:ehcache="http://www.springmodules.org/schema/ehcache" xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> diff --git a/src/main/webapp/WEB-INF/context/portlet/news.xml b/src/main/webapp/WEB-INF/context/portlet/news.xml index 4f1ac6e5..f06ed9f1 100644 --- a/src/main/webapp/WEB-INF/context/portlet/news.xml +++ b/src/main/webapp/WEB-INF/context/portlet/news.xml @@ -25,9 +25,9 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> @@ -43,4 +43,6 @@ + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/context/portlet/single-feed.xml b/src/main/webapp/WEB-INF/context/portlet/single-feed.xml index 06a96de5..f96cbfee 100644 --- a/src/main/webapp/WEB-INF/context/portlet/single-feed.xml +++ b/src/main/webapp/WEB-INF/context/portlet/single-feed.xml @@ -25,9 +25,9 @@ xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd - http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> @@ -35,5 +35,6 @@ - + + diff --git a/src/main/webapp/WEB-INF/context/servlet/ajaxResponseServletContext.xml b/src/main/webapp/WEB-INF/context/servlet/ajaxResponseServletContext.xml index 6b1929ba..ce66028e 100644 --- a/src/main/webapp/WEB-INF/context/servlet/ajaxResponseServletContext.xml +++ b/src/main/webapp/WEB-INF/context/servlet/ajaxResponseServletContext.xml @@ -23,8 +23,8 @@ + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> diff --git a/src/main/webapp/WEB-INF/jsp/editSingleFeed.jsp b/src/main/webapp/WEB-INF/jsp/editSingleFeed.jsp index 850ad899..01ef6475 100644 --- a/src/main/webapp/WEB-INF/jsp/editSingleFeed.jsp +++ b/src/main/webapp/WEB-INF/jsp/editSingleFeed.jsp @@ -20,13 +20,13 @@ --%> - + - - -

Preferences

+ + +
+ + +
+ +
+ + +
+ +
+ + +
+