1 13 14 package org.ejbca.core.model.ra.userdatasource; 15 16 import java.io.Serializable ; 17 import java.util.ArrayList ; 18 import java.util.Collection ; 19 import java.util.HashSet ; 20 import java.util.Iterator ; 21 import java.util.Set ; 22 23 import org.ejbca.core.model.UpgradeableDataHashMap; 24 import org.ejbca.core.model.log.Admin; 25 26 27 28 37 public abstract class BaseUserDataSource extends UpgradeableDataHashMap implements Serializable , Cloneable { 38 40 41 public static final String TRUE = "true"; 42 public static final String FALSE = "false"; 43 44 45 public static final int ANYCA = -1; 46 47 public static final String TYPE = "type"; 49 50 protected static final String DESCRIPTION = "DESCRIPTION"; 51 protected static final String APPLICABLECAS = "APPLICABLECAS"; 52 protected static final String MODIFYABLEFIELDS = "MODIFYABLEFIELDS"; 53 54 56 59 public BaseUserDataSource() { 60 setDescription(""); 61 62 ArrayList applicablecas = new ArrayList (); 63 setApplicableCAs(applicablecas); 64 65 HashSet modifyableFields = new HashSet (); 66 for(int i=0; i< UserDataSourceVO.AVAILABLEMODIFYABLEFIELDS.length; i++){ 67 modifyableFields.add(new Integer (UserDataSourceVO.AVAILABLEMODIFYABLEFIELDS[i])); 68 } 69 setModifiableFields(modifyableFields); 70 71 } 72 73 77 public String getDescription() { return (String ) data.get(DESCRIPTION);} 78 79 82 public void setDescription(String description){ data.put(DESCRIPTION, description); } 83 84 90 public Collection getApplicableCAs(){ 91 return (Collection ) data.get(APPLICABLECAS); 92 } 93 94 99 100 public void setApplicableCAs(Collection applicablecas){ 101 data.put(APPLICABLECAS, applicablecas); 102 } 103 104 108 public boolean isApplicableToAnyCA(){ 109 return ((Collection ) data.get(APPLICABLECAS)).contains(new Integer (ANYCA)); 110 } 111 112 117 public Set getModifiableFields(){ 118 return (Set ) data.get(MODIFYABLEFIELDS); 119 } 120 121 125 126 public void setModifiableFields(Set modifiableFields){ 127 data.put(MODIFYABLEFIELDS, modifiableFields); 128 } 129 130 134 public Collection fetchUserDataSourceVOs(Admin admin, String searchstring) throws UserDataSourceException{ 135 Collection result = fetch(admin,searchstring); 136 137 Set isModifyable = getModifiableFields(); 138 Iterator iter = result.iterator(); 139 while(iter.hasNext()){ 140 UserDataSourceVO next = (UserDataSourceVO) iter.next(); 141 next.setIsModifyableSet(isModifyable); 142 } 143 return result; 144 } 145 146 148 157 protected abstract Collection fetch(Admin admin, String searchstring) throws UserDataSourceException; 158 159 160 161 167 public abstract void testConnection(Admin admin) throws UserDataSourceConnectionException; 168 169 170 public abstract Object clone() throws CloneNotSupportedException ; 171 172 173 public abstract float getLatestVersion(); 174 175 176 public void upgrade(){ 177 } 179 180 181 182 } 183 | Popular Tags |