/** * Gets the Fascinator home directory as a File object. * * @return a File representing the Fascinator home directory */ public static File getPathFile() { return new File(getPath()); }
private List<String> getPackageTypesFromFileSystem() { List<String> packageTypes = new ArrayList<String>(); File harvestDir = FascinatorHome.getPathFile("harvest"); @SuppressWarnings("unchecked") Collection<File> jsonFiles = FileUtils.listFiles(harvestDir, new String[]{"json"}, false); for (File file : jsonFiles) { packageTypes.add(file.getName().substring(0,file.getName().length()-5)); } return packageTypes; } }
/** * Gets the Fascinator home directory, which is used for configuration, * storage, etc. The directory can be set through the following: * * <ul> * <li>Environment variable: FASCINATOR_HOME</li> * <li>System property: fascinator.home</li> * </ul> * * @return a directory path */ public static String getPath() { String home = System.getProperty(SYSTEM_KEY, getenv("FASCINATOR_HOME", DEFAULT_PATH)); return FilenameUtils.separatorsToSystem(home); }
/** * Gets a relative directory inside the Fascinator home directory. * * @param subDir the directory name * @return a File representing the directory */ public static File getPathFile(String subDir) { return new File(getPath(subDir)); }
private void run() throws CompilationFailedException, IOException { groovyShell.evaluate(FascinatorHome .getPathFile("upgrade" + File.separator + groovyScript)); }
/** * Gets a relative directory inside the Fascinator home directory. * * @param subDir the directory name * @return a directory path */ public static String getPath(String subDir) { return getPath() + File.separator + FilenameUtils.separatorsToSystem(subDir); }
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); }
public RedboxReport() throws IOException { super(); strDateFormat = "dd/MM/yyyy"; reportCriteriaOptionsJson = new JsonSimple(new File( FascinatorHome.getPath("reports") + "/reportCriteriaOptions.json")); }
/** * Get a message listener from the ServiceLoader * * @param id Listener identifier * @return GenericMessageListener implementation matching the ID, if found */ private GenericListener getListener(String id) { ServiceLoader<GenericListener> listeners = ServiceLoader .load(GenericListener.class); for (GenericListener listener : listeners) { if (id.equals(listener.getId())) { return listener; } } File groovyFile = FascinatorHome .getPathFile("plugins/listener/" + id + ".groovy"); if (groovyFile.exists()) { GroovyClassLoader gcl = new GroovyClassLoader(); try { Class<GenericListener> clazz = gcl.parseClass(groovyFile); return clazz.newInstance(); } catch (Exception e) { // Throwing RuntimeException to keep it unchecked // TODO: Remove later throw new RuntimeException(e); } } 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")); }
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); }
/** * 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(); }
rulesConfig = packageType + ".json"; File rulesConfigFile = FascinatorHome.getPathFile(harvestPath + rulesConfig); File rulesScriptFile = FascinatorHome.getPathFile(harvestPath + rulesScript);