1 5 package com.opensymphony.user.provider.file; 6 7 import com.opensymphony.module.propertyset.PropertySet; 8 import com.opensymphony.module.propertyset.PropertySetManager; 9 10 import com.opensymphony.user.Entity; 11 12 import org.apache.commons.logging.Log; 13 import org.apache.commons.logging.LogFactory; 14 15 16 import java.util.ArrayList ; 17 import java.util.Collections ; 18 import java.util.List ; 19 import java.util.Properties ; 20 21 22 29 public class FileProfileProvider implements com.opensymphony.user.provider.ProfileProvider { 30 32 protected static final Log log = LogFactory.getLog(FileProfileProvider.class); 33 34 protected FilePropertySetCache propertySetCache; 35 36 38 public PropertySet getPropertySet(String name) { 39 if (!propertySetCache.propertySets.containsKey(name)) { 40 return null; 41 } 42 43 return (PropertySet) propertySetCache.propertySets.get(name); 44 } 45 46 public boolean create(String name) { 47 if (propertySetCache.propertySets.containsKey(name)) { 48 return false; 49 } 50 51 PropertySet propertySet = PropertySetManager.getInstance("serializable", null); 52 propertySetCache.propertySets.put(name, propertySet); 53 54 return propertySetCache.store(); 55 } 56 57 public void flushCaches() { 58 propertySetCache.store(); 59 } 60 61 public boolean handles(String name) { 62 return propertySetCache.propertySets.containsKey(name); 63 } 64 65 public boolean init(Properties properties) { 66 return true; 67 } 68 69 public List list() { 70 return Collections.unmodifiableList(new ArrayList (propertySetCache.propertySets.keySet())); 71 } 72 73 public boolean load(String name, Entity.Accessor accessor) { 74 return true; 75 } 76 77 public boolean remove(String name) { 78 boolean rv = propertySetCache.propertySets.remove(name) != null; 79 80 return rv && propertySetCache.store(); 81 } 82 83 public boolean store(String name, Entity.Accessor accessor) { 84 return propertySetCache.store(); 85 } 86 } 87 88 | Popular Tags |