NIHVIVO-1207 Create unit tests for Authenticate. The UserDaoStub and WebappDaoFactoryStub are created here instead of their usual location, because I plan to factor them out.
This commit is contained in:
parent
631870cad2
commit
d9ea7672df
3 changed files with 764 additions and 0 deletions
|
@ -0,0 +1,412 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State.FORCED_PASSWORD_CHANGE;
|
||||||
|
import static edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State.LOGGING_IN;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import stubs.javax.servlet.ServletConfigStub;
|
||||||
|
import stubs.javax.servlet.ServletContextStub;
|
||||||
|
import stubs.javax.servlet.http.HttpServletRequestStub;
|
||||||
|
import stubs.javax.servlet.http.HttpServletResponseStub;
|
||||||
|
import stubs.javax.servlet.http.HttpSessionStub;
|
||||||
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
|
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.User;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
public class AuthenticateTest extends AbstractTestClass {
|
||||||
|
private static final String USER_DBA_NAME = "dbaName";
|
||||||
|
private static final String USER_DBA_URI = "dbaURI";
|
||||||
|
private static final String USER_DBA_PASSWORD = "dbaPassword";
|
||||||
|
|
||||||
|
private static final String USER_OLDHAND_NAME = "oldHandName";
|
||||||
|
private static final String USER_OLDHAND_URI = "oldHandURI";
|
||||||
|
private static final String USER_OLDHAND_PASSWORD = "oldHandPassword";
|
||||||
|
|
||||||
|
private static final String URL_LOGIN_PAGE = Controllers.LOGIN
|
||||||
|
+ "?login=block";
|
||||||
|
private static final String URL_SITE_ADMIN_PAGE = Controllers.SITE_ADMIN
|
||||||
|
+ "?login=block";
|
||||||
|
private static final String URL_HOME_PAGE = "";
|
||||||
|
private static final String URL_SESSION_REDIRECT = "/sessionRedirect";
|
||||||
|
private static final String URL_CONTEXT_REDIRECT_LOCAL = "/servletContextRedirect";
|
||||||
|
private static final String URL_CONTEXT_REDIRECT_REMOTE = "http://servletContextRedirect";
|
||||||
|
private static final String URL_SELF_EDITOR_PAGE = "/individual?uri=selfEditorURI";
|
||||||
|
|
||||||
|
private static final LoginStatusBean LOGIN_STATUS_DBA = new LoginStatusBean(
|
||||||
|
USER_DBA_URI, USER_DBA_NAME, LoginStatusBean.DBA);
|
||||||
|
|
||||||
|
private static final LoginStatusBean LOGIN_STATUS_OLDHAND = new LoginStatusBean(
|
||||||
|
USER_OLDHAND_URI, USER_OLDHAND_NAME, LoginStatusBean.NON_EDITOR);
|
||||||
|
|
||||||
|
private UserDaoStub userDao;
|
||||||
|
private WebappDaoFactoryStub webappDaoFactory;
|
||||||
|
private ServletContextStub servletContext;
|
||||||
|
private ServletConfigStub servletConfig;
|
||||||
|
private HttpSessionStub session;
|
||||||
|
private HttpServletRequestStub request;
|
||||||
|
private HttpServletResponseStub response;
|
||||||
|
private Authenticate auth;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() throws MalformedURLException, ServletException {
|
||||||
|
User dbaUser = new User();
|
||||||
|
dbaUser.setUsername(USER_DBA_NAME);
|
||||||
|
dbaUser.setURI(USER_DBA_URI);
|
||||||
|
dbaUser.setRoleURI("50");
|
||||||
|
dbaUser.setMd5password(Authenticate.applyMd5Encoding(USER_DBA_PASSWORD));
|
||||||
|
|
||||||
|
User ohUser = new User();
|
||||||
|
ohUser.setUsername(USER_OLDHAND_NAME);
|
||||||
|
ohUser.setURI(USER_OLDHAND_URI);
|
||||||
|
ohUser.setRoleURI("1");
|
||||||
|
ohUser.setMd5password(Authenticate
|
||||||
|
.applyMd5Encoding(USER_OLDHAND_PASSWORD));
|
||||||
|
ohUser.setLoginCount(100);
|
||||||
|
|
||||||
|
userDao = new UserDaoStub();
|
||||||
|
userDao.addUser(dbaUser);
|
||||||
|
userDao.addUser(ohUser);
|
||||||
|
|
||||||
|
webappDaoFactory = new WebappDaoFactoryStub();
|
||||||
|
webappDaoFactory.setUserDao(userDao);
|
||||||
|
|
||||||
|
servletContext = new ServletContextStub();
|
||||||
|
servletContext.setAttribute("webappDaoFactory", webappDaoFactory);
|
||||||
|
|
||||||
|
servletConfig = new ServletConfigStub();
|
||||||
|
servletConfig.setServletContext(servletContext);
|
||||||
|
|
||||||
|
session = new HttpSessionStub();
|
||||||
|
session.setServletContext(servletContext);
|
||||||
|
|
||||||
|
request = new HttpServletRequestStub();
|
||||||
|
request.setSession(session);
|
||||||
|
request.setRequestUrl(new URL("http://this.that/vivo/siteAdmin"));
|
||||||
|
request.setMethod("POST");
|
||||||
|
|
||||||
|
response = new HttpServletResponseStub();
|
||||||
|
|
||||||
|
auth = new Authenticate();
|
||||||
|
auth.init(servletConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void alreadyLoggedIn() {
|
||||||
|
LoginStatusBean.setBean(session, LOGIN_STATUS_DBA);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoProcessBean();
|
||||||
|
assertExpectedStatusBean(LOGIN_STATUS_DBA);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void justGotHere() {
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
|
||||||
|
// TODO Surprise! if no session, we get this:
|
||||||
|
// assertNoLoginProcessBean();
|
||||||
|
|
||||||
|
// TODO Surprise! if there is a session, we would have expected this:
|
||||||
|
// assertExpectedLoginProcessBean(LOGGING_IN, "", "", "");
|
||||||
|
|
||||||
|
// TODO Surprise! but we get this:
|
||||||
|
assertExpectedProcessBean(State.NOWHERE, "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loggingInNoUsername() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(LOGGING_IN, "", "",
|
||||||
|
"Please enter your email address.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loggingInUsernameNotRecognized() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
setLoginNameAndPassword("unknownBozo", null);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(LOGGING_IN, "unknownBozo", "",
|
||||||
|
"The email or password you entered is incorrect.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loggingInNoPassword() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
setLoginNameAndPassword(USER_DBA_NAME, null);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(LOGGING_IN, USER_DBA_NAME, "",
|
||||||
|
"Please enter your password.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loggingInPasswordIsIncorrect() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
setLoginNameAndPassword(USER_DBA_NAME, "bogus_password");
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(LOGGING_IN, USER_DBA_NAME, "",
|
||||||
|
"The email or password you entered is incorrect.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loggingInSuccessfulNotFirstTime() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
setLoginNameAndPassword(USER_OLDHAND_NAME, USER_OLDHAND_PASSWORD);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertExpectedStatusBean(LOGIN_STATUS_OLDHAND);
|
||||||
|
assertNoProcessBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// first-time password change
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void loggingInSuccessfulFirstTime() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
setLoginNameAndPassword(USER_DBA_NAME, USER_DBA_PASSWORD);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME, "", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changingPasswordCancel() {
|
||||||
|
setProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME);
|
||||||
|
request.addParameter("cancel", "true");
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_HOME_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertNoProcessBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changingPasswordWrongLength() {
|
||||||
|
setProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME);
|
||||||
|
setNewPasswordAttempt("HI", "HI");
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME, "",
|
||||||
|
"Please enter a password between 6 and 12 characters in length.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changingPasswordDontMatch() {
|
||||||
|
setProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME);
|
||||||
|
setNewPasswordAttempt("LongEnough", "DoesNotMatch");
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME, "",
|
||||||
|
"The passwords entered do not match.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changingPasswordSameAsBefore() {
|
||||||
|
setProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME);
|
||||||
|
setNewPasswordAttempt(USER_DBA_PASSWORD, USER_DBA_PASSWORD);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertNoStatusBean();
|
||||||
|
assertExpectedProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME, "",
|
||||||
|
"Please choose a different password from the "
|
||||||
|
+ "temporary one provided initially.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changingPasswordSuccess() {
|
||||||
|
setProcessBean(FORCED_PASSWORD_CHANGE, USER_DBA_NAME);
|
||||||
|
setNewPasswordAttempt("NewPassword", "NewPassword");
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedRedirect(URL_LOGIN_PAGE);
|
||||||
|
assertExpectedStatusBean(LOGIN_STATUS_DBA);
|
||||||
|
assertNoProcessBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Assorted redirects: these assume a successful non-first-time login.
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void redirectOnSession() {
|
||||||
|
session.setAttribute("postLoginRequest", URL_SESSION_REDIRECT);
|
||||||
|
loginNotFirstTime();
|
||||||
|
assertExpectedLiteralRedirect(URL_SESSION_REDIRECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void redirectOnServletContext() {
|
||||||
|
servletContext.setAttribute("postLoginRequest",
|
||||||
|
URL_CONTEXT_REDIRECT_LOCAL);
|
||||||
|
loginNotFirstTime();
|
||||||
|
assertExpectedRedirect(URL_CONTEXT_REDIRECT_LOCAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void redirectOnServletContextToExternalUrl() {
|
||||||
|
servletContext.setAttribute("postLoginRequest",
|
||||||
|
URL_CONTEXT_REDIRECT_REMOTE);
|
||||||
|
loginNotFirstTime();
|
||||||
|
assertExpectedLiteralRedirect(URL_CONTEXT_REDIRECT_REMOTE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void redirectSelfEditor() {
|
||||||
|
userDao.setIndividualsUserMayEditAs(USER_OLDHAND_URI,
|
||||||
|
Collections.singletonList("selfEditorURI"));
|
||||||
|
loginNotFirstTime();
|
||||||
|
assertExpectedRedirect(URL_SELF_EDITOR_PAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void redirectNoneOfTheAbove() {
|
||||||
|
loginNotFirstTime();
|
||||||
|
assertExpectedRedirect(URL_SITE_ADMIN_PAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// helper methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private void setProcessBean(State state) {
|
||||||
|
LoginProcessBean processBean = new LoginProcessBean();
|
||||||
|
processBean.setState(state);
|
||||||
|
session.setAttribute(LoginProcessBean.SESSION_ATTRIBUTE, processBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setProcessBean(State state, String username) {
|
||||||
|
LoginProcessBean processBean = new LoginProcessBean();
|
||||||
|
processBean.setState(state);
|
||||||
|
processBean.setUsername(username);
|
||||||
|
session.setAttribute(LoginProcessBean.SESSION_ATTRIBUTE, processBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setLoginNameAndPassword(String loginName, String password) {
|
||||||
|
request.addParameter("loginName", loginName);
|
||||||
|
request.addParameter("loginPassword", password);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setNewPasswordAttempt(String newPassword,
|
||||||
|
String confirmPassword) {
|
||||||
|
request.addParameter("newPassword", newPassword);
|
||||||
|
request.addParameter("confirmPassword", confirmPassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertExpectedRedirect(String path) {
|
||||||
|
assertEquals("redirect", request.getContextPath() + path,
|
||||||
|
response.getRedirectLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This is for explicit redirect URLs that already include context. */
|
||||||
|
private void assertExpectedLiteralRedirect(String path) {
|
||||||
|
assertEquals("redirect", path, response.getRedirectLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertNoProcessBean() {
|
||||||
|
assertNull(session.getAttribute(LoginProcessBean.SESSION_ATTRIBUTE));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertExpectedProcessBean(State state, String username,
|
||||||
|
String infoMessage, String errorMessage) {
|
||||||
|
LoginProcessBean bean = (LoginProcessBean) session
|
||||||
|
.getAttribute(LoginProcessBean.SESSION_ATTRIBUTE);
|
||||||
|
assertNotNull("login process bean", bean);
|
||||||
|
assertEquals("state", state, bean.getState());
|
||||||
|
assertEquals("info message", infoMessage, bean.getInfoMessage());
|
||||||
|
assertEquals("error message", errorMessage, bean.getErrorMessage());
|
||||||
|
assertEquals("username", username, bean.getUsername());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertNoStatusBean() {
|
||||||
|
assertNull(session.getAttribute("loginStatus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertExpectedStatusBean(LoginStatusBean expected) {
|
||||||
|
LoginStatusBean bean = (LoginStatusBean) session
|
||||||
|
.getAttribute("loginStatus");
|
||||||
|
assertNotNull("login status bean", bean);
|
||||||
|
assertEquals("user URI", expected.getUserURI(), bean.getUserURI());
|
||||||
|
assertEquals("user name", expected.getUsername(), bean.getUsername());
|
||||||
|
assertEquals("security level", expected.getSecurityLevel(),
|
||||||
|
bean.getSecurityLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Boilerplate login process for the rediret tests. */
|
||||||
|
private void loginNotFirstTime() {
|
||||||
|
setProcessBean(LOGGING_IN);
|
||||||
|
setLoginNameAndPassword(USER_OLDHAND_NAME, USER_OLDHAND_PASSWORD);
|
||||||
|
|
||||||
|
auth.doPost(request, response);
|
||||||
|
|
||||||
|
assertExpectedStatusBean(LOGIN_STATUS_OLDHAND);
|
||||||
|
assertNoProcessBean();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private void showBeans() {
|
||||||
|
LoginProcessBean processBean = (LoginProcessBean) session
|
||||||
|
.getAttribute(LoginProcessBean.SESSION_ATTRIBUTE);
|
||||||
|
System.out.println("LoginProcessBean=" + processBean);
|
||||||
|
LoginStatusBean statusBean = (LoginStatusBean) session
|
||||||
|
.getAttribute("loginStatus");
|
||||||
|
System.out.println("LoginStatusBean=" + statusBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.User;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
|
||||||
|
|
||||||
|
public class UserDaoStub implements UserDao {
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Stub infrastructure
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private Map<String, User> usersByUsername = new HashMap<String, User>();
|
||||||
|
private Map<String, List<String>> individualsUserMayEditAs = new HashMap<String, List<String>>();
|
||||||
|
|
||||||
|
public void addUser(User user) {
|
||||||
|
usersByUsername.put(user.getUsername(), user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndividualsUserMayEditAs(String userUri, List<String> uriList) {
|
||||||
|
individualsUserMayEditAs.put(userUri, uriList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Stub methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUserByUsername(String username) {
|
||||||
|
return usersByUsername.get(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does nothing for now. Do we need to record that the user has been
|
||||||
|
* updated?
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateUser(User user) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getIndividualsUserMayEditAs(String userURI) {
|
||||||
|
if (individualsUserMayEditAs.containsKey(userURI)) {
|
||||||
|
return individualsUserMayEditAs.get(userURI);
|
||||||
|
} else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Un-implemented methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public User getUserByURI(String URI) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getUserByURI() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<User> getAllUsers() {
|
||||||
|
throw new RuntimeException("UserDaoStub.getAllUsers() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String insertUser(User user) {
|
||||||
|
throw new RuntimeException("UserDaoStub.insertUser() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteUser(User user) {
|
||||||
|
throw new RuntimeException("UserDaoStub.deleteUser() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getUserAccountEmails() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getUserAccountEmails() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserEmailAddress(String userURI) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserDaoStub.getUserEmailAddress() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,260 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.edit;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.ApplicationDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.Classes2ClassesDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.FlagDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.PortalDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.TabDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.TabIndividualRelationDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.TabVClassRelationDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.UserDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple stub for the WebappDaoFactory.
|
||||||
|
*/
|
||||||
|
public class WebappDaoFactoryStub implements WebappDaoFactory {
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Stub infrastructure
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
private UserDao userDao;
|
||||||
|
|
||||||
|
public void setUserDao(UserDao userDao) {
|
||||||
|
this.userDao = userDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Stub methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserDao getUserDao() {
|
||||||
|
return userDao;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Un-implemented methods
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getProperties() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getProperties() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String checkURI(String uriStr) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.checkURI() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String checkURI(String uriStr, boolean checkUniqueness) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.checkURI() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLanguageProfile() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getLanguageProfile() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDefaultNamespace() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getDefaultNamespace() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getNonuserNamespaces() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getNonuserNamespaces() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getPreferredLanguages() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getPreferredLanguages() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getCommentsForResource(String resourceURI) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getCommentsForResource() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WebappDaoFactory getUserAwareDaoFactory(String userURI) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getUserAwareDaoFactory() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUserURI() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getUserURI() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Classes2ClassesDao getClasses2ClassesDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getClasses2ClassesDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataPropertyDao getDataPropertyDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getDataPropertyDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatatypeDao getDatatypeDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getDatatypeDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectPropertyDao getObjectPropertyDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getObjectPropertyDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OntologyDao getOntologyDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getOntologyDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VClassDao getVClassDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getVClassDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataPropertyStatementDao getDataPropertyStatementDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getDataPropertyStatementDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IndividualDao getIndividualDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getIndividualDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectPropertyStatementDao getObjectPropertyStatementDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getObjectPropertyStatementDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationDao getApplicationDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getApplicationDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PortalDao getPortalDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getPortalDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TabDao getTabDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getTabDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TabIndividualRelationDao getTabs2EntsDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getTabs2EntsDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TabVClassRelationDao getTabs2TypesDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getTabs2TypesDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeywordIndividualRelationDao getKeys2EntsDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getKeys2EntsDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KeywordDao getKeywordDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getKeywordDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LinksDao getLinksDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getLinksDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LinktypeDao getLinktypeDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getLinktypeDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FlagDao getFlagDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getFlagDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VClassGroupDao getVClassGroupDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getVClassGroupDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyGroupDao getPropertyGroupDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getPropertyGroupDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NamespaceDao getNamespaceDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getNamespaceDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PropertyInstanceDao getPropertyInstanceDao() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"WebappDaoFactoryStub.getPropertyInstanceDao() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue