use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAccountActivation method loadUser.
private UserType loadUser(PageParameters params) {
String userOid = getOidFromParameter(params);
if (userOid == null) {
getSession().error(getString("PageAccountActivation.user.not.found"));
throw new RestartResponseException(PageLogin.class);
}
Task task = createAnonymousTask(LOAD_USER);
OperationResult result = new OperationResult(LOAD_USER);
return runPrivileged(new Producer<UserType>() {
private static final long serialVersionUID = 1L;
@Override
public UserType run() {
Collection<SelectorOptions<GetOperationOptions>> options = getOperationOptionsBuilder().item(UserType.F_LINK_REF).resolve().item(UserType.F_LINK_REF, ShadowType.F_RESOURCE_REF).resolve().build();
PrismObject<UserType> user = WebModelServiceUtils.loadObject(UserType.class, userOid, options, PageAccountActivation.this, task, result);
if (user == null) {
return null;
}
return user.asObjectable();
}
});
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAccountActivation method initLayout.
private void initLayout() {
WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
activationContainer.setOutputMarkupId(true);
add(activationContainer);
activationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !activated;
}
});
Form<?> form = new MidpointForm<>(ID_MAIN_FORM);
activationContainer.add(form);
Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", userModel != null && userModel.getObject() != null && userModel.getObject().getName() != null ? getLocalizationService().translate(userModel.getObject().getName().toPolyString()) : ""));
usernamePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
return false;
}
});
form.add(usernamePanel);
PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
form.add(passwordPanel);
AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
propagatePassword(target, getForm());
}
@Override
protected void onError(AjaxRequestTarget target) {
getSession().error(getString("PageAccountActivation.account.activation.failed"));
target.add(getFeedbackPanel());
}
};
form.setDefaultButton(confirmPasswrod);
form.add(confirmPasswrod);
WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
confirmationContainer.setOutputMarkupId(true);
confirmationContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return activated;
}
});
add(confirmationContainer);
AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(PageLogin.class);
}
};
confirmationContainer.add(linkToLogin);
RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
confirmationContainer.add(activatedShadows);
List<ShadowType> shadowsToActivate = getShadowsToActivate();
if (shadowsToActivate.isEmpty()) {
LOGGER.error("No accounts to validate for user {}", userModel.getObject());
getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
throw new RestartResponseException(PageLogin.class);
}
for (ShadowType shadow : shadowsToActivate) {
Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
activatedShadows.add(shadowDesc);
}
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class TreeTablePanel method deleteNodeConfirmedPerformed.
private void deleteNodeConfirmedPerformed(SelectableBeanImpl<OrgType> orgToDelete, AjaxRequestTarget target) {
OperationResult result = new OperationResult(OPERATION_DELETE_OBJECT);
PageBase page = getPageBase();
if (orgToDelete == null) {
orgToDelete = getTreePanel().getRootFromProvider();
}
if (orgToDelete.getValue() == null) {
return;
}
if (CollectionUtils.isEmpty(orgToDelete.getValue().getParentOrgRef())) {
OrgTreeStateStorage storage = getTreePanel().getOrgTreeStateStorage();
if (storage != null) {
storage.setSelectedTabId(-1);
}
getTreePanel().setSelectedItem(null, storage);
}
String oidToDelete = orgToDelete.getValue().getOid();
WebModelServiceUtils.deleteObject(OrgType.class, oidToDelete, result, page);
result.computeStatusIfUnknown();
page.showResult(result);
target.add(getPageBase().getFeedbackPanel());
// TODO is this ok? [pmed]
throw new RestartResponseException(getPage().getClass());
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAuthenticationBase method createDynamicFormQuery.
protected ObjectQuery createDynamicFormQuery() {
DynamicFormPanel<UserType> userDynamicPanel = getDynamicForm();
List<ItemPath> filledItems = userDynamicPanel.getChangedItems();
PrismObject<UserType> user;
try {
user = userDynamicPanel.getObject();
} catch (SchemaException e1) {
getSession().error(getString("pageForgetPassword.message.usernotfound"));
throw new RestartResponseException(PageForgotPassword.class);
}
List<EqualFilter> filters = new ArrayList<>();
QueryFactory queryFactory = getPrismContext().queryFactory();
for (ItemPath path : filledItems) {
PrismProperty<?> property = user.findProperty(path);
EqualFilter filter = queryFactory.createEqual(path, property.getDefinition(), null);
filter.setValue(property.getAnyValue().clone());
filters.add(filter);
}
return queryFactory.createQuery(queryFactory.createAnd((List) filters));
}
use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.
the class PageAuthenticationBase method initSelfRegistrationConfiguration.
private void initSelfRegistrationConfiguration() {
SecurityPolicyType securityPolicy = resolveSecurityPolicy();
this.selfRegistrationDto = new SelfRegistrationDto();
try {
this.selfRegistrationDto.initSelfRegistrationDto(securityPolicy);
} catch (SchemaException e) {
LOGGER.error("Failed to initialize self registration configuration.", e);
getSession().error(createStringResource("PageSelfRegistration.selfRegistration.configuration.init.failed").getString());
throw new RestartResponseException(PageLogin.class);
}
}
Aggregations