DSpaceConfigurationService implements ConfigurationService { @Override public synchronized boolean setProperty(String name, Object value) { if (value != null && String.class.isInstance(value)) { value = ((String) value).trim(); } boolean changed = false; if (name == null) { throw new IllegalArgumentException("name cannot be null for setting configuration"); } else { Object oldValue = getConfiguration().getProperty(name); if (value == null && oldValue != null) { changed = true; getConfiguration().clearProperty(name); log.info("Cleared the configuration setting for name (" + name + ")"); } else if (value != null && !value.equals(oldValue)) { changed = true; getConfiguration().setProperty(name, value); } } return changed; } DSpaceConfigurationService();  DSpaceConfigurationService(String providedHome); @Override Properties getProperties(); @Override List<String> getPropertyKeys(); @Override List<String> getPropertyKeys(String prefix); @Override Configuration getConfiguration(); @Override Object getPropertyValue(String name); @Override String getProperty(String name); @Override String getProperty(String name, String defaultValue); @Override String[] getArrayProperty(String name); @Override String[] getArrayProperty(String name, String[] defaultValue); @Override boolean getBooleanProperty(String name); @Override boolean getBooleanProperty(String name, boolean defaultValue); @Override int getIntProperty(String name); @Override int getIntProperty(String name, int defaultValue); @Override long getLongProperty(String name); @Override long getLongProperty(String name, long defaultValue); @Override T getPropertyAsType(String name, Class<T> type); @Override T getPropertyAsType(String name, T defaultValue); @Override T getPropertyAsType(String name, T defaultValue, boolean setDefaultIfNotFound); @Override boolean hasProperty(String name); @Override synchronized boolean addPropertyValue(String name, Object value); @Override synchronized boolean setProperty(String name, Object value); String[] loadConfiguration(Map<String, Object> properties); boolean loadConfig(String key, Object value); void clear(); void clearConfig(String key); @Override synchronized void reloadConfig(); @Override String toString(); static final String DSPACE; static final String EXT_CONFIG; static final String DOT_CONFIG; static final String DSPACE_HOME; static final String DEFAULT_CONFIG_DIR; static final String DEFAULT_CONFIG_DEFINITION_FILE; static final String DSPACE_CONFIG_DEFINITION_PATH; static final String DSPACE_CONFIG_PATH; static final String DSPACE_SERVER_ID; static final char CONFIG_LIST_DELIMITER; }
@Test public void testSetProperty() { Object prop = configurationService.getPropertyValue("newOne"); assertNull(prop); boolean changed = configurationService.setProperty("newOne", "1111111"); assertTrue(changed); prop = configurationService.getPropertyValue("newOne"); assertNotNull(prop); assertEquals("1111111", prop); int i = configurationService.getIntProperty("newOne"); assertEquals(1111111, i); prop = configurationService.getPropertyValue("newBool"); assertNull(prop); changed = configurationService.setProperty("newBool", true); assertTrue(changed); prop = configurationService.getPropertyValue("newBool"); assertNotNull(prop); assertEquals(Boolean.TRUE, prop); boolean b = configurationService.getBooleanProperty("newBool"); assertEquals(true, b); changed = configurationService.setProperty("newBool", true); assertFalse(changed); changed = configurationService.setProperty("newBool", null); assertTrue(changed); prop = configurationService.getPropertyValue("newBool"); assertNull(prop); prop = configurationService.getPropertyValue("newString"); assertNull(prop); changed = configurationService.setProperty("newString", " Hi There "); assertTrue(changed); String s = configurationService.getProperty("newString"); assertNotNull(s); assertEquals("Hi There", s); configurationService.clearConfig("newOne"); configurationService.clearConfig("newBool"); configurationService.clearConfig("newString"); prop = null; }