private void unannounceStorageNode(Subject subject, StorageNode clusterNode, PropertyList addresses) { Configuration parameters = new Configuration(); parameters.put(addresses); scheduleOperation(subject, clusterNode, parameters, "unannounce"); }
private void addScriptsEnvironment(Configuration operationParameters) { Configuration pluginConfiguration = resourceContext.getPluginConfiguration(); PropertyList startScriptEnv = pluginConfiguration .getList(TomcatServerOperationsDelegate.START_SCRIPT_ENVIRONMENT_PROPERTY); PropertyList shutdownScriptEnv = pluginConfiguration .getList(TomcatServerOperationsDelegate.SHUTDOWN_SCRIPT_ENVIRONMENT_PROPERTY); if (startScriptEnv != null) { operationParameters.put(startScriptEnv); } if (shutdownScriptEnv != null) { operationParameters.put(shutdownScriptEnv); } } }
private Configuration getNewOrCleansed(Configuration config) { if (config == null) { return new Configuration(); } else { return config.deepCopy(); } }
private void prepareConfigForMergeIntoStructured(Configuration config, Configuration latestStructured) { config.getAllProperties().clear(); for (Property property : latestStructured.getProperties()) { config.put(property); } }
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(); }
Property templateProperty = templateConfiguration.get(propertyDef.getName()); if (templateProperty == null) { throw new IllegalArgumentException("The property [" + propertyDef.getName() int numberOfProperties = pluginConfiguration.getProperties().size(); pluginConfiguration.put(templateProperty.deepCopy(false)); modified = true; int numberOfProperties = pluginConfiguration.getProperties().size(); String propertyValue = pluginConfiguration.getSimpleValue(propertyDef.getName(), null); if (propertyValue == null) { Property templateProperty = templateConfiguration.get(propertyDef.getName()); pluginConfiguration.put(templateProperty.deepCopy(false)); modified = true;
/** * Gets the value of the simple property with the specified name. If the property is not defined, null will be * returned. * * @param name the name of the simple property * @return the value of the simple property with the specified name, or null if the property is not defined * * @since 4.4 */ public String getSimpleValue(String name) { return getSimpleValue(name, null); }
String protocol = report.getConfiguration().getSimpleValue(CONFIG_PROTOCOL, null); if ((null == protocol) || protocol.toUpperCase().contains("HTTP")) { report.getConfiguration().remove(propDef.getName()); report.getConfiguration().remove(propDef.getName()); report.getConfiguration().remove(propDef.getName()); report.getConfiguration().remove(CONFIG_V5_KEEP_ALIVE_TIMEOUT); for (String key : report.getConfiguration().getSimpleProperties().keySet()) { EmsAttribute attribute = bean.getAttribute(key); if (attribute == null) { log.debug("Removing " + key + " does correspond to an attribut"); report.getConfiguration().remove(key); continue; // skip unsupported attributes PropertySimple prop = report.getConfiguration().getSimple(key); 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()) {
private Configuration mergeExistingResourcePluginConfiguration(Resource resource, Configuration pluginConfig) { // If there is no update necessary just return the current plugin config of the existing resource Configuration result = resource.getPluginConfiguration(); ConfigurationDefinition configDef = resource.getResourceType().getPluginConfigurationDefinition(); if (null == configDef) { return result; } Configuration existingPluginConfig = resource.getPluginConfiguration().deepCopy(false); Configuration defaultPluginConfig = ConfigurationUtility.createDefaultConfiguration(configDef); boolean configChanged = false; // for each property, update the existing plugin config if discovery has set a non-default value for (String propertyName : pluginConfig.getAllProperties().keySet()) { Property discoveredProp = pluginConfig.get(propertyName); Property defaultProp = defaultPluginConfig.get(propertyName); if (!discoveredProp.equals(defaultProp)) { if (log.isDebugEnabled()) { log.debug("Discovery reported a new version of " + resource + ". Updating value of config property" + " from [" + existingPluginConfig.get(propertyName) + "] to [" + discoveredProp + "]."); } existingPluginConfig.put(discoveredProp); configChanged = true; } } if (configChanged) { result = mergeExistingResourcePluginConfigurationOnServer(resource, existingPluginConfig); } return result; }
protected List<String> determineGlobs(Configuration configuration, String name) { PropertySimple includeGlobsProp = configuration.getSimple(name); if (includeGlobsProp == null) return null; List<String> ret = new ArrayList<String>(); ret.addAll(getGlobList(includeGlobsProp)); return ret; }
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; }
@Override boolean isConnectorPropertyDefined() { PropertyList staticConnectors = configuration.getList(STATIC_CONNECTORS_PROPERTY); return staticConnectors != null && !staticConnectors.getList().isEmpty(); }
if (merge) { for (Property p : config.getProperties()) { if (newConfig.get(p.getName()) == null) newConfig.put(p); if (merge) { for (Property p : config.getProperties()) { if (newConfig.get(p.getName()) == null) newConfig.put(p);
@Override public CreateResourceReport createResource(CreateResourceReport report) { if (report.getResourceConfiguration().get(TYPE_CONFIGURATION) != null) { PropertySimple typeProperty = (PropertySimple) configuration.get(TYPE_CONFIGURATION); configuration.remove(TYPE_CONFIGURATION); report.getPluginConfiguration().put(new PropertySimple("path", typeProperty.getStringValue())); } else if (report.getResourceConfiguration().get(NAME_CONFIGURATION) != null) { PropertySimple nameProperty = (PropertySimple) configuration.get(NAME_CONFIGURATION); configuration.remove(NAME_CONFIGURATION); report.setUserSpecifiedResourceName(nameProperty.getStringValue());
/** * 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); }
public void print(Configuration config) { out.println("Configuration [" + config.getId() + "] - " + config.getNotes()); for (PropertySimple p : config.getSimpleProperties().values()) { print(p, 1); } for (PropertyList p : config.getListProperties().values()) { print(p, 1); } for (PropertyMap p : config.getMapProperties().values()) { print(p, 1); } }
/** * Use this method if an operation returned a simple string result. This is a convenience method that places the * given result string in the {@link #getComplexResults()} object under the name * {@link #SIMPLE_OPERATION_RESULT_NAME}. * * @param simpleResult a simple string result */ public void setSimpleResult(String simpleResult) { complexResults.put(new PropertySimple(SIMPLE_OPERATION_RESULT_NAME, simpleResult)); }
@Override public Configuration loadResourceConfiguration() throws Exception { ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition(); if (configDef.getDefaultTemplate().getConfiguration().get(TYPE_CONFIGURATION) != null) { //__type is a fake property, do not attempt to load it from the managed server configDef.getPropertyDefinitions().remove(TYPE_CONFIGURATION); ConfigurationLoadDelegate delegate = new ConfigurationLoadDelegate(configDef, getASConnection(), address); Configuration configuration = delegate.loadResourceConfiguration(); //manually load type based on the resource path PropertySimple pathProperty = (PropertySimple) context.getPluginConfiguration().get("path"); String type = pathProperty.getStringValue(); type = type.substring(type.lastIndexOf(',') + 1, type.lastIndexOf('=')); configuration.put(new PropertySimple(TYPE_CONFIGURATION, type)); return configuration; } else if (configDef.getDefaultTemplate().getConfiguration().get(NAME_CONFIGURATION) != null) { //__name is a fake property, do not attempt to load it from the managed server configDef.getPropertyDefinitions().remove(NAME_CONFIGURATION); ConfigurationLoadDelegate delegate = new ConfigurationLoadDelegate(configDef, getASConnection(), address); Configuration configuration = delegate.loadResourceConfiguration(); //manually load name based on the resource path PropertySimple pathProperty = (PropertySimple) context.getPluginConfiguration().get("path"); String name = pathProperty.getStringValue(); name = name.substring(name.lastIndexOf('=') + 1); configuration.put(new PropertySimple(NAME_CONFIGURATION, name)); return configuration; } return super.loadResourceConfiguration(); }
/** * Returns the resource's plugin configuration. This is used to configure the subsystem that is used to actually * talk to the managed resource. Do not confuse this with the <i>resource configuration</i>, which is the actual * configuration settings for the managed resource itself. * * @return plugin configuration */ public Configuration getPluginConfiguration() { return this.pluginConfiguration.deepCopy(); }