Mercurial > hg > LGServices
view src/main/java/de/mpiwg/web/jsp/SessionBean.java @ 27:3b3e2963c8f7 dev_dataverse4
new: rewrite LGServices for LGDataverse with the new dataverse, dataverse4.0
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Sep 2015 16:33:31 +0200 |
parents | ce2e3f2814c0 |
children | ab2fae5c5156 |
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.log4j.Logger; import de.mpiwg.gazetteer.dataverse.DataverseUtils; import de.mpiwg.gazetteer.dataverse.bo.VDCUser; 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(); 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.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){ // check userGroups List<String> theUserGroups = new ArrayList<String>(); theUserGroups.add("mpiwg"); theUserGroups.add("nuist"); // test theUserGroups.add("mygroup2"); if (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; } }