diff --git a/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java b/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java
index 65ecd722dc..23a3e6f51e 100644
--- a/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java
+++ b/api/src/main/java/edu/cornell/mannlib/vedit/controller/BaseEditController.java
@@ -9,34 +9,41 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Random;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vedit.util.FormUtils;
+import edu.cornell.mannlib.vitro.webapp.auth.attributes.AccessObjectType;
+import edu.cornell.mannlib.vitro.webapp.auth.attributes.AccessOperation;
+import edu.cornell.mannlib.vitro.webapp.auth.policy.EntityPolicyController;
+import edu.cornell.mannlib.vitro.webapp.beans.PermissionSet;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroHttpServlet;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
-import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
+import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class BaseEditController extends VitroHttpServlet {
- public static final boolean FORCE_NEW = true; // when you know you're starting a new edit process
+ public static final String ENTITY_URI_ATTRIBUTE_NAME = "_permissionsEntityURI";
+ public static final String ENTITY_TYPE_ATTRIBUTE_NAME = "_permissionsEntityType";
+
+ public static final boolean FORCE_NEW = true; // when you know you're starting a new edit process
public static final String JSP_PREFIX = "/templates/edit/specific/";
@@ -51,82 +58,87 @@ public class BaseEditController extends VitroHttpServlet {
private final int MAX_EPOS = 5;
private final Calendar cal = Calendar.getInstance();
- /* EPO is reused if the controller is passed an epoKey, e.g.
- if a previous form submission failed validation, or the edit is a multistage process. */
+ /*
+ * EPO is reused if the controller is passed an epoKey, e.g. if a previous form submission failed validation, or the
+ * edit is a multistage process.
+ */
protected EditProcessObject createEpo(HttpServletRequest request) {
- return createEpo(request, false);
+ return createEpo(request, false);
}
protected EditProcessObject createEpo(HttpServletRequest request, boolean forceNew) {
- /* this is actually a bit of a misnomer, because we will reuse an epo
- if an epoKey parameter is passed */
+ /*
+ * this is actually a bit of a misnomer, because we will reuse an epo if an epoKey parameter is passed
+ */
EditProcessObject epo = null;
HashMap epoHash = getEpoHash(request);
String existingEpoKey = request.getParameter("_epoKey");
- if (!forceNew && existingEpoKey != null && epoHash.get(existingEpoKey) != null) {
+ if (!forceNew && existingEpoKey != null && epoHash.get(existingEpoKey) != null) {
epo = (EditProcessObject) epoHash.get(existingEpoKey);
epo.setKey(existingEpoKey);
epo.setUseRecycledBean(true);
} else {
LinkedList epoKeylist = getEpoKeylist(request);
if (epoHash.size() == MAX_EPOS) {
- try {
- epoHash.remove(epoKeylist.getFirst());
- epoKeylist.removeFirst();
- } catch (Exception e) {
- // see JIRA issue VITRO-340, "Odd exception from backend editing"
- // possible rare concurrency issue here
- log.error("Error removing old EPO", e);
- }
+ try {
+ epoHash.remove(epoKeylist.getFirst());
+ epoKeylist.removeFirst();
+ } catch (Exception e) {
+ // see JIRA issue VITRO-340, "Odd exception from backend editing"
+ // possible rare concurrency issue here
+ log.error("Error removing old EPO", e);
+ }
}
Random rand = new Random();
String epoKey = createEpoKey();
while (epoHash.get(epoKey) != null) {
- epoKey+=Integer.toHexString(rand.nextInt());
+ epoKey += Integer.toHexString(rand.nextInt());
}
epo = new EditProcessObject();
- epoHash.put (epoKey,epo);
+ epoHash.put(epoKey, epo);
epoKeylist.add(epoKey);
epo.setKey(epoKey);
- epo.setReferer( (forceNew) ? request.getRequestURL().append('?').append(request.getQueryString()).toString() : request.getHeader("Referer") );
+ epo.setReferer((forceNew) ? request.getRequestURL().append('?').append(request.getQueryString()).toString()
+ : request.getHeader("Referer"));
epo.setSession(request.getSession());
}
return epo;
}
- private LinkedList getEpoKeylist(HttpServletRequest request){
+ private LinkedList getEpoKeylist(HttpServletRequest request) {
return (LinkedList) request.getSession().getAttribute(EPO_KEYLIST_ATTR);
}
- private HashMap getEpoHash(HttpServletRequest request){
+ private HashMap getEpoHash(HttpServletRequest request) {
HashMap epoHash = (HashMap) request.getSession().getAttribute(EPO_HASH_ATTR);
if (epoHash == null) {
epoHash = new HashMap();
- request.getSession().setAttribute(EPO_HASH_ATTR,epoHash);
- //since we're making a new EPO hash, we should also make a new keylist.
+ request.getSession().setAttribute(EPO_HASH_ATTR, epoHash);
+ // since we're making a new EPO hash, we should also make a new keylist.
LinkedList epoKeylist = new LinkedList();
- request.getSession().setAttribute(EPO_KEYLIST_ATTR,epoKeylist);
+ request.getSession().setAttribute(EPO_KEYLIST_ATTR, epoKeylist);
}
return epoHash;
}
- private String createEpoKey(){
+ private String createEpoKey() {
return Long.toHexString(cal.getTimeInMillis());
}
- protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo){
- VitroRequest vreq = new VitroRequest(request);
- request.setAttribute("epoKey",epo.getKey());
- request.setAttribute("epo",epo);
- request.setAttribute("globalErrorMsg",epo.getAttribute("globalErrorMsg"));
- request.setAttribute("css", "");
+ protected void setRequestAttributes(HttpServletRequest request, EditProcessObject epo) {
+ VitroRequest vreq = new VitroRequest(request);
+ request.setAttribute("epoKey", epo.getKey());
+ request.setAttribute("epo", epo);
+ request.setAttribute("globalErrorMsg", epo.getAttribute("globalErrorMsg"));
+ request.setAttribute("css", "");
}
protected void populateBeanFromParams(Object bean, HttpServletRequest request) {
Map params = request.getParameterMap();
Enumeration paramNames = request.getParameterNames();
- while (paramNames.hasMoreElements()){
+ while (paramNames.hasMoreElements()) {
String key = "";
try {
key = (String) paramNames.nextElement();
@@ -157,9 +169,9 @@ protected void populateBeanFromParams(Object bean, HttpServletRequest request) {
}
}
- public List