public void print(PropertySimple p, int depth) { out.println(indent(depth) + p.getName() + " = " + p.getStringValue()); }
@Override public CreateResourceReport createResource(CreateResourceReport report) { report.setStatus(CreateResourceStatus.INVALID_CONFIGURATION); Address createAddress = new Address(this.address); String path = report.getPluginConfiguration().getSimpleValue("path", ""); String resourceName; if (!path.contains("=")) { // this is not a singleton subsystem // resources like example=test1 and example=test2 can be created resourceName = report.getUserSpecifiedResourceName(); } else { // this is a request to create a true singleton subsystem // both the path and the name are set at resource level configuration resourceName = path.substring(path.indexOf('=') + 1); path = path.substring(0, path.indexOf('=')); } createAddress.add(path, resourceName); Operation op = new Operation("add", createAddress); for (Property prop : report.getResourceConfiguration().getProperties()) { SimpleEntry<String, ?> entry = null; boolean isEntryEligible = true; if (prop instanceof PropertySimple) { PropertySimple propertySimple = (PropertySimple) prop; PropertyDefinitionSimple propertyDefinition = this.configurationDefinition.getPropertyDefinitionSimple(propertySimple.getName()); if (propertyDefinition == null || (!propertyDefinition.isRequired() && propertySimple.getStringValue() == null)) { isEntryEligible = false; } else { entry = preparePropertySimple(propertySimple, propertyDefinition); } } else if (prop instanceof PropertyList) { PropertyList propertyList = (PropertyList) prop; PropertyDefinitionList propertyDefinition = this.configurationDefinition.getPropertyDefinitionList(propertyList.getName()); if (!propertyDefinition.isRequired() && propertyList.getList().size() == 0) { isEntryEligible = false; } else { entry = preparePropertyList(propertyList, propertyDefinition); } } else if (prop instanceof PropertyMap) { PropertyMap propertyMap = (PropertyMap) prop; PropertyDefinitionMap propertyDefinition = this.configurationDefinition.getPropertyDefinitionMap(propertyMap.getName()); if (!propertyDefinition.isRequired() && propertyMap.getMap().size() == 0) { isEntryEligible = false; } else { entry = preparePropertyMap(propertyMap, propertyDefinition); } } if (isEntryEligible) { op.addAdditionalProperty(entry.getKey(), entry.getValue()); } } Result result = this.connection.execute(op); if (result.isSuccess()) { report.setStatus(CreateResourceStatus.SUCCESS); report.setResourceKey(createAddress.getPath()); report.setResourceName(report.getUserSpecifiedResourceName()); } else { report.setStatus(CreateResourceStatus.FAILURE); report.setErrorMessage(result.getFailureDescription()); } return report; }
private void save() { if (editor.validate()) { Map<String, PropertySimple> simpleProperties = editor.getConfiguration().getSimpleProperties(); HashMap<String, String> props = new HashMap<String, String>(); for (PropertySimple simple : simpleProperties.values()) { String value = (simple.getStringValue() != null) ? simple.getStringValue() : ""; // some of our properties actually need different values on the server than how they were // visualized in the UI. // -- JAASProvider is a boolean in the UI but must be "LDAP" if it was true and "JDBC" if it // was false // -- LDAPProtocol is a boolean in the UI but must be "ssl" if true and "" if it was false // -- some other numerical values need to be converted to milliseconds if (Constant.JAASProvider.equals(simple.getName())) { if (Boolean.parseBoolean(value)) { value = Constant.LDAPJAASProvider; } else { value = Constant.JDBCJAASProvider; } } else if (Constant.LDAPProtocol.equals(simple.getName())) { if (Boolean.parseBoolean(value)) { value = "ssl"; } else { value = ""; } } else if (Constant.AgentMaxQuietTimeAllowed.equals(simple.getName())) { value = convertMinutesToMillis(value); } else if (Constant.DataMaintenance.equals(simple.getName())) { value = convertHoursToMillis(value); } else if (Constant.AvailabilityPurge.equals(simple.getName()) || Constant.AlertPurge.equals(simple.getName()) || Constant.TraitPurge.equals(simple.getName()) || Constant.RtDataPurge.equals(simple.getName()) || Constant.EventPurge.equals(simple.getName()) || Constant.DriftFilePurge.equals(simple.getName()) || Constant.BaselineFrequency.equals(simple.getName()) || Constant.BaselineDataSet.equals(simple.getName())) { value = convertDaysToMillis(value); } props.put(simple.getName(), value); } GWTServiceLookup.getSystemService() .setSystemConfiguration( props, false, new AsyncCallback<Void>() { @Override public void onSuccess(Void result) { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_admin_systemSettings_savedSettings(), Message.Severity.Info)); } @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_admin_systemSettings_saveFailure(), caught); } }); } else { CoreGUI.getMessageCenter() .notify( new Message( MSG.view_admin_systemSettings_fixBeforeSaving(), Severity.Warning, EnumSet.of(Message.Option.Transient))); } }