diff src/main/java/de/mpiwg/web/jsp/JSPProxy.java @ 43:9dbbbfd474f4

new: 1.existing topic in search result. 2.difference-set of book for topic
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 23 Dec 2015 16:03:32 +0100
parents 815cd86bb9ec
children 13555aff1f88
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/web/jsp/JSPProxy.java	Fri Dec 18 11:50:24 2015 +0100
+++ b/src/main/java/de/mpiwg/web/jsp/JSPProxy.java	Wed Dec 23 16:03:32 2015 +0100
@@ -28,6 +28,28 @@
 		
 		try{
 			
+			
+			if(StringUtils.equals(bean, "loginBean")){
+				getSessionBean().loadParameters(request, response);
+			
+				if(StringUtils.equals(action, "login")){
+					getSessionBean().login();
+				}else if(StringUtils.equals(action, "logout")){
+					getSessionBean().logout();
+				}
+				return TopicListPage.page;	// the new home page
+				//return "pages/home.jsp";
+				
+			} else if (getSessionBean() == null || getSessionBean().getUser() == null) {
+				// return to home page where will ask user to login.
+				
+				// alert session timeout
+				getSessionBean().addMsg("Timeout or Logout at another page! Please login again.");
+				
+				return TopicListPage.page;	// the new home page
+			}
+		
+			
 			if(StringUtils.equals(bean, BranchPage.bean)){
 				
 				getSessionBean().getBranchPage().loadParameters(request, response);
@@ -133,18 +155,7 @@
 				
 				return HomePage.page;
 				
-			}else if(StringUtils.equals(bean, "loginBean")){
-				getSessionBean().loadParameters(request, response);
-				
-				if(StringUtils.equals(action, "login")){
-					getSessionBean().login();
-				}else if(StringUtils.equals(action, "logout")){
-					getSessionBean().logout();
-				}
-				
-				return TopicListPage.page;
-				//return "pages/home.jsp";
-				
+			
 			}else if(StringUtils.equals(bean, SearchPage.bean)){
 				getSessionBean().getSearchPage().loadParameters(request, response);
 				
@@ -334,6 +345,11 @@
 					getSessionBean().getTopicPage().updateDescription();
 					getSessionBean().getTopicListPage().forceLoadTopics();
 					
+				} else if( StringUtils.equals(action ,"updateKeywords")) {
+					getSessionBean().getTopicPage().updateKeywords();
+					getSessionBean().getTopicListPage().forceLoadTopics();
+			
+					
 				/* ====== */
 					
 					
@@ -341,13 +357,20 @@
 					getSessionBean().getTopicPage().deleteSection(getLongParameter("sectionId"));
 				
 				
-				} else if(StringUtils.equals(action, "addSectionToTopic")) {
+				} else if(StringUtils.equals(action, "addSection")) {
 					Long selectedSectionId = getLongParameter("selectedSectionId");
 					Long selectedTopicId = getLongParameter("selectedTopicId");
+					getSessionBean().getTopicPage().addSectionToTopic(selectedSectionId, selectedTopicId);
+					getSessionBean().getSearchPage().updateTopicSectionRelation();
 					
-					getSessionBean().getTopicPage().addSectionToTopic(selectedSectionId, selectedTopicId);
 					return SearchPage.page;
+				
+				} else if(StringUtils.equals(action, "addAllSections")) {
+					Long selectedTopicId = getLongParameter("selectedTopicId");
+					getSessionBean().getTopicPage().addAllSectionsToTopic(getSessionBean().getSearchPage().getFilteredSectionList(), selectedTopicId);
+					getSessionBean().getSearchPage().updateTopicSectionRelation();
 					
+					return SearchPage.page;
 					
 					
 				//SORTING