Revision 731
Added by bojilova almost 23 years ago
MetaCatUtil.java | ||
---|---|---|
258 | 258 |
boolean poundflag = false; |
259 | 259 |
int arrcount = 0; |
260 | 260 |
|
261 |
for (int i=0; i < query.length(); i++) { |
|
261 |
if ( query != null ) { |
|
262 |
for (int i=0; i < query.length(); i++) { |
|
262 | 263 |
|
263 |
// go throught the remainder of the query one character at a time. |
|
264 |
if (query.charAt(i) == '=') { |
|
265 |
// if the current char is a # then the preceding should be a name |
|
266 |
if (!poundflag && ampflag) { |
|
267 |
params[arrcount][0] = temp.trim(); |
|
268 |
temp = ""; |
|
269 |
} else { |
|
270 |
//if there are two #s or &s in a row throw an exception. |
|
271 |
throw new MalformedURLException("metacatURL: Two parameter names " + "not allowed in sequence"); |
|
272 |
} |
|
273 |
poundflag = true; |
|
274 |
ampflag = false; |
|
275 |
} else if (query.charAt(i) == '&' || i == query.length()-1) { |
|
276 |
//the text preceding the & should be the param value. |
|
277 |
if (i == query.length() - 1) { |
|
278 |
//if at the end of the string grab the last value and append it. |
|
279 |
if (query.charAt(i) != '=') { |
|
264 |
// go throught the remainder of the query one character at a time. |
|
265 |
if (query.charAt(i) == '=') { |
|
266 |
// if the current char is a # then the preceding should be a name |
|
267 |
if (!poundflag && ampflag) { |
|
268 |
params[arrcount][0] = temp.trim(); |
|
269 |
temp = ""; |
|
270 |
} else { |
|
271 |
//if there are two #s or &s in a row throw an exception. |
|
272 |
throw new MalformedURLException("metacatURL: Two parameter names "+ |
|
273 |
"not allowed in sequence"); |
|
274 |
} |
|
275 |
poundflag = true; |
|
276 |
ampflag = false; |
|
277 |
} else if (query.charAt(i) == '&' || i == query.length()-1) { |
|
278 |
//the text preceding the & should be the param value. |
|
279 |
if (i == query.length() - 1) { |
|
280 |
//if at the end of the string grab the last value and append it. |
|
281 |
if (query.charAt(i) != '=') { |
|
280 | 282 |
//ignore an extra & on the end of the string |
281 |
temp += query.charAt(i); |
|
283 |
temp += query.charAt(i); |
|
284 |
} |
|
282 | 285 |
} |
283 |
} |
|
284 |
|
|
285 |
if (!ampflag && poundflag) { |
|
286 |
params[arrcount][1] = temp.trim(); |
|
287 |
parameters.put(params[arrcount][0], params[arrcount][1]); |
|
288 |
temp = ""; |
|
289 |
arrcount++; //increment the array to the next row. |
|
286 |
|
|
287 |
if (!ampflag && poundflag) { |
|
288 |
params[arrcount][1] = temp.trim(); |
|
289 |
parameters.put(params[arrcount][0], params[arrcount][1]); |
|
290 |
temp = ""; |
|
291 |
arrcount++; //increment the array to the next row. |
|
292 |
} else { |
|
293 |
//if there are two =s or &s in a row through an exception |
|
294 |
throw new MalformedURLException("metacatURL: Two parameter values "+ |
|
295 |
"not allowed in sequence"); |
|
296 |
} |
|
297 |
poundflag = false; |
|
298 |
ampflag = true; |
|
290 | 299 |
} else { |
291 |
//if there are two =s or &s in a row through an exception |
|
292 |
throw new MalformedURLException("metacatURL: Two parameter values " + |
|
293 |
"not allowed in sequence"); |
|
300 |
//get the next character in the string |
|
301 |
temp += query.charAt(i); |
|
294 | 302 |
} |
295 |
poundflag = false; |
|
296 |
ampflag = true; |
|
297 |
} else { |
|
298 |
//get the next character in the string |
|
299 |
temp += query.charAt(i); |
|
300 | 303 |
} |
301 | 304 |
} |
302 | 305 |
return parameters; |
Also available in: Unified diff
- merged "getabstract" and "getdatadoc" actions to "read" action;
- put MIME types everywhere for the returned data;
- zip when more than one doc/files were requested or when specified by qformat="zip" parameter;
- get rid of "relation" parameter, instead use "docid" parameter name only - when more that one docid - zip them;
- get abstract for a metacat doc (docid) when "abstractpath" parameter is specified
- small fix in MetaCatUtil when parsing a query string of URL
So now "read" action can read xml metadata or any data files from Metacat or any file thru HTTP URLConnection
using these parameters and their combinations:
action=read
docid=nceas.1
docid=http://...?docid=nceas.2
docid=metacat://...?docid=nceas.3
docid=http://.../filename
qformat=html
qformat=xml(default for metacat metadata)
qformat=zip(default when more than one docids requested)
abstractpath