Project

General

Profile

« Previous | Next » 

Revision 6000

refactor the names of these Data Manager implementation classes so that it's easier to use them with the default/local versions of similar. These classes utilize Metacat-specific configuration values rather than relying soley on the bundles that are used in the stand-alone DM lib.

View differences:

src/edu/ucsb/nceas/metacat/dataquery/ConfigurableEcogridEndPoint.java
1
/**
2
 *    '$RCSfile: ConfigurableEcogridEndPoint.java,v $'
3
 *
4
 *     '$Author: leinfelder $'
5
 *       '$Date: 2008/06/20 17:47:12 $'
6
 *   '$Revision: 1.1 $'
7
 *
8
 *  For Details: http://ecoinformatics.org
9
 *
10
 * Copyright (c) 2007 The Regents of the University of California.
11
 * All rights reserved.
12
 * 
13
 * Permission is hereby granted, without written agreement and without
14
 * license or royalty fees, to use, copy, modify, and distribute this
15
 * software and its documentation for any purpose, provided that the
16
 * above copyright notice and the following two paragraphs appear in
17
 * all copies of this software.
18
 * 
19
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
20
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
22
 * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
23
 * OF SUCH DAMAGE.
24
 * 
25
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
28
 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
29
 * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31
 */
32
package edu.ucsb.nceas.metacat.dataquery;
33

  
34
import org.ecoinformatics.datamanager.download.EcogridEndPointInterface;
35

  
36
import edu.ucsb.nceas.metacat.properties.PropertyService;
37
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
38

  
39
/**
40
 * This class implements EcogridEndPointInterface and is configurable using a properties file.
41
 * Should be useful for switching to remote endpoints etc.
42
 * 
43
 * @author leinfelder
44
 *
45
 */
46
public class ConfigurableEcogridEndPoint implements EcogridEndPointInterface 
47
{  
48
		
49
	private String metacatEcogridEndPoint = null;
50
	private String metacatEcogridAuthEndPoint = null;
51
	private String metacatEcogridPutEndPoint = null;
52
	private String metacatEcogridIdentifierEndPoint = null;
53
	private String srbEcogridEndPoint = null;
54
	private String srbMachineName = null;
55
	
56
	protected String baseURL = null;
57
	
58
	public ConfigurableEcogridEndPoint() {
59
		if (!loadProperties()) {
60
			try {
61
				//use values from server where deployed
62
				baseURL = 
63
					"http://"
64
					+ PropertyService.getProperty("server.name")
65
					+ ":"
66
					+ PropertyService.getProperty("server.httpPort")
67
					+ "/"
68
					+ PropertyService.getProperty("application.context")
69
					+ "/services/";
70
				metacatEcogridEndPoint = baseURL + "QueryService";
71
				metacatEcogridAuthEndPoint = baseURL + "AuthenticationService";
72
				metacatEcogridPutEndPoint = baseURL + "PutService";
73
				metacatEcogridIdentifierEndPoint = baseURL + "IdentificationService";
74
			} catch (PropertyNotFoundException e) {
75
				//we are SOL now
76
				e.printStackTrace();
77
			}
78
		}	
79
	}
80
	
81
	private boolean loadProperties() {
82
		try {
83
			metacatEcogridEndPoint 				= PropertyService.getProperty("datamanager.endpoint.query");
84
			metacatEcogridAuthEndPoint 			= PropertyService.getProperty("datamanager.endpoint.authentication");
85
			metacatEcogridPutEndPoint 			= PropertyService.getProperty("datamanager.endpoint.put");
86
			metacatEcogridIdentifierEndPoint 	= PropertyService.getProperty("datamanager.endpoint.identifier");
87
			srbEcogridEndPoint 					= PropertyService.getProperty("datamanager.srb.endpoint");
88
			srbMachineName 						= PropertyService.getProperty("datamanager.srb.machinename");
89
		} catch (PropertyNotFoundException e) {
90
			//e.printStackTrace();
91
			return false;
92
		}
93
		if (metacatEcogridEndPoint == null || metacatEcogridEndPoint.length() == 0) {
94
			return false;
95
		}
96
		return true;
97
	}
98
	 /**
99
	    * Gets the end point which Metacat implements ecogrid interface.
100
	    * This end point will be used to handle ecogrid protocol
101
        * 
102
	    * @return end point url string
103
	    */
104
	   public String getMetacatEcogridEndPoint()
105
	   {
106
		   return metacatEcogridEndPoint;
107
	   }
108
	   
109
	   public String getMetacatEcogridAuthEndPoint()
110
	   {
111
		   return metacatEcogridAuthEndPoint;
112
	   }
113
	   
114
	   public String getMetacatEcogridPutEndPoint()
115
	   {
116
		   return metacatEcogridPutEndPoint;
117
	   }
118
	   
119
	   public String getMetacatEcogridIdentifierEndPoint() 
120
	   {
121
			return metacatEcogridIdentifierEndPoint;
122
		}
123
	   
124
       
125
	   /**
126
	    * Gets the end point which SRB implements ecogrid interface.
127
	    * This end point will be used to handle srb protocol.
128
        * 
129
	    * @return end point url string
130
	    */
131
	   public String getSRBEcogridEndPoint()
132
	   {
133
		   return srbEcogridEndPoint;
134
	   }
135

  
136
       
137
	   /**
138
	    * Gets the machine name which srb protocol will be used.
139
	    * The default value for this class is "srb-mcat.sdsc.edu".
140
        * 
141
	    * @return the machine name of srb server
142
	    */
143
	   public String getSRBMachineName()
144
	   {
145
		   return srbMachineName;
146
	   }
147
       
148
}
149

  
src/edu/ucsb/nceas/metacat/dataquery/ConfigurableAuthenticatedEcogridEndPoint.java
1
/**
2
 *    '$RCSfile: ConfigurableEcogridEndPoint.java,v $'
3
 *
4
 *     '$Author: leinfelder $'
5
 *       '$Date: 2008/06/20 17:47:12 $'
6
 *   '$Revision: 1.1 $'
7
 *
8
 *  For Details: http://ecoinformatics.org
9
 *
10
 * Copyright (c) 2007 The Regents of the University of California.
11
 * All rights reserved.
12
 * 
13
 * Permission is hereby granted, without written agreement and without
14
 * license or royalty fees, to use, copy, modify, and distribute this
15
 * software and its documentation for any purpose, provided that the
16
 * above copyright notice and the following two paragraphs appear in
17
 * all copies of this software.
18
 * 
19
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
20
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
22
 * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
23
 * OF SUCH DAMAGE.
24
 * 
25
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
28
 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
29
 * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31
 */
32
package edu.ucsb.nceas.metacat.dataquery;
33

  
34
import org.ecoinformatics.datamanager.download.AuthenticatedEcogridEndPointInterface;
35

  
36
import edu.ucsb.nceas.metacat.properties.PropertyService;
37
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
38

  
39
/**
40
 * This class implements AuthenticatedEcogridEndPointInterface 
41
 * and is configurable using the properties file.
42
 * Useful for switching to remote endpoints etc.
43
 * 
44
 * @author leinfelder
45
 *
46
 */
47
public class ConfigurableAuthenticatedEcogridEndPoint 
48
	extends ConfigurableEcogridEndPoint implements AuthenticatedEcogridEndPointInterface  {  
49
		
50
	private String metacatAuthenticatedEcogridEndPoint = null;
51
	private String sessionId = null;
52
	
53
	public ConfigurableAuthenticatedEcogridEndPoint() {
54
		super();
55
		if (!loadProperties()) {
56
			metacatAuthenticatedEcogridEndPoint = baseURL + "AuthenticatedQueryService";
57
		}
58
	}
59
	
60
	public ConfigurableAuthenticatedEcogridEndPoint(String sessionId) {
61
		this();
62
		this.sessionId = sessionId;
63
	}
64
	
65
	private boolean loadProperties() {
66
		try {
67
			metacatAuthenticatedEcogridEndPoint = PropertyService.getProperty("datamanager.endpoint.authenticatedquery");
68
		} catch (PropertyNotFoundException e) {
69
			//e.printStackTrace();
70
			return false;
71
		}
72
		if (metacatAuthenticatedEcogridEndPoint == null || metacatAuthenticatedEcogridEndPoint.length() == 0) {
73
			return false;
74
		}
75
		return true;
76
	}
77
	
78
	 /**
79
	    * Gets the end point which Metacat implements authenticated ecogrid interface.
80
	    * This end point will be used to handle ecogrid protocol
81
        * 
82
	    * @return end point url string
83
	    */
84
	   public String getMetacatAuthenticatedEcogridEndPoint()
85
	   {
86
		   return metacatAuthenticatedEcogridEndPoint;
87
	   }
88

  
89
	   public String getSessionId()
90
	   {
91
		   return sessionId;
92
	   }
93
	   
94
	   public void setSessionId(String id) {
95
		   sessionId = id;
96
	   }
97
       
98
}
99

  
src/edu/ucsb/nceas/metacat/dataquery/DatabaseConnectionPoolFactory.java
1
/**
2
 *    '$RCSfile: DatabaseConnectionPoolFactory.java,v $'
3
 *
4
 *     '$Author: leinfelder $'
5
 *       '$Date: 2007/10/05 21:10:17 $'
6
 *   '$Revision: 1.1 $'
7
 *
8
 *  For Details: http://kepler.ecoinformatics.org
9
 *
10
 * Copyright (c) 2003 The Regents of the University of California.
11
 * All rights reserved.
12
 * 
13
 * Permission is hereby granted, without written agreement and without
14
 * license or royalty fees, to use, copy, modify, and distribute this
15
 * software and its documentation for any purpose, provided that the
16
 * above copyright notice and the following two paragraphs appear in
17
 * all copies of this software.
18
 * 
19
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
20
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
22
 * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
23
 * OF SUCH DAMAGE.
24
 * 
25
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
28
 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
29
 * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31
 */
32
package edu.ucsb.nceas.metacat.dataquery;
33

  
34
import edu.ucsb.nceas.metacat.properties.PropertyService;
35

  
36
import java.sql.Connection;
37
import java.sql.SQLException;
38

  
39
import org.apache.commons.logging.Log;
40
import org.apache.commons.logging.LogFactory;
41
import org.ecoinformatics.datamanager.database.ConnectionNotAvailableException;
42
import org.ecoinformatics.datamanager.database.DatabaseConnectionPoolInterface;
43

  
44
/**
45
 * This class provides an implementation of DataConnetionPoolInterface 
46
 * Implementation and database information for this class will be read from property file.
47
 * 
48
 * @author leinfelder
49
 * 
50
 */
51
public class DatabaseConnectionPoolFactory {
52
	
53
	public static Log log = LogFactory.getLog(DatabaseConnectionPoolFactory.class);
54
	
55
	private static String implementationClass = null;
56
		
57
	static {
58
		loadOptions();
59
	}
60
	
61
	/**
62
	 * Constructor. Loading database parameter from property file
63
	 * 
64
	 */
65
	public DatabaseConnectionPoolFactory() {
66
	}
67

  
68
	/**
69
	 * Loads Data Manager options from a configuration file.
70
	 */
71
	private static void loadOptions() {
72
		try {
73
			implementationClass = PropertyService.getProperty("datamanager.implementation");
74
		} 
75
		catch (Exception e) {
76
			log.error("Error in loading options: " + e.getMessage());
77
		}
78
	}
79

  
80
	public static DatabaseConnectionPoolInterface getDatabaseConnectionPoolInterface() {
81
		DatabaseConnectionPoolInterface instance = null;
82
		try {
83
			instance = 
84
				(DatabaseConnectionPoolInterface) Class.forName(implementationClass).newInstance();
85
		} catch (Exception e) {
86
			log.error(e.getMessage() 
87
					+ ": could not create DatabaseConnectionPoolInterface implementation: " 
88
					+ implementationClass);
89
			e.printStackTrace();
90
		} 
91
		
92
		return instance;
93

  
94
	}
95

  
96
	public static void main(String arg[]) {
97
		Connection conn = null;
98
		try {
99
			conn = DatabaseConnectionPoolFactory.getDatabaseConnectionPoolInterface().getConnection();
100
			log.debug("conn=" + conn);
101
			
102
		} catch (SQLException e) {
103
			// TODO Auto-generated catch block
104
			e.printStackTrace();
105
		} catch (ConnectionNotAvailableException e) {
106
			// TODO Auto-generated catch block
107
			e.printStackTrace();
108
		}
109
		finally {
110
			try {
111
				conn.close();
112
			} catch (SQLException e) {
113
				// TODO Auto-generated catch block
114
				e.printStackTrace();
115
			}
116
		}
117
	}
118
}
src/edu/ucsb/nceas/metacat/dataquery/DataQuery.java
55 55
	 */
56 56
	public DataQuery() {
57 57
		// initialize the endpoint, not authenticated
58
		endPointInfo = new ConfigurableEcogridEndPoint();
58
		endPointInfo = new MetacatEcogridEndPoint();
59 59
		init();
60 60
	}
61 61
	
62 62
	public DataQuery(String sessionId) {
63 63
		// initialize the necessary parts
64
		endPointInfo = new ConfigurableAuthenticatedEcogridEndPoint(sessionId);
64
		endPointInfo = new MetacatAuthenticatedEcogridEndPoint(sessionId);
65 65
		init();
66 66
	}
67 67
	
68 68
	private void init() {
69
		connectionPool = DatabaseConnectionPoolFactory.getDatabaseConnectionPoolInterface();
69
		connectionPool = MetacatDatabaseConnectionPoolFactory.getDatabaseConnectionPoolInterface();
70 70
		dataManager = 
71 71
			DataManager.getInstance(connectionPool, connectionPool.getDBAdapterName());
72 72
	}
src/edu/ucsb/nceas/metacat/dataquery/MetacatAuthenticatedEcogridEndPoint.java
1
/**
2
 *    '$RCSfile: ConfigurableEcogridEndPoint.java,v $'
3
 *
4
 *     '$Author: leinfelder $'
5
 *       '$Date: 2008/06/20 17:47:12 $'
6
 *   '$Revision: 1.1 $'
7
 *
8
 *  For Details: http://ecoinformatics.org
9
 *
10
 * Copyright (c) 2007 The Regents of the University of California.
11
 * All rights reserved.
12
 * 
13
 * Permission is hereby granted, without written agreement and without
14
 * license or royalty fees, to use, copy, modify, and distribute this
15
 * software and its documentation for any purpose, provided that the
16
 * above copyright notice and the following two paragraphs appear in
17
 * all copies of this software.
18
 * 
19
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
20
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
22
 * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
23
 * OF SUCH DAMAGE.
24
 * 
25
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
28
 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
29
 * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31
 */
32
package edu.ucsb.nceas.metacat.dataquery;
33

  
34
import org.ecoinformatics.datamanager.download.AuthenticatedEcogridEndPointInterface;
35

  
36
import edu.ucsb.nceas.metacat.properties.PropertyService;
37
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
38

  
39
/**
40
 * This class implements AuthenticatedEcogridEndPointInterface 
41
 * and is configurable using the properties file.
42
 * Useful for switching to remote endpoints etc.
43
 * 
44
 * @author leinfelder
45
 *
46
 */
47
public class MetacatAuthenticatedEcogridEndPoint 
48
	extends MetacatEcogridEndPoint implements AuthenticatedEcogridEndPointInterface  {  
49
		
50
	private String metacatAuthenticatedEcogridEndPoint = null;
51
	private String sessionId = null;
52
	
53
	public MetacatAuthenticatedEcogridEndPoint() {
54
		super();
55
		if (!loadProperties()) {
56
			metacatAuthenticatedEcogridEndPoint = baseURL + "AuthenticatedQueryService";
57
		}
58
	}
59
	
60
	public MetacatAuthenticatedEcogridEndPoint(String sessionId) {
61
		this();
62
		this.sessionId = sessionId;
63
	}
64
	
65
	private boolean loadProperties() {
66
		try {
67
			metacatAuthenticatedEcogridEndPoint = PropertyService.getProperty("datamanager.endpoint.authenticatedquery");
68
		} catch (PropertyNotFoundException e) {
69
			//e.printStackTrace();
70
			return false;
71
		}
72
		if (metacatAuthenticatedEcogridEndPoint == null || metacatAuthenticatedEcogridEndPoint.length() == 0) {
73
			return false;
74
		}
75
		return true;
76
	}
77
	
78
	 /**
79
	    * Gets the end point which Metacat implements authenticated ecogrid interface.
80
	    * This end point will be used to handle ecogrid protocol
81
        * 
82
	    * @return end point url string
83
	    */
84
	   public String getMetacatAuthenticatedEcogridEndPoint()
85
	   {
86
		   return metacatAuthenticatedEcogridEndPoint;
87
	   }
88

  
89
	   public String getSessionId()
90
	   {
91
		   return sessionId;
92
	   }
93
	   
94
	   public void setSessionId(String id) {
95
		   sessionId = id;
96
	   }
97
       
98
}
99

  
src/edu/ucsb/nceas/metacat/dataquery/MetacatDatabaseConnectionPoolFactory.java
1
/**
2
 *    '$RCSfile: DatabaseConnectionPoolFactory.java,v $'
3
 *
4
 *     '$Author: leinfelder $'
5
 *       '$Date: 2007/10/05 21:10:17 $'
6
 *   '$Revision: 1.1 $'
7
 *
8
 *  For Details: http://kepler.ecoinformatics.org
9
 *
10
 * Copyright (c) 2003 The Regents of the University of California.
11
 * All rights reserved.
12
 * 
13
 * Permission is hereby granted, without written agreement and without
14
 * license or royalty fees, to use, copy, modify, and distribute this
15
 * software and its documentation for any purpose, provided that the
16
 * above copyright notice and the following two paragraphs appear in
17
 * all copies of this software.
18
 * 
19
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
20
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
22
 * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
23
 * OF SUCH DAMAGE.
24
 * 
25
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
28
 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
29
 * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31
 */
32
package edu.ucsb.nceas.metacat.dataquery;
33

  
34
import edu.ucsb.nceas.metacat.properties.PropertyService;
35

  
36
import java.sql.Connection;
37
import java.sql.SQLException;
38

  
39
import org.apache.commons.logging.Log;
40
import org.apache.commons.logging.LogFactory;
41
import org.ecoinformatics.datamanager.database.ConnectionNotAvailableException;
42
import org.ecoinformatics.datamanager.database.DatabaseConnectionPoolInterface;
43

  
44
/**
45
 * This class provides an implementation of DataConnetionPoolInterface 
46
 * Implementation and database information for this class will be read from property file.
47
 * 
48
 * @author leinfelder
49
 * 
50
 */
51
public class MetacatDatabaseConnectionPoolFactory {
52
	
53
	public static Log log = LogFactory.getLog(MetacatDatabaseConnectionPoolFactory.class);
54
	
55
	private static String implementationClass = null;
56
		
57
	static {
58
		loadOptions();
59
	}
60
	
61
	/**
62
	 * Constructor. Loading database parameter from property file
63
	 * 
64
	 */
65
	public MetacatDatabaseConnectionPoolFactory() {
66
	}
67

  
68
	/**
69
	 * Loads Data Manager options from a configuration file.
70
	 */
71
	private static void loadOptions() {
72
		try {
73
			implementationClass = PropertyService.getProperty("datamanager.implementation");
74
		} 
75
		catch (Exception e) {
76
			log.error("Error in loading options: " + e.getMessage());
77
		}
78
	}
79

  
80
	public static DatabaseConnectionPoolInterface getDatabaseConnectionPoolInterface() {
81
		DatabaseConnectionPoolInterface instance = null;
82
		try {
83
			instance = 
84
				(DatabaseConnectionPoolInterface) Class.forName(implementationClass).newInstance();
85
		} catch (Exception e) {
86
			log.error(e.getMessage() 
87
					+ ": could not create DatabaseConnectionPoolInterface implementation: " 
88
					+ implementationClass);
89
			e.printStackTrace();
90
		} 
91
		
92
		return instance;
93

  
94
	}
95

  
96
	public static void main(String arg[]) {
97
		Connection conn = null;
98
		try {
99
			conn = MetacatDatabaseConnectionPoolFactory.getDatabaseConnectionPoolInterface().getConnection();
100
			log.debug("conn=" + conn);
101
			
102
		} catch (SQLException e) {
103
			// TODO Auto-generated catch block
104
			e.printStackTrace();
105
		} catch (ConnectionNotAvailableException e) {
106
			// TODO Auto-generated catch block
107
			e.printStackTrace();
108
		}
109
		finally {
110
			try {
111
				conn.close();
112
			} catch (SQLException e) {
113
				// TODO Auto-generated catch block
114
				e.printStackTrace();
115
			}
116
		}
117
	}
118
}
src/edu/ucsb/nceas/metacat/dataquery/MetacatEcogridEndPoint.java
1
/**
2
 *    '$RCSfile: ConfigurableEcogridEndPoint.java,v $'
3
 *
4
 *     '$Author: leinfelder $'
5
 *       '$Date: 2008/06/20 17:47:12 $'
6
 *   '$Revision: 1.1 $'
7
 *
8
 *  For Details: http://ecoinformatics.org
9
 *
10
 * Copyright (c) 2007 The Regents of the University of California.
11
 * All rights reserved.
12
 * 
13
 * Permission is hereby granted, without written agreement and without
14
 * license or royalty fees, to use, copy, modify, and distribute this
15
 * software and its documentation for any purpose, provided that the
16
 * above copyright notice and the following two paragraphs appear in
17
 * all copies of this software.
18
 * 
19
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
20
 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
21
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
22
 * IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY
23
 * OF SUCH DAMAGE.
24
 * 
25
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
26
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
27
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
28
 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY
29
 * OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
30
 * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
31
 */
32
package edu.ucsb.nceas.metacat.dataquery;
33

  
34
import org.ecoinformatics.datamanager.download.EcogridEndPointInterface;
35

  
36
import edu.ucsb.nceas.metacat.properties.PropertyService;
37
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
38

  
39
/**
40
 * This class implements EcogridEndPointInterface and is configurable using a properties file.
41
 * Should be useful for switching to remote endpoints etc.
42
 * 
43
 * @author leinfelder
44
 *
45
 */
46
public class MetacatEcogridEndPoint implements EcogridEndPointInterface 
47
{  
48
		
49
	private String metacatEcogridEndPoint = null;
50
	private String metacatEcogridAuthEndPoint = null;
51
	private String metacatEcogridPutEndPoint = null;
52
	private String metacatEcogridIdentifierEndPoint = null;
53
	private String srbEcogridEndPoint = null;
54
	private String srbMachineName = null;
55
	
56
	protected String baseURL = null;
57
	
58
	public MetacatEcogridEndPoint() {
59
		if (!loadProperties()) {
60
			try {
61
				//use values from server where deployed
62
				baseURL = 
63
					"http://"
64
					+ PropertyService.getProperty("server.name")
65
					+ ":"
66
					+ PropertyService.getProperty("server.httpPort")
67
					+ "/"
68
					+ PropertyService.getProperty("application.context")
69
					+ "/services/";
70
				metacatEcogridEndPoint = baseURL + "QueryService";
71
				metacatEcogridAuthEndPoint = baseURL + "AuthenticationService";
72
				metacatEcogridPutEndPoint = baseURL + "PutService";
73
				metacatEcogridIdentifierEndPoint = baseURL + "IdentificationService";
74
			} catch (PropertyNotFoundException e) {
75
				//we are SOL now
76
				e.printStackTrace();
77
			}
78
		}	
79
	}
80
	
81
	private boolean loadProperties() {
82
		try {
83
			metacatEcogridEndPoint 				= PropertyService.getProperty("datamanager.endpoint.query");
84
			metacatEcogridAuthEndPoint 			= PropertyService.getProperty("datamanager.endpoint.authentication");
85
			metacatEcogridPutEndPoint 			= PropertyService.getProperty("datamanager.endpoint.put");
86
			metacatEcogridIdentifierEndPoint 	= PropertyService.getProperty("datamanager.endpoint.identifier");
87
			srbEcogridEndPoint 					= PropertyService.getProperty("datamanager.srb.endpoint");
88
			srbMachineName 						= PropertyService.getProperty("datamanager.srb.machinename");
89
		} catch (PropertyNotFoundException e) {
90
			//e.printStackTrace();
91
			return false;
92
		}
93
		if (metacatEcogridEndPoint == null || metacatEcogridEndPoint.length() == 0) {
94
			return false;
95
		}
96
		return true;
97
	}
98
	 /**
99
	    * Gets the end point which Metacat implements ecogrid interface.
100
	    * This end point will be used to handle ecogrid protocol
101
        * 
102
	    * @return end point url string
103
	    */
104
	   public String getMetacatEcogridEndPoint()
105
	   {
106
		   return metacatEcogridEndPoint;
107
	   }
108
	   
109
	   public String getMetacatEcogridAuthEndPoint()
110
	   {
111
		   return metacatEcogridAuthEndPoint;
112
	   }
113
	   
114
	   public String getMetacatEcogridPutEndPoint()
115
	   {
116
		   return metacatEcogridPutEndPoint;
117
	   }
118
	   
119
	   public String getMetacatEcogridIdentifierEndPoint() 
120
	   {
121
			return metacatEcogridIdentifierEndPoint;
122
		}
123
	   
124
       
125
	   /**
126
	    * Gets the end point which SRB implements ecogrid interface.
127
	    * This end point will be used to handle srb protocol.
128
        * 
129
	    * @return end point url string
130
	    */
131
	   public String getSRBEcogridEndPoint()
132
	   {
133
		   return srbEcogridEndPoint;
134
	   }
135

  
136
       
137
	   /**
138
	    * Gets the machine name which srb protocol will be used.
139
	    * The default value for this class is "srb-mcat.sdsc.edu".
140
        * 
141
	    * @return the machine name of srb server
142
	    */
143
	   public String getSRBMachineName()
144
	   {
145
		   return srbMachineName;
146
	   }
147
       
148
}
149

  

Also available in: Unified diff