You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2009/12/10 02:09:36 UTC
svn commit: r889044 -
/ofbiz/branches/release09.04/framework/base/src/org/ofbiz/base/util/UtilHttp.java
Author: lektran
Date: Thu Dec 10 01:09:36 2009
New Revision: 889044
URL: http://svn.apache.org/viewvc?rev=889044&view=rev
Log:
Merged from trunk r889038:
Added two new methods to UtilHttp to assist in temporarily storing and retreiving request parameters to/from the session.
Also partially merged r889043:
Fix typo
Modified:
ofbiz/branches/release09.04/framework/base/src/org/ofbiz/base/util/UtilHttp.java
Modified: ofbiz/branches/release09.04/framework/base/src/org/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release09.04/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=889044&r1=889043&r2=889044&view=diff
==============================================================================
--- ofbiz/branches/release09.04/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/branches/release09.04/framework/base/src/org/ofbiz/base/util/UtilHttp.java Thu Dec 10 01:09:36 2009
@@ -53,6 +53,7 @@
import javolution.util.FastList;
import javolution.util.FastMap;
+import org.apache.commons.lang.RandomStringUtils;
import org.owasp.esapi.errors.EncodingException;
/**
@@ -1320,4 +1321,35 @@
}
return rowCount;
}
+
+ public static String stashParameterMap(HttpServletRequest request) {
+ HttpSession session = request.getSession();
+ Map<String, Map<String, Object>> paramMapStore = UtilGenerics.checkMap(session.getAttribute("_PARAM_MAP_STORE_"));
+ if (paramMapStore == null) {
+ paramMapStore = FastMap.newInstance();
+ session.setAttribute("_PARAM_MAP_STORE_", paramMapStore);
+ }
+ Map<String, Object> parameters = UtilHttp.getParameterMap(request);
+ String paramMapId = RandomStringUtils.randomAlphanumeric(10);
+ paramMapStore.put(paramMapId, parameters);
+ return paramMapId;
+ }
+
+ public static void restoreStashedParameterMap(HttpServletRequest request, String paramMapId) {
+ HttpSession session = request.getSession();
+ Map<String, Map<String, Object>> paramMapStore = UtilGenerics.checkMap(session.getAttribute("_PARAM_MAP_STORE_"));
+ if (paramMapStore != null) {
+ Map<String, Object> paramMap = paramMapStore.get(paramMapId);
+ if (paramMap != null) {
+ paramMapStore.remove(paramMapId);
+ for (Map.Entry<String, Object> paramEntry : paramMap.entrySet()) {
+ if (request.getAttribute(paramEntry.getKey()) != null) {
+ Debug.logWarning("Skipped loading parameter [" + paramEntry.getKey() + "] because it would have overwritten a request attribute" , module);
+ continue;
+ }
+ request.setAttribute(paramEntry.getKey(), paramEntry.getValue());
+ }
+ }
+ }
+ }
}