1 /*
2 * ConfigurationStore.java
3 *
4 * Created on October 20, 2004, 12:47 PM
5 */
6
7 package gov.bnl.gums.configuration;
8
9 import gov.bnl.gums.GUMS;
10 import gov.bnl.gums.GridUser;
11 import gov.bnl.gums.persistence.PersistenceFactory;
12 import gov.bnl.gums.userGroup.ManualUserGroup;
13 import gov.bnl.gums.userGroup.UserGroup;
14
15 import java.io.IOException;
16 import java.text.DateFormat;
17 import java.text.SimpleDateFormat;
18 import java.util.Collection;
19 import java.util.Date;
20 import java.util.Iterator;
21 import java.util.Map;
22
23 import org.apache.log4j.Logger;
24
25 /**
26 * Encapsulate the logic of retrieving the configuration from where it is stored.
27 * This will allow to retrieve the configuration from a File, from a database,
28 * or from whenever we will need to.
29 *
30 * @author Gabriele Carcassi, Jay Packard
31 */
32 public abstract class ConfigurationStore {
33 static protected DateFormat format = new SimpleDateFormat("yyyy_MM_dd_HHmmss");
34
35 /**
36 * Delete backup configuration
37 *
38 * @param A date string
39 */
40 public abstract void deleteBackupConfiguration(String name);
41
42 /**
43 * Get a list of config date strings that have been backed up
44 *
45 * @return collection of date strings.
46 */
47 public abstract Collection getBackupNames();
48
49 /**
50 * Get last modified
51 *
52 * @return Date
53 */
54 public abstract Date getLastModification();
55
56 /**
57 * Defines whether a configuration can be retrieved from the store.
58 * This should only check whether configuration information is accessible,
59 * not if it is inconsistent. For example, it should check whether
60 * the configuration file is present, not if contains valid information.
61 *
62 * @return true if the store is configured correctly.
63 */
64 public abstract boolean isActive();
65
66 /**
67 * Restores configuration in memory. If the configuration cannot be loaded
68 * due to an inconsistency in the store, it should throw an exception.
69 *
70 * @param A date string
71 * @return A configuration object.
72 */
73 public abstract Configuration restoreConfiguration(String dateStr) throws Exception;
74
75 /**
76 * Loads the configuration in memory if or from storage based on reload. This is
77 * useful if needsReload was called previously and you don't want to look it
78 * up again for performance's sake. If the configuration cannot be loaded due to an
79 * inconsistency in the store, it should throw an exception.
80 *
81 * @return A configuration object.
82 */
83 public abstract Configuration retrieveConfiguration() throws Exception;
84
85 /**
86 * Set and store the configuration. A configuration may specify to store the configuration
87 * using another configuration store, so this function also returns itself or a updated
88 * configuration store
89 *
90 * @param conf
91 * @param backupCopy
92 */
93 public abstract void setConfiguration(Configuration conf, boolean backupCopy, String name, Date date) throws Exception;
94
95 static public DateFormat getFormat() {
96 return format;
97 }
98
99 }