if (item.getName() != null) { return false; } else if (!name.equals(item.getName())) { return false; if (item.getType() != null) { return false; } else if (!type.equals(item.getType())) { return false; if (item.getValue() != null) { return false; if (!value.equals(item.getValue())) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(join((String[]) item.getValue(), ARRAY_SEPARATOR))) { return false; if (item.getDefaultValue() != null) { return false;
if (item.getName() != null) { return false; } else if (!name.equals(item.getName())) { return false; if (item.getType() != null) { return false; } else if (!type.equals(item.getType())) { return false; if (item.getValue() != null) { return false; if (!value.equals(item.getValue())) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(String.valueOf(item.getValue()))) { return false; if (!value.equals(join((String[]) item.getValue(), ARRAY_SEPARATOR))) { return false; if (item.getDefaultValue() != null) { return false;
if (item.getValue() != null) { hItem.setValue(serializeValue(item.getValue(), item.getType(), item.isSecured())); } else if (!value.equals(item.getValue())) { hItem.setValue(serializeValue(item.getValue(), item.getType(), item.isSecured())); if (item.getDefaultValue() != null) { hItem.setDefaultValue(serializeValue(item.getDefaultValue(), item.getType(), item.isSecured())); } else if (!defaultValue.equals(item.getDefaultValue())) { hItem.setDefaultValue(serializeValue(item.getDefaultValue(), item.getType(), item.isSecured())); hItem.setType(item.getType()); hItem.setDefaulted(item.isDefaulted()); hItem.setSecured(item.isSecured()); hItem.setRegistered(item.isRegistered()); hItem.setSource(item.getSource()); hItem.setDescription(item.getDescription()); hItem.setDynamic(item.isDynamic()); hItem.setModified(new Date()); hItem.setRawValue(serializeValue(getRawProperty(hItem.getName()), ServerConfigurationService.TYPE_STRING, item.isSecured())); updatedItem = hItem;
String propertyName = configItem.getName(); if (IS_DEFAULT && (propertyName.startsWith(DEFAULT_INDEX))) { propertyName = propertyName.replaceFirst(DEFAULT_INDEX, "index."); mergedConfig.put(propertyName, (String) configItem.getValue()); } else if (propertyName.startsWith(LOCAL_INDEX)) { propertyName = propertyName.replaceFirst(LOCAL_INDEX, "index."); mergedConfig.put(propertyName, (String) configItem.getValue());
if (item == null || neverPersistItems.contains(item.getName())) { return null; serialValue = serializeValue(item.getValue(), item.getType(), item.isSecured()); serialDefaultValue = serializeValue(item.getDefaultValue(), item.getType(), item.isSecured()); serialRawValue = serializeValue(getRawProperty(item.getName()), ServerConfigurationService.TYPE_STRING, item.isSecured()); } catch (IllegalClassException ice) { log.error("Skip ConfigItem {}, {}", item, ice.getMessage()); item.getName(), serialValue, serialRawValue, item.getType(), item.getDescription(), item.getSource(), serialDefaultValue, item.isRegistered(), item.isDefaulted(), item.isSecured(), item.isDynamic());
List<MBeanAttributeInfo> attributeInfos = new ArrayList<>(); for (ConfigItem item : serverConfigurationService.getConfigData().getItems()) { String type = item.getType(); switch (type) { case ServerConfigurationService.TYPE_BOOLEAN: break; attributeInfos.add(new MBeanAttributeInfo(item.getName(), type, item.getDescription(), !item.isSecured(), true, false));
public ConfigDataImpl(List<ConfigItem> configItems) { ArrayList<ConfigItemImpl> cis = new ArrayList<ConfigItemImpl>(configItems.size()); HashSet<String> sourceSet = new HashSet<String>(); for (ConfigItem configItem : configItems) { if (configItem != null) { cis.add((ConfigItemImpl)configItem.copy()); if (configItem.getSource() != null && !"UNKNOWN".equals(configItem.getSource())) { sourceSet.add(configItem.getSource()); } totalConfigItems++; if (configItem.isRegistered()) { registeredConfigItems++; } else { unRegisteredConfigItems++; } } } this.sources = sourceSet.toArray(new String[sourceSet.size()]); Collections.sort(cis); this.items = new ArrayList<ConfigItem>(cis); } public int getTotalConfigItems() {
public ConfigItem registerConfigItem(ConfigItem configItem) { if (configItem == null) { throw new IllegalArgumentException("configItem must be set"); } ConfigItemImpl ci = null; if (StringUtils.isNotBlank(configItem.getName())) { ci = new ConfigItemImpl(configItem.getName(), configItem.getValue(), configItem.getSource()); if (configItem.getValue() != null) { ci.setValue(configItem.getValue()); } if (configItem.getDefaultValue() != null) { ci.setDefaultValue(configItem.getDefaultValue()); } ci = this.addConfigItem(ci, ci.getSource()); } else { log.warn("Skipping registering invalid config item (name not set): "+configItem); } return ci; }
/** * {@inheritDoc} */ public String getRawProperty(String name) { String rv = null; if (this.rawProperties.containsKey(name)) { // NOTE: raw properties ONLY contains the data read in from the properties files rv = StringUtils.trimToNull((String) this.rawProperties.get(name)); } else { // check the config storage since it is not in the raw props ConfigItem ci = getConfigItem(name); if (ci != null && ci.getValue() != null) { rv = ci.getValue().toString(); } } if (rv == null) rv = ""; return rv; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ConfigItem other = (ConfigItem) obj; if (name == null) { if (other.getName() != null) return false; } else if (!name.equals(other.getName())) return false; return true; }
@Override public void changed(ConfigItem item, ConfigItem previous) { // a ConfigItem has changed if (item == null) { return; } HibernateConfigItem hItem = findByName(item.getName()); if (hItem == null) { // new hItem hItem = createHibernateConfigItem(item); } else { // existing hItem, update it hItem = updateHibernateConfigItem(hItem, item); } saveOrUpdate(hItem); }
/** * merges the contents of one config item (the safely changed fields) into this one * @param ci any config item */ public void merge(ConfigItem ci) { if (ci != null) { //this.name = name; this.value = ci.getValue(); this.type = setValue(ci.getValue()); this.description = ci.getDescription(); if (StringUtils.isNotBlank(ci.getSource())) { this.source = ci.getSource(); } this.defaultValue = ci.getDefaultValue(); this.dynamic = ci.isDynamic(); } }
@Override public AttributeList getAttributes(String[] attributes) { AttributeList list = new AttributeList(); for (ConfigItem item: serverConfigurationService.getConfigData().getItems()) { String name = item.getName(); Object value = item.getValue(); Attribute attribute; if (item.isSecured()) { attribute = new Attribute(name, null); } else { attribute = new Attribute(name, value); } list.add(attribute); } return list; }
@SuppressWarnings("NullableProblems") public int compareTo(ConfigItem ci) { if (ci == null) { throw new NullPointerException("Cannot compare this to a null value"); } return this.name.compareToIgnoreCase(ci.getName()); }
/** * Make an impl from something that implements ConfigItem by copying the field values * @param ci a ci object */ @SuppressWarnings("unused") public ConfigItemImpl(ConfigItem ci) { this(ci.getName(), ci.getValue(), ci.getType(), ci.getDescription(), ci.getSource(), ci.getDefaultValue(), ci.getRequested(), ci.getChanged(), null, ci.isRegistered(), ci.isDefaulted(), ci.isSecured(), ci.isDynamic()); if (ci.getHistory() != null) { this.history = Arrays.asList(ci.getHistory()); } else { this.history = new ArrayList<ConfigHistory>(); } }