private void prepareConfigForMergeIntoRaws(Configuration config, Set<RawConfiguration> latestRaws) { config.getRawConfigurations().clear(); for (RawConfiguration raw : latestRaws) { config.addRawConfiguration(raw); } }
/** * Closes the definition of the current raw configuration and returns to the parent context. * @return the parent context */ public Builder closeRawConfiguration() { getMap().getRawConfigurations().add(rawConfig); return Builder.this; } }
rcEquals = this.getRawConfigurations().equals(that.getRawConfigurations());
public void executeUpdate(int resourceId, Configuration configuration) throws PluginContainerException { ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId); StringBuilder errors = new StringBuilder(); for (RawConfiguration rawConfig : configuration.getRawConfigurations()) { try { facet.validateRawConfiguration(rawConfig); facet.persistRawConfiguration(rawConfig); } catch (Throwable t) { // TODO Might want to specify in the error detail whether the validate or update call failed errors.append(t.getMessage()).append("\n\n"); } } if (errors.length() > 0) { throw new ConfigurationUpdateException(errors.toString()); } } }
public void executeUpdate(int resourceId, Configuration configuration) throws PluginContainerException { ResourceConfigurationFacet facet = loadResourceConfigFacetWithWriteLock(resourceId); StringBuilder errors = new StringBuilder(); try { facet.validateStructuredConfiguration(configuration); facet.persistStructuredConfiguration(configuration); } catch (Throwable t) { errors.append(t.getMessage()); } for (RawConfiguration rawConfig : configuration.getRawConfigurations()) { try { facet.validateRawConfiguration(rawConfig); facet.persistRawConfiguration(rawConfig); } catch (Throwable t) { errors.append(t.getMessage()).append("\n\n"); } } if (errors.length() > 0) { throw new ConfigurationUpdateException(errors.toString()); } } }
for (RawConfiguration rawConfiguration : configuration.getRawConfigurations()) { try { facet.validateRawConfiguration(rawConfiguration);
/** * Will return the persisted Resource Configuration update, or null if the specified Configuration * is identical to the currently persisted Configuration. */ private ResourceConfigurationUpdate persistNewAgentReportedResourceConfiguration(Resource resource, Configuration liveConfig) throws ConfigurationUpdateStillInProgressException { if (liveConfig.getRawConfigurations() != null) { for (RawConfiguration raw : liveConfig.getRawConfigurations()) { MessageDigestGenerator sha256Generator = new MessageDigestGenerator(MessageDigestGenerator.SHA_256); sha256Generator.add(raw.getContents().getBytes()); raw.setSha256(sha256Generator.getDigestString()); } } /* * NOTE: We pass the overlord, since this is a system side-effect. here, the system * and *not* the user, is choosing to persist the most recent configuration because it was different * from the last known value. again, the user isn't attempting to change the value; instead, *JON* * is triggering save based on the semantics that we want to provide for configuration updates. * For the same reason, we pass null as the subject. */ ResourceConfigurationUpdate update = this.configurationManager .persistResourceConfigurationUpdateInNewTransaction(this.subjectManager.getOverlord(), resource.getId(), liveConfig, ConfigurationUpdateStatus.SUCCESS, null, false); // resource.setResourceConfiguration(liveConfig.deepCopy(false)); resource.setResourceConfiguration(liveConfig.deepCopyWithoutProxies()); return update; }
private void mergeRawsIntoStructured(Configuration configuration, ResourceConfigurationFacet facet) { Configuration structuredConfig = facet.loadStructuredConfiguration(); if (structuredConfig != null) { prepareConfigForMergeIntoStructured(configuration, structuredConfig); for (RawConfiguration rawConfig : configuration.getRawConfigurations()) { String contents = rawConfig.getContents(); String sha256 = new MessageDigestGenerator(MessageDigestGenerator.SHA_256).calcDigestString(contents); rawConfig.setContents(contents, sha256); structuredConfig.addRawConfiguration(rawConfig); facet.mergeStructuredConfiguration(rawConfig, configuration); } } }