Project

General

Profile

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

    
(2-2/5)