Example usage for org.apache.commons.configuration Configuration getString

List of usage examples for org.apache.commons.configuration Configuration getString

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getString.

Prototype

String getString(String key);

Source Link

Document

Get a string associated with the given configuration key.

Usage

From source file:com.microrisc.simply.init.SimpleInitObjectsFactory.java

/** 
 * Creates connected networks settings.// www . ja va  2s.c o  m
 * @param configuration configuration needed for getting network settings
 * @return map of configuration of each network to connect
 * @throws org.apache.commons.configuration.ConfigurationException if 
 *         if an error has occured during getting connected networks configurations
 */
protected Map<String, Configuration> createNetworksSettings(Configuration configuration)
        throws ConfigurationException {
    String settingsFileName = configuration.getString("networkSettings.configFile");
    return XMLConfigurationMappingReader.getConfigMapping(settingsFileName, "network", "id");
}

From source file:com.qmetry.qaf.automation.ws.rest.DefaultRestClient.java

@Override
protected Client createClient() {
    Configuration props = getBundle().subset(REST_CLIENT_PROP_PREFIX);
    Iterator<?> iter = props.getKeys();

    while (iter.hasNext()) {
        String prop = (String) iter.next();
        client.getProperties().put(REST_CLIENT_PROP_PREFIX + prop, props.getString(prop));
    }/*from  w  w  w .  j av  a  2s  .co  m*/
    return client;
}

From source file:gr.abiss.calipso.tiers.controller.AbstractModelWithAttachmentsController.java

@RequestMapping(value = "{subjectId}/uploads/{propertyName}/thumbs/{id}", method = RequestMethod.GET)
@ApiOperation(value = "Get file thumb/preview image of a file upload   ")
public void thumbnail(HttpServletResponse response, @PathVariable String subjectId,
        @PathVariable String propertyName, @PathVariable String id) {
    Configuration config = ConfigurationFactory.getConfiguration();
    String fileUploadDirectory = config.getString(ConfigurationFactory.FILES_DIR);
    BinaryFile file = binaryFileService.findById(id);
    File fileFile = new File(fileUploadDirectory + file.getParentPath() + "/" + file.getThumbnailFilename());
    response.setContentType(file.getContentType());
    response.setContentLength(file.getThumbnailSize().intValue());
    try {/*from   ww  w . j  ava2 s . c o  m*/
        InputStream is = new FileInputStream(fileFile);
        IOUtils.copy(is, response.getOutputStream());
    } catch (IOException e) {
        LOGGER.error("Could not show thumbnail " + id, e);
    }
}

From source file:gr.abiss.calipso.tiers.controller.AbstractModelWithAttachmentsController.java

@ApiOperation(value = "Get an uploaded file")
@RequestMapping(value = "{subjectId}/uploads/{propertyName}/files/{id}", method = RequestMethod.GET)
public void getFile(HttpServletResponse response, @PathVariable String subjectId,
        @PathVariable String propertyName, @PathVariable String id) {
    Configuration config = ConfigurationFactory.getConfiguration();
    String fileUploadDirectory = config.getString(ConfigurationFactory.FILES_DIR);
    BinaryFile file = binaryFileService.findById(id);
    File fileFile = new File(fileUploadDirectory + file.getParentPath() + "/" + file.getNewFilename());
    response.setContentType(file.getContentType());
    response.setContentLength(file.getSize().intValue());
    try {// w w  w  . j  av a 2s. c om
        InputStream is = new FileInputStream(fileFile);
        IOUtils.copy(is, response.getOutputStream());
    } catch (IOException e) {
        LOGGER.error("Could not show picture " + id, e);
    }
}

From source file:gr.abiss.calipso.tiers.controller.AbstractModelWithAttachmentsController.java

@ApiOperation(value = "Delete an uploaded file")
@RequestMapping(value = "{subjectId}/uploads/{propertyName}/{id}", method = RequestMethod.DELETE)
public @ResponseBody List deleteById(@PathVariable String subjectId, @PathVariable String propertyName,
        @PathVariable String id) {
    Configuration config = ConfigurationFactory.getConfiguration();
    String fileUploadDirectory = config.getString(ConfigurationFactory.FILES_DIR);
    BinaryFile file = binaryFileService.findById(id);
    File fileFile = new File(fileUploadDirectory + "/" + file.getNewFilename());
    fileFile.delete();//from ww w .j ava  2 s. c o m
    File thumbnailFile = new File(fileUploadDirectory + "/" + file.getThumbnailFilename());
    thumbnailFile.delete();
    binaryFileService.delete(file);
    List<Map<String, Object>> results = new ArrayList();
    Map<String, Object> success = new HashMap();
    success.put("success", true);
    results.add(success);
    return results;
}

From source file:gr.abiss.calipso.userDetails.controller.ProviderSignInController.java

/**
 * Creates a new provider sign-in controller.
 * @param connectionFactoryLocator the locator of {@link ConnectionFactory connection factories} used to support provider sign-in.
 * Note: this reference should be a serializable proxy to a singleton-scoped target instance.
 * This is because {@link ProviderSignInAttempt} are session-scoped objects that hold ConnectionFactoryLocator references.
 * If these references cannot be serialized, NotSerializableExceptions can occur at runtime.
 * @param usersConnectionRepository the global store for service provider connections across all users.
 * Note: this reference should be a serializable proxy to a singleton-scoped target instance.
 * @param signInAdapter handles user sign-in
 *///from  w  w  w.  j  a v  a  2  s. co m
@Inject
public ProviderSignInController(ConnectionFactoryLocator connectionFactoryLocator,
        UsersConnectionRepository usersConnectionRepository, SignInAdapter signInAdapter) {
    super(connectionFactoryLocator, usersConnectionRepository, signInAdapter);

    Configuration config = ConfigurationFactory.getConfiguration();
    String applicationUrl = config.getString("calipso.baseurl");
    LOGGER.info("Setting applicationUrl to " + applicationUrl);
    //this.setApplicationUrl(applicationUrl);
}

From source file:com.manydesigns.elements.fields.DateField.java

public DateField(PropertyAccessor accessor, Mode mode, String prefix) {
    super(accessor, mode, prefix);

    DateFormat dateFormatAnnotation = accessor.getAnnotation(DateFormat.class);
    if (dateFormatAnnotation != null) {
        datePattern = dateFormatAnnotation.value();
    } else {/*from  w  w  w  . j av a2  s. c o  m*/
        Configuration elementsConfiguration = ElementsProperties.getConfiguration();
        datePattern = elementsConfiguration.getString(ElementsProperties.FIELDS_DATE_FORMAT);
    }
    dateTimeFormatter = DateTimeFormat.forPattern(datePattern);
    setMaxLength(dateTimeFormatter.getParser().estimateParsedLength());

    containsTime = datePattern.contains("HH") || datePattern.contains("mm") || datePattern.contains("ss");

    String tmpPattern = datePattern;
    if (tmpPattern.contains("MM")) {
        tmpPattern = tmpPattern.replaceAll("MM", "mm");
    }
    jsDatePattern = tmpPattern;
}

From source file:cz.cas.lib.proarc.common.config.AppConfigurationTest.java

@Test
public void testReadProperty() throws Exception {
    // init proarc.cfg
    final String expectedPropValue = "test-?"; // test UTF-8
    Properties props = new Properties();
    props.put(TEST_PROPERTY_NAME, expectedPropValue);
    createConfigFile(props, proarcCfg);/*  w w w.  j a va2  s.c  om*/

    AppConfiguration pconfig = factory.create(new HashMap<String, String>() {
        {
            put(AppConfiguration.PROPERTY_APP_HOME, confHome.toString());
        }
    });

    Configuration config = pconfig.getConfiguration();
    assertEquals(expectedPropValue, config.getString(TEST_PROPERTY_NAME));
    assertEquals(EXPECTED_DEFAULT_VALUE, config.getString(TEST_DEFAULT_PROPERTY_NAME));

    // test reload (like servlet reload)
    final String expectedReloadValue = "reload";
    props.put(TEST_PROPERTY_NAME, expectedReloadValue);
    OutputStreamWriter propsOut = new OutputStreamWriter(new FileOutputStream(proarcCfg), "UTF-8");
    // FileChangedReloadingStrategy waits 5s to reload changes so give it a chance
    Thread.sleep(5000);
    props.store(propsOut, null);
    propsOut.close();
    assertTrue(proarcCfg.exists());

    AppConfiguration pconfigNew = factory.create(new HashMap<String, String>() {
        {
            put(AppConfiguration.PROPERTY_APP_HOME, confHome.toString());
        }
    });

    Configuration configNew = pconfigNew.getConfiguration();
    assertEquals(expectedReloadValue, configNew.getString(TEST_PROPERTY_NAME));
    assertEquals(EXPECTED_DEFAULT_VALUE, configNew.getString(TEST_DEFAULT_PROPERTY_NAME));

    // test FileChangedReloadingStrategy
    assertEquals(expectedReloadValue, config.getString(TEST_PROPERTY_NAME));
    assertEquals(EXPECTED_DEFAULT_VALUE, config.getString(TEST_DEFAULT_PROPERTY_NAME));
}

From source file:com.jpeterson.littles3.service.impl.FileStorageServiceImpl.java

public List<Bucket> findBuckets(String username) throws IOException {
    StringBuffer buffer = new StringBuffer();
    Configuration configuration = getConfiguration();
    String storageLocation = configuration.getString(CONFIG_STORAGE_LOCATION);
    String bucketDirectory = configuration.getString(CONFIG_DIRECTORY_BUCKETS, DIRECTORY_BUCKETS);

    logger.debug("Finding buckets for user " + username);

    buffer.append(storageLocation);//  w  ww. java2s.  co m

    if (!storageLocation.endsWith(fileSeparator)) {
        buffer.append(fileSeparator);
    }

    buffer.append(bucketDirectory);

    if (!bucketDirectory.endsWith(fileSeparator)) {
        buffer.append(fileSeparator);
    }

    File dir = new File(buffer.toString());

    if (!dir.isDirectory()) {
        return new ArrayList<Bucket>();
    }

    // TODO: apply username filter

    File[] bucketFiles = dir.listFiles();
    ArrayList<Bucket> buckets = new ArrayList<Bucket>();

    for (int i = 0; i < bucketFiles.length; i++) {
        Bucket bucket = new Bucket();
        bucket.setName(bucketFiles[i].getName());
        // TODO: not really creation date, need to add to database
        bucket.setCreated(new Date(bucketFiles[i].lastModified()));
        buckets.add(bucket);
    }

    return buckets;
}

From source file:com.appeligo.epg.DefaultEpg.java

private DefaultEpg() {
    Configuration config = ConfigUtils.getSystemConfig();
    try {/*w  ww .ja v  a2  s  .c  o m*/
        HessianProxyFactory factory = new HessianProxyFactory();
        String epgURL = config.getString("epgEndpoint");
        defaultEpgProvider = (EPGProvider) factory.create(EPGProvider.class, epgURL);
    } catch (Exception e) {
        log.fatal("Can't connect to EPG.", e);
    }
    minCachedPrograms = config.getInt("minCachedPrograms", 1000);
    maxCachedPrograms = config.getInt("maxCachedPrograms", 1500);
    log.debug("minCachedPrograms=" + minCachedPrograms + ", maxCachedPrograms=" + maxCachedPrograms);
    programCache = Collections
            .synchronizedMap(new ActiveCache<String, Program>(minCachedPrograms, maxCachedPrograms));
}