Example usage for java.util Properties containsKey

List of usage examples for java.util Properties containsKey

Introduction

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

Prototype

@Override
    public boolean containsKey(Object key) 

Source Link

Usage

From source file:org.deegree.console.metadata.ResourceManagerMetadata.java

private ResourceManagerMetadata(ResourceManager<?> mgr, Workspace workspace) {
    this.workspace = workspace;
    if (mgr.getMetadata() != null) {
        for (ResourceProvider<?> provider : mgr.getProviders()) {
            ResourceProviderMetadata providerMd = ResourceProviderMetadata.getMetadata(provider);
            if ("LockDbProviderProvider".equals(providerMd.getName())) {
                continue;
            }/*from w w w  .j av a 2  s.co m*/
            providers.add(provider);
            providerNames.add(providerMd.getName());
            nameToProvider.put(providerMd.getName(), provider);
        }
    } else {
        providers = Collections.emptyList();
    }

    String className = mgr.getClass().getName();
    String metadataUrl = "/META-INF/console/resourcemanager/" + className;
    URL url = ResourceManagerMetadata.class.getResource(metadataUrl);
    if (url != null) {
        LOG.debug("Loading resource manager metadata from '" + url + "'");
        Properties props = new Properties();
        InputStream is = null;
        try {
            is = url.openStream();
            props.load(is);
            name = props.getProperty("name");
            if (name != null) {
                name = name.trim();
            }
            category = props.getProperty("category");
            if (props.containsKey("start_view")) {
                startView = props.getProperty("start_view").trim();
            }
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(is);
        }
    } else {
        throw new RuntimeException("Internal error: File '" + metadataUrl + "' missing on classpath.");
    }
    this.mgr = mgr;
}

From source file:com.mirth.connect.server.util.JavaScriptUtil.java

private void initialize() {
    /*/*from   w  w  w  .j  ava  2s  . c om*/
     * Checks mirth.properties for the rhino.optimizationlevel property.
     * Setting it to -1 runs it in interpretive mode. See MIRTH-1627 for
     * more information.
     */

    Properties properties = PropertyLoader.loadProperties("mirth");

    if (MapUtils.isNotEmpty(properties) && properties.containsKey("rhino.optimizationlevel")) {
        rhinoOptimizationLevel = Integer.valueOf(properties.getProperty("rhino.optimizationlevel")).intValue();
        logger.debug("set Rhino context optimization level: " + rhinoOptimizationLevel);
    } else {
        logger.debug("using defualt Rhino context optimization level (-1)");
    }
}

From source file:org.apache.sqoop.mapreduce.hcat.SqoopHCatUtilities.java

public static void configureExportInputFormat(SqoopOptions opts, Job job, ConnManager connMgr, String dbTable,
        Configuration config) throws IOException {

    LOG.info("Configuring HCatalog for export job");
    SqoopHCatUtilities hCatUtils = SqoopHCatUtilities.instance();
    hCatUtils.configureHCat(opts, job, connMgr, dbTable, job.getConfiguration());
    job.setInputFormatClass(getInputFormatClass());
    Map<String, List<Integer>> dbColInfo = hCatUtils.getDbColumnInfo();
    MapWritable columnTypesJava = new MapWritable();
    Properties mapColumnJava = opts.getMapColumnJava();
    for (Map.Entry<String, List<Integer>> e : dbColInfo.entrySet()) {
        Text columnName = new Text(e.getKey());
        Text columnText = null;//w w  w . j a v a 2s.com
        if (mapColumnJava.containsKey(e.getKey())) {
            columnText = new Text(mapColumnJava.getProperty(e.getKey()));
        } else {
            columnText = new Text(connMgr.toJavaType(dbTable, e.getKey(), e.getValue().get(0)));
        }
        columnTypesJava.put(columnName, columnText);
    }
    MapWritable columnTypesSql = new MapWritable();
    for (Map.Entry<String, List<Integer>> e : dbColInfo.entrySet()) {
        Text columnName = new Text(e.getKey());
        IntWritable sqlType = new IntWritable(e.getValue().get(0));
        columnTypesSql.put(columnName, sqlType);
    }
    DefaultStringifier.store(config, columnTypesJava, SqoopHCatUtilities.HCAT_DB_OUTPUT_COLTYPES_JAVA);
    DefaultStringifier.store(config, columnTypesSql, SqoopHCatUtilities.HCAT_DB_OUTPUT_COLTYPES_SQL);
}

From source file:org.netxilia.api.impl.storage.DataSourceConfigurationServiceImpl.java

@Override
public synchronized void deleteConfigurationForWorkbook(WorkbookId workbookKey)
        throws StorageException, NotFoundException {
    init();//from   w w  w  .ja  v  a2 s.co  m
    Properties props = loadWorkbookToDataSourceFile();
    if (props.containsKey(workbookKey.getKey())) {
        notifyDeleteConfigurationForWorkbook(workbookKey);
        props.remove(workbookKey.getKey());
        saveWorkbookToDataSourceFile(props);
    }

}

From source file:org.callistasoftware.maven.plugins.propertyscanner.MyMojo.java

public void execute() throws MojoExecutionException {
    logger = getLog();/*from  w  w w .j  a  va  2  s.  c  o  m*/

    //load all properties
    Properties properties = loadProperties(logger);

    Set<String> allTokens = new HashSet<String>();
    //read all jsp files
    allTokens.addAll(scanJspFiles(logger));

    //read all java files
    allTokens.addAll(scanJavaFiles(logger));

    //verify that all tokens are present in properties files
    for (String token : allTokens) {
        if (!properties.containsKey(token)) {
            logger.warn("could not find translation for key: " + token);
        } else {
            properties.setProperty(token, PROPERTY_FOUND_FLAG);
        }
    }

    for (String key : properties.stringPropertyNames()) {
        if (properties.getProperty(key) != PROPERTY_FOUND_FLAG) {
            logger.warn("Unused property found, key:" + key + " and value:" + properties.getProperty(key));
        }
    }
}

From source file:com.virtualparadigm.packman.processor.JPackageManagerBU.java

public static Properties validate(File tempDir) {
    logger.info("PackageManager::validate()");

    // INVALID (return empty properties) IF:
    //   package.properties not found
    //   package properties does not contain name and version
    //   found installed version greater than package to be installed

    Properties packageProperties = new Properties();
    InputStream packagePropInputStream = null;
    try {//www.  j a va 2  s.co  m
        packagePropInputStream = new FileInputStream(new File(tempDir.getAbsolutePath() + "/"
                + JPackageManagerBU.METADATA_DIR_NAME + "/" + JPackageManagerBU.PACKAGE_PROPERTIES_FILE_NAME));
        packageProperties.load(packagePropInputStream);
        logger.info("  loaded package properties.");
    } catch (IOException ioe) {
        logger.error("", ioe);
        //            ioe.printStackTrace();
    } finally {
        if (packagePropInputStream != null) {
            try {
                packagePropInputStream.close();
            } catch (Exception e) {
                logger.error("", e);
                //                    e.printStackTrace();
            }
        }
    }

    if (packageProperties.containsKey(JPackageManagerBU.PACKAGE_NAME_KEY)
            && packageProperties.containsKey(JPackageManagerBU.PACKAGE_VERSION_KEY)) {
        VersionNumber installedVersionNumber = null;
        Package installPackage = JPackageManagerBU
                .findInstalledPackage(packageProperties.getProperty(PACKAGE_NAME_KEY));
        if (installPackage == null) {
            installedVersionNumber = new VersionNumber("0");
        } else {
            installedVersionNumber = installPackage.getVersionNumber();
        }
        if (installedVersionNumber.compareTo(
                new VersionNumber(packageProperties.getProperty(JPackageManagerBU.PACKAGE_VERSION_KEY))) >= 0) {
            logger.info("  installed version is more recent.");
            //installed version greater than or equal to package to install
            packageProperties = null;
        }
    } else {
        logger.info("  could not find package.name or package.version values for new package.");
        //return null to signify error/invalid
        packageProperties = null;
    }
    return packageProperties;
}

From source file:net.sf.keystore_explorer.crypto.csr.spkac.Spkac.java

/**
 * Load a SPKAC.//w  w w  .  j  a  v  a  2  s.  c o  m
 *
 * @param is
 *            Stream to load from
 * @throws IOException
 *             If an I/O problem occurs
 * @throws SpkacMissingPropertyException
 *             If no subject is present in SPKAC
 * @throws SpkacException
 *             If load fails
 */
public Spkac(InputStream is) throws IOException, SpkacException {
    Properties properties = readProperties(is);

    if (!properties.containsKey(SPKAC_PROPERTY)) {
        throw new SpkacMissingPropertyException(MessageFormat
                .format(res.getString("SpkacNoIncludeRequiredProperty.exception.message"), SPKAC_PROPERTY));
    }

    subject = getSubject(properties);

    String spkacProperty = properties.getProperty(SPKAC_PROPERTY);

    derSpkac = Base64.decode(spkacProperty);

    decodeSpkac(derSpkac);
}

From source file:com.alfaariss.oa.engine.authentication.configuration.ConfigurationProfile.java

private Properties readExtendedProperties(IConfigurationManager config, Element eProperties)
        throws OAException {
    Properties prop = new Properties();
    Element eProperty = config.getSection(eProperties, "property");
    while (eProperty != null) {
        String sName = config.getParam(eProperty, "name");
        if (sName == null) {
            _logger.error("No 'name' item found in 'property' section in configuration");
            throw new OAException(SystemErrors.ERROR_CONFIG_READ);
        }/*from  ww  w  .  j av a2  s . c  om*/
        if (prop.containsKey(sName)) {
            _logger.error(
                    "Duplicate 'name' item found in 'property' section in configuration, property is not added: "
                            + sName);
            throw new OAException(SystemErrors.ERROR_CONFIG_READ);
        }

        String sValue = config.getParam(eProperty, "value");
        if (sValue == null) {
            _logger.error("No 'value' item found in 'property' section in configuration");
            throw new OAException(SystemErrors.ERROR_CONFIG_READ);
        }

        prop.put(sName, sValue);
        eProperty = config.getNextSection(eProperty);
    }
    return prop;
}

From source file:com.francetelecom.clara.cloud.logicalmodel.LogicalConfigServiceTest.java

@Test
public void entries_with_empty_values_are_supported() throws BusinessException {
    LogicalConfigService lcs = createConfigSetLogicalModelCatalog("#comment\nkeyWithEmptyValue=", false,
            "prefix.");
    Properties mergedProperties = new Properties();
    lcs.mergeAndCheckForDuplicateKeys(mergedProperties, IGNORED_DUPLICATES, IGNORE_COLLISIONS);
    Assert.assertTrue("expected keyWithEmptyValue to be present in list of keys",
            mergedProperties.containsKey("prefix.keyWithEmptyValue"));
    Assert.assertEquals("expected empty value to return empty string", "",
            mergedProperties.getProperty("prefix.keyWithEmptyValue"));
}

From source file:org.apache.ctakes.ytex.kernel.SparseDataExporterImpl.java

@Override
public void exportData(Properties props, SparseDataFormatter formatter, BagOfWordsDecorator bDecorator)
        throws IOException {
    InstanceData instanceLabel = this.getKernelUtil().loadInstances(props.getProperty("instanceClassQuery"));
    if (props.containsKey("folds")) {
        this.getKernelUtil().generateFolds(instanceLabel, props);
    }/*  ww  w.j av a 2  s. c o m*/
    // load label - instance id maps
    // sparseData.setLabelToInstanceMap(this.getKernelUtil().loadInstances(
    // props.getProperty("instanceClassQuery"),
    // sparseData.getLabelToClassMap()));
    this.exportData(instanceLabel, formatter, props, bDecorator);
    // this.loadData(sparseData,
    // props.getProperty("numericWordQuery"),
    // props.getProperty("nominalWordQuery"), bDecorator);
    // this.exportData(sparseData, formatter, props);
}