/***** * Parse a JSON object from an inputstream * * @param in, the inputstream to read and parse * @return JsonConfigHelper object after parsing */ public JsonSimple getJsonObject(InputStream in) { try { return new JsonSimple(in); } catch (IOException ex) { log.error("Failure during stream access", ex); return null; } }
public RedboxReport(String name, String label) throws IOException { super(name, label); strDateFormat = "dd/MM/yyyy"; reportCriteriaOptionsJson = new JsonSimple(new File( FascinatorHome.getPath("reports") + "/reportCriteriaOptions.json")); }
public RedboxReport() throws IOException { super(); strDateFormat = "dd/MM/yyyy"; reportCriteriaOptionsJson = new JsonSimple(new File( FascinatorHome.getPath("reports") + "/reportCriteriaOptions.json")); }
@Override public void init(String jsonString) throws PluginException { try { setConfig(new JsonSimple(jsonString)); } catch (IOException ioe) { throw new AccessControlException(ioe); } }
/** * Creates JSON Configuration object from the provided input stream * * @param jsonIn : The input stream to read * @throws IOException if there was an error during creation */ public JsonSimpleConfig(InputStream jsonIn) throws IOException { super(jsonIn); systemConfig = new JsonSimple(JsonSimpleConfig.getSystemFile()); loadIncludeDir(); }
/** * Creates JSON Configuration object from the provided config file * * @param jsonFile : The file containing JSON * @throws IOException if there was an error during creation */ public JsonSimpleConfig(File jsonFile) throws IOException { super(jsonFile); systemConfig = new JsonSimple(JsonSimpleConfig.getSystemFile()); loadIncludeDir(); }
@Override public void init(File jsonFile) throws PluginException { try { setConfig(new JsonSimple(jsonFile)); } catch (IOException ioe) { throw new AccessControlException(ioe); } }
/** * Get a playload in JsonSimple format from the payload instance * * @param payload : Payload object * @return JsonSimple or null */ public JsonSimple getPayloadJsonSimple(Payload payload) { JsonSimple jsonSimple = null; if (payload == null) { return null; } try { jsonSimple = new JsonSimple(payload.open()); } catch (Exception e) { log.error("Failed to retrive payload. ID of payload: {}, more: {}", payload.getId(), e.getMessage()); } return jsonSimple; }
/** * Creates JSON Configuration object from the provided config string * * @param jsonString : The JSON in string form * @throws IOException if there was an error during creation */ public JsonSimpleConfig(String jsonString) throws IOException { super(jsonString); systemConfig = new JsonSimple(JsonSimpleConfig.getSystemFile()); loadIncludeDir(); }
protected String getSuccessResponseString(String oid) { return new JsonSimple(getSuccessResponse(oid)).toString(true); } }
public MagicMimeTypeIdentifierWrapper() { super(); try { JsonSimpleConfig config = new JsonSimpleConfig(); mimeTypes = new JsonSimple(config.getObject("mime-types")); identifier = new MagicMimeTypeIdentifier(); } catch (IOException e) { log.warn("Failed to load custom MIME types"); } }
/** * Initializes the plugin using the specified JSON String * * @param jsonString * JSON configuration string * @throws PluginException * if there was an error in initialization */ @Override public void init(String jsonString) throws AccessControlException { try { setConfig(new JsonSimple(jsonString)); } catch (IOException e) { throw new AccessControlException(e); } }
/** * Initializes the plugin using the specified JSON configuration * * @param jsonFile * JSON configuration file * @throws AccessControlException * if there was an error in initialization */ @Override public void init(File jsonFile) throws AccessControlException { try { setConfig(new JsonSimple(jsonFile)); } catch (IOException ioe) { throw new AccessControlException(ioe); } }
private JsonSimple getMintData(DateFormat solrDateFormat) throws IOException { String url = systemConfig.getString("http://localhost:9001/mint", "proxy-urls", "Published_Records_By_Type") + "&dateFrom=" + solrDateFormat.format(fromDate) + "&dateTo=" + solrDateFormat.format(toDate); BasicHttpClient client = new BasicHttpClient(url); GetMethod get = new GetMethod(url); client.executeMethod(get); JsonSimple mintResult = new JsonSimple(get.getResponseBodyAsString()); return mintResult; }
/** * Creates JSON Configuration object from the system config file * * @throws IOException if there was an error during creation */ public JsonSimpleConfig() throws IOException { super(JsonSimpleConfig.getSystemFile()); systemConfig = new JsonSimple(JsonSimpleConfig.getSystemFile()); loadIncludeDir(); }
private DigitalObject getRulesObject(File rulesConfigFile) throws IOException, StorageException { JsonSimpleConfig config = new JsonSimpleConfig(); String harvestPath = "harvest/workflows/"; if ("mint".equals(config.getString(null, "system"))) { harvestPath = "harvest/"; } JsonSimple rulesConfigJson = new JsonSimple(rulesConfigFile); String rulesScript = rulesConfigJson.getString(null, "indexer", "script", "rules"); File rulesScriptFile = FascinatorHome.getPathFile(harvestPath + rulesScript); return harvestFileMapService.get(rulesScriptFile); }
@SuppressWarnings("unchecked") public void updateAndSaveKeys(@SuppressWarnings("rawtypes") JSONArray keys) throws IOException { JsonObject jsonObject = new JsonObject(); JsonObject apiJsonObject = new JsonObject(); apiJsonObject.put("clients", keys); jsonObject.put("api", apiJsonObject); FileUtils.writeStringToFile(this.apiKeysFile, new JsonSimple(jsonObject).toString(true)); this.clients = keys; initialiseKeyMap(); }
/** * Initial load of the authorized key map * * @throws IOException */ public ApiKeyTokenService() throws IOException { JsonSimpleConfig sysconfig = new JsonSimpleConfig(); String apiKeyFilePath = sysconfig.getString(FascinatorHome.getPath(SECURITY_APIKEYS_JSON_PATH), "api", "apiKeyFile"); this.apiKeysFile = new File(apiKeyFilePath); if (!this.apiKeysFile.exists()) { updateAndSaveKeys(new JSONArray()); } JsonSimple apiKeyJson = new JsonSimple(apiKeysFile); this.clients = apiKeyJson.getArray("api", "clients"); initialiseKeyMap(); }
@ApiOperation(value = "gets the record's Object Metadata", tags="objectmeta") @ApiResponses({ @ApiResponse(code = 200, message = "The object metadata is returned"), @ApiResponse(code = 500, message = "General Error", response = Exception.class) }) @Get("json") public String getMetadataResource() throws StorageException, IOException { Storage storage = (Storage) ApplicationContextProvider.getApplicationContext().getBean("fascinatorStorage"); String oid = getAttribute("oid"); DigitalObject digitalObject = StorageUtils.getDigitalObject(storage, oid); Properties metadata = digitalObject.getMetadata(); JsonObject jsonObject = new JsonObject(); for (Object keyObject : metadata.keySet()) { jsonObject.put((String) keyObject, metadata.getProperty((String) keyObject)); } return new JsonSimple(jsonObject).toString(true); }
@SuppressWarnings("unchecked") @ApiOperation(value = "List datastreams in an object", tags = "datastream") @ApiResponses({ @ApiResponse(code = 200, message = "The datastreams are listed"), @ApiResponse(code = 500, message = "Oid does not exist in storage", response = StorageException.class) }) @Get("json") public JsonRepresentation getDatastreamList() throws StorageException, IOException { Storage storage = (Storage) ApplicationContextProvider.getApplicationContext().getBean("fascinatorStorage"); String oid = getAttribute("oid"); DigitalObject digitalObject = StorageUtils.getDigitalObject(storage, oid); JsonObject responseObject = getSuccessResponse(oid); JSONArray dataStreamIds = new JSONArray(); dataStreamIds.addAll(digitalObject.getPayloadIdList()); responseObject.put("datastreamIds", dataStreamIds); return new JsonRepresentation(new JsonSimple(responseObject).toString(true)); }