List of usage examples for java.util Properties containsKey
@Override public boolean containsKey(Object key)
From source file:org.obiba.mica.search.queries.StudyQuery.java
@Nullable @Override/*from w ww .j av a 2 s . com*/ protected Properties getAggregationsProperties(List<String> filter) { Properties properties = getAggregationsProperties(filter, taxonomyService.getStudyTaxonomy()); if (!properties.containsKey(JOIN_FIELD)) properties.put(JOIN_FIELD, ""); return properties; }
From source file:org.deegree.console.metadata.ResourceProviderMetadata.java
private String getExampleDisplayName(final Properties props, final String examplePrefix, final String exampleLocation) { if (props.containsKey(examplePrefix + "name")) { return props.getProperty(examplePrefix + "name").trim(); }//from www.ja v a 2 s .com final int fileNameStart = exampleLocation.lastIndexOf("/") + 1; String exampleName = exampleLocation.substring(fileNameStart); final int fileNameEnd = exampleName.lastIndexOf('.'); if (fileNameEnd != -1) { exampleName = exampleName.substring(0, fileNameEnd); } return exampleName; }
From source file:och.service.props.impl.FileProps.java
@Override public String getVal(Object oKey, String defaultVal) { String key = String.valueOf(oKey); Properties props = state; return props.containsKey(key) ? (String) props.get(key) : defaultVal; }
From source file:com.linkedin.haivvreo.AvroGenericRecordReader.java
/** * Attempt to retrieve the reader schema. Haivvreo has a couple opportunities * to provide this, depending on whether or not we're just selecting data * or running with a MR job./*from w ww .j a v a 2s.c o m*/ * @return Reader schema for the Avro object, or null if it has not been provided. * @throws HaivvreoException */ private Schema getSchema(JobConf job, FileSplit split) throws HaivvreoException, IOException { // In "select * from table" situations (non-MR), Haivvreo can add things to the job // It's safe to add this to the job since it's not *actually* a mapred job. // Here the global state is confined to just this process. String s = job.get(AvroSerDe.HAIVVREO_SCHEMA); if (s != null) return Schema.parse(s); // Inside of a MR job, we can pull out the actual properties if (Utilities.getHiveJobID(job) != null) { MapredWork mapRedWork = Utilities.getMapRedWork(job); // Iterate over the Path -> Partition descriptions to find the partition // that matches our input split. for (Map.Entry<String, PartitionDesc> pathsAndParts : mapRedWork.getPathToPartitionInfo().entrySet()) { String partitionPath = pathsAndParts.getKey(); if (pathIsInPartition(split, partitionPath)) { if (LOG.isInfoEnabled()) LOG.info("Matching partition " + partitionPath + " with input split " + split); Properties props = pathsAndParts.getValue().getProperties(); if (props.containsKey(HaivvreoUtils.SCHEMA_LITERAL) || props.containsKey(HaivvreoUtils.SCHEMA_URL)) { return HaivvreoUtils.determineSchemaOrThrowException(props); } else return null; // If it's not in this property, it won't be in any others } } if (LOG.isInfoEnabled()) LOG.info("Unable to match filesplit " + split + " with a partition."); } // No more places to get the schema from. Give up. May have to re-encode later. return null; }
From source file:org.spring.data.gemfire.config.DistributedSystemValidationBeanPostProcessor.java
protected void logDiff(String sourceLabel, Properties source, String targetLabel, Properties target) { for (String propertyName : target.stringPropertyNames()) { if (source.containsKey(propertyName)) { String sourcePropertyValue = StringUtils.trimWhitespace(source.getProperty(propertyName)); String targetPropertyValue = StringUtils.trimWhitespace(target.getProperty(propertyName)); if (!targetPropertyValue.equals(sourcePropertyValue)) { System.out.printf( "**CONFIGURATION ERROR** Expected the %1$s value (%2$s) of property (%3$s); but %4$s value was (%5$s)%n", sourceLabel, sourcePropertyValue, propertyName, targetLabel, targetPropertyValue); }//from w w w .ja v a2 s .co m } } }
From source file:net.ronoaldo.code.appenginetools.RemoteApiHelper.java
/** * Start the connection, and perform the {@link ApiProxy} setup for the * current {@link Thread}./*from ww w . j a va 2s .com*/ */ public void connect() { logger.info("Connecting with " + url.getHost() + ", port " + url.getPort() + ", path=" + url.getPath()); RemoteApiOptions options = new RemoteApiOptions().server(// url.getHost(), url.getPort()).remoteApiPath(url.getPath()); Properties credentials = getCredentials(); // If we have a previous session, reuse it: if (credentials.containsKey("host")) { options.credentials(// credentials.getProperty("email"), serialize(credentials)); } else { options.credentials(credentials.getProperty("email"), credentials.getProperty("password")); } remoteApi = new RemoteApiInstaller(); try { remoteApi.install(options); storeCredentials(remoteApi.serializeCredentials()); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:nl.opengeogroep.filesetsync.client.plugin.SetFileXpathToHttpRequestHeaderPlugin.java
private void updateHeader(String header) { String file = null, xpathString = null, lastModified = null, lastValue = null; try {// w ww .ja va2s . c o m Properties props = headers.get(header); if (props == null || !props.containsKey("file") || !props.containsKey("xpath")) { log.warn("Invalid configuration for header " + header + ", ignoring"); return; } file = props.getProperty("file"); xpathString = props.getProperty("xpath"); lastModified = props.getProperty("lastModified"); lastValue = props.getProperty("lastValue"); File f = new File(file); if (!f.exists() || !f.canRead()) { log.warn(String.format("Cannot read value for header \"%s\" from file \"%s\"", header, file)); return; } if (lastModified != null && lastModified.equals(f.lastModified() + "")) { log.trace("File for header value " + header + " was not modified, keeping value " + lastValue); return; } Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f); XPath xpath = XPathFactory.newInstance().newXPath(); String value = xpath.evaluate(xpathString, doc); log.info(String.format("Value extracted from file \"%s\" using xpath \"%s\": %s", file, xpathString, value)); props.put("lastValue", value); props.put("lastModified", f.lastModified() + ""); } catch (Exception e) { log.error(String.format( "Error updating header %s, file=%s, xpathString=%s, lastModified=%s, lastValue=%s", header, file, xpathString, lastModified, lastValue), e); } }
From source file:org.apache.stratos.cloud.controller.iaases.ec2.EC2PartitionValidator.java
@Override public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException { // validate the existence of the region and zone properties. try {/* www . jav a 2s.co m*/ if (properties.containsKey(Scope.REGION.toString())) { String region = properties.getProperty(Scope.REGION.toString()); if (iaasProvider.getImage() != null && !iaasProvider.getImage().contains(region)) { String message = String.format( "Invalid partition detected [partition-id] %s, [region] %s. Image ID does not " + "contain region [image] %s", partition.getId(), region, iaasProvider.getImage()); log.error(message); throw new InvalidPartitionException(message); } iaas.isValidRegion(region); IaasProvider updatedIaasProvider = new IaasProvider(iaasProvider); if (properties.containsKey(Scope.ZONE.toString())) { String zone = properties.getProperty(Scope.ZONE.toString()); iaas.isValidZone(region, zone); updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, zone); } updateProperties(updatedIaasProvider, properties); Iaas updatedIaas = updatedIaasProvider.buildIaas(); updatedIaas.setIaasProvider(updatedIaasProvider); return updatedIaasProvider; } else { return iaasProvider; } } catch (Exception ex) { String message = String.format("Invalid partition detected: [partition-id] %s", partition.getId()); log.error(message, ex); throw new InvalidPartitionException(message, ex); } }
From source file:org.apache.stratos.cloud.controller.iaases.openstack.OpenstackPartitionValidator.java
@Override public IaasProvider validate(Partition partition, Properties properties) throws InvalidPartitionException { try {//from w w w.ja v a2 s . c o m // validate the existence of the zone and hosts properties. if (properties.containsKey(Scope.REGION.toString())) { String region = properties.getProperty(Scope.REGION.toString()); if (iaasProvider.getImage() != null && !iaasProvider.getImage().contains(region)) { String message = String.format( "Invalid partition detected [partition-id] %s, [region] %s. Image ID does not " + "contain region [image] %s", partition.getId(), region, iaasProvider.getImage()); log.error(message); throw new InvalidPartitionException(message); } iaas.isValidRegion(region); IaasProvider updatedIaasProvider = new IaasProvider(iaasProvider); if (properties.containsKey(Scope.ZONE.toString())) { String zone = properties.getProperty(Scope.ZONE.toString()); iaas.isValidZone(region, zone); } updateOtherProperties(updatedIaasProvider, properties); Iaas updatedIaas = updatedIaasProvider.buildIaas(); updatedIaas.setIaasProvider(updatedIaasProvider); return updatedIaasProvider; } else { return iaasProvider; } } catch (Exception e) { String message = String.format("Invalid partition detected: [partition-id] %s", partition.getId()); log.error(message, e); throw new InvalidPartitionException(message, e); } }
From source file:de.qucosa.servlet.MetsDisseminatorServlet.java
private FedoraClientFactory attemptToCreateFedoraClientFactoryFrom(Properties properties) { if (properties.containsKey(PROP_FEDORA_CREDENTIALS) && properties.containsKey(PROP_FEDORA_HOST_URL)) { final Credentials credentials = Credentials .fromColonSeparatedString(properties.getProperty(PROP_FEDORA_CREDENTIALS)); return new FedoraClientFactory(properties.getProperty(PROP_FEDORA_HOST_URL), credentials.getUsername(), credentials.getPassword()); }/* w w w . j a v a2 s. com*/ return null; }