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 01:52:38 UTC
svn commit: r889038 -
/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
Author: lektran
Date: Thu Dec 10 00:52:37 2009
New Revision: 889038
URL: http://svn.apache.org/viewvc?rev=889038&view=rev
Log:
Added two new methods to UtilHttp to assist in temporarily storing and retreiving request parameters to/from the session.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=889038&r1=889037&r2=889038&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Thu Dec 10 00:52:37 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;
/**
@@ -1318,4 +1319,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 restoreStashedParamaterMap(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());
+ }
+ }
+ }
+ }
}