private String getRequired(String name) throws ModuleInitializationException { String value = getParameter(name); if (value != null) { return value; } else { throw new ModuleInitializationException(name + " parameter " + "is required", getRole()); } }
private int getRequiredInt(String name, int min, int max) throws ModuleInitializationException { try { int value = Integer.parseInt(getRequired(name)); if (value < min || value > max) { throw new ModuleInitializationException(name + " parameter is out of range, expected [" + min + "-" + max + "]", getRole()); } return value; } catch (NumberFormatException e) { throw new ModuleInitializationException(name + " parameter must be " + "an integer", getRole()); } }
private Map<String, String> getAliases() { HashMap<String, String> map = new HashMap<String, String>(); Iterator<String> iter = parameterNames(); while (iter.hasNext()) { String pName = iter.next(); String[] parts = pName.split(":"); if (parts.length == 2 && parts[0].equals("alias")) { map.put(parts[1], getParameter(pName)); } } map.put("fedora", Constants.FEDORA.uri); map.put("dc", Constants.DC.uri); map.put("fedora-model", Constants.MODEL.uri); map.put("fedora-rels-ext", Constants.RELS_EXT.uri); map.put("fedora-view", Constants.VIEW.uri); map.put("rdf", Constants.RDF.uri); map.put("mulgara", Constants.MULGARA.uri); map.put("xml-schema", Constants.RDF_XSD.uri); return map; }
int level = getRequiredInt("level", 0, 1); if (level == 0) { logger.info("Disabled in configuration ( level={} ), exiting", level); return; boolean syncUpdates = getBoolean("syncUpdates", false); try { TriplestoreConnector connector = null; String ds = getParameter("datastore"); if (ds != null){ logger.info("Configuring triplestore connector from fcfg datastore configuration {}", ds); connector = getConnector(getServer() .getDatastoreConfig(ds)); logger.info("Configuring triplestore from bean {}", TriplestoreConnector.class.getName()); connector = getServer().getBean(TriplestoreConnector.class.getName(),TriplestoreConnector.class); getServer().getBean(TripleGenerator.class.getName(), TripleGenerator.class); level, syncUpdates); setAliasMap(getAliases()); getRole(), e);
private TriplestoreConnector getConnector(Parameterized datastore) throws Exception { if (datastore == null) { throw new ModuleInitializationException("Specifed datastore " + "does not exist in fedora.fcfg", getRole()); } Map<String, String> config = datastore.getParameters(); // make sure path, if specified and relative, is translated // to an absolute path based on the value of FEDORA_HOME String path = config.get("path"); if (path != null) { config.put("path", datastore.getParameter("path", true)); } String className = config.get("connectorClassName"); if (className == null) { throw new ResourceIndexException("Required datastore parameter " + "is missing: connectorClassName"); } getServer().getStatusFile().append(ServerState.STARTING, "Initializing Triplestore"); return TriplestoreConnector.init(className, config); }
/** * Shutdown the RI module by closing the wrapped ResourceIndex. * * @throws ModuleShutdownException * if any error occurs while closing. */ @Override public void shutdownModule() throws ModuleShutdownException { if (_ri != null) { try { _ri.close(); } catch (TrippiException e) { throw new ModuleShutdownException("Error closing RI", getRole(), e); } } }
int level = getRequiredInt("level", 0, 1); if (level == 0) { logger.info("Disabled in configuration ( level={} ), exiting", level); return; boolean syncUpdates = getBoolean("syncUpdates", false); try { TriplestoreConnector connector = null; String ds = getParameter("datastore"); if (ds != null){ logger.info("Configuring triplestore connector from fcfg datastore configuration {}", ds); connector = getConnector(getServer() .getDatastoreConfig(ds)); logger.info("Configuring triplestore from bean {}", TriplestoreConnector.class.getName()); connector = getServer().getBean(TriplestoreConnector.class.getName(),TriplestoreConnector.class); getServer().getBean(TripleGenerator.class.getName(), TripleGenerator.class); level, syncUpdates); setAliasMap(getAliases()); getRole(), e);
private TriplestoreConnector getConnector(Parameterized datastore) throws Exception { if (datastore == null) { throw new ModuleInitializationException("Specifed datastore " + "does not exist in fedora.fcfg", getRole()); } Map<String, String> config = datastore.getParameters(); // make sure path, if specified and relative, is translated // to an absolute path based on the value of FEDORA_HOME String path = config.get("path"); if (path != null) { config.put("path", datastore.getParameter("path", true)); } String className = config.get("connectorClassName"); if (className == null) { throw new ResourceIndexException("Required datastore parameter " + "is missing: connectorClassName"); } getServer().getStatusFile().append(ServerState.STARTING, "Initializing Triplestore"); return TriplestoreConnector.init(className, config); }
/** * Shutdown the RI module by closing the wrapped ResourceIndex. * * @throws ModuleShutdownException * if any error occurs while closing. */ @Override public void shutdownModule() throws ModuleShutdownException { if (_ri != null) { try { _ri.close(); } catch (TrippiException e) { throw new ModuleShutdownException("Error closing RI", getRole(), e); } } }
private String getRequired(String name) throws ModuleInitializationException { String value = getParameter(name); if (value != null) { return value; } else { throw new ModuleInitializationException(name + " parameter " + "is required", getRole()); } }
private int getRequiredInt(String name, int min, int max) throws ModuleInitializationException { try { int value = Integer.parseInt(getRequired(name)); if (value < min || value > max) { throw new ModuleInitializationException(name + " parameter is out of range, expected [" + min + "-" + max + "]", getRole()); } return value; } catch (NumberFormatException e) { throw new ModuleInitializationException(name + " parameter must be " + "an integer", getRole()); } }
private Map<String, String> getAliases() { HashMap<String, String> map = new HashMap<String, String>(); Iterator<String> iter = parameterNames(); while (iter.hasNext()) { String pName = iter.next(); String[] parts = pName.split(":"); if (parts.length == 2 && parts[0].equals("alias")) { map.put(parts[1], getParameter(pName)); } } map.put("fedora", Constants.FEDORA.uri); map.put("dc", Constants.DC.uri); map.put("fedora-model", Constants.MODEL.uri); map.put("fedora-rels-ext", Constants.RELS_EXT.uri); map.put("fedora-view", Constants.VIEW.uri); map.put("rdf", Constants.RDF.uri); map.put("mulgara", Constants.MULGARA.uri); map.put("xml-schema", Constants.RDF_XSD.uri); return map; }
private boolean getBoolean(String name, boolean defaultValue) throws ModuleInitializationException { String value = getParameter(name); if (value == null) { return defaultValue; } value = value.toLowerCase(); if (value.equals("true") || value.equals("yes") || value.equals("on")) { return true; } else if (value.equals("false") || value.equals("no") || value.equals("off")) { return false; } else { throw new ModuleInitializationException(name + " parameter, if " + "specified, must be a boolean (true or false)", getRole()); } }
private boolean getBoolean(String name, boolean defaultValue) throws ModuleInitializationException { String value = getParameter(name); if (value == null) { return defaultValue; } value = value.toLowerCase(); if (value.equals("true") || value.equals("yes") || value.equals("on")) { return true; } else if (value.equals("false") || value.equals("no") || value.equals("off")) { return false; } else { throw new ModuleInitializationException(name + " parameter, if " + "specified, must be a boolean (true or false)", getRole()); } }