public StatisticalReport(JsonSimple config) throws IOException { super(config); strDateFormat = config.getString("dd/MM/yyyy", "report", "dateFormat"); }
"Inclusion directory found:'" + INCLUDE_DIR_KEY + "', merging all files in '" + config.getString(null, INCLUDE_DIR_KEY) + "' ending with: {}", extList); List<File> configFiles = new ArrayList(FileUtils.listFiles(new File( config.getString(null, INCLUDE_DIR_KEY)), extList .toArray(new String[extList.size()]), true));
public RedboxReport(JsonSimple config) throws IOException { super(config); strDateFormat = config.getString("dd/MM/yyyy", "report", "dateFormat"); }
/** * Generate orders for the list of normal transformers scheduled to execute * on the tool chain * * @param message * The incoming message, which contains the tool chain config for * this object * @param response * The response to edit * @param oid * The object to schedule for clearing */ private void scheduleTransformers(JsonSimple message, JsonSimple response) { String oid = message.getString(null, "oid"); List<String> list = message.getStringList("transformer", "metadata"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); // Add item config to message... if it exists JsonObject itemConfig = message.getObject( "transformerOverrides", id); if (itemConfig != null) { JsonObject config = (JsonObject) order.get("config"); config.putAll(itemConfig); } } } }
/** * Retrieve the String value on the given path. * * @param defaultValue : The fallback value to use if the path is invalid or * not found * @param path : An array of indeterminate length to use as the path * @return String : The String value found on the given path, or null if no * default provided */ @Override public String getString(String defaultValue, Object... path) { String string = super.getString(null, path); if (string == null) { if (systemConfig != null) { return systemConfig.getString(defaultValue, path); } return defaultValue; } return string; }
/** * Generate orders for the list of normal transformers scheduled to execute * on the tool chain * * @param message The incoming message, which contains the tool chain config * for this object * @param response The response to edit * @param oid The object to schedule for clearing */ private void scheduleTransformers(JsonSimple message, JsonSimple response) { String oid = message.getString(null, "oid"); List<String> list = message.getStringList( "transformer", "metadata"); if (list != null && !list.isEmpty()) { for (String id : list) { JsonObject order = newTransform(response, id, oid); // Add item config to message... if it exists JsonObject itemConfig = message.getObject( "transformerOverrides", id); if (itemConfig != null) { JsonObject config = (JsonObject) order.get("config"); config.putAll(itemConfig); } } } }
/** * Given the name of the provided template, change the extension for use as * a payload ID. * * @param templateName : The name of the template file * @return String: The payload ID to use */ protected String payloadName(String templateName) { String extension = itemConfig.getString("xml", "outputExtension"); return templateName.substring(0, templateName.lastIndexOf(".")) + "." + extension; }
/** * Trivial wrapper for call into JSON Library. Removes the difficulty of * dealing with a null argument and a vararg from Velocity. * * @param json: The JSON object to get from * @param field: The field in the JSON object to get * @return String: The data in the field, possibly NULL */ public String get(JsonSimple json, Object... field) { if (json == null) { log.error("NULL JSON object provided!"); return ""; } return json.getString(null, field); }
private boolean workflowCompleted(String oid) { JsonSimple workflow = getWorkflowData(oid); if (workflow == null) { log.error("Error accessing workflow data '{}'", oid); return false; } String step = workflow.getString(null, "step"); if (step == null || !step.equals("live")) { log.debug("Workflow step '{}', ignoring.", step); return false; } return true; }
@Override public String identify(byte[] firstBytes, String fileName, URI uri) { String ext = FilenameUtils.getExtension(fileName); String mimeType = mimeTypes.getString(null, ext); if (mimeType != null) { return mimeType; } return identifier.identify(firstBytes, fileName, uri); } }
/** * To check if configuration file is outdated * * @return <code>true</code> if outdated, <code>false</code> otherwise */ public boolean isOutdated() { boolean outdated = false; String systemVersion = getString(null, "version"); if (systemVersion == null) { return true; } try { JsonSimple compiledConfig = new JsonSimple(getClass() .getResourceAsStream("/" + SYSTEM_CONFIG_FILE)); String compiledVersion = compiledConfig.getString(null, "version"); outdated = !systemVersion.equals(compiledVersion); if (compiledVersion == null) { return false; } if (outdated) { log.debug("Configuration versions do not match! '{}' != '{}'", systemVersion, compiledVersion); } } catch (IOException ioe) { log.error("Failed to parse compiled configuration!", ioe); } return outdated; }
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; }
field = json.getString(null, "field"); if (field == null) { throw new HarvesterException("In a filter definition, missing the mandatory attribute 'field'"); String matchTypeStr = json.getString("ANY", "multi"); try { type = MultiMatchType.valueOf(matchTypeStr); throw new HarvesterException("In a filter definition, invalid filter match type '" + matchTypeStr + "', valid values are " + MultiMatchType.values()); String regexStr = json.getString(null, "regex"); if (regexStr == null) { throw new HarvesterException("In a filter definition, missing the mandatory attribute 'regex'");
private boolean okToProcess(DigitalObject in, JsonSimple itemConfig) throws TransformerException { if (itemConfig.getBoolean(false, "checkForTFMETAProperty")) { String propertyName = itemConfig.getString(null, "TFMETAPropertyName"); String propertyValue = itemConfig.getString(null, "TFMETAPropertyValue"); if (propertyName != null && propertyValue != null) {
/** * Using Mint to look up labels of saved Mint item ids * * @param systemConfig: Json config file * @param urlName: Query url defined in config file * @param ids: String contains query ids * @return ArrayList<String>: Labels of query ids */ public ArrayList<String> getMintLabels(JsonSimpleConfig systemConfig, String urlName, String ids) { Map<String, String> mapIds = new HashMap<String, String>(); mapIds.put("id",ids); try { JsonSimple labelsMint = MintLookupHelper.get(systemConfig, urlName, mapIds); ArrayList<String> labels = new ArrayList(); JSONArray arr = labelsMint.getJsonArray(); for (int i = 0; i < arr.size(); i++) { JsonSimple labelJson = new JsonSimple(arr.get(i).toString()); labels.add(labelJson.getString("", "label")); } return labels; } catch (Exception ex) { log.error("PDF transfer - When retrieving Mint labels: ", ex); return null; } } }
/** * Process an index order * * @param order The complete JSON order * @param boolean True if successful, otherwise False */ private boolean index(JsonSimple order) { // Sanity check our OID String oid = order.getString(null, "oid"); if (oid == null) { log.error("Invalid indexer order, no OID supplied!"); return false; } // Let the indexer do its thing try { indexer.index(oid); if (order.getBoolean(false, "forceCommit")) { indexer.commit(); } return true; } catch (IndexerException ex) { log.error("Error indexing OID '{}'", oid, ex); return false; } }
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); }
/** * Assess a workflow event to see how it effects curation * * @param response * The response object * @param message * The incoming message */ private void workflowCuration(JsonSimple response, JsonSimple message) { String oid = message.getString(null, "oid"); if (!workflowCompleted(oid)) { return; } // Resolve relationships before we continue try { JSONArray relations = mapRelations(oid); // Unless there was an error, we should be good to go if (relations != null) { JsonObject request = createTask(response, oid, "curation-request"); if (!relations.isEmpty()) { request.put("relationships", relations); } } } catch (Exception ex) { log.error("Error processing relations: ", ex); return; } }
/** * Generate a fairly common list of orders to transform and index an object. * This mirrors the traditional tool chain. * * @param message The response to modify * @param message The message we received */ private void reharvest(JsonSimple response, JsonSimple message) { String oid = message.getString(null, "oid"); try { if (oid != null) { setRenderFlag(oid); // Transformer config JsonSimple itemConfig = getConfigFromStorage(oid); if (itemConfig == null) { log.error("Error accessing item configuration!"); return; } itemConfig.getJsonObject().put("oid", oid); // Tool chain scheduleTransformers(itemConfig, response); newIndex(response, oid); createTask(response, oid, "clear-render-flag"); } else { log.error("Cannot reharvest without an OID!"); } } catch (Exception ex) { log.error("Error during reharvest setup: ", ex); } }
String oid = message.getString(null, "oid");