public JSONObject buildJsonRequest(ValuesManager form) { JSONObject entry = new JSONObject(); addToJsonObject(entry, FIRST_NAME, form.getValueAsString(FIRST_NAME)); addToJsonObject(entry, LAST_NAME, form.getValueAsString(LAST_NAME)); addToJsonObject(entry, NUMBER, form.getValueAsString(NUMBER)); JSONObject contactInfo = new JSONObject(); addToJsonObject(contactInfo, JOB_TITLE, form.getValueAsString(JOB_TITLE)); addToJsonObject(contactInfo, JOB_DEPT, form.getValueAsString(JOB_DEPT)); addToJsonObject(contactInfo, COMPANY_NAME, form.getValueAsString(COMPANY_NAME)); addToJsonObject(contactInfo, ASSISTANT_NAME, form.getValueAsString(ASSISTANT_NAME)); addToJsonObject(contactInfo, CELL_PHONE_NUMBER, form.getValueAsString(CELL_PHONE_NUMBER)); addToJsonObject(contactInfo, HOME_PHONE_NUMBER, form.getValueAsString(HOME_PHONE_NUMBER)); addToJsonObject( contactInfo, ASSISTANT_PHONE_NUMBER, form.getValueAsString(ASSISTANT_PHONE_NUMBER)); addToJsonObject(contactInfo, FAX_NUMBER, form.getValueAsString(FAX_NUMBER)); addToJsonObject(contactInfo, IM_ID, form.getValueAsString(IM_ID)); addToJsonObject(contactInfo, IM_DISPLAY_ID, form.getValueAsString(IM_DISPLAY_ID)); addToJsonObject(contactInfo, ALTERNATE_IM_ID, form.getValueAsString(ALTERNATE_IM_ID)); addToJsonObject(contactInfo, LOCATION, form.getValueAsString(LOCATION)); addToJsonObject(contactInfo, EMAIL_ADDRESS, form.getValueAsString(EMAIL_ADDRESS)); addToJsonObject( contactInfo, ALTERNATE_EMAIL_ADDRESS, form.getValueAsString(ALTERNATE_EMAIL_ADDRESS)); JSONObject homeAddress = new JSONObject(); addToJsonObject(homeAddress, ADDRESS_STREET, form.getValueAsString(HOME_STREET)); addToJsonObject(homeAddress, ADDRESS_CITY, form.getValueAsString(HOME_CITY)); addToJsonObject(homeAddress, ADDRESS_STATE, form.getValueAsString(HOME_STATE)); addToJsonObject(homeAddress, ADDRESS_COUNTRY, form.getValueAsString(HOME_COUNTRY)); addToJsonObject(homeAddress, ADDRESS_ZIP, form.getValueAsString(HOME_ZIP)); contactInfo.put(HOME_ADDRESS, homeAddress); JSONObject officeAddress = new JSONObject(); addToJsonObject(officeAddress, ADDRESS_STREET, form.getValueAsString(OFFICE_STREET)); addToJsonObject(officeAddress, ADDRESS_CITY, form.getValueAsString(OFFICE_CITY)); addToJsonObject(officeAddress, ADDRESS_STATE, form.getValueAsString(OFFICE_STATE)); addToJsonObject(officeAddress, ADDRESS_COUNTRY, form.getValueAsString(OFFICE_COUNTRY)); addToJsonObject(officeAddress, ADDRESS_ZIP, form.getValueAsString(OFFICE_ZIP)); addToJsonObject(officeAddress, OFFICE_DESIGNATION, form.getValueAsString(OFFICE_DESIGNATION)); contactInfo.put(OFFICE_ADDRESS, officeAddress); entry.put(PhonebookDataSource.CONTACT_INFORMATION, contactInfo); JSONObject clientRequestObject = new JSONObject(); clientRequestObject.put(KEY, entry); return clientRequestObject; }
private void onSubmit(final GUIInfo info) { vm.validate(); Tab tab = tabs.getSelectedTab(); int tabIndex = tabs.getSelectedTabNumber(); DynamicForm form = (DynamicForm) tab.getPane(); if (form.hasErrors()) { } else { if (step == 4) { if (!vm.validate()) SC.warn("invalidfields"); SetupInfo data = new SetupInfo(); data.setDbDriver(vm.getValueAsString(DB_DRIVER)); data.setDbUrl(vm.getValueAsString(DB_URL)); data.setDbUsername(vm.getValueAsString(DB_USERNAME)); data.setDbPassword(vm.getValueAsString(DB_PASSWORD)); data.setDbEngine(vm.getValueAsString(DB_ENGINE)); data.setDbType(vm.getValueAsString(DB_TYPE)); data.setLanguage(vm.getValueAsString(LANGUAGE)); data.setSmtpHost(vm.getValueAsString(SMTP_HOST)); data.setSmtpPort((Integer) vm.getValues().get(SMTP_PORT)); data.setSmtpUsername(vm.getValueAsString(SMTP_USERNAME)); data.setSmtpPassword(vm.getValueAsString(SMTP_PASSWORD)); data.setSmtpSender(vm.getValueAsString(SMTP_SENDER)); data.setSmtpSecureAuth((Boolean) vm.getValues().get(SMTP_SECURE_AUTH)); data.setSmtpSecuryConntection(vm.getValueAsString(SMTP_SECURITY_CONNECTION)); data.setRepositoryFolder(vm.getValueAsString(REPOSITORY_FOLDER)); data.setDbDialect(engines.get(data.getDbEngine())[3]); data.setDbValidationQuery(engines.get(data.getDbEngine())[4]); data.setRegEmail(vm.getValueAsString(REG_EMAIL)); data.setRegName(vm.getValueAsString(REG_NAME)); data.setRegOrganization(vm.getValueAsString(REG_ORGANIZATION)); data.setRegWebsite(vm.getValueAsString(REG_WEBSITE)); if (data.getDbType().equals(I18N.message(INTERNAL))) { data.setDbEngine("Hsqldb"); data.setDbDriver("org.hsqldb.jdbcDriver"); data.setDbUrl( ("jdbc:hsqldb:" + data.getRepositoryFolder() + "/db/").replaceAll("//", "/")); data.setDbUsername("sa"); data.setDbPassword(""); data.setDbValidationQuery("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS"); data.setDbDialect("org.hibernate.dialect.HSQLDialect"); } SetupServiceAsync setupService = (SetupServiceAsync) GWT.create(SetupService.class); setupService.setup( data, new AsyncCallback<Void>() { @Override public void onFailure(Throwable caught) { SC.warn(caught.getMessage()); submit.setDisabled(false); } @Override public void onSuccess(Void arg) { SC.say( I18N.message("installationperformed"), I18N.message("installationend", info.getProductName()), new BooleanCallback() { @Override public void execute(Boolean value) { Util.redirect(Util.contextPath() + "frontend.jsp"); } }); submit.setDisabled(false); } }); submit.setDisabled(true); // Clear an eventually saved documents list grid settings. Offline.put("doclist", ""); } else { // Go to the next tab and enable the contained panel tabs.selectTab(tabIndex + 1); tabs.getSelectedTab().getPane().setDisabled(false); if (step < tabs.getSelectedTabNumber()) step++; if (step == 4) submit.setTitle(I18N.message("setup")); } } }