Mercurial > hg > LGServices
view src/main/java/de/mpiwg/web/jsp/SessionBean.java @ 54:a00efd5d9e77
new: adding delete saved table function
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 04 Feb 2016 11:30:46 +0100 |
parents | db2088ac1f50 |
children | b8ad346e39a0 |
line wrap: on
line source
package de.mpiwg.web.jsp; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import de.mpiwg.gazetteer.dataverse.DataverseUtils; import de.mpiwg.gazetteer.dataverse.bo.VDCUser; import de.mpiwg.gazetteer.utils.DataProvider; public class SessionBean extends AbstractJSPPage { private static Logger logger = Logger.getLogger(SessionBean.class); public static final String BEAN_NAME = "sessionBean"; private List<String> msgList = new ArrayList<String>(); private VDCUser user; private String userName; private String password; private String currentSectionId = "5190882"; private SearchPage searchPage = new SearchPage(); private HomePage homePage = new HomePage(); private CreateFilePage createFilePage = new CreateFilePage(); private BranchPage branchPage = new BranchPage(); private BooksPage booksPage = new BooksPage(); private FullTextSearchPage fullTextSearchPage = new FullTextSearchPage(); private TopicListPage topicListPage = new TopicListPage(); private TopicPage topicPage = new TopicPage(); public SessionBean(){ logger.info("\n\n### SessionBean #####\n\n"); } public void loadParameters(HttpServletRequest request, HttpServletResponse response){ this.request = request; this.response = response; this.userName = getParameter("userName"); this.password = getParameter("password"); } public void reset(){ this.user = null; this.searchPage = new SearchPage(); this.homePage = new HomePage(); this.createFilePage = new CreateFilePage(); this.branchPage = new BranchPage(); this.booksPage = new BooksPage(); this.fullTextSearchPage = new FullTextSearchPage(); this.topicListPage = new TopicListPage(); this.topicPage = new TopicPage(); this.userName = new String(); this.password = new String(); } public List<String> getMsgList() { return msgList; } public void setMsgList(List<String> msgList) { this.msgList = msgList; } public void resetMsgList(){ this.msgList = null; } public void logout(){ this.reset(); } public void login(){ try { this.user = DataverseUtils.login(userName, password); if(this.user != null){ List<String> theUserGroups = new ArrayList<String>(); theUserGroups.add("mpiwg"); theUserGroups.add("nuist"); // check if user has role in the "Chinese Local Gazetteers" Dataverse, rather than the following hardcoded checking // use dvn/getRoleAssignments?user=&password=&datasetId= if ( StringUtils.equals(userName, "dataverseAdmin") || DataverseUtils.isUserInLG(userName, password) || DataverseUtils.isUserInGroups(this.user.getUserName(), theUserGroups)){ this.user.setPassword(this.password); this.homePage.loadParameters(request, response); this.homePage.reloadBranches(); } else { this.user = null; addMsg("Please contact/email us to activate your account!"); } // ----- }else{ addMsg("User account not found, or username and password do not match!"); } } catch (Exception e) { internalError(e); } } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public VDCUser getUser() { return user; } public void setUser(VDCUser user) { this.user = user; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getCurrentSectionId() { return currentSectionId; } public void setCurrentSectionId(String currentSectionId) { this.currentSectionId = currentSectionId; } public SearchPage getSearchPage() { return searchPage; } public BooksPage getBooksPage(){ return booksPage; } public void setSearchPage(SearchPage searchPage) { this.searchPage = searchPage; } public HomePage getHomePage() { return homePage; } public void setHomePage(HomePage homePage) { this.homePage = homePage; } public CreateFilePage getCreateFilePage() { return createFilePage; } public void setCreateFilePage(CreateFilePage createFilePage) { this.createFilePage = createFilePage; } public BranchPage getBranchPage() { return branchPage; } public void setBranchPage(BranchPage branchPage) { this.branchPage = branchPage; } public FullTextSearchPage getFullTextSearchPage() { return fullTextSearchPage; } public void setFullTextSearchPage(FullTextSearchPage fullTextSearchPage) { this.fullTextSearchPage = fullTextSearchPage; } public TopicListPage getTopicListPage() { return topicListPage; } public void setTopicListPage(TopicListPage topicListPage) { this.topicListPage = topicListPage; } public TopicPage getTopicPage() { return topicPage; } public void setTopicPage(TopicPage topicPage) { this.topicPage = topicPage; } }