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:org.openmrs.messagesource.impl.MutableResourceBundleMessageSource.java

/**
 * @see org.openmrs.messagesource.MutableMessageSource#removePresentation(org.openmrs.messagesource.PresentationMessage)
 */// w ww  . ja v  a  2s  .  c o  m
public void removePresentation(PresentationMessage message) {
    File propertyFile = findPropertiesFileFor(message.getCode());
    if (propertyFile != null) {
        Properties props = new Properties();
        try {
            OpenmrsUtil.loadProperties(props, propertyFile);
            props.remove(message.getCode());
            OpenmrsUtil.storeProperties(props, propertyFile, PROPERTIES_FILE_COMMENT);
        } catch (Exception e) {
            log.error("Error generated", e);
        }
    }
}

From source file:com.silverpeas.bootstrap.SilverpeasContextBootStrapper.java

/**
 * Initialise the System.properties according to Silverpeas needs and configuration.
 *
 * @param sce/* www.j a  va2 s. c om*/
 */
@Override
public void contextInitialized(ServletContextEvent sce) {
    ResourceBundle silverpeasInitialisationSettings = FileUtil.loadBundle(
            "org.silverpeas._silverpeasinitialize.settings._silverpeasinitializeSettings",
            new Locale("fr", ""));

    loadExternalJarLibraries();

    String systemSettingsPath = silverpeasInitialisationSettings.getString("pathInitialize");
    if (!StringUtil.isDefined(systemSettingsPath)) {
        Logger.getLogger("bootstrap").log(Level.SEVERE,
                "Repository Initialize for systemSettings.properties file is not defined in Settings.");
    } else {
        File pathInitialize = new File(systemSettingsPath);
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(new File(pathInitialize, "systemSettings.properties"));
            Properties systemFileProperties = new Properties(System.getProperties());
            systemFileProperties.load(fis);

            // Fix - empty proxy port and proxy host not supported by Spring Social
            if (!StringUtil.isDefined(systemFileProperties.getProperty("http.proxyPort"))) {
                systemFileProperties.remove("http.proxyPort");
            }
            if (!StringUtil.isDefined(systemFileProperties.getProperty("http.proxyHost"))) {
                systemFileProperties.remove("http.proxyHost");
            }

            System.setProperties(systemFileProperties);
            if (isTrustoreConfigured()) {
                registerSSLSocketFactory();
            }
        } catch (FileNotFoundException e) {
            Logger.getLogger("bootstrap").log(Level.SEVERE,
                    "File systemSettings.properties in directory {0} not found.", pathInitialize);
        } catch (IOException e) {
            Logger.getLogger("bootstrap").log(Level.SEVERE, "Unable to read systemSettings.properties.");
        } catch (GeneralSecurityException e) {
            Logger.getLogger("bootstrap").log(Level.SEVERE, "Unable to configure the trustore.");
        } finally {
            IOUtils.closeQuietly(fis);
        }

    }
    URLManager.setSilverpeasVersion(sce.getServletContext().getInitParameter("SILVERPEAS_VERSION"));
    springContextListener.contextInitialized(sce);
}

From source file:org.eclipse.kura.core.deployment.install.InstallImpl.java

public void removePackageFromConfFile(String packageName) {
    Properties deployedPackages = getDeployedPackages();
    deployedPackages.remove(packageName);

    if (this.dpaConfPath == null) {
        s_logger.warn(MESSAGE_CONFIGURATION_FILE_NOT_SPECIFIED);
        return;/*from ww w.  j a v  a2s.  c om*/
    }

    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(this.dpaConfPath);
        deployedPackages.store(fos, null);
        fos.flush();
        fos.getFD().sync();
    } catch (IOException e) {
        s_logger.error("Error writing package configuration file", e);
    } finally {
        try {
            if (fos != null) {
                fos.close();
            }
        } catch (IOException e) {
            s_logger.error("Exception while closing opened resources!", e);
        }
    }
}

From source file:org.wso2.carbon.identity.notification.mgt.json.bean.JsonSubscription.java

/**
 * Set endpoints to the json subscription object
 *
 * @param prefix              Prefix of the endpoint properties key. ie json.subscribe.eventName.endpoint.endpointName
 * @param endpointsProperties Properties which are relevant to endpoint.
 *///from  w  w w.  j  a  va2 s. c o m
private void setEndpoints(String prefix, Properties endpointsProperties) {

    Properties endpointNames = NotificationManagementUtils.getSubProperties(prefix, endpointsProperties);
    Enumeration endpointNameSet = endpointNames.propertyNames();

    while (endpointNameSet.hasMoreElements()) {
        String key = (String) endpointNameSet.nextElement();
        String endpointName = (String) endpointNames.remove(key);

        String endpointKey = prefix + "." + endpointName;
        Properties endpointProperties = NotificationManagementUtils.getPropertiesWithPrefix(endpointKey,
                endpointsProperties);

        try {
            endpointInfoList.add(buildEndpoint(endpointKey, endpointProperties));
        } catch (NotificationManagementException e) {
            log.error("Error while building endpoint object with key " + endpointKey, e);
        }
    }
}

From source file:com.siberhus.tdfl.mapping.BeanWrapLineMapper.java

private void switchPropertyNames(Properties properties, String oldName, String newName) {
    String value = properties.getProperty(oldName);
    properties.remove(oldName);
    properties.setProperty(newName, value);
}

From source file:org.eclipse.thym.android.core.adt.AndroidFrameworkAction.java

@Override
public void unInstall() throws CoreException {
    String libref = "";
    if (isCustom) {
        IPath dest = new Path(this.projectDir.toString()).append(getFrameworkSubDir());
        File destFile = new File(dest.toString());
        FileUtils.deleteQuietly(destFile);
        libref = getFrameworkSubDir().toString();
    } else {/*  www .  j a  v  a  2  s. c om*/
        File sdkDir = new File(AndroidCore.getSDKLocation());
        File subSDK = new File(sdkDir, source.toString());
        libref = subSDK.toString();
    }
    try {
        File propertiesFile = getPropertiesFile();
        Properties properties = new Properties();
        properties.load(new FileReader(propertiesFile));

        int index = 1;
        String keyName = "android.library.reference." + Integer.toString(index);
        while (properties.containsKey(keyName)) {
            String val = properties.getProperty(keyName);
            if (val.equals(libref)) {
                properties.remove(keyName);
                break;
            }
            ++index;
            keyName = "android.library.reference." + Integer.toString(index);
        }
        properties.store(new FileWriter(propertiesFile), "Updated by Eclipse THyM");
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID,
                "Updating the project.properties file has failed", e));
    }
}

From source file:org.apache.solr.client.solrj.io.sql.DriverImpl.java

public Connection connect(String url, Properties props) throws SQLException {
    if (!acceptsURL(url)) {
        return null;
    }//from  w w w .ja  v a2s  .c  om

    URI uri = processUrl(url);

    loadParams(uri, props);

    if (!props.containsKey("collection")) {
        throw new SQLException(
                "The connection url has no connection properties. At a mininum the collection must be specified.");
    }
    String collection = (String) props.remove("collection");

    if (!props.containsKey("aggregationMode")) {
        props.setProperty("aggregationMode", "facet");
    }

    // JDBC requires metadata like field names from the SQLHandler. Force this property to be true.
    props.setProperty("includeMetadata", "true");

    String zkHost = uri.getAuthority() + uri.getPath();

    return new ConnectionImpl(url, zkHost, collection, props);
}

From source file:org.eclipse.thym.blackberry.core.bdt.BlackBerryFrameworkAction.java

@Override
public void unInstall() throws CoreException {
    String libref = "";
    if (isCustom) {
        IPath dest = new Path(this.projectDir.toString()).append(getFrameworkSubDir());
        File destFile = new File(dest.toString());
        FileUtils.deleteQuietly(destFile);
        libref = getFrameworkSubDir().toString();
    } else {//from   w  ww . j  a  va  2 s .  c om
        File sdkDir = new File(BlackBerryCore.getSDKLocation());
        File subSDK = new File(sdkDir, source.toString());
        libref = subSDK.toString();
    }
    try {
        File propertiesFile = getPropertiesFile();
        Properties properties = new Properties();
        properties.load(new FileReader(propertiesFile));

        int index = 1;
        String keyName = "android.library.reference." + Integer.toString(index);
        while (properties.containsKey(keyName)) {
            String val = properties.getProperty(keyName);
            if (val.equals(libref)) {
                properties.remove(keyName);
                break;
            }
            ++index;
            keyName = "android.library.reference." + Integer.toString(index);
        }
        properties.store(new FileWriter(propertiesFile), "Updated by Eclipse THyM");
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, BlackBerryCore.PLUGIN_ID,
                "Updating the project.properties file has failed", e));
    }
}

From source file:com.ibm.jaggr.core.impl.options.OptionsImpl.java

@Override
public synchronized void setOption(String name, String value) throws IOException {
    // update the property
    Properties props = getProps();
    if (value == null) {
        props.remove(name);
    } else {//from w  w w . jav a 2  s  . c  om
        props.setProperty(name, value);
    }
    setProps(props);
    // Persist the new properties
    saveProps(props);

    long seq = SequenceNumberProvider.incrementAndGetSequenceNumber();
    // Notify update listeners
    updateNotify(seq);
    // Notify options instances using the same properties file
    propsFileUpdateNotify(props, seq);

}

From source file:com.ecyrd.jspwiki.auth.UserManagerTest.java

/**
 * @see junit.framework.TestCase#setUp()
 *//*from   w  w w.ja  v a  2 s .c o m*/
protected void setUp() throws Exception {
    super.setUp();
    Properties props = new Properties();
    props.load(TestEngine.findTestProperties());

    // Make sure user profile save workflow is OFF
    props.remove("jspwiki.approver" + UserManager.SAVE_APPROVER);

    // Make sure we are using the XML user database
    props.put(XMLUserDatabase.PROP_USERDATABASE, "tests/etc/userdatabase.xml");
    m_engine = new TestEngine(props);
    m_mgr = m_engine.getUserManager();
    m_db = m_mgr.getUserDatabase();
    m_groupName = "Group" + System.currentTimeMillis();
}