use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class DynamicFormPanel method initialize.
private void initialize(final PrismObject<O> prismObject, String formOid, Form<?> mainForm, final Task task, final PageBase parentPage, boolean enforceRequiredFields) {
if (prismObject == null) {
getSession().error(getString("DynamicFormPanel.object.must.not.be.null"));
throw new RestartResponseException(parentPage);
}
// setParent(parentPage);
form = loadForm(formOid, task, parentPage);
if (form == null || form.getFormDefinition() == null) {
LOGGER.debug("No form or form definition; form OID = {}", formOid);
// to avoid wicket exceptions
add(new Label(ID_FORM_FIELDS));
return;
}
PrismObjectWrapperFactory<O> factory = parentPage.findObjectWrapperFactory(prismObject.getDefinition());
PrismObjectWrapper<O> objectWrapper = createObjectWrapper(factory, task, prismObject, enforceRequiredFields);
wrapperModel = LoadableModel.create(() -> objectWrapper, true);
initLayout(mainForm, parentPage);
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class DynamicFormPanel method instantiateObject.
private PrismObject<O> instantiateObject(QName objectType, PageBase parentPage) {
PrismObjectDefinition<O> objectDef = parentPage.getPrismContext().getSchemaRegistry().findObjectDefinitionByType(objectType);
PrismObject<O> prismObject;
try {
prismObject = objectDef.instantiate();
} catch (SchemaException e) {
LoggingUtils.logException(LOGGER, "Could not initialize model for forgot password", e);
throw new RestartResponseException(parentPage);
}
return prismObject;
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageForgotPassword method processResetPassword.
private void processResetPassword(AjaxRequestTarget target, Form<?> form) {
UserType user = searchUser(form);
if (user == null) {
getSession().error(getString("pageForgetPassword.message.user.not.found"));
throw new RestartResponseException(PageForgotPassword.class);
}
LOGGER.trace("Reset Password user: {}", user);
if (getResetPasswordPolicy() == null) {
LOGGER.debug("No policies for reset password defined");
getSession().error(getString("pageForgetPassword.message.policy.not.found"));
throw new RestartResponseException(PageForgotPassword.class);
}
switch(getResetPasswordPolicy().getResetMethod()) {
case MAIL:
OperationResult result = saveUserNonce(user, getResetPasswordPolicy().getNoncePolicy());
if (result.getStatus() == OperationResultStatus.SUCCESS) {
submited = true;
target.add(PageForgotPassword.this);
} else {
getSession().error(getString("PageForgotPassword.send.nonce.failed"));
LOGGER.error("Failed to send nonce to user: {} ", result.getMessage());
throw new RestartResponseException(PageForgotPassword.this);
}
break;
case SECURITY_QUESTIONS:
LOGGER.trace("Forward to PageSecurityQuestions");
PageParameters params = new PageParameters();
params.add(PageSecurityQuestions.SESSION_ATTRIBUTE_POID, user.getOid());
setResponsePage(PageSecurityQuestions.class, params);
break;
default:
getSession().error(getString("pageForgetPassword.message.reset.method.not.supported"));
LOGGER.error("Reset method {} not supported.", getResetPasswordPolicy().getResetMethod());
throw new RestartResponseException(PageForgotPassword.this);
}
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAttorneySelection method getAttorneySelectionQuery.
private ObjectQuery getAttorneySelectionQuery() {
ModelInteractionService service = getModelInteractionService();
Task task = createSimpleTask(OPERATION_GET_DONOR_FILTER);
try {
ObjectQuery query = PageAttorneySelection.this.getPrismContext().queryFactory().createQuery();
// todo target authorization action
ObjectFilter filter = service.getDonorFilter(UserType.class, null, null, task, task.getResult());
query.addFilter(filter);
return query;
} catch (CommonException ex) {
LOGGER.error("Couldn't get donor filter, reason: {}", ex.getMessage());
LOGGER.debug("Couldn't get donor filter", ex);
PageError error = new PageError(ex);
throw new RestartResponseException(error);
}
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class FlexibleLabelModel method getDefaultValue.
private String getDefaultValue() {
C object = model.getObject();
if (object == null) {
return "";
}
PrismProperty<?> property;
try {
property = object.asPrismContainerValue().findOrCreateProperty(path);
} catch (SchemaException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
// todo show message in page error [lazyman]
throw new RestartResponseException(PageError.class);
}
if (property == null || property.getRealValue() == null) {
return "";
}
if (property.getRealValue() instanceof PolyString) {
return serviceLocator.getLocalizationService().translate((PolyString) property.getRealValue(), serviceLocator.getLocale(), true);
}
return property.getRealValue().toString();
}
Aggregations