Subversion Repositories XServices

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
187 brianR 1
/**
2
 *
3
 */
4
package net.brutex.xservices.util;
5
 
6
import java.net.URL;
7
 
8
import org.apache.commons.configuration.ConfigurationException;
9
import org.apache.commons.configuration.PropertiesConfiguration;
10
import org.apache.commons.jcs.JCS;
11
import org.apache.commons.jcs.access.exception.CacheException;
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14
 
15
import net.brutex.mgmt.openair.OpenAirRestConnection;
16
 
17
/**
18
 * @author brosenberger
19
 *
20
 */
21
public final class OpenAirConnection {
22
	private final static Logger logger = LogManager.getLogger();
23
 
24
	public static OpenAirRestConnection getOpenAirConnection() {
25
		final PropertiesConfiguration props;
26
		try {
27
			final String config = "../openair.properties";
28
			logger.info("Loading Open Air connection details from {}", config.toString());
29
			final URL configloc = OpenAirConnection.class.getClassLoader().getResource(config);
30
			logger.debug("Loading Open Air connection details from {}", configloc.toString());
31
 
32
			props = new PropertiesConfiguration(configloc);
33
			final String user = props.getString("user");
34
			final String password = props.getString("password");
35
			final String company = props.getString("company");
36
			final String apikey = props.getString("apikey", "_PUT_HERE_");
37
			final String namespace = props.getString("namespace", "");
38
 
39
			final OpenAirRestConnection con;
40
 
41
			con = new OpenAirRestConnection(JCS.getInstance("OACache"), company, user, password);
42
			return con;
43
		} catch (CacheException e) {
44
			logger.error(e.getMessage(), e);
45
			e.printStackTrace();
46
		} catch (ConfigurationException e) {
47
			logger.error(e.getMessage(), e);
48
			e.printStackTrace();
49
		} finally {
50
 
51
		}
52
		return null;
53
	}
54
 
55
 
56
}