@Override boolean isConnectorPropertyDefined() { PropertyList staticConnectors = configuration.getList(STATIC_CONNECTORS_PROPERTY); return staticConnectors != null && !staticConnectors.getList().isEmpty(); }
@Override protected void appendToStringInternals(StringBuilder str) { super.appendToStringInternals(str); str.append(", list=").append(getList()); }
public void print(PropertyList p, int depth) { out.println(indent(depth) + p.getName() + " [" + p.getList().size() + "] {"); if (p.getList().size() > 0 && p.getList().get(0) instanceof PropertyMap) { consistentMaps(p.getList()); } else { for (Property entry : p.getList()) { if (entry instanceof PropertySimple) { print((PropertySimple) entry, depth + 1); } else if (entry instanceof PropertyMap) { print((PropertyMap) entry, depth + 1); } } } out.println(indent(depth) + "}"); }
private static List<Object> getInnerList(PropertyList propertyList, PropertyDefinitionList definition, boolean strict) { List<Object> result = new ArrayList<Object>(propertyList.getList().size()); if (definition==null) { if (strict) { throw new IllegalArgumentException("No Definition exists for " + propertyList.getName()); } } PropertyDefinition memberDefinition = null; if (definition != null) { memberDefinition = definition.getMemberDefinition(); } for (Property property : propertyList.getList()) { Object target = convertProperty(property,memberDefinition, strict); result.add(target); } return result; }
private boolean hasErrors(PropertyList list) { if (list.getErrorMessage() != null) { return true; } for (Property p : list.getList()) { if (hasErrors(p)) { return true; } } return false; }
private static void traverse(PropertyDefinitionList definition, PropertyList list, List<PropertySimple> replacementCandidates) { PropertyDefinition memberDef = definition.getMemberDefinition(); List<Property> members = list.getList(); for(Property prop : members) { propertySwitch(memberDef, prop, replacementCandidates); } }
private List<String> findAssignedServerGroups() { List<String> groups = new ArrayList<String>(); Configuration config = new Configuration(); loadAssignedServerGroups(config); for (Property prop : config.getList("*1").getList()) { PropertyMap map = (PropertyMap) prop; groups.add(map.getSimpleValue("server-group", null)); } return groups; }
private List<Filter> getFilters(String type) { PropertyList filtersListProperty = configuration.getList(type); if (filtersListProperty == null) { return emptyList(); } List<Filter> filters = new ArrayList<Filter>(); for (Property property : filtersListProperty.getList()) { PropertyMap filter = (PropertyMap) property; filters.add(new Filter(filter.getSimpleValue(DriftConfigurationDefinition.PROP_PATH, "."), filter .getSimpleValue(DriftConfigurationDefinition.PROP_PATTERN, ""))); } return filters; } }
private static void validatePropertyListSize(PropertyList propertyList, PropertyDefinitionList propertyDefinitionList, List<String> errorMessages) { int listMin = propertyDefinitionList.getMin(); int listMax = propertyDefinitionList.getMax(); if (listMin == 0 && listMax == Integer.MAX_VALUE) { return; } int listSize = propertyList.getList().size(); if (listMin == 0 && listMax < Integer.MAX_VALUE && listSize > listMax) { errorMessages.add("The list property '" + propertyDefinitionList.getName() + "' should contain " + listMax + " row(s) at most"); } else if (listMin > 0 && listMax == Integer.MAX_VALUE && listSize < listMin) { errorMessages.add("The list property '" + propertyDefinitionList.getName() + "' should contain at least " + listMin + " row(s)"); } else if (listSize < listMin || listSize > listMax) { errorMessages.add("The list property '%s' should contain a minimum of " + listMin + " and a maximum of " + listMax + " row(s)"); } }
private static void applyEnvironmentVars(PropertyList environment, ProcessExecution processExecution) { if (environment != null) { Map<String, String> environmentVariables = processExecution.getEnvironmentVariables(); for (Property prop : environment.getList()) { PropertyMap var = (PropertyMap) prop; environmentVariables.put(var.getSimpleValue("name", null), var.getSimpleValue("value", null)); } processExecution.setEnvironmentVariables(environmentVariables); } }
/** * Adds a child property to the end of this list. This method also sets the * {@link Property#setParentList(PropertyList) parent list} for the child property to make persistence work. * * @param property the property to add to this list */ public void add(@NotNull Property property) { if (this.memberPropertyName == null) { this.memberPropertyName = property.getName(); } if (!property.getName().equals(this.memberPropertyName)) { throw new IllegalStateException("All properties in a PropertyList (id=[" + getId() + "], name=[" + getName() + "]) must have the same name: [" + property.getName() + "] != [" + this.memberPropertyName + "]"); } getList().add(property); property.setParentList(this); }
@Override public CreateResourceReport createResource(CreateResourceReport report) { Configuration resourceConfiguration = report.getResourceConfiguration(); PropertyList entries = resourceConfiguration.getList("entries"); if (entries != null && entries.getList().isEmpty()) { report.setErrorMessage("You need to provide at least one JNDI name"); report.setStatus(CreateResourceStatus.FAILURE); return report; } report = super.createResource(report); return report; } }
@Override public void updateResourceConfiguration(ConfigurationUpdateReport report) { Configuration resourceConfiguration = report.getConfiguration(); PropertyList entries = resourceConfiguration.getList("entries"); if (entries == null || entries.getList().isEmpty()) { report.setErrorMessage("You need to provide at least one JNDI name"); report.setStatus(ConfigurationUpdateStatus.FAILURE); return; } //defer the rest of the validation for connector and discovery group name to //the base class super.updateResourceConfiguration(report); } }
PropertySimple findOverrideForMetric(MetricTemplate def, PropertyList overrides) { for (Property p : overrides.getList()) { PropertyMap map = (PropertyMap) p; String metricName = map.getSimpleValue(METRIC_NAME_PROPERTY, null); String resourceTypeName = map.getSimpleValue(RESOURCE_TYPE_NAME_PROPERTY, null); String resourceTypePlugin = map.getSimpleValue(RESOURCE_TYPE_PLUGIN_PROPERTY, null); PropertySimple updateSchedules = map.getSimple(UPDATE_SCHEDULES_PROPERTY); if (metricName == null || resourceTypeName == null || resourceTypePlugin == null || updateSchedules == null) { continue; } if (metricName.equals(def.getMetricName()) && resourceTypeName.equals(def.getResourceTypeName()) && resourceTypePlugin.equals(def.getResourceTypePlugin())) { return updateSchedules; } } return null; } }
@Override public void updateResourceConfiguration(ConfigurationUpdateReport report) { // We need to filter the path properties that are marked with the read-only flag // This is done by setting the logical removed flag on the map to signal // the write delegate to skip the map Configuration config = report.getConfiguration(); PropertyList propertyList = config.getList("*3"); for (Property property : propertyList.getList()) { PropertyMap map = (PropertyMap) property; String ro = map.getSimpleValue("read-only", "false"); if (Boolean.parseBoolean(ro)) { map.setErrorMessage(ConfigurationWriteDelegate.LOGICAL_REMOVED); } } super.updateResourceConfiguration(report); }
public MapInListUIComponentTreeFactory(AbstractConfigurationComponent config, String listName, int listIndex) { super(config, getPropertyDefinitions(config.getConfigurationDefinition(), listName), (PropertyMap) config .getConfiguration().getList(listName).getList().get(listIndex), true, createValueExpressionFormat( config.getConfigurationExpressionString(), listName, listIndex)); this.listIndex = listIndex; }
private static void adaptPropertyList(PropertyList source, PropertyList target, PropertyDefinitionList definition, Object parent, boolean adaptReadonlyProperties) { if ((adaptReadonlyProperties || !definition.isReadOnly())) { if (target == null) { target = new PropertyList(definition.getName()); add(parent, target); } if (target.getList().isEmpty()) { PropertyDefinition memberDef = definition.getMemberDefinition(); for (Property p : source.getList()) { PropertyType type = conforms(p, memberDef); if (type != null && type != PropertyType.UNKNOWN) { Property targetMember = instantiateDefaultProperty(memberDef); target.add(targetMember); adaptProperty(p, targetMember, memberDef, target, adaptReadonlyProperties); } } } } }
private static void replace(PropertySimple prop) { ObfuscatedPropertySimple replacement = new ObfuscatedPropertySimple(prop); replacement.setParentList(prop.getParentList()); replacement.setParentMap(prop.getParentMap()); replacement.setConfiguration(prop.getConfiguration()); if (prop.getParentList() != null) { List<Property> list = prop.getParentList().getList(); int idx = list.indexOf(prop); list.remove(prop); list.add(idx, replacement); } else if (prop.getParentMap() != null) { Map<String, Property> map = prop.getParentMap().getMap(); replaceInMap(replacement, map); } else { Configuration conf = prop.getConfiguration(); replaceInMap(replacement, conf.getMap()); } }
private int addNewMap(AbstractConfigurationComponent config) { String listName = config.getListName(); PropertyDefinitionMap mapDefinition = (PropertyDefinitionMap) config.getConfigurationDefinition() .getPropertyDefinitionList(listName).getMemberDefinition(); String mapName = mapDefinition.getName(); PropertyMap newMap = new PropertyMap(mapName); for (PropertyDefinition mapMemberDefinition : mapDefinition.getOrderedPropertyDefinitions()) { PropertyDefinitionSimple simpleDefinition = (PropertyDefinitionSimple) mapMemberDefinition; newMap.put(new PropertySimple(simpleDefinition.getName(), (simpleDefinition.isRequired()) ? "" : null)); } PropertyList list = config.getConfiguration().getList(listName); list.add(newMap); return list.getList().size() - 1; }