Revision 384
Added by berkley over 24 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
455 | 455 |
String xmlquery = DBQuery.createSQuery(params); |
456 | 456 |
Hashtable doclist = runQuery(xmlquery); |
457 | 457 |
String qformat = ((String[])params.get("qformat"))[0]; |
458 |
String resultdoc = createResultDocument(doclist, xmlquery);
|
|
458 |
String resultdoc = createResultDocument(doclist, transformQuery(params));
|
|
459 | 459 |
|
460 | 460 |
//format and transform the results |
461 | 461 |
if(qformat.equals("html")) { |
... | ... | |
469 | 469 |
} |
470 | 470 |
|
471 | 471 |
/** |
472 |
* Removes the <?xml version="x"?> tag from the beginning of xmlquery |
|
473 |
* so it can properly be placed in the <query> tag of the resultset. |
|
474 |
* This method is overwritable so that other applications can customize |
|
475 |
* the structure of what is in the <query> tag. |
|
476 |
* |
|
477 |
* @param xmlquery is the query to remove the <?xml version="x"?> tag from. |
|
478 |
*/ |
|
479 |
protected String transformQuery(Hashtable params) |
|
480 |
{ |
|
481 |
//DBQuery.createSQuery is a re-calling of a previously called |
|
482 |
//function but it is necessary |
|
483 |
//so that overriding methods have access to the params hashtable |
|
484 |
String xmlquery = DBQuery.createSQuery(params); |
|
485 |
//the <?xml version="1.0"?> tag is the first 22 characters of the |
|
486 |
xmlquery = xmlquery.trim(); |
|
487 |
int index = xmlquery.indexOf("?>"); |
|
488 |
return xmlquery.substring(index + 2, xmlquery.length()); |
|
489 |
} |
|
490 |
|
|
491 |
/** |
|
472 | 492 |
* Run the query and return a hashtable of results. |
473 | 493 |
* |
474 | 494 |
* @param xmlquery the query to run |
... | ... | |
548 | 568 |
//like the <?xml?> tag inside the <query> tag. This is supposed to be |
549 | 569 |
//the way that the query itself is sent back to the client. |
550 | 570 |
|
551 |
//resultset.append(" <query>" + xmlquery + "</query>");
|
|
571 |
resultset.append(" <query>" + xmlquery + "</query>"); |
|
552 | 572 |
|
553 | 573 |
Enumeration doclistkeys = doclist.keys(); |
554 | 574 |
while (doclistkeys.hasMoreElements()) |
... | ... | |
652 | 672 |
} |
653 | 673 |
newdocid = dbw.write(xml, doAction, accNumber); |
654 | 674 |
} catch (NullPointerException npe) { |
655 |
newdocid = dbw.write(xml, doAction, null);
|
|
675 |
newdocid = dbw.write(xml, doAction, null); |
|
656 | 676 |
} |
657 | 677 |
} catch (Exception e) { |
658 | 678 |
response.setContentType("text/html"); |
Also available in: Unified diff
-fixed the bug where a pathquery document was not valid inside of the <query> tags in a resultset document.
-provided override support for a new function called transformQuery() which allows specific applications to
customize what is returned in the <query> tag