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))); } }
private DynamicForm getServerDetails() { final DynamicForm form = new LocatableDynamicForm(extendLocatorId("serverDetails")); form.setWidth100(); form.setExtraSpace(15); form.setIsGroup(true); form.setGroupTitle(MSG.view_admin_systemSettings_serverDetails()); final StaticTextItem productName = new StaticTextItem("productname", MSG.common_title_name()); final StaticTextItem productVersion = new StaticTextItem("productversion", MSG.common_title_version()); final StaticTextItem productBuildNumber = new StaticTextItem( "productbuild", MSG.view_admin_systemSettings_serverDetails_buildNumber()); final StaticTextItem serverTimezone = new StaticTextItem("timezone", MSG.view_admin_systemSettings_serverDetails_tz()); final StaticTextItem serverTime = new StaticTextItem("localtime", MSG.view_admin_systemSettings_serverDetails_time()); final StaticTextItem serverInstallDir = new StaticTextItem("installdir", MSG.view_admin_systemSettings_serverDetails_installDir()); final StaticTextItem dbUrl = new StaticTextItem("dbUrl", MSG.view_admin_systemSettings_serverDetails_dbUrl()); final StaticTextItem dbProductName = new StaticTextItem("dbProductName", MSG.view_admin_systemSettings_serverDetails_dbName()); final StaticTextItem dbProductVersion = new StaticTextItem( "dbProductVersion", MSG.view_admin_systemSettings_serverDetails_dbVersion()); final StaticTextItem dbDriverName = new StaticTextItem( "dbDriverName", MSG.view_admin_systemSettings_serverDetails_dbDriverName()); final StaticTextItem dbDriverVersion = new StaticTextItem( "dbDriverVersion", MSG.view_admin_systemSettings_serverDetails_dbDriverVersion()); final StaticTextItem currentMeasRawTable = new StaticTextItem( "currentMeasRawTable", MSG.view_admin_systemSettings_serverDetails_currentTable()); final StaticTextItem nextMeasTableRotation = new StaticTextItem( "nextMeasTableRotation", MSG.view_admin_systemSettings_serverDetails_nextRotation()); productName.setWrapTitle(false); productVersion.setWrapTitle(false); productBuildNumber.setWrapTitle(false); serverTimezone.setWrapTitle(false); serverTime.setWrapTitle(false); serverInstallDir.setWrapTitle(false); dbUrl.setWrapTitle(false); dbProductName.setWrapTitle(false); dbProductVersion.setWrapTitle(false); dbDriverName.setWrapTitle(false); dbDriverVersion.setWrapTitle(false); currentMeasRawTable.setWrapTitle(false); nextMeasTableRotation.setWrapTitle(false); form.setItems( productName, productVersion, productBuildNumber, serverTimezone, serverTime, serverInstallDir, dbUrl, dbProductName, dbProductVersion, dbDriverName, dbDriverVersion, currentMeasRawTable, nextMeasTableRotation); GWTServiceLookup.getSystemService() .getServerDetails( new AsyncCallback<ServerDetails>() { @Override public void onSuccess(ServerDetails result) { ProductInfo productInfo = result.getProductInfo(); form.setValue(productName.getName(), productInfo.getName()); form.setValue(productVersion.getName(), productInfo.getVersion()); form.setValue(productBuildNumber.getName(), productInfo.getBuildNumber()); Map<Detail, String> details = result.getDetails(); form.setValue( serverTimezone.getName(), details.get(ServerDetails.Detail.SERVER_TIMEZONE)); form.setValue( serverTime.getName(), details.get(ServerDetails.Detail.SERVER_LOCAL_TIME)); form.setValue( serverInstallDir.getName(), details.get(ServerDetails.Detail.SERVER_INSTALL_DIR)); form.setValue( dbUrl.getName(), details.get(ServerDetails.Detail.DATABASE_CONNECTION_URL)); form.setValue( dbProductName.getName(), details.get(ServerDetails.Detail.DATABASE_PRODUCT_NAME)); form.setValue( dbProductVersion.getName(), details.get(ServerDetails.Detail.DATABASE_PRODUCT_VERSION)); form.setValue( dbDriverName.getName(), details.get(ServerDetails.Detail.DATABASE_DRIVER_NAME)); form.setValue( dbDriverVersion.getName(), details.get(ServerDetails.Detail.DATABASE_DRIVER_VERSION)); form.setValue( currentMeasRawTable.getName(), details.get(ServerDetails.Detail.CURRENT_MEASUREMENT_TABLE)); form.setValue( nextMeasTableRotation.getName(), details.get(ServerDetails.Detail.NEXT_MEASUREMENT_TABLE_ROTATION)); } @Override public void onFailure(Throwable caught) { CoreGUI.getErrorHandler() .handleError(MSG.view_admin_systemSettings_cannotLoadServerDetails(), caught); } }); return form; }
@Override protected void onDraw() { super.onDraw(); GWTServiceLookup.getSystemService() .getSystemSettings( new AsyncCallback<SystemSettings>() { @Override public void onSuccess(SystemSettings result) { canvas.addMember(getServerDetails()); Configuration config = new Configuration(); for (Map.Entry<String, String> entry : result.getSystemConfiguration().entrySet()) { String name = entry.getKey(); String value = (entry.getValue() == null) ? "" : entry.getValue(); // some of our properties are actually different values on the server than how // they are to be // visualized in the UI. // -- JAASProvider is a boolean in the UI but is "LDAP" if it was true and "JDBC" // if it was false // -- LDAPProtocol is a boolean in the UI but is "ssl" if true and "" if it was // false // -- some other numerical values need to be converted from milliseconds if (Constant.JAASProvider.equals(name)) { value = Boolean.toString(value.equals(Constant.LDAPJAASProvider)); } else if (Constant.LDAPProtocol.equals(name)) { value = Boolean.toString(value.equalsIgnoreCase("ssl")); } else if (Constant.AgentMaxQuietTimeAllowed.equals(name)) { value = convertMillisToMinutes(value); } else if (Constant.DataMaintenance.equals(name)) { value = convertMillisToHours(value); } else if (Constant.AvailabilityPurge.equals(name) || Constant.AlertPurge.equals(name) || Constant.TraitPurge.equals(name) || Constant.RtDataPurge.equals(name) || Constant.EventPurge.equals(name) || Constant.DriftFilePurge.equals(name) || Constant.BaselineFrequency.equals(name) || Constant.BaselineDataSet.equals(name)) { value = convertMillisToDays(value); } else if (Constant.EnableAgentAutoUpdate.equals(name)) { if (value.trim().length() == 0) { value = "false"; // if, for some reason, this value was empty, use false - let the // user explicitly enable it } } else if (Constant.EnableDebugMode.equals(name)) { if (value.trim().length() == 0) { value = "false"; } } else if (Constant.EnableExperimentalFeatures.equals(name)) { if (value.trim().length() == 0) { value = "false"; } } else if (Constant.DataReindex.equals(name)) { if (value.trim().length() == 0) { value = "true"; } } PropertySimple prop = new PropertySimple(name, value); config.put(prop); } // build our config definition and populate our config editor editor = new ConfigurationEditor( extendLocatorId("configEditor"), getSystemSettingsDefinition(config, result.getDriftPlugins()), config); editor.addPropertyValueChangeListener(SystemSettingsView.this); canvas.addMember(editor); ToolStrip toolStrip = new ToolStrip(); toolStrip.setWidth100(); toolStrip.setMembersMargin(5); toolStrip.setLayoutMargin(5); saveButton = new LocatableIButton(extendLocatorId("Save"), MSG.common_button_save()); saveButton.addClickHandler( new ClickHandler() { public void onClick(ClickEvent clickEvent) { save(); } }); toolStrip.addMember(saveButton); canvas.addMember(toolStrip); } @Override public void onFailure(Throwable t) { CoreGUI.getErrorHandler() .handleError(MSG.view_admin_systemSettings_cannotLoadSettings(), t); } }); }