Clean up unused code.
This commit is contained in:
parent
579ce5fdd8
commit
dfa7e6e2ea
1 changed files with 35 additions and 53 deletions
|
@ -35,9 +35,9 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
|
|
||||||
/** If they are changing their password on first login, show them this form. */
|
/** If they are changing their password on first login, show them this form. */
|
||||||
public static final String TEMPLATE_FORCE_PASSWORD_CHANGE = "login-forcedPasswordChange.ftl";
|
public static final String TEMPLATE_FORCE_PASSWORD_CHANGE = "login-forcedPasswordChange.ftl";
|
||||||
|
|
||||||
/** Show error message */
|
/** Show error message */
|
||||||
public static final String TEMPLATE_SERVER_ERROR = Template.ERROR_MESSAGE.toString();
|
public static final String TEMPLATE_SERVER_ERROR = Template.ERROR_MESSAGE.toString();
|
||||||
|
|
||||||
public static final String BODY_LOGIN_NAME = "loginName";
|
public static final String BODY_LOGIN_NAME = "loginName";
|
||||||
public static final String BODY_FORM_ACTION = "formAction";
|
public static final String BODY_FORM_ACTION = "formAction";
|
||||||
|
@ -45,18 +45,14 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
public static final String BODY_ERROR_MESSAGE = "errorMessage";
|
public static final String BODY_ERROR_MESSAGE = "errorMessage";
|
||||||
public static final String BODY_CANCEL_URL = "cancelUrl";
|
public static final String BODY_CANCEL_URL = "cancelUrl";
|
||||||
|
|
||||||
/** If no portal is specified in the request, use this one. */
|
|
||||||
private static final int DEFAULT_PORTAL_ID = 1;
|
|
||||||
|
|
||||||
public LoginTemplateHelper(HttpServletRequest req) {
|
public LoginTemplateHelper(HttpServletRequest req) {
|
||||||
super(req);
|
super(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Version for JSP page */
|
/** Version for JSP page */
|
||||||
public String showLoginPage(HttpServletRequest request) {
|
public String showLoginPage(HttpServletRequest request) {
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
State state = getCurrentLoginState(vreq);
|
State state = getCurrentLoginState(vreq);
|
||||||
log.debug("State on exit: " + state);
|
log.debug("State on exit: " + state);
|
||||||
|
|
||||||
|
@ -70,35 +66,34 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
return doTemplate(vreq, showError(request, e));
|
return doTemplate(vreq, showError(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Version for Freemarker page */
|
/** Version for Freemarker page */
|
||||||
public TemplateResponseValues showLoginPanel(VitroRequest vreq) {
|
public TemplateResponseValues showLoginPanel(VitroRequest vreq) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
State state = getCurrentLoginState(vreq);
|
State state = getCurrentLoginState(vreq);
|
||||||
log.debug("State on exit: " + state);
|
log.debug("State on exit: " + state);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
// RY Why does this case exist? We don't call this method if a user is logged in.
|
// RY Why does this case exist? We don't call this method if a user is logged in.
|
||||||
case LOGGED_IN:
|
case LOGGED_IN:
|
||||||
return null;
|
return null;
|
||||||
case FORCED_PASSWORD_CHANGE:
|
case FORCED_PASSWORD_CHANGE:
|
||||||
//return doTemplate(vreq, showPasswordChangeScreen(vreq), body, config);
|
// return doTemplate(vreq, showPasswordChangeScreen(vreq), body, config);
|
||||||
return showPasswordChangeScreen(vreq);
|
return showPasswordChangeScreen(vreq);
|
||||||
default:
|
default:
|
||||||
//return doTemplate(vreq, showLoginScreen(vreq), body, config);
|
// return doTemplate(vreq, showLoginScreen(vreq), body, config);
|
||||||
return showLoginScreen(vreq);
|
return showLoginScreen(vreq);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
return showError(vreq, e);
|
return showError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User is just starting the login process. Be sure that we have a
|
* User is just starting the login process. Be sure that we have a
|
||||||
* {@link LoginProcessBean} with the correct status. Show them the login
|
* {@link LoginProcessBean} with the correct status. Show them the login
|
||||||
|
@ -122,7 +117,7 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
trv.put(BODY_ERROR_MESSAGE, errorMessage);
|
trv.put(BODY_ERROR_MESSAGE, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
return trv;
|
return trv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,17 +141,17 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
}
|
}
|
||||||
return trv;
|
return trv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateResponseValues showError(HttpServletRequest request, Exception e) {
|
private TemplateResponseValues showError(Exception e) {
|
||||||
TemplateResponseValues trv = new TemplateResponseValues(
|
TemplateResponseValues trv = new TemplateResponseValues(
|
||||||
TEMPLATE_SERVER_ERROR);
|
TEMPLATE_SERVER_ERROR);
|
||||||
trv.put(BODY_ERROR_MESSAGE, "Internal server error:<br /> " + e);
|
trv.put(BODY_ERROR_MESSAGE, "Internal server error:<br /> " + e);
|
||||||
return trv;
|
return trv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We processed a response, and want to show a template.
|
* We processed a response, and want to show a template. Version for JSP
|
||||||
* Version for JSP page.
|
* page.
|
||||||
*/
|
*/
|
||||||
private String doTemplate(VitroRequest vreq, TemplateResponseValues values) {
|
private String doTemplate(VitroRequest vreq, TemplateResponseValues values) {
|
||||||
// Set it up like FreeMarkerHttpServlet.doGet() would do.
|
// Set it up like FreeMarkerHttpServlet.doGet() would do.
|
||||||
|
@ -164,14 +159,13 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
Map<String, Object> sharedVariables = getSharedVariables(vreq, new HashMap<String, Object>());
|
Map<String, Object> sharedVariables = getSharedVariables(vreq, new HashMap<String, Object>());
|
||||||
Map<String, Object> root = new HashMap<String, Object>(sharedVariables);
|
Map<String, Object> root = new HashMap<String, Object>(sharedVariables);
|
||||||
Map<String, Object> body = new HashMap<String, Object>(sharedVariables);
|
Map<String, Object> body = new HashMap<String, Object>(sharedVariables);
|
||||||
root.putAll(getRootValues(vreq));
|
root.putAll(getRootValues(vreq));
|
||||||
|
|
||||||
// Add the values that we got, and merge to the template.
|
// Add the values that we got, and merge to the template.
|
||||||
body.putAll(values.getMap());
|
body.putAll(values.getMap());
|
||||||
return mergeMapToTemplate(values.getTemplateName(), body, config);
|
return mergeMapToTemplate(values.getTemplateName(), body, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where are we in the process? Logged in? Not? Somewhere in between?
|
* Where are we in the process? Logged in? Not? Somewhere in between?
|
||||||
*/
|
*/
|
||||||
|
@ -213,16 +207,4 @@ public class LoginTemplateHelper extends LoginTemplateHelperBase {
|
||||||
String urlParams = "?login=block&cancel=true";
|
String urlParams = "?login=block&cancel=true";
|
||||||
return contextPath + "/authenticate" + urlParams;
|
return contextPath + "/authenticate" + urlParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* What portal are we currently in?
|
|
||||||
*/
|
|
||||||
private String getPortalIdString(HttpServletRequest request) {
|
|
||||||
String portalIdParameter = request.getParameter("home");
|
|
||||||
if (portalIdParameter == null) {
|
|
||||||
return String.valueOf(DEFAULT_PORTAL_ID);
|
|
||||||
} else {
|
|
||||||
return portalIdParameter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue