List of usage examples for java.util Properties remove
@Override public synchronized Object remove(Object key)
From source file:org.omegat.core.team2.ProjectTeamSettings.java
/** * Update setting./*from w ww.ja v a2 s . co m*/ */ public synchronized void set(String key, String newValue) { try { Properties p = new Properties(); File f = configFile; File fNew = new File(configFile.getAbsolutePath() + ".new"); if (f.exists()) { try (FileInputStream in = new FileInputStream(f)) { p.load(in); } } else { f.getParentFile().mkdirs(); } if (newValue != null) { p.setProperty(key, newValue); } else { p.remove(key); } try (FileOutputStream out = new FileOutputStream(fNew)) { p.store(out, null); } f.delete(); FileUtils.moveFile(fNew, f); } catch (Exception ex) { throw new RuntimeException(ex); } }
From source file:org.wso2.carbon.identity.notification.mgt.email.bean.EmailSubscription.java
/** * Set endpoints to the email subscription * * @param prefix prefix of the subscription * @param endpointsProperties Properties which are related to endpoints */// w w w . j a v a 2s .c om private void setEndpoints(String prefix, Properties endpointsProperties) { Properties endpointNames = NotificationManagementUtils.getSubProperties(prefix, endpointsProperties); Enumeration endpointNameSet = endpointNames.propertyNames(); // Build all the endpoints by iterating through properties while (endpointNameSet.hasMoreElements()) { String key = (String) endpointNameSet.nextElement(); String endpointName = (String) endpointNames.remove(key); // Build endpoint key using endpoint name String endpointKey = prefix + "." + endpointName; Properties endpointProperties = NotificationManagementUtils.getPropertiesWithPrefix(endpointKey, endpointsProperties); // Build and add email endpoint object to subscription try { emailEndpointInfoList.add(buildEndpoint(endpointKey, endpointProperties)); } catch (NotificationManagementException e) { // If the particular endpoint building fails, An error message will be printed at the startup time. // And continue with building other endpoints log.error("Error while building endpoint object for endpoint with key " + endpointKey, e); } } }
From source file:org.opencastproject.capture.impl.ConfigurationManagerTest.java
@Test public void testBrokenCapabilities() throws IOException, ConfigurationException { Properties sourceProps = new Properties(); InputStream is = getClass().getClassLoader().getResourceAsStream("config/capture.properties"); if (is == null) { Assert.fail();/*from w w w . ja va 2 s .com*/ } sourceProps.load(is); IOUtils.closeQuietly(is); sourceProps.remove("capture.device.MOCK_PRESENTER.src"); sourceProps.remove("capture.device.MOCK_PRESENTER.outputfile"); configManager.setItem("capture.device.MOCK_PRESENTER.src", null); configManager.setItem("capture.device.MOCK_PRESENTER.outputfile", null); configManager.setItem("org.opencastproject.storage.dir", new File("./target", "configman-test").getAbsolutePath()); configManager.setItem("org.opencastproject.server.url", "http://localhost:8080"); configManager.updated(sourceProps); Assert.assertNull(configManager.getCapabilities()); }
From source file:net.geoprism.FileMerger.java
public void mergeProperties(File base, File override, File export) throws IOException { if (!export.exists()) { export.createNewFile();/*w w w.ja v a2s.c o m*/ } if (!base.exists()) { if (override != export) { FileUtils.copyFile(override, export); } return; } Properties baseProps = new Properties(); baseProps.load(new FileInputStream(base)); Properties overrideProps = new Properties(); overrideProps.load(new FileInputStream(override)); Iterator<Object> i = overrideProps.keySet().iterator(); while (i.hasNext()) { String key = (String) i.next(); String value = overrideProps.getProperty(key); if (value.equals("$REMOVE$")) { baseProps.remove(key); } else { baseProps.setProperty(key, value); } } baseProps.store(new FileOutputStream(export), null); }
From source file:com.zimbra.cs.mailclient.smtp.SmtpTransportTest.java
@After public void tearDown() { Properties props = JMSession.getSession().getProperties(); props.remove("mail.smtp.sendpartial"); props.remove("mail.smtp.from"); JMSession.getSession().getProperties().remove("mail.smtp.sendpartial"); if (server != null) { server.destroy();/*from w w w . ja v a 2 s.co m*/ } }
From source file:org.sonatype.sisu.bl.jsw.JSWConfig.java
/** * @return all system properties that start with "wrapper." *///w w w.j ava 2 s.c om private Properties wrapperPropertiesFromSystem() { Properties props = new Properties(); props.putAll(System.getProperties()); Collection<String> propNames = Properties2.sortKeys(props); for (final String propName : propNames) { if (!propName.startsWith("wrapper.")) { props.remove(propName); } } return props; }
From source file:org.wso2.carbon.identity.event.EventMgtConfigBuilder.java
/** * Build and store per module configuration objects *///w w w . ja v a 2s. c om private void build() { Properties moduleNames = EventManagementUtils.getSubProperties("module.name", notificationMgtConfigProperties); Enumeration propertyNames = moduleNames.propertyNames(); // Iterate through events and build event objects while (propertyNames.hasMoreElements()) { String key = (String) propertyNames.nextElement(); String moduleName = (String) moduleNames.remove(key); moduleConfiguration.put(moduleName, buildModuleConfigurations(moduleName)); } }
From source file:org.wso2.carbon.identity.event.IdentityEventConfigBuilder.java
/** * Build and store per module configuration objects *//*from w ww . j ava2s .c o m*/ private void build() { Properties moduleNames = IdentityEventUtils.getSubProperties("module.name", notificationMgtConfigProperties); Enumeration propertyNames = moduleNames.propertyNames(); // Iterate through events and build event objects while (propertyNames.hasMoreElements()) { String key = (String) propertyNames.nextElement(); String moduleName = (String) moduleNames.remove(key); moduleConfiguration.put(moduleName, buildModuleConfigurations(moduleName)); } }
From source file:org.kuali.rice.krad.util.KRADUtils.java
/** * Removes parameters from the given properties object that are request specific (useful when manupulating the * current URL to invoke something else) * * @param requestParameters properties instance containing the parameters to clean *///from ww w .ja va 2 s . c o m public static void cleanRequestParameters(Properties requestParameters) { requestParameters.remove(UifParameters.SESSION_ID); requestParameters.remove(UifParameters.AJAX_REQUEST); requestParameters.remove(UifParameters.AJAX_RETURN_TYPE); requestParameters.remove(UifParameters.FORM_KEY); requestParameters.remove(UifParameters.JUMP_TO_ID); requestParameters.remove(UifParameters.FOCUS_ID); }
From source file:org.apache.archiva.metadata.repository.file.FileMetadataRepository.java
private static void clearMetadataFacetProperties(Collection<MetadataFacet> facetList, Properties properties, String prefix) {// w w w. j a v a 2 s. c om List<Object> propsToRemove = new ArrayList<>(); for (MetadataFacet facet : facetList) { for (Object key : new ArrayList(properties.keySet())) { String keyString = (String) key; if (keyString.startsWith(prefix + facet.getFacetId() + ":")) { propsToRemove.add(key); } } } for (Object key : propsToRemove) { properties.remove(key); } }