Changeset 1491 for MDService2/trunk/MDService2/src/eu/clarin/cmdi/mdservice/action/GenericProxyAction.java
- Timestamp:
- 08/22/11 12:35:53 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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(){
Note: See TracChangeset
for help on using the changeset viewer.