Example usage for org.apache.commons.configuration.plist PropertyListConfiguration save

List of usage examples for org.apache.commons.configuration.plist PropertyListConfiguration save

Introduction

In this page you can find the example usage for org.apache.commons.configuration.plist PropertyListConfiguration save.

Prototype

public void save(Writer out) throws ConfigurationException 

Source Link

Usage

From source file:edu.isi.wings.portal.controllers.DomainController.java

private boolean saveUserConfig(String file) {
    PropertyListConfiguration config = new PropertyListConfiguration();
    config.addProperty("user.domain", this.domain.getDomainName());
    for (String domname : this.user_domains.keySet()) {
        DomainInfo dom = this.user_domains.get(domname);
        config.addProperty("user.domains.domain(-1).name", dom.getName());
        config.addProperty("user.domains.domain.dir", dom.getDirectory());
        if (dom.isLegacy())
            config.addProperty("user.domains.domain.legacy", dom.isLegacy());
        else/*ww w  .ja  v  a  2 s. c  om*/
            config.addProperty("user.domains.domain.url", dom.getUrl());
    }
    try {
        config.save(file);
        return true;
    } catch (ConfigurationException e) {
        e.printStackTrace();
        return false;
    }
}

From source file:edu.isi.wings.portal.classes.config.Config.java

private void createDefaultPortalConfig(HttpServletRequest request) {
    String server = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
    String storageDir = null;//from w  w w.  j a  v  a 2 s  .  c  om
    String home = System.getProperty("user.home");
    if (home != null && !home.equals(""))
        storageDir = home + File.separator + ".wings" + 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);

    File loc1 = new File("/usr/bin/dot");
    File loc2 = new File("/usr/local/bin/dot");
    config.addProperty("graphviz", loc2.exists() ? loc2.getAbsolutePath() : loc1.getAbsolutePath());
    config.addProperty("ontology.data", ontdirurl + "/data.owl");
    config.addProperty("ontology.component", ontdirurl + "/component.owl");
    config.addProperty("ontology.workflow", ontdirurl + "/workflow.owl");
    config.addProperty("ontology.execution", ontdirurl + "/execution.owl");
    config.addProperty("ontology.resource", ontdirurl + "/resource.owl");

    this.addEngineConfig(config,
            new ExeEngine("Local", LocalExecutionEngine.class.getCanonicalName(), ExeEngine.Type.BOTH));
    this.addEngineConfig(config, new ExeEngine("Distributed",
            DistributedExecutionEngine.class.getCanonicalName(), ExeEngine.Type.BOTH));

    /*this.addEngineConfig(config, new ExeEngine("OODT",
    OODTExecutionEngine.class.getCanonicalName(), ExeEngine.Type.PLAN));
            
    this.addEngineConfig(config, new ExeEngine("Pegasus", 
    PegasusExecutionEngine.class.getCanonicalName(), ExeEngine.Type.PLAN));*/

    try {
        config.save(this.configFile);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:edu.isi.wings.portal.classes.Config.java

private void initializePortalConfig(HttpServletRequest request) {
    this.contextRootPath = request.getContextPath();

    PropertyListConfiguration serverConfig = getPortalConfiguration(request);
    this.storageDirectory = serverConfig.getString("storage.local");
    this.tdbDirectory = serverConfig.getString("storage.tdb");
    this.serverUrl = serverConfig.getString("server");
    this.dotFile = serverConfig.getString("graphviz");
    this.dataOntologyUrl = serverConfig.getString("ontology.data");
    this.componentOntologyUrl = serverConfig.getString("ontology.component");
    this.workflowOntologyUrl = serverConfig.getString("ontology.workflow");
    this.executionOntologyUrl = serverConfig.getString("ontology.execution");
    this.resourceOntologyUrl = serverConfig.getString("ontology.resource");

    this.exportCommunityUrl = serverUrl + contextRootPath + exportServletPath + "/" + communityRelativeDir;
    this.communityPath = contextRootPath + "/" + communityRelativeDir;
    this.communityDir = storageDirectory + File.separator + communityRelativeDir;
    // Create communityDir (if it doesn't exist)
    File uf = new File(this.communityDir);
    if (!uf.exists() && !uf.mkdirs())
        System.err.println("Cannot create community directory : " + uf.getAbsolutePath());

    this.engines = new HashMap<String, ExeEngine>();
    @SuppressWarnings("unchecked")
    List<SubnodeConfiguration> enginenodes = serverConfig.configurationsAt("execution.engine");
    for (SubnodeConfiguration enode : enginenodes) {
        ExeEngine engine = this.getExeEngine(enode);
        this.engines.put(engine.getName(), engine);
    }//from   w w w  .j  ava 2 s .  c  o m
    // Add in the distributed engine if it doesn't already exist
    if (!this.engines.containsKey("Distributed")) {
        ExeEngine distengine = new ExeEngine("Distributed", DistributedExecutionEngine.class.getCanonicalName(),
                ExeEngine.Type.BOTH);
        this.engines.put(distengine.getName(), distengine);
        this.addEngineConfig(serverConfig, distengine);
        try {
            serverConfig.save(this.configFile);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:edu.isi.wings.portal.classes.domains.Domain.java

public boolean saveDomain() {
    PropertyListConfiguration config = new PropertyListConfiguration();
    config.addProperty("name", this.domainName);
    config.addProperty("useSharedTripleStore", this.useSharedTripleStore);

    config.addProperty("executions.engine.plan", this.planEngine);
    config.addProperty("executions.engine.step", this.stepEngine);

    this.setUrlMapProp(config, "workflows.library", this.templateLibrary);
    this.setUrlMapProp(config, "workflows.prefix", this.newTemplateDirectory);

    this.setUrlMapProp(config, "executions.library", this.executionLibrary);
    this.setUrlMapProp(config, "executions.prefix", this.newExecutionDirectory);

    this.setUrlMapProp(config, "data.ontology", this.dataOntology);
    this.setUrlMapProp(config, "data.library", this.dataLibrary);
    config.addProperty("data.library.storage", this.dataLibrary.getStorageDirectory());

    config.addProperty("components.namespace", this.componentLibraryNamespace);
    this.setUrlMapProp(config, "components.abstract", this.abstractComponentLibrary);
    config.addProperty("components.concrete", this.concreteComponentLibrary.getName());

    for (DomainLibrary clib : this.concreteComponentLibraries) {
        config.addProperty("components.libraries.library(-1).url", clib.getUrl());
        config.addProperty("components.libraries.library.map", clib.getMapping());
        config.addProperty("components.libraries.library.name", clib.getName());
        config.addProperty("components.libraries.library.storage", clib.getStorageDirectory());
    }/*from w w w  . j av  a 2  s  .  co  m*/

    for (Permission permission : this.permissions) {
        config.addProperty("permissions.permission(-1).userid", permission.getUserid());
        config.addProperty("permissions.permission.canRead", permission.canRead());
        config.addProperty("permissions.permission.canWrite", permission.canWrite());
        config.addProperty("permissions.permission.canExecute", permission.canExecute());
    }

    if (this.domainDirectory != null) {
        File domdir = new File(this.domainDirectory);
        if (!domdir.exists() && !domdir.mkdirs())
            System.err.println("Could not create domain directory: " + this.domainDirectory);
    }
    try {
        config.save(this.domainConfigFile);
        return true;
    } catch (ConfigurationException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:edu.isi.wings.portal.classes.config.Config.java

private void initializePortalConfig(HttpServletRequest request) {
    this.contextRootPath = request.getContextPath();

    PropertyListConfiguration serverConfig = getPortalConfiguration(request);
    this.storageDirectory = serverConfig.getString("storage.local");
    this.tdbDirectory = serverConfig.getString("storage.tdb");
    this.serverUrl = serverConfig.getString("server");
    this.dotFile = serverConfig.getString("graphviz");
    this.clients = serverConfig.getString("clients");
    this.dataOntologyUrl = serverConfig.getString("ontology.data");
    this.componentOntologyUrl = serverConfig.getString("ontology.component");
    this.workflowOntologyUrl = serverConfig.getString("ontology.workflow");
    this.executionOntologyUrl = serverConfig.getString("ontology.execution");
    this.resourceOntologyUrl = serverConfig.getString("ontology.resource");

    if (serverConfig.containsKey("light-reasoner"))
        this.isLightReasoner = serverConfig.getBoolean("light-reasoner");

    this.exportCommunityUrl = serverUrl + contextRootPath + exportServletPath + "/" + communityRelativeDir;
    this.communityPath = contextRootPath + "/" + usersRelativeDir + "/" + communityRelativeDir;

    this.communityDir = storageDirectory + File.separator + communityRelativeDir;
    // Create communityDir (if it doesn't exist)
    File uf = new File(this.communityDir);
    if (!uf.exists() && !uf.mkdirs())
        System.err.println("Cannot create community directory : " + uf.getAbsolutePath());

    // Load engine configurations
    this.engines = new HashMap<String, ExeEngine>();
    List<HierarchicalConfiguration> enginenodes = serverConfig.configurationsAt("execution.engine");
    for (HierarchicalConfiguration enode : enginenodes) {
        ExeEngine engine = this.getExeEngine(enode);
        this.engines.put(engine.getName(), engine);
    }//  www . ja v a  2 s . c  o m
    // Add in the distributed engine if it doesn't already exist
    if (!this.engines.containsKey("Distributed")) {
        ExeEngine distengine = new ExeEngine("Distributed", DistributedExecutionEngine.class.getCanonicalName(),
                ExeEngine.Type.BOTH);
        this.engines.put(distengine.getName(), distengine);
        this.addEngineConfig(serverConfig, distengine);
        try {
            serverConfig.save(this.configFile);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // Load publishing configuration
    if (serverConfig.containsKey("publisher.url")) {
        String publishUrl = serverConfig.getString("publisher.url");
        String tstoreUrl = serverConfig.getString("publisher.triple-store");
        String uploadUrl = serverConfig.getString("publisher.upload-server.url");
        String uploadDir = serverConfig.getString("publisher.upload-server.directory");
        String uploadHost = serverConfig.getString("publisher.upload-server.host");
        String uploadUserId = serverConfig.getString("publisher.upload-server.userid");
        String uploadKey = serverConfig.getString("publisher.upload-server.private-key");
        String sizeString = serverConfig.getString("publisher.upload-server.max-upload-size");
        this.publisher = new Publisher();
        this.publisher.setUrl(publishUrl);
        this.publisher.setTstoreUrl(tstoreUrl);
        ServerDetails upserver = new ServerDetails();
        upserver.setUrl(uploadUrl);
        upserver.setHostUserId(uploadUserId);
        upserver.setDirectory(uploadDir);
        upserver.setHost(uploadHost);
        upserver.setPrivateKey(uploadKey);
        if (sizeString != null) {
            long size = this.getSizeFromString(sizeString);
            upserver.setMaxUploadSize(size);
        }
        this.publisher.setUploadServer(upserver);
    }
}