Java 类org.apache.commons.configuration.plist.PropertyListConfiguration 实例源码

项目:ontosoft    文件:SoftwareRepository.java   
private void setConfiguration() {
  PropertyListConfiguration props = Config.get().getProperties();
  this.server = props.getString("server");
  onturi = KBConstants.ONTURI();
  caturi = KBConstants.CATURI();
  liburi = this.LIBURI();
  enumuri = this.ENUMURI();

  ontns = KBConstants.ONTNS();
  catns = KBConstants.CATNS();

  tdbdir = props.getString("storage.tdb");
  File tdbdirf = new File(tdbdir);
  if(!tdbdirf.exists() && !tdbdirf.mkdirs()) {
    System.err.println("Cannot create tdb directory : "+tdbdirf.getAbsolutePath());
  }

  // TODO: Parse "imports" and "exports" details

  topclass = ontns + "Software";
  uniongraph = "urn:x-arq:UnionGraph";

  owlns = KBConstants.OWLNS();
  rdfns = KBConstants.RDFNS();
  rdfsns = KBConstants.RDFSNS();
}
项目:ontosoft    文件:ProvenanceRepository.java   
private void initializeKB() {
  PropertyListConfiguration props = Config.get().getProperties();
  this.server = props.getString("server");

  String tdbdir = props.getString("storage.tdb");
  File tdbdirf = new File(tdbdir);
  if(!tdbdirf.exists() && !tdbdirf.mkdirs()) {
    System.err.println("Cannot create tdb directory : "+tdbdirf.getAbsolutePath());
  }

  owlns = KBConstants.OWLNS();
  rdfns = KBConstants.RDFNS();
  rdfsns = KBConstants.RDFSNS();
  ontns = KBConstants.PROVNS();

  this.fac = new OntFactory(OntFactory.JENA, tdbdir);
  try {
    this.ontkb = fac.getKB(KBConstants.PROVURI(), OntSpec.PLAIN, false, true);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
项目:ontosoft    文件:Config.java   
private void createDefaultServerConfig(HttpServletRequest request, String configFile) {
  String server = request.getScheme() + "://" + request.getServerName() + ":"
          + request.getServerPort() + request.getContextPath();
  String storageDir = null;
  String home = System.getProperty("user.home");
  if (home != null && !home.equals(""))
      storageDir = home + File.separator + ".ontosoft" + File.separator + "storage";
  else
      storageDir = System.getProperty("java.io.tmpdir") +
              File.separator + "ontosoft" + File.separator + "storage";
  if (!new File(storageDir).mkdirs())
      System.err.println("Cannot create storage directory: " + storageDir);

  PropertyListConfiguration config = new PropertyListConfiguration();
  config.addProperty("storage.local", storageDir);
  config.addProperty("storage.tdb", storageDir + File.separator + "TDB");
  config.addProperty("storage.db", storageDir + File.separator + "DB");
  config.addProperty("server", server);
  config.addProperty("perm_feature_enabled", "true");

  try {
      config.save("file://" + configFile);
  } catch (Exception e) {
      e.printStackTrace();
  }
}
项目:ontosoft    文件:PermissionRepository.java   
private void initializeKB() {
  PropertyListConfiguration props = Config.get().getProperties();
  this.server = props.getString("server");

  String tdbdir = props.getString("storage.tdb");
  File tdbdirf = new File(tdbdir);
  if(!tdbdirf.exists() && !tdbdirf.mkdirs()) {
    System.err.println("Cannot create tdb directory : "+tdbdirf.getAbsolutePath());
  }

  owlns = KBConstants.OWLNS();
  rdfns = KBConstants.RDFNS();
  rdfsns = KBConstants.RDFSNS();
  ontns = KBConstants.PERMNS();
  foafns = KBConstants.FOAFNS();

  authclass = ontns + "Authorization";
  readclass = ontns + "Read";
  writeclass = ontns + "Write";

  this.fac = new OntFactory(OntFactory.JENA, tdbdir);
  try {
    this.permontkb = fac.getKB(KBConstants.PERMURI(), OntSpec.PLAIN, false, true);
    this.foafkb = fac.getKB(KBConstants.FOAFURI(), OntSpec.PLAIN, false, true);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
项目:ontosoft    文件:SoftwareRepository.java   
public Boolean getPermissionFeatureEnabled() {
  PropertyListConfiguration props = Config.get().getProperties();
  String isenabled = props.getString("perm_feature_enabled");
  if(isenabled != null && isenabled.equals("true")) {
    return true;
  }
  return false;
}
项目:ontosoft    文件:Config.java   
private PropertyListConfiguration loadServerConfiguration(HttpServletRequest request) {
  String configFile = null;
  if(request != null) {
    ServletContext app = request.getSession().getServletContext();
    configFile = app.getInitParameter("config.file");
  }
  if (configFile == null) {
      String home = System.getProperty("user.home");
      if (home != null && !home.equals(""))
          configFile = home + File.separator + ".ontosoft"
                  + File.separator + "server.properties";
      else
          configFile = "/etc/ontosoft/server.properties";
  }
  // Create configFile if it doesn't exist (portal.properties)
  File cfile = new File(configFile);
  if (!cfile.exists()) {
      if (!cfile.getParentFile().exists() && !cfile.getParentFile().mkdirs()) {
          System.err.println("Cannot create config file directory : " + cfile.getParent());
          return null;
      }
      if (request != null)
          createDefaultServerConfig(request, configFile);
  }
  // Load properties from configFile
  PropertyListConfiguration props = new PropertyListConfiguration();
  try {
      props.load(configFile);
  } catch (Exception e) {
      e.printStackTrace();
  }
  return props;
}
项目:turbosoft    文件:Config.java   
private void initializePortalConfig(HttpServletRequest request) {
  this.contextRootPath = request.getContextPath();
  this.scriptPath = this.contextRootPath + request.getServletPath();

  PropertyListConfiguration serverConfig = getPortalConfiguration(request);
  this.storageDirectory = serverConfig.getString("storage.local");
  this.tdbDirectory = serverConfig.getString("storage.tdb");
  this.serverUrl = serverConfig.getString("server");
  this.softwareOntologyUrl = serverConfig.getString("ontology.software");
  this.dataOntologyUrl = serverConfig.getString("ontology.data");
  this.communityOntologyUrl = serverConfig.getString("ontology.community");
  this.resourceOntologyUrl = serverConfig.getString("ontology.resource");
  if(this.communityOntologyUrl == null)
    this.communityOntologyUrl = ontdirurl + "/community.owl";

  this.standardNamesOntologies = new HashMap<String, String>();
  SubnodeConfiguration snconfig = serverConfig.configurationAt("ontology.standard_names");

  for(@SuppressWarnings("unchecked")
  Iterator<String> it = snconfig.getKeys(); it.hasNext(); ) {
    String snrepo = it.next();
    String snurl = snconfig.getString(snrepo);
    this.standardNamesOntologies.put(snrepo,  snurl);
  }

  this.miscProperties = new HashMap<String, String>();
  try {
    SubnodeConfiguration misc = serverConfig.configurationAt("misc");
    for(@SuppressWarnings("unchecked")
    Iterator<String> it = misc.getKeys(); it.hasNext(); ) {
      String key = it.next();
      String value = misc.getString(key);
      this.miscProperties.put(key,  value);
    }
  }
  catch (Exception e) { }
}
项目:turbosoft    文件:Config.java   
private PropertyListConfiguration getPortalConfiguration(
    HttpServletRequest request) {
  ServletContext app = request.getSession().getServletContext();
  this.configFile = app.getInitParameter("config.file");
  if (this.configFile == null) {
    String home = System.getProperty("user.home");
    if (home != null && !home.equals(""))
      this.configFile = home + File.separator + this.defaultStorageDir
          + File.separator + "portal.properties";
    else
      this.configFile = "/etc/wings/portal.properties";
  }
  // Create configFile if it doesn't exist (portal.properties)
  File cfile = new File(this.configFile);
  if (!cfile.exists()) {
    if (!cfile.getParentFile().mkdirs()) {
      System.err.println("Cannot create config file directory : "
          + cfile.getParent());
      return null;
    }
    createDefaultPortalConfig(request);
  }

  // Load properties from configFile
  PropertyListConfiguration props = new PropertyListConfiguration();
  try {
    props.load(this.configFile);
  } catch (Exception e) {
    e.printStackTrace();
  }
  return props;
}
项目:turbosoft    文件:Config.java   
private void createDefaultPortalConfig(HttpServletRequest request) {
  String server = request.getScheme() + "://" + request.getServerName() + ":"
      + request.getServerPort();
  String storageDir = null;
  String home = System.getProperty("user.home");
  if (home != null && !home.equals(""))
    storageDir = home + File.separator + this.defaultStorageDir
        + File.separator + "storage";
  else
    storageDir = System.getProperty("java.io.tmpdir") + File.separator
        + "wings" + File.separator + "storage";
  if (!new File(storageDir).mkdirs())
    System.err.println("Cannot create storage directory: " + storageDir);

  PropertyListConfiguration config = new PropertyListConfiguration();
  config.addProperty("storage.local", storageDir);
  config.addProperty("storage.tdb", storageDir + File.separator + "TDB");
  config.addProperty("server", server);

  config.addProperty("ontology.software", ontdirurl + "/software.owl");
  config.addProperty("ontology.data", ontdirurl + "/data.owl");
  config.addProperty("ontology.resource", ontdirurl + "/resource.owl");
  config.addProperty("ontology.community", ontdirurl + "/community.owl");

  config.addProperty("misc.tikaUrl", "http://[Tika Server]/detect/stream");
  config.addProperty("misc.solrUrl", "http://[Solr Server]/solr");
  config.addProperty("misc.dratHome", "/path/to/drat");

  config.addProperty("ontology.standard_names.CSDMS", ontdirurl + "/CSDMS.owl");

  try {
    config.save(this.configFile);
  } catch (Exception e) {
    e.printStackTrace();
  }
}
项目:ontosoft    文件:Config.java   
public PropertyListConfiguration getProperties() {
  return this.props;
}