1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2009 University of New Mexico and the
|
4
|
* Regents of the University of California
|
5
|
*
|
6
|
* '$Author: costa $'
|
7
|
* '$Date: 2009-07-27 17:47:44 -0400 (Mon, 27 Jul 2009) $'
|
8
|
* '$Revision: 4999 $'
|
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
|
* Additional Copyright 2006 OCLC, Online Computer Library Center
|
25
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
26
|
* you may not use this file except in compliance with the License.
|
27
|
* You may obtain a copy of the License at
|
28
|
*
|
29
|
* http://www.apache.org/licenses/LICENSE-2.0
|
30
|
*
|
31
|
* Unless required by applicable law or agreed to in writing, software
|
32
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
33
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
34
|
* See the License for the specific language governing permissions and
|
35
|
* limitations under the License.
|
36
|
*/
|
37
|
|
38
|
package edu.ucsb.nceas.metacat.oaipmh.harvester;
|
39
|
|
40
|
import java.io.IOException;
|
41
|
import javax.xml.parsers.ParserConfigurationException;
|
42
|
import javax.xml.transform.TransformerException;
|
43
|
import org.xml.sax.SAXException;
|
44
|
|
45
|
|
46
|
/**
|
47
|
* This class represents an Identify response on either the server or on the
|
48
|
* client
|
49
|
*
|
50
|
* @author Jeffrey A. Young, OCLC Online Computer Library Center
|
51
|
*/
|
52
|
public class Identify extends HarvesterVerb {
|
53
|
|
54
|
/**
|
55
|
* Mock object constructor (for unit testing purposes)
|
56
|
*/
|
57
|
public Identify() {
|
58
|
super();
|
59
|
}
|
60
|
|
61
|
|
62
|
/**
|
63
|
* Client-side Identify verb constructor
|
64
|
*
|
65
|
* @param baseURL
|
66
|
* the baseURL of the server to be queried
|
67
|
* @exception MalformedURLException
|
68
|
* the baseURL is bad
|
69
|
* @exception IOException
|
70
|
* an I/O error occurred
|
71
|
*/
|
72
|
public Identify(String baseURL) throws IOException,
|
73
|
ParserConfigurationException, SAXException, TransformerException {
|
74
|
super(getRequestURL(baseURL));
|
75
|
}
|
76
|
|
77
|
|
78
|
/**
|
79
|
* Get the oai:protocolVersion value from the Identify response
|
80
|
*
|
81
|
* @return the oai:protocolVersion value
|
82
|
* @throws TransformerException
|
83
|
* @throws NoSuchFieldException
|
84
|
*/
|
85
|
public String getProtocolVersion() throws TransformerException,
|
86
|
NoSuchFieldException {
|
87
|
if (SCHEMA_LOCATION_V2_0.equals(getSchemaLocation())) {
|
88
|
return getSingleString(
|
89
|
"/oai20:OAI-PMH/oai20:Identify/oai20:protocolVersion"
|
90
|
);
|
91
|
}
|
92
|
else {
|
93
|
throw new NoSuchFieldException(getSchemaLocation());
|
94
|
}
|
95
|
}
|
96
|
|
97
|
|
98
|
/**
|
99
|
* generate the Identify request URL for the specified baseURL
|
100
|
*
|
101
|
* @param baseURL
|
102
|
* @return the requestURL
|
103
|
*/
|
104
|
private static String getRequestURL(String baseURL) {
|
105
|
StringBuffer requestURL = new StringBuffer(baseURL);
|
106
|
requestURL.append("?verb=Identify");
|
107
|
return requestURL.toString();
|
108
|
}
|
109
|
}
|