/** * 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(); }
public AlertNotification(AlertNotification source) { this.configuration = source.configuration.deepCopy(false); if (source.extraConfiguration != null) { this.extraConfiguration = source.extraConfiguration.deepCopy(false); } else { this.extraConfiguration = null; } this.senderName = source.senderName; }
/** * Clones this object in the same manner as {@link #deepCopy()}. * * @return a clone of this configuration * * @see #deepCopy() */ @SuppressWarnings("override") //@Override //GWT trips over this, WTH! public Configuration clone() { return deepCopy(); }
/** * Makes a fully independent copy of this object and returns it. This means all children N-levels deep in the * hierarchy of this Configuration object are copied. * * <p>This is the underlying implementation for the {@link #clone()} method.</p> * * @return a clone of this configuration */ public Configuration deepCopy() { return deepCopy(true); }
public DashboardPortlet deepCopy(boolean keepIds) { DashboardPortlet newPortlet = new DashboardPortlet(); if (keepIds) { newPortlet.id = this.id; } newPortlet.name = this.name; newPortlet.portletKey = this.portletKey; newPortlet.column = this.column; newPortlet.index = this.index; newPortlet.height = this.height; newPortlet.configuration = this.configuration != null ? this.configuration.deepCopy(keepIds) : null; return newPortlet; }
private Configuration getMergedConfiguration(Configuration base, Configuration changes) { Configuration results = base.deepCopy(false); merge(results, changes); return results; }
private Configuration getNewOrCleansed(Configuration config) { if (config == null) { return new Configuration(); } else { return config.deepCopy(); } }
public Configuration createConfiguration() { // Create a clone of this template's Configuration with all id's zeroed out. return getConfiguration().deepCopy(false); }
public ServerPlugin getServerPluginRelationships(ServerPlugin plugin) { Query query = entityManager.createNamedQuery(ServerPlugin.QUERY_FIND_BY_NAME); query.setParameter("name", plugin.getName()); plugin = (ServerPlugin) query.getSingleResult(); Configuration config = plugin.getPluginConfiguration(); if (config != null) { config = entityManager.find(Configuration.class, config.getId()); plugin.setPluginConfiguration(config.deepCopy()); } config = plugin.getScheduledJobsConfiguration(); if (config != null) { config = entityManager.find(Configuration.class, config.getId()); plugin.setScheduledJobsConfiguration(config.deepCopy()); } return plugin; }
/** * @param subjectId the subject to get preferences of * @return the <b>COPY</b> of the configuration object - changes done to that instance will not be reflected in the persisted * preferences */ @Override @Lock(LockType.READ) public Configuration getPreferences(int subjectId) { load(subjectId); Configuration config = subjectPreferences.get(subjectId); if (config == null) { return new Configuration(); } else { return config.deepCopy(); } }
/** * Returns a copy of the {@link #getResourceType() resource type}'s default plugin configuration. * * @return copy of the resource's default plugin configuration */ private Configuration createDefaultPluginConfiguration() { ConfigurationDefinition definition = resourceType.getPluginConfigurationDefinition(); if (definition != null) { ConfigurationTemplate template = definition.getDefaultTemplate(); if (template != null) { return template.getConfiguration().deepCopy(); } } // There is no default plugin config template defined - return an empty one. return new Configuration(); } }
@Override public void persistUpdatedResourceConfiguration(int resourceId, Configuration resourceConfiguration) { ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager(); SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager(); Subject overlord = subjectManager.getOverlord(); ResourceConfigurationUpdate update = configurationManager.persistResourceConfigurationUpdateInNewTransaction( overlord, resourceId, resourceConfiguration, ConfigurationUpdateStatus.SUCCESS, null, false); if (update == null) { LOG.debug("Not persisting Configuration " + resourceConfiguration + ", since it is identical to the current revision."); return; } Configuration configuration = update.getConfiguration().deepCopy(false); // clone the config, zeroing out ids configurationManager.setResourceConfiguration(resourceId, configuration); // now set it as the current config on the Resource }
@Override public void executeResourceConfigurationUpdate(int updateId) { ResourceConfigurationUpdate update = getResourceConfigurationUpdate(subjectManager.getOverlord(), updateId); Configuration originalConfig = update.getConfiguration(); update.setConfiguration(originalConfig.deepCopy(false)); executeResourceConfigurationUpdate(update); }
/** * Returns the default plugin configuration as defined in the {@link #getResourceType() resource type}'s default * template. This returns a new copy of the default configuration; it will not return the same configuration * instance to any future call to this method. * * @return a new copy of the default plugin configuration */ public Configuration getDefaultPluginConfiguration() { ConfigurationDefinition definition = resourceType.getPluginConfigurationDefinition(); if (definition != null) { ConfigurationTemplate template = definition.getDefaultTemplate(); if (template != null) { return template.getConfiguration().deepCopy(); } } return new Configuration(); // there is no default plugin config available, return an empty one }
public Dashboard deepCopy(boolean keepIds) { Dashboard newDashboard = new Dashboard(); if (keepIds) { newDashboard.id = this.id; } newDashboard.name = this.name; newDashboard.owner = this.owner; newDashboard.shared = this.shared; newDashboard.configuration = this.configuration.deepCopy(keepIds); for (DashboardPortlet portlet : portlets) { DashboardPortlet newPortlet = portlet.deepCopy(keepIds); newPortlet.setDashboard(this); newDashboard.addPortlet(newPortlet, newPortlet.getColumn(), newPortlet.getIndex()); } return newDashboard; }
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; }
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public CreateResourceHistory persistCreateHistory(Subject user, int parentResourceId, int resourceTypeId, String createResourceName, Configuration configuration) { // Load relationships Resource parentResource = entityManager.getReference(Resource.class, parentResourceId); ResourceType resourceType = entityManager.getReference(ResourceType.class, resourceTypeId); // CreateResourceHistory.configuration is one-to-one, so make sure to clone the config, zeroing out all id's. Configuration configurationClone = (configuration != null) ? configuration.deepCopy(false) : null; // Persist and establish relationships CreateResourceHistory history = new CreateResourceHistory(parentResource, resourceType, user.getName(), configurationClone); history.setCreatedResourceName(createResourceName); history.setStatus(CreateResourceStatus.IN_PROGRESS); entityManager.persist(history); parentResource.addCreateChildResourceHistory(history); // Caller will need this parentResource.getAgent(); return history; }
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public ConfigurationUpdateResponse executePluginConfigurationUpdate(PluginConfigurationUpdate update) { Resource resource = update.getResource(); Configuration configuration = update.getConfiguration(); configuration = configuration.deepCopy(false); ConfigurationUpdateResponse response = null; try { // now let's tell the agent to actually update the resource component's plugin configuration AgentClient agentClient = this.agentManager.getAgentClient(resource.getAgent()); agentClient.getDiscoveryAgentService().updatePluginConfiguration(resource.getId(), configuration); try { agentClient.getDiscoveryAgentService().executeServiceScanDeferred(resource.getId()); } catch (Exception e) { LOG.warn("Failed to execute service scan - cannot detect children of the newly connected resource [" + resource + "]", e); } response = new ConfigurationUpdateResponse(update.getId(), null, ConfigurationUpdateStatus.SUCCESS, null); } catch (Exception e) { response = new ConfigurationUpdateResponse(update.getId(), null, e); } return response; }
protected ResourceOperationHistory createOperationHistory(String jobName, String jobGroup, ResourceOperationSchedule schedule, GroupOperationHistory groupHistory, OperationManagerLocal operationManager) { // we need the operation definition to fill in the history item OperationDefinition op; op = operationManager.getSupportedResourceOperation(schedule.getSubject(), schedule.getResource().getId(), schedule.getOperationName(), false); // first we need to create an INPROGRESS history item Configuration parameters = schedule.getParameters(); if (parameters != null) { parameters = parameters.deepCopy(false); // we need a copy to avoid constraint violations upon delete } ResourceOperationHistory history; history = new ResourceOperationHistory(jobName, jobGroup, schedule.getSubject().getName(), op, parameters, schedule.getResource(), groupHistory); // persist the results of the initial create ResourceOperationHistory persisted; persisted = (ResourceOperationHistory) operationManager.updateOperationHistory(schedule.getSubject(), history); history.setId(persisted.getId()); // we need this - this enables the server to successfully update the group history later return persisted; }