use of password.pwm.ws.client.rest.form.FormDataResponseBean in project pwm by pwm-project.
the class NewUserUtils method remoteSendFormData.
private static void remoteSendFormData(final PwmRequest pwmRequest, final NewUserForm newUserForm, final FormDataRequestBean.Mode mode) throws PwmUnrecoverableException, PwmDataValidationException {
final RestFormDataClient restFormDataClient = new RestFormDataClient(pwmRequest.getPwmApplication(), pwmRequest.getSessionLabel());
if (!restFormDataClient.isEnabled()) {
return;
}
final NewUserBean newUserBean = NewUserServlet.getNewUserBean(pwmRequest);
final NewUserProfile newUserProfile = NewUserServlet.getNewUserProfile(pwmRequest);
final FormDataRequestBean.FormInfo formInfo = FormDataRequestBean.FormInfo.builder().mode(mode).moduleProfileID(newUserBean.getProfileID()).sessionID(pwmRequest.getPwmSession().getLoginInfoBean().getGuid()).module(FormDataRequestBean.FormType.NewUser).build();
final FormDataRequestBean formDataRequestBean = FormDataRequestBean.builder().formInfo(formInfo).formConfigurations(newUserProfile.readSettingAsForm(PwmSetting.NEWUSER_FORM)).formValues(newUserForm.getFormData()).build();
final FormDataResponseBean formDataResponseBean = restFormDataClient.invoke(formDataRequestBean, pwmRequest.getLocale());
if (formDataResponseBean.isError()) {
final ErrorInformation error = new ErrorInformation(PwmError.ERROR_REMOTE_ERROR_VALUE, formDataResponseBean.getErrorDetail(), new String[] { formDataResponseBean.getErrorMessage() });
throw new PwmDataValidationException(error);
}
}
Aggregations