Changeset 1455 for MDService2/trunk/MDService2/src/eu
- Timestamp:
- 06/29/11 21:54:52 (13 years ago)
- Location:
- MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
r1429 r1455 523 523 } 524 524 525 public Boolean isSRURepository(){ 526 //Boolean issru = false; 527 String srustr = ""; 528 529 if (repositories == null ) { 530 try { 531 setRepositories(GenericProxyAction.createRepositories()); 532 } catch (IOException e) { 533 // TODO Auto-generated catch block 534 e.printStackTrace(); 535 } catch (InterruptedException e) { 536 // TODO Auto-generated catch block 537 e.printStackTrace(); 538 } catch (TransformerException e) { 539 // TODO Auto-generated catch block 540 e.printStackTrace(); 541 } 542 } 543 // static repositories 544 net.sf.json.JSONArray json = getRepositories(); 545 for(int i=0;i<json.size();i++){ 546 if (json.getJSONObject(i).getString("name").equals(getRepository())){ 547 srustr = json.getJSONObject(i).getString("sruextern"); 548 } 549 } 550 551 return (srustr.equals("1")); 552 553 } 525 554 public String addDurationKey(){ 526 555 String req_key = getRequestKey(); -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/SRUProxyAction.java
r1236 r1455 15 15 import java.net.URL; 16 16 import java.util.HashMap; 17 import java.util.Iterator; 18 import java.util.Map; 19 import java.util.Set; 17 20 18 21 import javax.servlet.http.HttpServletRequest; … … 287 290 mdrepoproxyaction.setActionkey(hash_operations.get(this.getOperation())); 288 291 292 // set the SRU extern property in proxyaction 293 if (this.getX_cmd_repository() != null ) { 294 mdrepoproxyaction.setRepository(this.getX_cmd_repository()); 295 //TODO\ 296 if (mdrepoproxyaction.getBaseURI() == null) this.Diagnostics().Add(Diagnostic.UNSUPPORTED_PARAMETERVALUE, "Unknown repository." + getX_cmd_repository()); 297 } 298 289 299 if (operation.equals("searchRetrieve")){ 290 300 … … 351 361 public void prepare() throws UnsupportedEncodingException{ 352 362 // special handling of parameter setting, x-cmd-... not alowed in java 353 this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository"));354 363 this.setX_cmd_collections(getServletRequest().getParameter("x-cmd-collections")); 355 364 356 // root call 365 // root call own SRU SERVER 357 366 //operation 358 367 if (operation.equals("explain") || operation == null){ … … 455 464 */ 456 465 public String execute() throws Exception { 466 this.setX_cmd_repository(getServletRequest().getParameter("x-cmd-repository")); 467 //check if extern SRU repository 468 if (this.getX_cmd_repository() != null){ 469 MDRepoProxyAction a = new MDRepoProxyAction(); 470 a.setRepository(this.getX_cmd_repository()); 471 // direct SRU - URL 472 if (a.isSRURepository() || (a.getBaseURI() == null)){ 473 String requestURL = ""; 474 if (a.getBaseURI() == null){ 475 requestURL = this.getX_cmd_repository(); 476 } else { 477 requestURL = a.getBaseURI(); 478 } 479 Set set = getServletRequest().getParameterMap().entrySet(); 480 Iterator i = set.iterator(); 481 String params = ""; 482 while(i.hasNext()){ 483 Map.Entry me = (Map.Entry)i.next(); 484 params = params + "&" + me.getKey() + "=" + ((String[])me.getValue())[0]; 485 } 486 params = params.substring(1); 487 URL url = new URL(requestURL + "?" + params); 488 //getServletRequest().getRequestURL() 489 resultStream = url.openStream();//getServletRequest().getRequestURL().openStream(); 490 return SUCCESS; 491 } 492 } 457 493 prepare(); 458 494 if (Diagnostics().Accepted()){ -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/model/Query.java
r1429 r1455 14 14 import java.net.MalformedURLException; 15 15 import java.net.URL; 16 import java.util.Iterator; 17 import java.util.Map; 18 import java.util.Set; 16 19 17 20 import javax.xml.parsers.DocumentBuilder; … … 33 36 public static String RECORDSET = "recordset"; 34 37 public static String RECORD = "record"; 38 public static String SRUEXTERN = "sruextern"; 35 39 36 40 public static String PARSED = "parsed"; … … 64 68 private int maxdepth=1; 65 69 70 private Map sruMap = null; 66 71 /** 67 72 * reference to the result-object … … 278 283 } 279 284 285 286 public Map getSruMap() { 287 return sruMap; 288 } 289 290 public void setSruMap(Map sruMap) { 291 this.sruMap = sruMap; 292 } 293 294 280 295 // apply rules form squery 281 296 public String createsqueryString (String _squery){ … … 342 357 if (type.equals(MODEL)) { 343 358 targetRequest = fromCMDIndex2Xpath() + "&maxdepth=" + getMaxdepth() ; /* + "&maxdepth=" + getMaxdepth() ); "&collection=" + getCollection() + */ 359 } else if (type.equals(SRUEXTERN)) { 360 targetRequest = "";//fromCMDIndex2Xpath() + "&maxdepth=" + getMaxdepth() ; /* + "&maxdepth=" + getMaxdepth() ); "&collection=" + getCollection() + */ 361 362 Set set = sruMap.entrySet(); 363 Iterator i = set.iterator(); 364 365 while(i.hasNext()){ 366 Map.Entry me = (Map.Entry)i.next(); 367 targetRequest = targetRequest + "&" + me.getKey() + "=" + me.getValue(); 368 } 369 344 370 } else if (type.equals(VALUES)) { 345 371 targetRequest = fromCMDIndex2Xpath() ; /* + "&maxdepth=" + getMaxdepth() ); "&collection=" + getCollection() + */ … … 363 389 Admin.notifyUser("Query.toURLParam.corrid=" + corrid); 364 390 targetRequest = "//MdSelfLink[ft:query(.,'" + corrid + "')]"; 365 } else { 366 if (query_cql == null){367 targetRequest = "//*" + "&collection=" + getCollection();368 } else {369 targetRequest = toXPath() + "&collection=" + getCollection();370 }371 if (startItem != null) {372 targetRequest = targetRequest + "&startItem=" + getStartItem();373 }374 if (maximumItems != null) {375 targetRequest = targetRequest + "&maxItems=" + getMaximumItems();376 }377 if ((options != null)) {378 targetRequest = targetRequest + "&format=xml-" + getOptions();379 }380 } 381 391 } else { 392 if (query_cql == null){ 393 targetRequest = "//*" + "&collection=" + getCollection(); 394 } else { 395 targetRequest = toXPath() + "&collection=" + getCollection(); 396 } 397 if (startItem != null) { 398 targetRequest = targetRequest + "&startItem=" + getStartItem(); 399 } 400 if (maximumItems != null) { 401 targetRequest = targetRequest + "&maxItems=" + getMaximumItems(); 402 } 403 if ((options != null)) { 404 targetRequest = targetRequest + "&format=xml-" + getOptions(); 405 } 406 } 407 382 408 return targetRequest; 383 409 384 410 } 385 411 386 412 /**
Note: See TracChangeset
for help on using the changeset viewer.