Changeset 1491
- Timestamp:
- 08/22/11 12:35:53 (13 years ago)
- Location:
- MDService2/trunk/MDService2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
MDService2/trunk/MDService2/WorkspaceProfile.xml
r1476 r1491 104 104 <Querysets>null</Querysets> 105 105 <Bookmarksets>null</Bookmarksets> 106 106 107 <created>a</created> 107 108 <lastchanged>a</lastchanged> 108 109 <profilename>a</profilename> 109 110 <username>a</username> 111 <Options> 112 <pazpartimeout>10</pazpartimeout> 113 </Options> 110 114 </WorkspaceProfile> 111 115 -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
r1488 r1491 46 46 47 47 private static JSONArray repositories = null; 48 private static JSONObject wp_options = null; 48 49 49 50 private Diagnostics diagnostics; … … 326 327 } 327 328 329 public JSONObject getWPOptions(){ 330 return wp_options; 331 } 332 333 public void setWPOptions(JSONObject op){ 334 GenericProxyAction.wp_options = op; 335 } 336 328 337 protected URL base_url ; 329 338 … … 484 493 } 485 494 495 public static JSONObject createWPOptions() throws IOException, InterruptedException, TransformerException, NoStylesheetException{ 496 String path = Admin.getConfig().getProperty("workspaceprofile.path") + WorkspaceAction.WORKSPACE_FILENAME;//PROFILENAME_SERVER; 497 File file=new File(path); 498 InputStream in = new BufferedInputStream( new FileInputStream(path));; 499 500 MDTransformer transformer = new MDTransformer(); 501 transformer.setSrcFile(file.toURI().toURL()); 502 transformer.setParams(MDTransformer.createParamsMap("xml2json")); 503 InputStream jsonstream = transformer.transformXML(in); 504 505 JSONObject json = JSONObject.fromObject(convertStreamToString(jsonstream)); 506 JSONArray wparray = json.getJSONObject("Profiles").getJSONArray("WorkspaceProfiles"); 507 JSONObject obj = null; 508 for (int i = 0; i < wparray.size(); ++i) { 509 JSONObject wp = wparray.getJSONObject(i); 510 if (wp.get("Options") != null){ 511 obj = wp.getJSONObject("Options"); 512 break; 513 } 514 } 515 516 // options as static variable 517 return obj; 518 519 } 520 521 public String getWPOption(String opt_key){ 522 String option_val = null; 523 524 525 if (wp_options == null ) { 526 try { 527 setWPOptions(GenericProxyAction.createWPOptions()); 528 } catch (IOException e) { 529 // TODO Auto-generated catch block 530 e.printStackTrace(); 531 } catch (InterruptedException e) { 532 // TODO Auto-generated catch block 533 e.printStackTrace(); 534 } catch (TransformerException e) { 535 // TODO Auto-generated catch block 536 e.printStackTrace(); 537 } catch (NoStylesheetException e) { 538 // TODO Auto-generated catch block 539 e.printStackTrace(); 540 } 541 } 542 // static options 543 if (wp_options != null){ 544 net.sf.json.JSONObject json = getWPOptions(); 545 option_val = json.getString(opt_key); 546 } 547 548 549 return option_val; 550 551 } 486 552 487 553 public String getRepositoryPath(){ -
MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/Pz2ProxyAction.java
r1488 r1491 189 189 190 190 InputStream is = null; 191 191 // TODO param settings 192 192 //init 193 193 setCommand("init"); … … 203 203 setSort("relevance"); 204 204 setBlock("1"); 205 //TODO timeout settings 206 long startMillis = System.currentTimeMillis(); 207 long timeout = 0; 208 if (this.getWPOption("pazpartimeout") == null){ 209 timeout = 1000; 210 } else { 211 timeout = Integer.parseInt(this.getWPOption("pazpartimeout")); 212 } 205 213 while (Integer.parseInt(activeclients) > 0){ 206 214 //activeclients = getDocumentData(this.getSourceStream(), "//show/activeclients"); 207 215 is = this.getSourceStream(); 208 216 activeclients = getDocumentData(is, "//show/activeclients"); 209 217 Thread.sleep(1000); 218 Admin.notifyUser("ActiveClients: " + activeclients, Admin.DEBUG); 219 if ((System.currentTimeMillis() - startMillis) > timeout) { 220 break; 221 } 210 222 } 211 223 is = this.getSourceStream();
Note: See TracChangeset
for help on using the changeset viewer.