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 */ EditProcessObject epo = null; HashMap epoHash = getEpoHash(request); String existingEpoKey = request.getParameter("_epoKey"); 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); } } Random rand = new Random(); String epoKey = createEpoKey(); while (epoHash.get(epoKey) != null) { epoKey += Integer.toHexString(rand.nextInt()); } epo = new EditProcessObject(); epoHash.put(epoKey, epo); epoKeylist.add(epoKey); epo.setKey(epoKey); epo.setReferer( (forceNew) ? request.getRequestURL().append('?').append(request.getQueryString()).toString() : request.getHeader("Referer")); epo.setSession(request.getSession()); } return epo; }