40 |
40 |
*/
|
41 |
41 |
public class RestIterator implements Iterator<String> {
|
42 |
42 |
|
|
43 |
// TODO: clean up the comments of replaced source code
|
43 |
44 |
private static final Log log = LogFactory.getLog(OaiIterator.class); // NOPMD by marko on 11/24/08 5:02 PM
|
44 |
45 |
|
45 |
46 |
private static final String wrapName = "recordWrap";
|
... | ... | |
72 |
73 |
final String resultFormatParam,
|
73 |
74 |
final String resultFormatValue,
|
74 |
75 |
final String resultSizeParam,
|
75 |
|
final String resultSizeValue,
|
|
76 |
final String resultSizeValueStr,
|
76 |
77 |
final String queryParams,
|
77 |
78 |
final String entityXpath
|
78 |
79 |
) {
|
... | ... | |
81 |
82 |
this.resumptionParam = resumptionParam;
|
82 |
83 |
this.resultFormatValue = resultFormatValue;
|
83 |
84 |
this.queryParams = queryParams;
|
84 |
|
|
|
85 |
this.resultSizeValue = Integer.valueOf(resultSizeValueStr);
|
|
86 |
|
85 |
87 |
queryFormat = StringUtils.isNotBlank(resultFormatParam) ? "&" + resultFormatParam + "=" + resultFormatValue : "";
|
86 |
|
querySize = StringUtils.isNotBlank(resultSizeParam) ? "&" + resultSizeParam + "=" + resultSizeValue : "";
|
|
88 |
querySize = StringUtils.isNotBlank(resultSizeParam) ? "&" + resultSizeParam + "=" + resultSizeValueStr : "";
|
87 |
89 |
|
88 |
90 |
try {
|
89 |
91 |
initXmlTransformation(resultTotalXpath, resumptionXpath, entityXpath);
|
... | ... | |
150 |
152 |
String resultXml = "";
|
151 |
153 |
String nextQuery = "";
|
152 |
154 |
try {
|
153 |
|
resultStream = new URL(query).openStream();
|
|
155 |
resultStream = new URL(query).openStream();
|
154 |
156 |
if("json".equals(resultFormatValue.toLowerCase())){
|
155 |
157 |
resultJson = IOUtils.toString(resultStream,"UTF-8");
|
156 |
158 |
|
... | ... | |
177 |
179 |
|
178 |
180 |
resumptionInt += resultSizeValue;
|
179 |
181 |
|
|
182 |
/* replaced by switch statement as follow
|
|
183 |
if("scan".equals(resumptionType.toLowerCase())) { resumptionStr = xprResumptionPath.evaluate(resultNode);}
|
|
184 |
if("count".equals(resumptionType.toLowerCase())){ resumptionStr = Integer.toString(resumptionInt); }
|
|
185 |
*/
|
180 |
186 |
switch(resumptionType.toLowerCase()) {
|
181 |
187 |
case "scan":
|
182 |
188 |
resumptionStr = xprResumptionPath.evaluate(resultNode);
|
... | ... | |
195 |
201 |
}
|
196 |
202 |
break;
|
197 |
203 |
default:
|
|
204 |
resultTotal = resumptionInt;
|
|
205 |
break;
|
198 |
206 |
}
|
199 |
|
/* if("scan".equals(resumptionType.toLowerCase())) { resumptionStr = xprResumptionPath.evaluate(resultNode);}
|
200 |
|
if("count".equals(resumptionType.toLowerCase())){ resumptionStr = Integer.toString(resumptionInt); }
|
201 |
|
*/
|
|
207 |
|
202 |
208 |
if (resultTotal == -1) {
|
203 |
209 |
resultTotal = Integer.parseInt(xprResultTotalPath.evaluate(resultNode));
|
204 |
210 |
log.info("resultTotal: " + resultTotal);
|
... | ... | |
209 |
215 |
nextQuery = baseUrl + "?" + queryParams + querySize + "&" + resumptionParam + "=" + resumptionStr + queryFormat;
|
210 |
216 |
} else
|
211 |
217 |
nextQuery = "";
|
|
218 |
|
|
219 |
log.info("nextQueryUrl: " + nextQuery);
|
212 |
220 |
return nextQuery;
|
213 |
221 |
|
214 |
222 |
} catch(Exception e) {
|
Small changes in the Rest_Json CollectorPlugin for the enhancements of the new OpenDOAR API at JISC under https://v2.sherpa.ac.uk/opendoar/