Project

General

Profile

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 ListSets 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 ListSets extends HarvesterVerb {
53

    
54
  /**
55
   * Mock object constructor (for unit testing purposes)
56
   */
57
  public ListSets() {
58
    super();
59
  }
60

    
61

    
62
  /**
63
   * Client-side ListSets 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 ListSets(String baseURL) throws IOException,
73
      ParserConfigurationException, SAXException, TransformerException {
74
    super(getRequestURL(baseURL));
75
  }
76

    
77

    
78
  /**
79
   * Get the oai:resumptionToken from the response
80
   * 
81
   * @return the oai:resumptionToken as a String
82
   * @throws TransformerException
83
   * @throws NoSuchFieldException
84
   */
85
  public String getResumptionToken() throws TransformerException,
86
      NoSuchFieldException {
87
    if (SCHEMA_LOCATION_V2_0.equals(getSchemaLocation())) {
88
      return getSingleString("/oai20:OAI-PMH/oai20:ListSets/oai20:resumptionToken");
89
    } else {
90
      throw new NoSuchFieldException(getSchemaLocation());
91
    }
92
  }
93

    
94

    
95
  /**
96
   * Generate a ListSets request for the given baseURL
97
   * 
98
   * @param baseURL
99
   * @return
100
   */
101
  private static String getRequestURL(String baseURL) {
102
    StringBuffer requestURL = new StringBuffer(baseURL);
103
    requestURL.append("?verb=ListSets");
104
    return requestURL.toString();
105
  }
106
}
(7-7/8)