Search in sources :

Example 1 with ExtendedProperties

use of org.apache.commons.collections.ExtendedProperties in project backstage by zepheira.

the class BackstageModule method createRepository.

public Repository createRepository(HttpServletRequest request, String repoType, String slug) throws Exception {
    ExtendedProperties properties = getProperties();
    String dbDir = properties.getString("backstage.databaseDir", "databases");
    SailRepository repository = null;
    File thisDbDir = new File(new File(dbDir, repoType), slug);
    if (repoType.equals(REPOTYPE_MEM)) {
        DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createMemoryRepository(thisDbDir);
        repository = (SailRepository) rs.repository;
        rs = null;
    } else if (repoType.equals(REPOTYPE_DISK)) {
        DataLoadingUtilities.RepoSailTuple rs = DataLoadingUtilities.createNativeRepository(thisDbDir);
        repository = (SailRepository) rs.repository;
        rs = null;
    } else {
        return null;
    }
    String lang = DataLoadingUtilities.contentTypeToLang(request.getContentType());
    if (lang == null) {
        throw new Exception("Unsupported content type");
    }
    DataLoadingUtilities.loadDataFromStream((InputStream) request.getInputStream(), request.getRequestURL().toString(), lang, repository.getSail());
    return repository;
}
Also used : SailRepository(org.openrdf.repository.sail.SailRepository) DataLoadingUtilities(edu.mit.simile.backstage.util.DataLoadingUtilities) File(java.io.File) ExtendedProperties(org.apache.commons.collections.ExtendedProperties) URISyntaxException(java.net.URISyntaxException) RepositoryException(org.openrdf.repository.RepositoryException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 2 with ExtendedProperties

use of org.apache.commons.collections.ExtendedProperties in project intellij-community by JetBrains.

the class VelocityHelper method getEngine.

private static synchronized VelocityEngine getEngine() {
    if (instance == null) {
        try {
            VelocityEngine engine = new VelocityEngine();
            ExtendedProperties extendedProperties = new ExtendedProperties();
            extendedProperties.addProperty(RuntimeConstants.RESOURCE_LOADER, "file");
            extendedProperties.addProperty(RuntimeConstants.PARSER_POOL_SIZE, "1");
            extendedProperties.addProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
            extendedProperties.addProperty("file.resource.loader.path", PathManager.getPluginsPath() + "/Copyright/resources");
            extendedProperties.addProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName());
            extendedProperties.addProperty("runtime.log.logsystem.log4j.category", CopyrightManager.class.getName());
            engine.setExtendedProperties(extendedProperties);
            engine.init();
            instance = engine;
        } catch (Exception ignored) {
        }
    }
    return instance;
}
Also used : VelocityEngine(org.apache.velocity.app.VelocityEngine) SimpleLog4JLogSystem(org.apache.velocity.runtime.log.SimpleLog4JLogSystem) CopyrightManager(com.intellij.copyright.CopyrightManager) ExtendedProperties(org.apache.commons.collections.ExtendedProperties)

Example 3 with ExtendedProperties

use of org.apache.commons.collections.ExtendedProperties in project backstage by zepheira.

the class BackstageModule method getStandaloneDatabase.

public Database getStandaloneDatabase() {
    if (s_standaloneDatabase == null) {
        ExtendedProperties properties = getProperties();
        String databaseString = properties.getString("backstage.hostedData.database");
        File database = (databaseString == null || databaseString.length() == 0) ? new File("database") : new File(databaseString);
        s_standaloneDatabase = new StandaloneDiskHostedDatabase(database);
    }
    return s_standaloneDatabase;
}
Also used : StandaloneDiskHostedDatabase(edu.mit.simile.backstage.model.data.StandaloneDiskHostedDatabase) File(java.io.File) ExtendedProperties(org.apache.commons.collections.ExtendedProperties)

Example 4 with ExtendedProperties

use of org.apache.commons.collections.ExtendedProperties in project intellij-community by JetBrains.

the class VelocityFactory method newVeloictyEngine.

/**
   * Returns a new instance of the VelocityEngine.
   * <p/>
   * The engine is initialized and outputs its logging to IDEA logging.
   *
   * @return a new velocity engine that is initialized.
   */
private static VelocityEngine newVeloictyEngine() {
    ExtendedProperties prop = new ExtendedProperties();
    prop.addProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName());
    prop.addProperty("runtime.log.logsystem.log4j.category", "GenerateToString");
    prop.addProperty(RuntimeConstants.RESOURCE_LOADER, "includes");
    prop.addProperty("includes.resource.loader.class", VelocityIncludesClassLoader.class.getName());
    VelocityEngine velocity = new VelocityEngine();
    velocity.setExtendedProperties(prop);
    velocity.init();
    return velocity;
}
Also used : SimpleLog4JLogSystem(org.apache.velocity.runtime.log.SimpleLog4JLogSystem) VelocityEngine(org.apache.velocity.app.VelocityEngine) VelocityIncludesClassLoader(com.intellij.codeInsight.generation.VelocityIncludesClassLoader) ExtendedProperties(org.apache.commons.collections.ExtendedProperties)

Aggregations

ExtendedProperties (org.apache.commons.collections.ExtendedProperties)4 File (java.io.File)2 VelocityEngine (org.apache.velocity.app.VelocityEngine)2 SimpleLog4JLogSystem (org.apache.velocity.runtime.log.SimpleLog4JLogSystem)2 VelocityIncludesClassLoader (com.intellij.codeInsight.generation.VelocityIncludesClassLoader)1 CopyrightManager (com.intellij.copyright.CopyrightManager)1 StandaloneDiskHostedDatabase (edu.mit.simile.backstage.model.data.StandaloneDiskHostedDatabase)1 DataLoadingUtilities (edu.mit.simile.backstage.util.DataLoadingUtilities)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 RepositoryException (org.openrdf.repository.RepositoryException)1 SailRepository (org.openrdf.repository.sail.SailRepository)1