1 16 package org.apache.cocoon.acting; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.thread.ThreadSafe; 20 21 import org.apache.cocoon.environment.ObjectModelHelper; 22 import org.apache.cocoon.environment.Session; 23 24 import java.util.Collection ; 25 import java.util.HashMap ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 40 public class SessionValidatorAction extends AbstractValidatorAction implements ThreadSafe { 41 42 45 protected HashMap createMapOfParameters(Map objectModel, Collection set) { 46 String name; 47 HashMap params = new HashMap (set.size()); 48 Session session = ObjectModelHelper.getRequest(objectModel).getSession(); 50 for (Iterator i = set.iterator(); i.hasNext();) { 51 name = ((Configuration) i.next()).getAttribute("name", "").trim(); 52 Object value = session.getAttribute(name); 53 params.put(name, value); 54 } 55 return params; 56 } 57 58 59 62 protected Map setResult(Map objectModel, Map actionMap, Map resultMap, boolean allOK) { 63 if (allOK){ 64 Session session = ObjectModelHelper.getRequest(objectModel).getSession(); 65 for (Iterator i = actionMap.entrySet().iterator(); i.hasNext(); ) { 66 Map.Entry me = (Map.Entry )i.next(); 67 session.setAttribute((String )me.getKey(), me.getValue()); 68 } 69 } 70 return super.setResult(objectModel, actionMap, resultMap, allOK); 71 } 72 73 74 77 boolean isStringEncoded() { 78 return false; 79 } 80 81 } 82 | Popular Tags |