public static KeyValue[] toKeyValue(Configuration _cfg) { final Set<KeyValue> values = new HashSet<KeyValue>(); final Iterator<String> iter = _cfg.getKeys(); String key = null; String[] value = null; while(iter.hasNext()) { key = iter.next(); if(!(key.equals("vulas.jira.usr")||key.equals("vulas.jira.pwd"))) values.add(new KeyValue(key, _cfg.getStringArray(key))); } return values.toArray(new KeyValue[values.size()]); } }
/** * Returns an array of {@link KeyValue}s with configuration settings read from {@link VulasConfiguration}. * @return 404 {@link HttpStatus#NOT_FOUND} if library with given SHA1 does not exist, 200 {@link HttpStatus#OK} if the library is found */ @RequestMapping(value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) public ResponseEntity<KeyValue[]> getConfiguration(@RequestParam(value="subset", required=false, defaultValue="")String subset) { try { KeyValue[] values = null; if(subset==null || subset.equals("")) values = KeyValue.toKeyValue(VulasConfiguration.getGlobal().getConfiguration()); else values = KeyValue.toKeyValue(VulasConfiguration.getGlobal().getConfiguration().subset(subset)); return new ResponseEntity<KeyValue[]>(values, HttpStatus.OK); } catch(Exception enfe) { return new ResponseEntity<KeyValue[]>(HttpStatus.INTERNAL_SERVER_ERROR); } } }
/** * Returns an array of {@link KeyValue}s with configuration settings read from {@link VulasConfiguration}. * @return 404 {@link HttpStatus#NOT_FOUND} if library with given digest does not exist, 200 {@link HttpStatus#OK} if the library is found */ @RequestMapping(value = "", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) public ResponseEntity<KeyValue[]> getConfiguration(@RequestParam(value="subset", required=false, defaultValue="")String subset) { try { KeyValue[] values = null; if(subset==null || subset.equals("")) values = KeyValue.toKeyValue(VulasConfiguration.getGlobal().getConfiguration()); else values = KeyValue.toKeyValue(VulasConfiguration.getGlobal().getConfiguration().subset(subset)); return new ResponseEntity<KeyValue[]>(values, HttpStatus.OK); } catch(Exception enfe) { return new ResponseEntity<KeyValue[]>(HttpStatus.INTERNAL_SERVER_ERROR); } } }