Add another debug statement; reformat.

This commit is contained in:
jeb228 2010-10-07 20:09:49 +00:00
parent 0093590bba
commit d6e507691a

View file

@ -146,29 +146,29 @@ public class ImageUploadController extends FreemarkerHttpServlet {
* </p> * </p>
*/ */
@Override @Override
protected ResponseValues processRequest(VitroRequest vreq) { protected ResponseValues processRequest(VitroRequest vreq) {
try { try {
// Parse the multi-part request. // Parse the multi-part request.
FileUploadServletRequest request = FileUploadServletRequest.parseRequest(vreq, FileUploadServletRequest request = FileUploadServletRequest
MAXIMUM_FILE_SIZE); .parseRequest(vreq, MAXIMUM_FILE_SIZE);
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {
dumpRequestDetails(vreq); dumpRequestDetails(vreq);
} }
// If they aren't authorized to do this, send them to login. // If they aren't authorized to do this, send them to login.
if (!checkAuthorized(vreq)) { if (!checkAuthorized(vreq)) {
String loginPage = request.getContextPath() + Controllers.LOGIN; String loginPage = request.getContextPath() + Controllers.LOGIN;
return new RedirectResponseValues(loginPage); return new RedirectResponseValues(loginPage);
} }
return buildTheResponse(vreq); return buildTheResponse(vreq);
} catch (Exception e) { } catch (Exception e) {
//log.error("Could not produce response page", e); // log.error("Could not produce response page", e);
return new ExceptionResponseValues(e); return new ExceptionResponseValues(e);
} }
} }
/** /**
* Handle the different actions. If not specified, the default action is to * Handle the different actions. If not specified, the default action is to
@ -480,8 +480,8 @@ public class ImageUploadController extends FreemarkerHttpServlet {
* URI. * URI.
*/ */
private String formAction(String entityUri, String action) { private String formAction(String entityUri, String action) {
UrlBuilder.ParamMap params = new UrlBuilder.ParamMap(PARAMETER_ENTITY_URI, UrlBuilder.ParamMap params = new UrlBuilder.ParamMap(
entityUri, PARAMETER_ACTION, action); PARAMETER_ENTITY_URI, entityUri, PARAMETER_ACTION, action);
return UrlBuilder.getPath(URL_HERE, params); return UrlBuilder.getPath(URL_HERE, params);
} }
@ -580,8 +580,6 @@ public class ImageUploadController extends FreemarkerHttpServlet {
} }
} }
/** /**
* If they are logged in as an Editor or better, they can do whatever they * If they are logged in as an Editor or better, they can do whatever they
* want. * want.
@ -591,7 +589,8 @@ public class ImageUploadController extends FreemarkerHttpServlet {
*/ */
private boolean checkAuthorized(VitroRequest vreq) private boolean checkAuthorized(VitroRequest vreq)
throws UserMistakeException { throws UserMistakeException {
if (LoginStatusBean.getBean(vreq).isLoggedInAtLeast(LoginStatusBean.EDITOR)) { if (LoginStatusBean.getBean(vreq).isLoggedInAtLeast(
LoginStatusBean.EDITOR)) {
log.debug("Authorized because logged in as Editor"); log.debug("Authorized because logged in as Editor");
return true; return true;
} }
@ -620,7 +619,10 @@ public class ImageUploadController extends FreemarkerHttpServlet {
} }
AuthorizationHelper helper = new AuthorizationHelper(vreq); AuthorizationHelper helper = new AuthorizationHelper(vreq);
return helper.isAuthorizedForRequestedAction(ra); boolean authorized = helper.isAuthorizedForRequestedAction(ra);
log.debug((authorized ? "" : "Not ") + "Authorized for '" + action
+ "' as self-editor; requested action = " + ra);
return authorized;
} }
} }