1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2005 University of New Mexico and the
|
4
|
* Regents of the University of California and the
|
5
|
* National Center for Ecological Analysis and Synthesis
|
6
|
* '$Author: costa $'
|
7
|
* '$Date: 2005-11-16 09:57:33 -0800 (Wed, 16 Nov 2005) $'
|
8
|
* '$Revision: 2741 $'
|
9
|
*
|
10
|
* This program is free software; you can redistribute it and/or modify
|
11
|
* it under the terms of the GNU General Public License as published by
|
12
|
* the Free Software Foundation; either version 2 of the License, or
|
13
|
* (at your option) any later version.
|
14
|
*
|
15
|
* This program is distributed in the hope that it will be useful,
|
16
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
* GNU General Public License for more details.
|
19
|
*
|
20
|
* You should have received a copy of the GNU General Public License
|
21
|
* along with this program; if not, write to the Free Software
|
22
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
*/
|
24
|
|
25
|
package edu.ucsb.nceas.metacat.advancedsearch;
|
26
|
|
27
|
|
28
|
/**
|
29
|
* @author dcosta
|
30
|
*
|
31
|
* MetacatHelper provides auxiliary methods for helping the advanced search
|
32
|
* classes interact with Metacat.
|
33
|
*/
|
34
|
public class MetacatHelper {
|
35
|
|
36
|
/**
|
37
|
* Constructs a DN (Distinguished Name) string for the ecoinformatics.org
|
38
|
* LDAP.
|
39
|
*
|
40
|
* @param username The LDAP uid, e.g. "dcosta"
|
41
|
* @param organization The LDAP organization, e.g. "LTER"
|
42
|
* @return DN The distinguished name string.
|
43
|
*/
|
44
|
public String constructDN(final String username, final String organization) {
|
45
|
final String DN = "uid=" + username +
|
46
|
",o=" + organization +
|
47
|
",dc=ecoinformatics,dc=org";
|
48
|
|
49
|
return DN;
|
50
|
}
|
51
|
|
52
|
|
53
|
/**
|
54
|
* Constructs a URL to the metacat servlet. Assumes that metacat is always
|
55
|
* configured to run in the "knb" context (the defacto standard).
|
56
|
*
|
57
|
* @param serverName A server name, e.g. "prairie.lternet.edu"
|
58
|
* @param serverPort A server port, e.g. 8080. If no port is required in
|
59
|
* the URL, pass a 0 and the argument will be ignored.
|
60
|
* @return metacatURL The URL to the metacat servlet.
|
61
|
*/
|
62
|
public String constructMetacatURL(final String serverName,
|
63
|
final int serverPort) {
|
64
|
String metacatURL = "http://" + serverName;
|
65
|
|
66
|
if (serverPort > 0) {
|
67
|
final Integer serverPortInteger = new Integer(serverPort);
|
68
|
final String serverPortString = serverPortInteger.toString();
|
69
|
metacatURL += ":" + serverPortString + "/knb/metacat";
|
70
|
}
|
71
|
else {
|
72
|
metacatURL += "/knb/metacat";
|
73
|
}
|
74
|
|
75
|
return metacatURL;
|
76
|
}
|
77
|
|
78
|
}
|