1 12 13 package com.openedit.modules.admin.users; 14 15 import java.util.Iterator ; 16 import java.util.Map ; 17 18 import com.openedit.WebPageRequest; 19 import com.openedit.users.UserManagerException; 20 21 22 27 public class PropertyContainerManipulator 28 { 29 32 public PropertyContainerManipulator() 33 { 34 super(); 35 } 36 37 45 public void createProperties(Map inParameters, Map inPropertyContainer) 46 throws UserManagerException 47 { 48 for (Iterator iter = inParameters.entrySet().iterator(); iter.hasNext();) 51 { 52 Map.Entry entry = (Map.Entry ) iter.next(); 53 54 if (entry.getKey().toString().startsWith("propertyName")) 55 { 56 String propertyName = entry.getValue().toString().trim(); 57 58 if (propertyName.length() > 0) 60 { 61 int propertyIndex = Integer.parseInt(entry.getKey().toString().substring(12)); 62 Object propertyValue = inParameters.get("propertyValue" + propertyIndex); 63 64 if (propertyValue != null) 65 { 66 inPropertyContainer.put(propertyName, propertyValue.toString()); 67 } 68 } 69 } 70 } 71 } 72 73 81 public void deleteProperties(WebPageRequest inContext, Map inPropertyContainer) 82 throws UserManagerException 83 { 84 String [] propertyNames = inContext.getRequestParameters("deletePropertyNames"); 85 86 for (int i = 0; i < propertyNames.length; i++) 87 { 88 inPropertyContainer.remove(propertyNames[i]); 89 } 90 91 } 92 93 101 public void updateProperties(Map inParameters, Map inPropertyContainer) 102 throws UserManagerException 103 { 104 for (Iterator iter = inParameters.entrySet().iterator(); iter.hasNext();) 105 { 106 Map.Entry entry = (Map.Entry ) iter.next(); 107 108 if (entry.getKey().toString().startsWith("value-")) 109 { 110 String propertyName = entry.getKey().toString().substring(6); 111 String propertyValue = entry.getValue().toString(); 112 if (propertyValue.length() > 0) 113 { 114 inPropertyContainer.put(propertyName, propertyValue); 115 } 116 else 117 { 118 inPropertyContainer.remove(propertyName); 119 } 120 } 121 } 122 } 123 } 124 | Popular Tags |