List of usage examples for java.util Properties isEmpty
@Override public boolean isEmpty()
From source file:com.ottogroup.bi.streaming.source.kafka.KafkaConsumerBuilder.java
/** * Adds all key/value pairs to properties * @param properties/*from ww w . ja v a 2 s. c o m*/ * @return */ public KafkaConsumerBuilder<T> addProperties(final Properties properties) { if (properties != null && !properties.isEmpty()) this.properties.putAll(properties); return this; }
From source file:org.pentaho.platform.repository2.unified.jcr.LocalizationUtil.java
private String findLocalizedString(final String locale, final String propertyName) { String localeString = locale; if (StringUtils.isBlank(localeString)) { localeString = DEFAULT;/* www. j a v a 2s . c o m*/ } if (this.localePropertiesMap != null) { Properties localeProperties = this.localePropertiesMap.get(localeString); if (localeProperties != null && !localeProperties.isEmpty()) { return localeProperties.getProperty(propertyName); // found localized string in map } } return null; }
From source file:com.ottogroup.bi.streaming.sink.kafka.KafkaProducerBuilder.java
/** * Adds all key/value pairs to properties * @param properties//from ww w. j a v a 2 s. co m * @return */ public KafkaProducerBuilder<T> addProperties(final Properties properties) { if (properties != null && !properties.isEmpty()) this.properties.putAll(properties); return this; }
From source file:org.artifactory.descriptor.security.sso.CrowdSettingsTest.java
/** * Tests the behavior of the client properties generator method */// w w w.ja va2 s. co m public void testClientPropertiesProduction() { String serverUrl = "http://my.url"; String applicationName = "artifactory"; String password = "secret"; long sessionValidationInterval = 1337; CrowdSettings crowdSettings = new CrowdSettings(); crowdSettings.setServerUrl(serverUrl); crowdSettings.setApplicationName(applicationName); crowdSettings.setPassword(password); crowdSettings.setSessionValidationInterval(sessionValidationInterval); //First test property generation when org.artifactory.descriptor.security.sso.CrowdSettings.enableIntegration is false Properties configurationProperties = crowdSettings.getConfigurationProperties(); Assert.assertTrue(configurationProperties.isEmpty(), "Generated configuration properties should be empty since the integration is not enabled."); //Now "enable" the integration and test the properties crowdSettings.setEnableIntegration(true); configurationProperties = crowdSettings.getConfigurationProperties(); assertEquals(configurationProperties.getProperty("crowd.server.url"), serverUrl, "Unexpected server URL property value"); assertEquals(configurationProperties.getProperty("application.name"), applicationName, "Unexpected application name property value"); assertEquals(configurationProperties.getProperty("application.password"), password, "Unexpected password property value"); assertEquals(Long.parseLong(configurationProperties.getProperty("session.validationinterval")), sessionValidationInterval, "Unexpected session validation interval property value"); assertTrue(StringUtils.isNotBlank(configurationProperties.getProperty("session.isauthenticated")), "session.isauthenticated session attribute key must have a value."); assertTrue(StringUtils.isNotBlank(configurationProperties.getProperty("session.tokenkey")), "session.tokenkey session attribute key must have a value."); assertTrue(StringUtils.isNotBlank(configurationProperties.getProperty("session.lastvalidation")), "session.lastvalidation session attribute key must have a value."); }
From source file:com.igormaznitsa.mindmap.model.ModelUtilsTest.java
@Test public void testExtractQueryParameters_Empty() throws Exception { final Properties properties = ModelUtils.extractQueryPropertiesFromURI(new URI("file://hello")); assertTrue(properties.isEmpty()); }
From source file:org.apache.falcon.extensions.Extension.java
@Override public List<Entity> getEntities(final String extensionName, final Properties extensionProperties) throws FalconException { if (StringUtils.isBlank(extensionName)) { throw new FalconException("Extension name cannot be null or empty"); }/* ww w . j ava 2 s . c om*/ validateProperties(extensionProperties); String name = extensionName.toLowerCase(); AbstractExtension extension = ExtensionFactory.getExtensionType(name); if (extension != null) { extension.validate(extensionProperties); Properties props = extension.getAdditionalProperties(extensionProperties); if (props != null && !props.isEmpty()) { extensionProperties.putAll(props); } } ExtensionStore store = ExtensionService.getExtensionStore(); String resourceName = extensionProperties.getProperty(ExtensionProperties.RESOURCE_NAME.getName()); if (StringUtils.isBlank(resourceName)) { resourceName = name; } Map<String, String> extensionResources = store.getExtensionResources(name); /* Get the resources */ String extensionTemplate = getExtensionTemplate(store, extensionResources, resourceName); String wfPath = getWFPath(extensionResources, resourceName); /* Get Lib path */ String wfLibPath = store.getExtensionLibPath(name); Entity entity = ExtensionProcessBuilderUtils.createProcessFromTemplate(extensionTemplate, name, extensionProperties, wfPath, wfLibPath); if (entity == null) { throw new FalconException("Entity created from the extension template cannot be null"); } LOG.info("Extension processing complete"); return Arrays.asList(entity); }
From source file:org.opensingular.form.processor.TypeProcessorAttributeReadFromFile.java
/** * Recupera a lista de valores extras de atributos associados a classe informada. * * @return Nunca null, mas pode ser um lista com contedo zero. *//*from ww w . ja v a 2 s .co m*/ @Nonnull private FileDefinitions readDefinitionsFor(@Nonnull Class<?> typeClass) { URL url = lookForFile(typeClass); if (url != null) { try { Properties props = PropertiesUtils.load(url); if (!props.isEmpty()) { return new FileDefinitions(url, readDefinitionsFor(props)); } } catch (Exception e) { throw new SingularFormException( "Erro lendo propriedades para " + typeClass.getName() + " em " + url, e); } } return FileDefinitions.EMPTY; }
From source file:org.eclipse.kura.net.admin.visitor.linux.IfcfgConfigWriter.java
public static void writeKuraExtendedConfig( NetInterfaceConfig<? extends NetInterfaceAddressConfig> netInterfaceConfig) throws KuraException { NetInterfaceStatus netInterfaceStatus = null; boolean gotNetConfigIP4 = false; List<? extends NetInterfaceAddressConfig> netInterfaceAddressConfigs = netInterfaceConfig .getNetInterfaceAddresses(); if (netInterfaceAddressConfigs != null && netInterfaceAddressConfigs.size() > 0) { for (NetInterfaceAddressConfig netInterfaceAddressConfig : netInterfaceAddressConfigs) { List<NetConfig> netConfigs = netInterfaceAddressConfig.getConfigs(); if (netConfigs != null && netConfigs.size() > 0) { for (int i = 0; i < netConfigs.size(); i++) { NetConfig netConfig = netConfigs.get(i); if (netConfig instanceof NetConfigIP4) { netInterfaceStatus = ((NetConfigIP4) netConfig).getStatus(); gotNetConfigIP4 = true; }//from w w w . j a v a 2 s . c o m } } } } if (!gotNetConfigIP4) { netInterfaceStatus = NetInterfaceStatus.netIPv4StatusDisabled; } s_logger.debug( "Setting NetInterfaceStatus to " + netInterfaceStatus + " for " + netInterfaceConfig.getName()); // set it all Properties kuraExtendedProps = KuranetConfig.getProperties(); if (kuraExtendedProps == null) { s_logger.debug("kuraExtendedProps was null"); kuraExtendedProps = new Properties(); } StringBuilder sb = new StringBuilder().append("net.interface.").append(netInterfaceConfig.getName()) .append(".config.ip4.status"); kuraExtendedProps.put(sb.toString(), netInterfaceStatus.toString()); // write it if (kuraExtendedProps != null && !kuraExtendedProps.isEmpty()) { try { KuranetConfig.storeProperties(kuraExtendedProps); } catch (IOException e) { throw new KuraException(KuraErrorCode.INTERNAL_ERROR, e); } } }
From source file:org.codice.ddf.admin.application.service.impl.ApplicationConfigInstaller.java
@Override public void run() { File configFile = new File(fileName); if (!configFile.exists()) { LOGGER.debug("No config file located, cannot load from it."); return;/*from w w w .j a va 2 s .co m*/ } InputStream is = null; try { is = new FileInputStream(configFile); Properties props = new Properties(); props.load(is); if (!props.isEmpty()) { LOGGER.debug("Found applications to install from config."); for (Entry<Object, Object> curApp : props.entrySet()) { String appName = curApp.getKey().toString(); String appLocation = curApp.getValue().toString(); LOGGER.debug("Starting app {} at location: {}", appName, appLocation); try { if (StringUtils.isNotEmpty(appLocation)) { appService.addApplication(new URI(appLocation)); } appService.startApplication(appName); } catch (ApplicationServiceException ase) { LOGGER.warn("Could not start " + appName, ase); } catch (URISyntaxException use) { LOGGER.warn("Could not install application, location is not a valid URI " + appLocation, use); } } LOGGER.debug("Finished installing applications, uninstalling installer module..."); try { if (!StringUtils.isBlank(postInstallFeatureStart)) { featuresService.installFeature(postInstallFeatureStart, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles)); } if (!StringUtils.isBlank(postInstallFeatureStop)) { featuresService.uninstallFeature(postInstallFeatureStop); } } catch (Exception e) { LOGGER.debug("Error while trying to run the post-install start and stop operations.", e); } } else { LOGGER.debug("No applications were found in the configuration file."); } is.close(); } catch (FileNotFoundException fnfe) { LOGGER.warn("Could not file the configuration file at " + configFile.getAbsolutePath(), fnfe); } catch (IOException ioe) { LOGGER.warn("Could not load file as property list.", ioe); } finally { IOUtils.closeQuietly(is); } }
From source file:org.springframework.batch.core.jsr.launch.support.BatchPropertyBeanPostProcessor.java
@Override public Object postProcessBeforeInitialization(final Object artifact, String artifactName) throws BeansException { Properties artifactProperties = getArtifactProperties(artifactName); if (artifactProperties.isEmpty()) { return artifact; }//w w w . j av a 2s .c o m injectBatchProperties(artifact, artifactProperties); return artifact; }