Example usage for java.util Properties remove

List of usage examples for java.util Properties remove

Introduction

In this page you can find the example usage for java.util Properties remove.

Prototype

@Override
    public synchronized Object remove(Object key) 

Source Link

Usage

From source file:com.logsniffer.util.value.support.PropertiesBasedSource.java

@Override
public void store(final String key, final String value) throws IOException {
    if (value != null) {
        logsnifferProperties.setProperty(key, value);
    } else {/*  w  w w  .j  av  a  2 s  . c o  m*/
        logsnifferProperties.remove(key);
    }
    File file = new File(homeDir.getHomeDir(), CoreAppConfig.LOGSNIFFER_PROPERTIES_FILE);
    LOGGER.info("Saving config value for key '{}' to file: {}", key, file.getAbsolutePath());
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream(file));
    } catch (IOException e) {
        LOGGER.warn("Failed to load current properties from file, continue with empty properties: "
                + file.getAbsolutePath(), e);
    }
    if (value != null) {
        properties.setProperty(key, value);
    } else {
        properties.remove(key);
    }
    properties.store(new FileOutputStream(file), null);
}

From source file:org.nuxeo.theme.editor.Editor.java

public static void assignStyleProperty(Element element, String propertyName, String value)
        throws ThemeException {

    final String themeName = ThemeManager.getThemeOf(element).getName();
    saveToUndoBuffer(themeName, "change style");

    Style style = (Style) ElementFormatter.getFormatFor(element, "style");
    if (style == null) {
        style = Manager.getThemeManager().createStyle();
        ElementFormatter.setFormat(element, style);
    }//from   w  w  w  .  j a  va2  s  .c  o  m
    Widget widget = (Widget) ElementFormatter.getFormatFor(element, "widget");
    if (widget == null) {
        return;
    }
    String viewName = widget.getName();
    Properties properties = style.getPropertiesFor(viewName, "");
    if (properties == null) {
        properties = new Properties();
    }
    if ("".equals(value)) {
        properties.remove(propertyName);
    } else {
        properties.setProperty(propertyName, value);
    }
    style.setPropertiesFor(viewName, "", properties);

    saveTheme(themeName);
}

From source file:org.echocat.jomon.resources.FileResource.java

@Override
public void setProperty(@Nonnull String name, @Nullable Object value) throws IOException {
    synchronized (this) {
        final Properties properties = getPropertiesInternal();
        if (value != null) {
            properties.put(name, value);
        } else {//  www. j av a  2s  . co  m
            properties.remove(name);
        }
        saveProperties(properties);
    }
}

From source file:org.codice.ddf.security.crl.generator.CrlGenerator.java

/**
 * Removes the CRL file location from the given property file.
 *
 * @param propertyFilePath - Property file path
 *//*from ww w  .  j av  a  2s  . co  m*/
private void removeProperty(String propertyFilePath) {
    Properties properties = PROPERTIES_LOADER.loadPropertiesWithoutSystemPropertySubstitution(propertyFilePath,
            null);
    properties.remove(CRL_PROPERTY_KEY);
    try (OutputStream outputStream = new FileOutputStream(propertyFilePath)) {
        properties.store(outputStream, null);
    } catch (IOException e) {
        LOGGER.warn("Unable to remove the {} property to the property file {}.", CRL_PROPERTY_KEY,
                propertyFilePath);
    }
}

From source file:org.mule.endpoint.MuleEndpointURI.java

public Properties getUserParams() {
    Properties p = new Properties();
    p.putAll(getParams());//from   w  ww. jav a  2s.  com
    p.remove(PROPERTY_ENDPOINT_NAME);
    p.remove(PROPERTY_ENDPOINT_URI);
    p.remove(PROPERTY_TRANSFORMERS);
    return p;
}

From source file:nl.strohalm.cyclos.services.customization.TranslationMessageServiceImpl.java

private void importOnlyNewProperties(final Properties properties) {
    final Iterator<String> allKeys = translationMessageDao.listAllKeys();
    try {//from   w  ww.  j  av a 2s .  c o  m
        while (allKeys.hasNext()) {
            final String key = allKeys.next();
            properties.remove(key);
        }
    } finally {
        DataIteratorHelper.close(allKeys);
    }

    // Only new keys are left on the properties object
    insertAll(properties);
}

From source file:org.geowebcache.s3.S3Ops.java

private void clearPendingBulkDelete(final String prefix, final long timestamp) throws GeoWebCacheException {
    Long taskTime = pendingDeletesKeyTime.get(prefix);
    if (taskTime == null) {
        return; // someone else cleared it up for us. A task that run after this one but
                // finished before?
    }/*from ww w . ja va 2s  . c  o m*/
    if (taskTime.longValue() > timestamp) {
        return;// someone else issued a bulk delete after this one for the same key prefix
    }
    final String pendingDeletesKey = keyBuilder.pendingDeletes();
    final Lock lock = locks.getLock(pendingDeletesKey);

    try {
        Properties deletes = getProperties(pendingDeletesKey);
        String storedVal = (String) deletes.remove(prefix);
        long storedTimestamp = storedVal == null ? Long.MIN_VALUE : Long.parseLong(storedVal);
        if (timestamp >= storedTimestamp) {
            putProperties(pendingDeletesKey, deletes);
        } else {
            S3BlobStore.log.info(
                    String.format("bulk delete finished but there's a newer one ongoing for bucket '%s/%s'",
                            bucketName, prefix));
        }
    } catch (StorageException e) {
        Throwables.propagate(e);
    } finally {
        lock.release();
    }
}

From source file:it.geosolutions.geobatch.imagemosaic.MetadataPresentationOnlineTest.java

protected File createDatastorePropFromFixtures() throws IOException {
    // create datastore file
    Properties datastore = new Properties();
    datastore.putAll(getPostgisParams());
    datastore.remove(JDBCDataStoreFactory.DBTYPE.key);
    datastore.setProperty("SPI", "org.geotools.data.postgis.PostgisNGDataStoreFactory");
    datastore.setProperty(PostgisNGDataStoreFactory.LOOSEBBOX.key, "true");
    datastore.setProperty(PostgisNGDataStoreFactory.ESTIMATED_EXTENTS.key, "false");

    File datastoreFile = new File(getTempDir(), "datastore.properties");
    LOGGER.info("Creating  " + datastoreFile);
    FileOutputStream out = new FileOutputStream(datastoreFile);
    datastore.store(out, "Datastore file created from fixtures");
    out.flush();//from www  .jav a  2s . c o  m
    out.close();
    return datastoreFile;
}

From source file:com.floreantpos.license.FiveStarPOSLicenseManager.java

private final License loadLicense(File licenseFile) throws LicenseException {

    Properties properties = loadProperties(licenseFile);
    if (!properties.containsKey(License.SIGNATURE)) {
        throw new LicenseException("Invalid license key! Please contact our support.");
    }//w ww .  jav  a  2 s  .c  om

    String signature = (String) properties.remove(License.SIGNATURE);
    String encoded = properties.toString();

    PublicKey publicKey = readPublicKey(String.format("/license/%s", PUBLIC_KEY_FILE));

    if (!verify(encoded.getBytes(), signature, publicKey)) {
        throw new LicenseException("Invalid license key! Please contact our support.");
    }

    License license = new License(properties);
    if (license.isExpired()) {
        throw new LicenseException("License key expired! Please contact our support.");
    }
    return license;
}

From source file:org.ngrinder.infra.AgentConfig.java

/**
 * Update agent pid file.//w  w w . j  ava  2  s  .  c om
 *
 * @param startMode startMode
 */
public void updateAgentPidProperties(String startMode) {
    checkNotNull(home);
    Properties properties = home.getProperties("pid");
    Set<String> names = properties.stringPropertyNames();
    if (names.size() > 1) {
        properties.remove(startMode + ".pid");
        home.saveProperties("pid", properties);
    } else if (names.contains(startMode + ".pid")) {
        removeAgentPidProperties();
    }
}