/** * Removes the given property from this Configuration object. The named property can be a * {@link PropertySimple simple property}, a {@link PropertyList list of properties} or a * {@link PropertyMap map of properties}. * * <p>Note that this only removes direct children of this Configuration. You cannot remove a property from within a * child list or map via this method.</p> * * @param name the name of the property to be removed from this configuration * * @return the named property or <code>null</code> if there was no direct child with the given name */ public Property remove(String name) { return getMap().remove(name); }
/** * Same as {@link #get(String)} except that it returns the object as a {@link PropertyList}. * * @param name the name of the list property to be retrieved * * @return the list property with the given name, or <code>null</code> if there was no list property with the given * name * * @throws ClassCastException if there was a property in this Configuration with the given name, but it was not of * type {@link PropertyList} */ @Override public PropertyList getList(String name) { return (PropertyList) getMap().get(name); }
/** * Same as {@link #get(String)} except that it returns the object as a {@link PropertySimple}. * * @param name the name of the simple property to be retrieved * * @return the simple property with the given name, or <code>null</code> if there was no simple property with the * given name * * @throws ClassCastException if there was a property in this Configuration with the given name, but it was not of * type {@link PropertySimple} */ @Override public PropertySimple getSimple(String name) { return (PropertySimple) getMap().get(name); }
/** * Same as {@link #get(String)} except that it returns the object as a {@link PropertyMap}. * * @param name the name of the map property to be retrieved * * @return the map property with the given name, or <code>null</code> if there was no map property with the given * name * * @throws ClassCastException if there was a property in this Configuration with the given name, but it was not of * type {@link PropertyMap} */ @Override public PropertyMap getMap(String name) { return (PropertyMap) getMap().get(name); }
/** * Returns the names of all properties that are <i>direct</i> children of this Configuration object. * * @return child property names */ @NotNull public Collection<String> getNames() { return getMap().keySet(); }
/** * Retrieves the given property from this Configuration object. The named property can be a * {@link PropertySimple simple property}, a {@link PropertyList list of properties} or a * {@link PropertyMap map of properties}. * * <p>Note that this only gets direct children of this Configuration. You cannot get a property from within a child * list or map via this method.</p> * * @param name the name of the property to be retrieved from this configuration * * @return the named property or <code>null</code> if there was no direct child with the given name */ @Override public Property get(String name) { return getMap().get(name); }
public String getSimpleValue(String name, @Nullable String defaultValue) { PropertySimple property = (PropertySimple) getMap().get(name); return ((property != null) && (property.getStringValue() != null)) ? property.getStringValue() : defaultValue; }
public void calculateGroupConfiguration() { this.groupConfiguration.getMap().clear(); if (this.members.isEmpty()) return; Map<String, PropertyDefinition> childPropertyDefinitions = this.configurationDefinition .getPropertyDefinitions(); List<AbstractPropertyMap> sourceParentPropertyMaps = new ArrayList<AbstractPropertyMap>(); for (ConfigurationSetMember member : this.members) sourceParentPropertyMaps.add(member.getConfiguration()); for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values()) calculateGroupProperty(childPropertyDefinition, sourceParentPropertyMaps, this.groupConfiguration); }
@Override boolean isConnectorPropertyDefined() { PropertyMap connector = configuration.getMap(CONNECTOR_PROPERTY); if (connector != null) { return isNotBlank(connector.getSimpleValue("name:0", EMPTY_STRING)); } return false; }
@Nullable private String getListMemberMapKey(PropertyDefinitionList propDefList) { Configuration pluginConfig = this.resourceContext.getPluginConfiguration(); PropertyMap mapKeyNames = pluginConfig.getMap("listMemberMapKeyNames"); if (mapKeyNames == null) { return null; } String listName = propDefList.getName(); return mapKeyNames.getSimpleValue(listName, null); }
/** * Adds the given property to this Configuration object. The property can be a * {@link PropertySimple simple property}, a {@link PropertyList list of properties} or a * {@link PropertyMap map of properties}. * * @param value the new property */ @Override public void put(Property value) { Map<String, Property> map = getMap(); if (value.getName()!=null) { map.put(value.getName().intern(),value); } else { map.put(value.getName(), value); } value.setConfiguration(this); }
public static void obfuscatePasswords(ConfigurationDefinition definition, Configuration config) { if (config == null || config.getMap().isEmpty()) { return; } if (definition == null || definition.getPropertyDefinitions().isEmpty()) { return; } List<PropertySimple> replacementCandidates = new ArrayList<PropertySimple>(); for(PropertyDefinition def : definition.getPropertyDefinitions().values()) { Property prop = config.get(def.getName()); propertySwitch(def, prop, replacementCandidates); } for(PropertySimple prop : replacementCandidates) { replace(prop); } }
public BaseDirectory getBasedir() { PropertyMap map = configuration.getMap(DriftConfigurationDefinition.PROP_BASEDIR); if (map == null) { return null; } String valueContext = map.getSimpleValue(DriftConfigurationDefinition.PROP_BASEDIR_VALUECONTEXT, null); String valueName = map.getSimpleValue(DriftConfigurationDefinition.PROP_BASEDIR_VALUENAME, null); BaseDirValueContext valueContextEnum; if (valueContext == null) { throw new NullPointerException("valueContext is null"); } else { try { valueContextEnum = BaseDirValueContext.valueOf(valueContext); } catch (Exception e) { throw new IllegalArgumentException("Invalid valueContext: " + valueContext); } } if (valueName == null) { throw new NullPointerException("valueName is null"); } return new BaseDirectory(valueContextEnum, valueName); }
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public Configuration getPluginConfiguration(int resourceId) { // Ensure that we return a non-proxied Configuration object that can survive after the // Hibernate session goes away. Query query = entityManager.createNamedQuery(Configuration.QUERY_GET_PLUGIN_CONFIG_BY_RESOURCE_ID); query.setParameter("resourceId", resourceId); Configuration pluginConfiguration = (Configuration) query.getSingleResult(); // Mask the configuration before returning it. Resource resource = resourceManager.getResourceById(subjectManager.getOverlord(), resourceId); ConfigurationDefinition pluginConfigurationDefinition = getPluginConfigurationDefinitionForResourceType( subjectManager.getOverlord(), resource.getResourceType().getId()); // We do not want the masked configurations persisted, so detach all entities before masking the configurations. pluginConfiguration.getMap().size(); entityManager.clear(); ConfigurationMaskingUtility.maskConfiguration(pluginConfiguration, pluginConfigurationDefinition); return pluginConfiguration; }
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public Configuration getResourceConfiguration(int resourceId) { // Ensure that we return a non-proxied Configuration object that can survive after the // Hibernate session goes away. Query query = entityManager.createNamedQuery(Configuration.QUERY_GET_RESOURCE_CONFIG_BY_RESOURCE_ID); query.setParameter("resourceId", resourceId); Configuration resourceConfiguration = (Configuration) query.getSingleResult(); // Mask the configuration before returning it. Resource resource = resourceManager.getResourceById(subjectManager.getOverlord(), resourceId); ConfigurationDefinition resourceConfigurationDefinition = getResourceConfigurationDefinitionForResourceType( subjectManager.getOverlord(), resource.getResourceType().getId()); // We do not want the masked configurations persisted, so detach all entities before masking the configurations. resourceConfiguration.getMap().size(); entityManager.clear(); ConfigurationMaskingUtility.maskConfiguration(resourceConfiguration, resourceConfigurationDefinition); return resourceConfiguration; }
@Override public Map<Integer, Configuration> getPluginConfigurationsForCompatibleGroup(Subject subject, int groupId) throws ConfigurationUpdateStillInProgressException, Exception { // The below call will also handle the check to see if the subject has perms to view the group. ResourceGroup group = this.resourceGroupManager .getResourceGroupById(subject, groupId, GroupCategory.COMPATIBLE); // Check to make sure no config updates, group-level or resource-level, are in progress. ensureNoPluginConfigurationUpdatesInProgress(group); // If we got this far, no updates are in progress, so go ahead and load the plugin configs from the DB. Map<Integer, Configuration> currentPersistedConfigs = getPersistedPluginConfigurationsForCompatibleGroup(group); // Mask the configurations before returning them. for (Configuration pluginConfiguration : currentPersistedConfigs.values()) { pluginConfiguration.getMap().size(); } ConfigurationDefinition pluginConfigurationDefinition = getPluginConfigurationDefinitionForResourceType( subjectManager.getOverlord(), group.getResourceType().getId()); // We do not want the masked configurations persisted, so detach all entities before masking the configurations. entityManager.clear(); for (Configuration pluginConfiguration : currentPersistedConfigs.values()) { ConfigurationMaskingUtility.maskConfiguration(pluginConfiguration, pluginConfigurationDefinition); } return currentPersistedConfigs; }
public MapInConfigurationUIComponentTreeFactory(AbstractConfigurationComponent configurationComponent, String mapName) { super(configurationComponent, getPropertyDefinitions(configurationComponent.getConfigurationDefinition(), mapName), configurationComponent.getConfiguration().getMap(mapName), false, createValueExpressionFormat( configurationComponent.getConfigurationExpressionString(), mapName)); }
@Override @SuppressWarnings("unchecked") public Map<Integer, Configuration> getResourceConfigurationMapForGroupUpdate(Subject subject, Integer groupResourceConfigurationUpdateId) { // this method will perform the CONFIGURE_READ security check for us, no need to keep reference to result GroupResourceConfigurationUpdate groupResourceConfigurationUpdate = getGroupResourceConfigurationUpdate( subject, groupResourceConfigurationUpdateId); Tuple<String, Object> groupIdParameter = new Tuple<String, Object>("groupConfigurationUpdateId", groupResourceConfigurationUpdateId); Map<Integer, Configuration> results = executeGetConfigurationMapQuery( Configuration.QUERY_GET_RESOURCE_CONFIG_MAP_BY_GROUP_UPDATE_ID, 100, groupIdParameter); // Mask the configurations before returning them. for (Configuration configuration : results.values()) { configuration.getMap().size(); } ConfigurationDefinition configurationDefinition = getResourceConfigurationDefinitionForResourceType( subjectManager.getOverlord(), groupResourceConfigurationUpdate.getGroup().getResourceType().getId()); // We do not want the masked configurations persisted, so detach all entities before masking the configurations. entityManager.clear(); for (Configuration configuration : results.values()) { ConfigurationMaskingUtility.maskConfiguration(configuration, configurationDefinition); } return results; }
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()); } }
@Override public Operation getBatchOperation() { CompositeOperation compositeOperation = new CompositeOperation(); if (hasDiscoveryGroupName()) { compositeOperation.addStep(new UndefineAttribute(address, CONNECTOR_ATTRIBUTE)); compositeOperation.addStep(new WriteAttribute(address, DISCOVERY_GROUP_NAME, configuration .getSimpleValue(DISCOVERY_GROUP_NAME))); } else { compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME)); compositeOperation.addStep(new WriteAttribute(address, CONNECTOR_ATTRIBUTE, Collections.singletonMap( configuration.getMap(CONNECTOR_PROPERTY).getSimpleValue("name:0", EMPTY_STRING), null))); } return compositeOperation; } }