@Override protected String getSystemPortal() { return systemConfig.getString(DEFAULT_PORTAL, "transformerDefaults", "jsonVelocityPDF", "portalId"); }
@Override protected String getTemplatePath() { return systemConfig.getString(null, "transformerDefaults", "jsonVelocityPDF", "templatesPath"); }
@Override protected String getUrlBase() { return systemConfig.getString(null, "urlBase"); }
protected String getTemplatePath() { return systemConfig.getString(null, "transformerDefaults", "jsonVelocity", "templatesPath"); }
@Override protected String getSystemPayload() { return systemConfig.getString(DEFAULT_PAYLOAD, "transformerDefaults", "jsonVelocityPDF", "sourcePayload"); }
protected String getUrlBase() { return systemConfig.getString(null, "urlBase"); }
protected String getSystemPayload() { return systemConfig.getString(DEFAULT_PAYLOAD, "transformerDefaults", "jsonVelocity", "sourcePayload"); }
protected String getSystemPortal() { return systemConfig.getString(DEFAULT_PORTAL, "transformerDefaults", "jsonVelocity", "portalId"); }
private void init() { String host = systemConfig.getString("localhost", "storage", "mongo", "host"); int port = systemConfig.getInteger(27017, "storage", "mongo", "port") .intValue(); String db = systemConfig.getString("redbox", "storage", "mongo", "db"); defaultCollection = systemConfig.getString("default", "storage", "mongo", "defaultCollection"); objectMetadataCollectionName = systemConfig.getString("tf_obj_meta", "storage", "mongo", "metadataCollection"); String payloadBackendName = systemConfig.getString("MONGO", "storage", "mongo", "payload_backend"); payloadBackend = MongoDigitalObject.PayloadBackend .valueOf(payloadBackendName); mongoClient = new MongoClient(host, port); mongoDb = mongoClient.getDatabase(db); }
private File getRulesConfigFile(String packageType) throws IOException { JsonSimpleConfig config = new JsonSimpleConfig(); String harvestPath = "harvest/workflows/"; String rulesConfig = config.getString(null, "portal", "packageTypes", packageType, "jsonconfig"); if ("mint".equals(config.getString(null, "system"))) { harvestPath = "harvest/"; rulesConfig = packageType + ".json"; } return FascinatorHome.getPathFile(harvestPath + rulesConfig); }
/** * Convert the provided String into an InputStream to pass to the storage API. * * @param string: The String to convert * @return InputStream: The InputStream holding the String's data * @throws IOException * @throws DocumentException src/test/java/com/googlecode/fascinator/transformer/jsonVelocity/JsonVelocityTransformerPDFTest.java */ private InputStream stream(String string) throws DocumentException, IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(string,new File(systemConfig.getString(PortalManager.DEFAULT_PORTAL_HOME, "portal", "home")).toURI().toURL().toString()); renderer.layout(); renderer.createPDF(bos); return new ByteArrayInputStream(bos.toByteArray()); }
/** * Set the default setting */ public void setSetting() { // Get the storage type to be indexed... try { storage = PluginManager.getStorage(config.getString( DEFAULT_STORAGE_TYPE, "storage", "type")); storage.init(configFile); indexer = PluginManager.getIndexer(config.getString( DEFAULT_INDEXER_TYPE, "indexer", "type")); indexer.init(configFile); rulesList = new ArrayList<String>(); log.info("Loaded {} and {}", realStorage.getName(), indexer .getName()); } catch (Exception e) { log.error("Failed to initialise storage", e); return; } }
public SpringStorageWrapper() { // initialise storage system JsonSimpleConfig systemConfiguration; try { systemConfiguration = new JsonSimpleConfig(); } catch (IOException e) { throw new RuntimeException(e); } String storageType = systemConfiguration.getString( DEFAULT_STORAGE_TYPE, "storage", "type"); storagePlugin = PluginManager.getStorage(storageType); if (storagePlugin == null) { throw new RuntimeException("Storage plugin '" + storageType + "'. Ensure it is in the classpath."); } try { storagePlugin.init(systemConfiguration.toString()); log.debug("Storage service has been initialiased: {}", storagePlugin.getName()); } catch (PluginException pe) { throw new RuntimeException("Failed to initialise storage", pe); } }
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); }
public void setConfig(JsonSimpleConfig config) throws IOException { // Get the basics file_path = config.getString(null, "roles", "internal", "path"); loadRoles(); JSONArray roleJsonArray = (JSONArray)config.getObject("roles", "internal").get("defaultRoles"); if(roleJsonArray != null) { defaultRoles = Arrays.copyOf(roleJsonArray.toArray(), roleJsonArray.size(), String[].class); } }
/** * Reset the transformer in preparation for a new object */ private void reset() throws TransformerException { // First time execution, prepare storage if (storage == null) { try { String storageType = config.getString(null, "storage", "type"); storage = PluginManager.getStorage(storageType); storage.init(JsonSimpleConfig.getSystemFile()); } catch (Exception ex) { throw new TransformerException(ex); } } }
/** * 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(); }
@SuppressWarnings("unchecked") @ApiOperation(value = "get information about the ReDBox instance", tags = "info") @ApiResponses({ @ApiResponse(code = 200, message = "The datastreams are listed"), @ApiResponse(code = 500, message = "Server configuration not found", response = IOException.class) }) @Get("json") public String getServerInformation() throws IOException{ JsonObject responseObject = getSuccessResponse(null); JsonSimpleConfig config = new JsonSimpleConfig(); responseObject.put("institution", config.getString(null, "identity","institution")); responseObject.put("applicationVersion", config.getString(null, "redbox.version.string")); JSONArray packageTypes = new JSONArray(); if ("mint".equals(config.getString(null, "system"))) { packageTypes.addAll(getPackageTypesFromFileSystem()); } else { JsonObject packageTypesObject = config.getObject("portal", "packageTypes"); packageTypes.addAll(packageTypesObject.keySet()); } responseObject.put("packageTypes", packageTypes); return new JsonSimple(responseObject).toString(true); }
@ApiOperation(value = "gets the record's metadata", tags = "recordmeta") @ApiResponses({ @ApiResponse(code = 200, message = "The record's metadata is returned"), @ApiResponse(code = 500, message = "General Error", response = Exception.class) }) @Get("json") public String getMetadataResource() throws StorageException, IOException { JsonSimpleConfig config = new JsonSimpleConfig(); Storage storage = (Storage) ApplicationContextProvider.getApplicationContext().getBean("fascinatorStorage"); String oid = getAttribute("oid"); DigitalObject digitalObject = StorageUtils.getDigitalObject(storage, oid); String payloadId; if ("mint".equals(config.getString(null, "system"))) { payloadId = "metadata.json"; } else { payloadId = findTfPackagePayload(digitalObject); } Payload payload = digitalObject.getPayload(payloadId); JsonSimple metadataObject = new JsonSimple(payload.open()); return gson.toJson(metadataObject.getJsonObject()); }