Reverting some changes from r6714 that were committed unintentionally
This commit is contained in:
parent
8cb70697a9
commit
55584d6be5
5 changed files with 41 additions and 37 deletions
|
@ -32,20 +32,20 @@ public class BrowseWidget extends Widget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WidgetTemplateValues process(Environment env, Map params,
|
protected WidgetTemplateValues process(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) throws Exception
|
HttpServletRequest request, ServletContext context) throws Exception
|
||||||
{
|
{
|
||||||
Mode mode = getMode( vreq, params );
|
Mode mode = getMode( request, params );
|
||||||
switch( mode ){
|
switch( mode ){
|
||||||
case VCLASS_ALPHA:
|
case VCLASS_ALPHA:
|
||||||
return doClassAlphaDisplay(env,params,vreq,context);
|
return doClassAlphaDisplay(env,params,request,context);
|
||||||
case CLASS_GROUP:
|
case CLASS_GROUP:
|
||||||
return doClassGroupDisplay(env, params, vreq, context);
|
return doClassGroupDisplay(env, params, request, context);
|
||||||
case VCLASS:
|
case VCLASS:
|
||||||
return doClassDisplay(env, params, vreq, context);
|
return doClassDisplay(env, params, request, context);
|
||||||
case ALL_CLASS_GROUPS:
|
case ALL_CLASS_GROUPS:
|
||||||
return doAllClassGroupsDisplay(env, params, vreq, context);
|
return doAllClassGroupsDisplay(env, params, request, context);
|
||||||
default:
|
default:
|
||||||
return doAllClassGroupsDisplay(env, params, vreq, context);
|
return doAllClassGroupsDisplay(env, params, request, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ public class BrowseWidget extends Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WidgetTemplateValues doAllClassGroupsDisplay(Environment env, Map params,
|
protected WidgetTemplateValues doAllClassGroupsDisplay(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) {
|
HttpServletRequest request, ServletContext context) {
|
||||||
Map<String,Object> body = getAllClassGroupData(vreq, params);
|
Map<String,Object> body = getAllClassGroupData(request, params);
|
||||||
try {
|
try {
|
||||||
body.put("urls",env.getDataModel().get("urls"));
|
body.put("urls",env.getDataModel().get("urls"));
|
||||||
body.put("urlMapping",env.getDataModel().get("urlMapping"));
|
body.put("urlMapping",env.getDataModel().get("urlMapping"));
|
||||||
|
@ -69,9 +69,10 @@ public class BrowseWidget extends Widget {
|
||||||
return new WidgetTemplateValues(macroName, body);
|
return new WidgetTemplateValues(macroName, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String,Object> getAllClassGroupData(VitroRequest vreq, Map params){
|
protected Map<String,Object> getAllClassGroupData(HttpServletRequest request, Map params){
|
||||||
Map<String,Object> map = new HashMap<String,Object>();
|
Map<String,Object> map = new HashMap<String,Object>();
|
||||||
|
|
||||||
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
List<VClassGroup> classGroups =
|
List<VClassGroup> classGroups =
|
||||||
vreq.getWebappDaoFactory().getVClassGroupDao().getPublicGroupsWithVClasses();
|
vreq.getWebappDaoFactory().getVClassGroupDao().getPublicGroupsWithVClasses();
|
||||||
|
|
||||||
|
@ -84,9 +85,9 @@ public class BrowseWidget extends Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WidgetTemplateValues doClassDisplay(Environment env, Map params,
|
protected WidgetTemplateValues doClassDisplay(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) {
|
HttpServletRequest request, ServletContext context) {
|
||||||
|
|
||||||
Map<String,Object> body = getClassData(vreq,params);
|
Map<String,Object> body = getClassData(request,params);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
body.put("urls",env.getDataModel().get("urls"));
|
body.put("urls",env.getDataModel().get("urls"));
|
||||||
|
@ -99,12 +100,13 @@ public class BrowseWidget extends Widget {
|
||||||
return new WidgetTemplateValues(macroName, body);
|
return new WidgetTemplateValues(macroName, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> getClassData(VitroRequest vreq, Map params) {
|
private Map<String, Object> getClassData(HttpServletRequest request, Map params) {
|
||||||
Map<String,Object> map = new HashMap<String,Object>();
|
Map<String,Object> map = new HashMap<String,Object>();
|
||||||
|
|
||||||
map.putAll(getClassGroupData(vreq, params));
|
map.putAll(getClassGroupData(request, params));
|
||||||
|
|
||||||
String classUri = getParam(Mode.VCLASS, vreq, params);
|
String classUri = getParam(Mode.VCLASS, request, params);
|
||||||
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
|
VClass vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(classUri);
|
||||||
map.put("class", new VClassTemplateModel(vclass));
|
map.put("class", new VClassTemplateModel(vclass));
|
||||||
|
|
||||||
|
@ -121,9 +123,9 @@ public class BrowseWidget extends Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected WidgetTemplateValues doClassGroupDisplay(Environment env,
|
protected WidgetTemplateValues doClassGroupDisplay(Environment env,
|
||||||
Map params, VitroRequest vreq, ServletContext context) {
|
Map params, HttpServletRequest request, ServletContext context) {
|
||||||
|
|
||||||
Map<String,Object> body = getClassGroupData(vreq,params);
|
Map<String,Object> body = getClassGroupData(request,params);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
body.put("urls",env.getDataModel().get("urls"));
|
body.put("urls",env.getDataModel().get("urls"));
|
||||||
|
@ -136,10 +138,11 @@ public class BrowseWidget extends Widget {
|
||||||
return new WidgetTemplateValues(macroName, body);
|
return new WidgetTemplateValues(macroName, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, Object> getClassGroupData(VitroRequest vreq, Map params) {
|
protected Map<String, Object> getClassGroupData(HttpServletRequest request, Map params) {
|
||||||
Map<String,Object> map = new HashMap<String,Object>();
|
Map<String,Object> map = new HashMap<String,Object>();
|
||||||
|
|
||||||
String vcgName = getParam(Mode.CLASS_GROUP, vreq, params);
|
String vcgName = getParam(Mode.CLASS_GROUP, request, params);
|
||||||
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
VClassGroup vcg = vreq.getWebappDaoFactory().getVClassGroupDao().getGroupByName(vcgName);
|
VClassGroup vcg = vreq.getWebappDaoFactory().getVClassGroupDao().getGroupByName(vcgName);
|
||||||
|
|
||||||
vreq.getWebappDaoFactory().getVClassDao().addVClassesToGroup(vcg, false, true);
|
vreq.getWebappDaoFactory().getVClassDao().addVClassesToGroup(vcg, false, true);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
import edu.cornell.mannlib.vitro.webapp.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Route;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
|
||||||
|
@ -68,14 +67,14 @@ public class LoginWidget extends Widget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WidgetTemplateValues process(Environment env, Map params,
|
protected WidgetTemplateValues process(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) {
|
HttpServletRequest request, ServletContext context) {
|
||||||
|
|
||||||
WidgetTemplateValues values = null;
|
WidgetTemplateValues values = null;
|
||||||
TemplateModel urls = null;
|
TemplateModel urls = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
urls = env.getDataModel().get("urls");
|
urls = env.getDataModel().get("urls");
|
||||||
State state = getCurrentLoginState(vreq);
|
State state = getCurrentLoginState(request);
|
||||||
log.debug("State on exit: " + state);
|
log.debug("State on exit: " + state);
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
|
@ -83,17 +82,17 @@ public class LoginWidget extends Widget {
|
||||||
// On the login page itself, show a message that the user is already logged in.
|
// On the login page itself, show a message that the user is already logged in.
|
||||||
// Otherwise, when redirecting to login page from a page that the logged-in user
|
// Otherwise, when redirecting to login page from a page that the logged-in user
|
||||||
// doesn't have access to, we would just show a blank page.
|
// doesn't have access to, we would just show a blank page.
|
||||||
if (vreq.getServletPath().equals(Route.LOGIN.path())) {
|
if (request.getServletPath().equals(Route.LOGIN.path())) {
|
||||||
values = showMessageToLoggedInUser(vreq);
|
values = showMessageToLoggedInUser(request);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
case FORCED_PASSWORD_CHANGE:
|
case FORCED_PASSWORD_CHANGE:
|
||||||
values = showPasswordChangeScreen(vreq);
|
values = showPasswordChangeScreen(request);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
values = showLoginScreen(vreq);
|
values = showLoginScreen(request);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e);
|
log.error(e);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -24,7 +25,7 @@ public class SelectListWidget extends Widget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WidgetTemplateValues process(Environment env, Map params,
|
protected WidgetTemplateValues process(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) {
|
HttpServletRequest request, ServletContext context) {
|
||||||
|
|
||||||
Object obj = params.get("fieldName");
|
Object obj = params.get("fieldName");
|
||||||
if( obj == null || !(obj instanceof SimpleScalar)){
|
if( obj == null || !(obj instanceof SimpleScalar)){
|
||||||
|
@ -37,8 +38,9 @@ public class SelectListWidget extends Widget {
|
||||||
throw new Error("SelectListWidget must have a parameter 'fieldName' of type String");
|
throw new Error("SelectListWidget must have a parameter 'fieldName' of type String");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpSession session = vreq.getSession(false);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,vreq);
|
HttpSession session = request.getSession(false);
|
||||||
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
||||||
|
|
||||||
WebappDaoFactory wdf;
|
WebappDaoFactory wdf;
|
||||||
if (editConfig != null) {
|
if (editConfig != null) {
|
||||||
|
|
|
@ -6,19 +6,19 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import freemarker.core.Environment;
|
import freemarker.core.Environment;
|
||||||
|
|
||||||
public class TestWidget extends Widget {
|
public class TestWidget extends Widget {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected WidgetTemplateValues process(Environment env, Map params,
|
protected WidgetTemplateValues process(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) {
|
HttpServletRequest request, ServletContext context) {
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
String macroName;
|
String macroName;
|
||||||
if (LoginStatusBean.getBean(vreq).isLoggedIn()) {
|
if (LoginStatusBean.getBean(request).isLoggedIn()) {
|
||||||
map.put("status", "logged in");
|
map.put("status", "logged in");
|
||||||
macroName = "loggedIn";
|
macroName = "loggedIn";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,11 +10,11 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import freemarker.core.Environment;
|
import freemarker.core.Environment;
|
||||||
import freemarker.core.Macro;
|
import freemarker.core.Macro;
|
||||||
import freemarker.template.Template;
|
import freemarker.template.Template;
|
||||||
|
@ -52,13 +52,13 @@ public abstract class Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String doMarkup(Environment env, Map params) {
|
public String doMarkup(Environment env, Map params) {
|
||||||
VitroRequest vreq = (VitroRequest) env.getCustomAttribute("vreq");
|
HttpServletRequest request = (HttpServletRequest) env.getCustomAttribute("request");
|
||||||
ServletContext context = (ServletContext) env.getCustomAttribute("context");
|
ServletContext context = (ServletContext) env.getCustomAttribute("context");
|
||||||
|
|
||||||
WidgetTemplateValues values = null;
|
WidgetTemplateValues values = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
values = process(env, params, vreq, context);
|
values = process(env, params, request, context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ public abstract class Widget {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
protected abstract WidgetTemplateValues process(Environment env, Map params,
|
protected abstract WidgetTemplateValues process(Environment env, Map params,
|
||||||
VitroRequest vreq, ServletContext context) throws Exception;
|
HttpServletRequest request, ServletContext context) throws Exception;
|
||||||
|
|
||||||
private String processMacroToString(Environment env, String widgetName, Macro macro, Map<String, Object> map) {
|
private String processMacroToString(Environment env, String widgetName, Macro macro, Map<String, Object> map) {
|
||||||
StringWriter out = new StringWriter();
|
StringWriter out = new StringWriter();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue