1 /* 2 * AccountPoolMapperDB.java 3 * 4 * Created on June 14, 2004, 3:18 PM 5 */ 6 7 package gov.bnl.gums.db; 8 9 import gov.bnl.gums.GridUser; 10 11 import java.util.Date; 12 import java.util.List; 13 import java.util.Map; 14 15 /** 16 * Provides the set of accounts for the AccountPoolMapper class which 17 * assignes accounts from a pool. 18 * <p> 19 * The implementation shouldn't buffer the information, as it the 20 * AccountPoolMapper responsability to do so. 21 * 22 * @author Gabriele Carcassi, Jay Packard 23 */ 24 /** 25 * @author jpackard 26 * 27 */ 28 public interface AccountPoolMapperDB { 29 30 /** 31 * Adds an account to the pool of free accounts. If the account 32 * already exists, will throw an exception 33 * 34 * @param account the account to be added 35 */ 36 void addAccount(String account); 37 38 /** 39 * Assigns a new account from the pool to the user. If the user is already 40 * mapped, will throw an exception. 41 * 42 * @todo decide which exception are thrown when 43 * @param userDN the user to be mapped 44 * @return the account or null if no more accounts are available 45 */ 46 String assignAccount(GridUser user); 47 48 /** 49 * @return the map this mapper is responsible for 50 */ 51 String getMap(); 52 53 /** 54 * This is a function meant to be used by a wrapper class that is caching some result from the database. 55 * When any writing operation occurs, this should return true until set to false by the wrapper class. 56 * 57 * @return whether changes require a cache refresh 58 */ 59 boolean needsCacheRefresh(); 60 61 /** 62 * Removes account from the pool of free accounts. 63 * 64 * @param account the account to be removed 65 * @return if account was removed 66 */ 67 boolean removeAccount(String account); 68 69 /** Retrieves the account associated to the Grid identity. 70 * 71 * @param userDN the certificate DN 72 * @param email 73 * @return the account or null if the user wasn't mapped 74 */ 75 String retrieveAccount(GridUser user); 76 77 /** Retrieves a user to account map. 78 * 79 * @return a Map between the userDN (String) as the key and the account (String). 80 */ 81 Map retrieveAccountMap(); 82 83 /** 84 * Retrieves an account to user DN map, including null DNs, where empty strings are returned 85 * if the account is unassigned. 86 * 87 * @return a Map between the userDN (String) as the key and the account (String). 88 */ 89 Map retrieveReverseAccountMap(); 90 91 /** 92 * Retrieve the list of accounts not in use since the given date. 93 * 94 * @param date the time since the accounts haven't been used. 95 * @return a list of String with the accounts 96 */ 97 List retrieveUsersNotUsedSince(Date date); 98 99 /** 100 * Call when a wrapper class using the DB object has updated its cache. 101 */ 102 void setCacheRefreshed(); 103 104 /** 105 * Unassigns whatever user is assigned to this account from the account mapping 106 * and renders that account available to the pool. 107 * 108 * @param account that should be unassigned 109 */ 110 void unassignAccount(String account); 111 112 /** 113 * Removes user from the mapping, and renders it available to the pool. 114 * 115 * @param user the user that shouldn't be mapped anymore 116 */ 117 void unassignUser(String user); 118 }