]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/java/org/open_ils/Sys.java
LP1910409 MARC Batch Edit Allows CSV Column 0
[Evergreen.git] / Open-ILS / src / java / org / open_ils / Sys.java
1 package org.open_ils;
2
3 import org.opensrf.*;
4 import org.opensrf.util.*;
5 import org.open_ils.*;
6 import org.open_ils.idl.*;
7 import org.opensrf.util.*;
8
9 import java.util.Map;
10 import java.util.HashMap;
11 import java.io.IOException;
12
13
14 public class Sys {
15
16     private static IDLParser idlParser = null;
17
18     /**
19      * Initializes the connection to the OpenSRF network and parses the IDL file.
20      * @param attrs A map of configuration attributes.  Options include:<br/>
21      * <ul>
22      * <li>configFile - The OpenSRF core config file</li>
23      * <li>configContext - The path to the config chunk in the config XML, typically "opensrf"</li>
24      * <li>logProtocol - Currently supported option is "file".</li>
25      * <li>logLevel - The log level.  Options are 1,2,3, or 4 (error, warn, info, debug)</li>
26      * <li>syslogFacility - For future use, when syslog is a supported log option</li>
27      * <li>idlFile - The path to the IDL file.  May be relative or absolute.  If this option is 
28      * not provided, the system will ask the OpenSRF Settings server for the IDL file path.</li>
29      * </ul>
30      */
31     public static void init(Map<String, String> attrs) throws ConfigException, SessionException, IOException, IDLException {
32
33         String configFile = attrs.get("configFile");
34         String configContext = attrs.get("configContext");
35         String logProto = attrs.get("logProtocol");
36         String logFile = attrs.get("logFile");
37         String logLevel = attrs.get("logLevel");
38         String syslogFacility = attrs.get("syslogFacility");
39         String idlFile = attrs.get("idlFile");
40
41
42         if(idlParser != null) {
43             /** if we've parsed the IDL file, then all of the global setup has been done.
44             *   We just need to verify this thread is connected to the OpenSRF network. */
45             org.opensrf.Sys.bootstrapClient(configFile, configContext);
46             return;
47         }
48
49         /** initialize the logging infrastructure */
50         if("file".equals(logProto))
51             Logger.init(Short.parseShort(logLevel), new FileLogger(logFile));
52
53         if("syslog".equals(logProto)) 
54             throw new ConfigException("syslog not yet implemented");
55
56         /** connect to the opensrf network. */
57         org.opensrf.Sys.bootstrapClient(configFile, configContext);
58
59         /** Grab the IDL file setting if not explicitly provided */
60         if(idlFile == null) {
61             SettingsClient client = SettingsClient.instance();
62             idlFile = client.getString("/IDL");
63         }
64
65         /** Parse the IDL if necessary */
66         idlParser = new IDLParser(idlFile);
67         idlParser.parse();
68     }
69 }
70