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.wso2.carbon.identity.notification.mgt.json.bean.JsonSubscription.java

/**
 * Build JsonEndpointInfo  objects from properties which has the prefix json.subscribe.eventName.endpoint
 * .endpointName// w w w .j  a v a 2  s. com
 *
 * @param prefix             prefix of the endpoint properties key. ie json.subscribe.eventName
 *                           .endpoint.endpointName
 * @param endpointProperties properties which has key with prefix. json.subscribe.eventName
 *                           .endpoint.endpointName
 * @return JsonEndpointInfo object build out of properties
 * @throws NotificationManagementException
 */
private JsonEndpointInfo buildEndpoint(String prefix, Properties endpointProperties)
        throws NotificationManagementException {

    JsonEndpointInfo jsonEndpointInfo = new JsonEndpointInfo();
    String url = (String) endpointProperties.remove(prefix + "." + JsonModuleConstants.Config.ADDRESS_QNAME);
    // If there is no configured json url address, stop building endpoint, throw an exception
    if (StringUtils.isNotEmpty(url)) {
        url = url.trim();
        if (log.isDebugEnabled()) {
            log.debug("Registering json endpoint with address " + url);
        }
        jsonEndpointInfo.setEndpoint(url);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Registering json endpoint with prefix " + prefix + " without url. Expecting the "
                    + "email url at event time");
        }
    }
    jsonEndpointInfo.setEndpoint(url);
    String template = (String) endpointProperties
            .remove(prefix + "." + JsonModuleConstants.Config.JSON_CONTENT_QNAME);

    if (template != null) {
        //Set the json template configured for endpoint.
        jsonEndpointInfo.setJsonConfigString(NotificationManagementUtils.readMessageTemplate(template.trim()));
    } else {
        // If template is null, subscription level template will be used on the time of
        // sending email
        if (log.isDebugEnabled()) {
            log.debug("No template configured for endpoint" + url);
        }
    }
    jsonEndpointInfo = setAuthenticationInfo(prefix, endpointProperties, jsonEndpointInfo);
    jsonEndpointInfo.setEndpointProperties(
            NotificationManagementUtils.buildSingleWordKeyProperties(prefix, endpointProperties));
    return jsonEndpointInfo;
}

From source file:ch.entwine.weblounge.common.impl.site.I18nDictionaryImpl.java

/**
 * {@inheritDoc}//  w  w w.j  a va 2  s .  com
 * 
 * @see ch.entwine.weblounge.common.site.I18nDictionary#remove(java.lang.String,
 *      ch.entwine.weblounge.common.language.Language)
 */
public void remove(String key, Language language) {
    Properties p = null;
    if (language != null)
        p = i18n.get(language);
    else
        p = defaults;
    if (p != null)
        p.remove(key);
}

From source file:org.unitime.timetable.solver.jgroups.AbstractSolverServer.java

@Override
public void setApplicationProperty(Long sessionId, String key, String value) {
    sLog.info("Set " + key + " to " + value + (sessionId == null ? "" : " (for session " + sessionId + ")"));
    Properties properties = (sessionId == null ? ApplicationProperties.getConfigProperties()
            : ApplicationProperties.getSessionProperties(sessionId));
    if (properties == null)
        return;/*w ww. j  a  v a 2s . c  o m*/
    if (value == null)
        properties.remove(key);
    else
        properties.setProperty(key, value);
}

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

/**
 * * deletes existing store/* ww  w  .  j ava2 s  .  com*/
 * * create a brand new mosaic dir
 * * create the mosaic on GS
 * 
 */
protected ImageMosaicConfiguration createMosaicConfig() throws IOException {

    // create datastore file
    Properties datastore = new Properties();
    datastore.putAll(getPostgisParams());
    datastore.remove(PostgisNGDataStoreFactory.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();
    out.close();
    //        datastore.store(System.out, "Datastore created from fixtures");
    //        datastore.list(System.out);

    // config
    ImageMosaicConfiguration conf = new ImageMosaicConfiguration("", "", "");
    conf.setTimeRegex("(?<=_)\\\\d{8}");
    conf.setTimeDimEnabled("true");
    conf.setTimePresentationMode("LIST");
    conf.setGeoserverURL(getFixture().getProperty("gs_url"));
    conf.setGeoserverUID(getFixture().getProperty("gs_user"));
    conf.setGeoserverPWD(getFixture().getProperty("gs_password"));
    conf.setDatastorePropertiesPath(datastoreFile.getAbsolutePath());
    conf.setDefaultNamespace(WORKSPACE);
    conf.setDefaultStyle("raster");
    conf.setCrs("EPSG:4326");

    return conf;
}

From source file:org.silverpeas.core.util.logging.LoggerConfigurationManager.java

/**
 * Saves the configuration of the logger referred by the specified configuration instance.
 * <p>// w w w  .j  a  va2 s .  com
 * If no configuration exists for the logger referred by the configuration object, then nothing
 * is done.
 * @param configuration the new configuration of the logger defined for the specified Silverpeas
 * module.
 */
public void saveLoggerConfiguration(LoggerConfiguration configuration) {
    Map<String, LoggerConfiguration> loggerConfigurations = getLoggerConfigurations();
    if (loggerConfigurations.containsKey(configuration.getNamespace())
            && configuration.hasConfigurationFile()) {
        try {
            Properties properties = new Properties();
            properties.load(new FileInputStream(configuration.getConfigurationFile()));
            if (configuration.getLevel() == null) {
                properties.remove(LOGGER_LEVEL);
            } else {
                properties.setProperty(LOGGER_LEVEL, configuration.getLevel().name());
            }
            properties.store(new FileOutputStream(configuration.getConfigurationFile()), null);
        } catch (IOException e) {
            java.util.logging.Logger.getLogger(THIS_LOGGER_NAMESPACE).log(java.util.logging.Level.WARNING,
                    e.getMessage(), e);
        }
    }
}

From source file:net.sf.farrago.namespace.jdbc.MedJdbcDataServer.java

protected static void removeNonDriverProps(Properties props) {
    // TODO jvs 19-June-2006:  Make this metadata-driven.
    props.remove(PROP_URL);
    props.remove(PROP_DRIVER_CLASS);//from www  .j  a va2 s  . co  m
    props.remove(PROP_CATALOG_NAME);
    props.remove(PROP_SCHEMA_NAME);
    props.remove(PROP_USER_NAME);
    props.remove(PROP_PASSWORD);
    props.remove(PROP_VERSION);
    props.remove(PROP_NAME);
    props.remove(PROP_TYPE);
    props.remove(PROP_EXT_OPTIONS);
    props.remove(PROP_TYPE_SUBSTITUTION);
    props.remove(PROP_TYPE_MAPPING);
    props.remove(PROP_TABLE_TYPES);
    props.remove(PROP_LOGIN_TIMEOUT);
    props.remove(PROP_USE_SCHEMA_NAME_AS_FOREIGN_QUALIFIER);
    props.remove(PROP_LENIENT);
    props.remove(PROP_DISABLED_PUSHDOWN_REL_PATTERN);
    props.remove(PROP_FETCH_SIZE);
    props.remove(PROP_AUTOCOMMIT);
    props.remove(PROP_SCHEMA_MAPPING);
    props.remove(PROP_TABLE_MAPPING);
    props.remove(PROP_TABLE_PREFIX_MAPPING);
    props.remove(PROP_JNDI_NAME);
    props.remove(PROP_MAX_IDLE_CONNECTIONS);
    props.remove(PROP_EVICTION_TIMER_PERIOD_MILLIS);
    props.remove(PROP_MIN_EVICTION_IDLE_MILLIS);
    props.remove(PROP_VALIDATION_TIMING);
    props.remove(PROP_DISABLE_CONNECTION_POOL);
}

From source file:oracle.kv.hadoop.table.TableInputFormatBase.java

/**
 * Set/create the artifacts required to connect to and interact
 * with a secure store; specifically, a login properties file,
 * a trust file containing public keys and/or certificates, and
 * <code>PasswordCredentials</code>. If the value input for the
 * <code>loginFile</code> and <code>trustFile</code> parameter
 * is a fully-qualified path, then this method initializes the
 * corresponding static variables to those values so that the
 * <code>getSplits</code> method can contact a secure store, extracts
 * the filenames from those paths, uses those values to initialize
 * the corresponding static filename variables used to initialize
 * the splits that are created, and returns.
 * <p>/*from   www.ja v a  2 s  .  c  o m*/
 * If the value input for the <code>loginFile</code> and
 * <code>trustFile</code> parameter is not a fully-qualified path,
 * then this method uses the given file names to retrieve the contents
 * of the associated login file and trust file as resources from
 * the classpath, and writes that information to corresponding files
 * on the local file system (in a directory owned by the user under
 * which the application is executed). After generating the local
 * files, the fully-qualified paths to those files are used to
 * initialize the corresponding static variables so that the
 * <code>getSplits</code> method can contact a secure store.
 */
private static void setLocalKVSecurity(final String loginFile,
        final PasswordCredentials userPasswordCredentials, final String trustFile) throws IOException {

    if (loginFile == null) {
        return;
    }

    if (userPasswordCredentials == null) {
        return;
    }

    if (trustFile == null) {
        return;
    }

    final File loginFd = new File(loginFile);
    boolean loginIsAbsolute = false;
    if (loginFd.isAbsolute()) {
        loginIsAbsolute = true;
        TableInputFormatBase.localLoginFile = loginFile;
        TableInputFormatBase.loginFlnm = loginFd.getName();
    } else {
        TableInputFormatBase.loginFlnm = loginFile;
    }

    TableInputFormatBase.passwordCredentials = userPasswordCredentials;

    final File trustFd = new File(trustFile);
    boolean trustIsAbsolute = false;
    if (trustFd.isAbsolute()) {
        trustIsAbsolute = true;
        TableInputFormatBase.trustFlnm = trustFd.getName();
    } else {
        TableInputFormatBase.trustFlnm = trustFile;
    }

    if (loginIsAbsolute && trustIsAbsolute) {
        return;
    }

    /*
     * If loginFile and/or trustFile is a filename and not an absolute
     * path, then generate local versions of the file.
     */
    final File userSecurityDirFd = new File(USER_SECURITY_DIR);
    if (!userSecurityDirFd.exists()) {
        if (!userSecurityDirFd.mkdirs()) {
            throw new IOException("failed to create " + userSecurityDirFd);
        }
    }

    final ClassLoader cl = TableInputFormatBase.class.getClassLoader();

    if (!loginIsAbsolute) {

        InputStream loginStream = null;
        if (cl != null) {
            loginStream = cl.getResourceAsStream(loginFlnm);
        } else {
            loginStream = ClassLoader.getSystemResourceAsStream(loginFlnm);
        }

        /*
         * Retrieve the login configuration as a resource from the
         * classpath, and write that information to the user's local
         * file system. But exclude any properties related to user
         * authorization; that is, exclude all properties of the form
         * 'oracle.kv.auth.*", to prevent those property values from
         * being sent and cached on the DataNodes.
         */
        final Properties loginProps = new Properties();
        if (loginStream != null) {
            loginProps.load(loginStream);
        }

        /* Exclude 'oracle.kv.auth.*" properties. */
        loginProps.remove(KVSecurityConstants.AUTH_USERNAME_PROPERTY);
        loginProps.remove(KVSecurityConstants.AUTH_WALLET_PROPERTY);
        loginProps.remove(KVSecurityConstants.AUTH_PWDFILE_PROPERTY);

        /* Strip off the path of the trust file. */
        final String trustProp = loginProps.getProperty(KVSecurityConstants.SSL_TRUSTSTORE_FILE_PROPERTY);
        if (trustProp != null) {
            final File trustPropFd = new File(trustProp);
            if (!trustPropFd.exists()) {
                loginProps.setProperty(KVSecurityConstants.SSL_TRUSTSTORE_FILE_PROPERTY, trustPropFd.getName());
            }
        }

        final File absoluteLoginFd = new File(USER_SECURITY_DIR + FILE_SEP + loginFlnm);
        final FileOutputStream loginFos = new FileOutputStream(absoluteLoginFd);
        try {
            loginProps.store(loginFos, null);
        } finally {
            loginFos.close();
        }

        TableInputFormatBase.localLoginFile = absoluteLoginFd.toString();
    }

    if (!trustIsAbsolute) {

        InputStream trustStream = null;
        if (cl != null) {
            trustStream = cl.getResourceAsStream(trustFlnm);
        } else {
            trustStream = ClassLoader.getSystemResourceAsStream(trustFlnm);
        }

        /*
         * Retrieve the trust credentials as a resource from the classpath,
         * and write that information to the user's local file system.
         */
        final File absoluteTrustFd = new File(USER_SECURITY_DIR + FILE_SEP + trustFlnm);
        final FileOutputStream trustFlnmFos = new FileOutputStream(absoluteTrustFd);

        try {
            int nextByte = trustStream.read();
            while (nextByte != -1) {
                trustFlnmFos.write(nextByte);
                nextByte = trustStream.read();
            }
        } finally {
            trustFlnmFos.close();
        }
    }
}

From source file:org.apache.openjpa.jdbc.schema.DBCPDriverDataSource.java

private String removeProperty(Properties props, String key) {
    if (props != null && key != null) {
        String entry = hasKey(props, key);
        if (entry != null)
            return (String) props.remove(entry);
    }/*w  ww.j  a va2s.  c  o  m*/
    return null;
}

From source file:com.zotoh.maedr.etc.CmdDevice.java

private void cfgDev(String dev) throws Exception {
    JSONObject top = loadConf(getCwd());
    if (!existsDevice(top, dev)) {
        throw new Exception("Unknown device type: " + dev);
    }/*from  www  .  j  av a 2 s  . c o m*/
    Class<?> z;
    if (DefaultDeviceFactory.getAllDefaultTypes().contains(dev)) {
        z = DefaultDeviceFactory.getDevCZ(dev);
    } else {
        z = getUserDevCZ(top, dev);
    }

    if (z == null) {
        throw new ClassNotFoundException("Class not found for device: " + dev);
    }

    Device d = (Device) z.getConstructor(DeviceManager.class).newInstance(_dummyDevMgr);
    Properties props = new Properties();
    boolean ok = false;

    if (d != null && d.supportsConfigMenu()) {
        ok = d.showConfigMenu(rcb(), props);
    }

    if (!ok) {
        return;
    }

    String id = nsb(props.remove("_id"));
    tstEStrArg("device id", id);
    props.put("type", dev);
    JSONObject obj = new JSONObject(props);
    JSONObject g = getDevs(top);

    if (g.has(id)) {
        throw new Exception("Another device with name \"" + id + "\" is defined already");
    } else {
        g.put(id, obj);
    }

    saveConf(getCwd(), top);
}

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

public Properties getUserParams() {
    Properties p = new Properties();
    p.putAll(params);/*from  w  w  w  .j  av  a 2 s.c  o m*/
    p.remove(PROPERTY_ENDPOINT_NAME);
    p.remove(PROPERTY_ENDPOINT_URI);
    p.remove(PROPERTY_CREATE_CONNECTOR);
    p.remove(PROPERTY_TRANSFORMERS);
    return p;
}