private static void mergeOpenPropertyMap(List<AbstractPropertyMap> memberParentPropertyMaps, AbstractPropertyMap groupParentPropertyMap) { for (String groupMemberPropertyName : groupParentPropertyMap.getMap().keySet()) { PropertySimple groupMemberProperty = groupParentPropertyMap.getSimple(groupMemberPropertyName); if (groupMemberProperty != null && groupMemberProperty.getOverride() != null && groupMemberProperty.getOverride()) { for (AbstractPropertyMap sourceParentPropertyMap : memberParentPropertyMaps) { PropertySimple sourcePropertySimple = sourceParentPropertyMap.getSimple(groupMemberPropertyName); if (sourcePropertySimple == null) { sourcePropertySimple = new PropertySimple(groupMemberPropertyName, groupMemberProperty .getStringValue()); sourceParentPropertyMap.put(sourcePropertySimple); } else { sourcePropertySimple.setStringValue(groupMemberProperty.getStringValue()); } } } } }
public void print(PropertySimple p, int depth) { out.println(indent(depth) + p.getName() + " = " + p.getStringValue()); }
/** * Return the object representation of the passed PropertySimple for the passed type * @param prop Property to evaluate * @param type Type to convert into * @return Converted object -- if no valid type is found, a String-value is returned. */ private Object getObjectForProperty(PropertySimple prop, PropertySimpleType type) { switch (type) { case STRING: return prop.getStringValue(); case INTEGER: return prop.getIntegerValue(); case BOOLEAN: return prop.getBooleanValue(); case LONG: return prop.getLongValue(); case FLOAT: return prop.getFloatValue(); case DOUBLE: return prop.getDoubleValue(); default: return prop.getStringValue(); } }
private void setPropertyError(Object rawPropValue, PropertySimple prop) { prop.setErrorMessage("The discovered value of this property was longer than " + PropertySimple.MAX_VALUE_LENGTH + " characters (the maximum length of an RHQ property). It has been left unset. Please see the Agent log for the full value."); log.warn("The discovered value for property [" + prop.getName() + "] was too long and was left unset. It is logged here for reference: " + rawPropValue); }
private static void unmaskPropertySimple(PropertySimple propertySimple, AbstractPropertyMap unmaskedParentPropertyMap) { if (propertySimple.isMasked()) { PropertySimple unmaskedPropertySimple = unmaskedParentPropertyMap.getSimple(propertySimple.getName()); String unmaskedValue = (unmaskedPropertySimple != null) ? unmaskedPropertySimple.getStringValue() : null; propertySimple.setStringValue(unmaskedValue); } }
try { PropertyDefinitionSimple def = configurationDefinition.getPropertyDefinitionSimple(property .getName()); if (!(ignoreReadOnly && def.isReadOnly())) { switch (def.getType()) { case INTEGER: { attribute.setValue(property.getIntegerValue()); break; attribute.setValue(property.getLongValue()); break; attribute.setValue(property.getBooleanValue()); break; attribute.setValue(property.getFloatValue()); break; attribute.setValue(property.getDoubleValue()); break; attribute.setValue(property.getStringValue()); break; property.setErrorMessage(ThrowableUtil.getStackAsString(e)); report .setErrorMessage("Failed setting resource configuration - see property error messages for details");
public static PropertySimple getGlobList(String name, List<String> simples) { StringBuilder bld = new StringBuilder(); if (simples != null) { for (String s : simples) { bld.append(s).append("|"); } } if (bld.length() > 0) { bld.deleteCharAt(bld.length() - 1); } return new PropertySimple(name, bld); }
@Override @Lock(LockType.WRITE) public void setUserProperty(int subjectId, String propertyName, String value) { load(subjectId); Configuration config = subjectPreferences.get(subjectId); if (config == null) { return; } PropertySimple prop = config.getSimple(propertyName); if (prop == null) { prop = new PropertySimple(propertyName, value); config.put(prop); // add new to collection mergeProperty(prop); } else if (prop.getStringValue() == null || !prop.getStringValue().equals(value)) { prop.setStringValue(value); mergeProperty(prop); } }
public void deleteResource() throws Exception { Configuration opConfig = new Configuration(); ResourceContext<TomcatUserDatabaseComponent> resourceContext = getResourceContext(); // We must strip the quotes off of name for the operation parameter PropertySimple nameProperty = resourceContext.getPluginConfiguration().getSimple(PLUGIN_CONFIG_NAME); String name = nameProperty.getStringValue(); nameProperty = new PropertySimple(CONFIG_USERNAME, name.substring(1, name.length() - 1)); opConfig.put(nameProperty); resourceContext.getParentResourceComponent().invokeOperation("removeUser", opConfig); resourceContext.getParentResourceComponent().save(); }
private static void adaptPropertySimple(PropertySimple source, PropertySimple target, PropertyDefinitionSimple definition, Object parent, boolean adaptReadonlyProperties) { if (adaptReadonlyProperties || !definition.isReadOnly()) { if (target == null) { target = new PropertySimple(); target.setName(definition.getName()); add(parent, target); } target.setStringValue(source.getStringValue()); } }
/** * @return the value as being stored in the database */ public String getObfuscatedStringValue() { return super.getStringValue(); }
if (managedRuntimeProp != null && managedRuntimeProp.getBooleanValue() != null && managedRuntimeProp.getBooleanValue()) { PropertySimple pathProp = new PropertySimple("path", resKey); config2.put(pathProp); String name = resKey.substring(resKey.lastIndexOf("=") + 1); Configuration config2 = context.getDefaultPluginConfiguration(); PropertySimple pathProp = new PropertySimple("path", path); config2.put(pathProp);
/** * Set the value of a simple property to the specified value. If the property is not yet defined, it will be added. * * @param name the name of the simple property to be set * @param value the new value for the property * * @since 4.4 */ public void setSimpleValue(String name, String value) { PropertySimple property = getSimple(name); if (value == null) { if (property != null) { remove(name); } } else { if (property == null) { put(new PropertySimple(name, value)); } else { property.setStringValue(value); } } }
public void setStartScript(File startScript) { PropertySimple prop = this.pluginConfig.getSimple(START_SCRIPT_PROP); if (prop == null) { prop = new PropertySimple(START_SCRIPT_PROP, null); this.pluginConfig.put(prop); } prop.setValue(startScript); }
private static void calculateGroupOpenPropertyMap(List<AbstractPropertyMap> sourceParentPropertyMaps, AbstractPropertyMap targetParentPropertyMap) { Map<String, Map<String, Integer>> memberNameValueFrequenciesMap = createMemberNameValueFrequenciesMap(sourceParentPropertyMaps); for (String memberName : memberNameValueFrequenciesMap.keySet()) { // Add each unique member to the target map, so the renderer will be able to display it on the main // config page. PropertySimple member = new PropertySimple(memberName, null); targetParentPropertyMap.put(member); // Also add it to each of the source config maps that don't already contain it, so that they can be // rendered as unset on the propSet page. for (AbstractPropertyMap map : sourceParentPropertyMaps) { if (map.get(memberName) == null) map.put(new PropertySimple(memberName, null)); } Map<String, Integer> valueFrequencies = memberNameValueFrequenciesMap.get(memberName); if (valueFrequencies.size() == 1 && valueFrequencies.values().iterator().next() == sourceParentPropertyMaps.size()) { // Set override to true so the renderers will know the prop is homogenous. member.setOverride(true); // And set the value, so it can be displayed on the main config page. member.setStringValue(valueFrequencies.keySet().iterator().next()); } } }
if (prop instanceof PropertySimple) { PropertySimple pro = (PropertySimple) prop; if (pro.getStringValue() == null || (pro.getStringValue() != null && pro.getStringValue().equals("null"))) { String p = context.getResourceType().getResourceConfigurationDefinition().getDefaultTemplate().getConfiguration().getSimpleValue(key); log.debug("Using default value for " + key + " value: " + def.getDefaultValue()); switch (def.getType()) { case INTEGER: { pro.setIntegerValue(Integer.valueOf(p)); break; pro.setLongValue((long) Long.valueOf(p)); break; pro.setBooleanValue(Boolean.valueOf(p)); pro.setStringValue(p); else if (pro.getStringValue() != null) pro.setStringValue(null); break;
/** * Sets the value of this property. You should pass the "clear text" value - the obfuscation of * the value in the database is done for you behind the scenes. */ @Override public void setValue(Object value) { //just use the logic in the superclass to set the value super.setValue(value); //and obtain the result this.clearTextValue = super.getStringValue(); //now set the underlying value to the obfuscated one super.setValue(obfuscate(clearTextValue)); //now we have the clear text string representation of the value in "clearTextValue", //the stringValue in the superclass contains the corresponding obfuscated string. }
if (eprop instanceof PropertySimple) { PropertySimple exps = existConf.getSimple(name); if (ps.getStringValue() != null) { exps.setStringValue(ps.getStringValue()); if (prop instanceof PropertySimple) { PropertySimple ps = newConf.getSimple(name); if (ps.getStringValue() != null) { Property property = ps.deepCopy(false); existConf.put(property);
private static void validatePropertySimple(PropertyDefinition propertyDefinition, PropertySimple propertySimple, PropertySimple currentPropertySimple, List<String> errorMessages) { // make sure required properties have a value if (propertyDefinition.isRequired() && (propertySimple.getStringValue() == null)) { errorMessages.add("Required property '" + propertyDefinition.getName() + "' has a null value."); propertySimple.setStringValue(""); } // make sure readOnly properties are not being changed if (propertyDefinition.isReadOnly() && null != currentPropertySimple) { String currentValue = currentPropertySimple.getStringValue(); // if there is no current value allow an initial value to be set for the readOnly property. if (!(null == currentValue || currentValue.trim().isEmpty() || propertySimple.getStringValue().equals( currentValue))) { errorMessages.add("ReadOnly property '" + propertyDefinition.getName() + "' has a value [" + propertySimple.getStringValue() + "] different than the current value [" + currentValue + "]. It is not allowed to change."); } } }
private boolean isTakeOver(Configuration deploymentConfiguration) { PropertySimple takeOver = deploymentConfiguration.getSimple("takeOver"); if (takeOver == null) { return false; } Boolean value = takeOver.getBooleanValue(); return value != null && value; } }