use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class PageAccount method savePerformed.
private void savePerformed(AjaxRequestTarget target) {
LOGGER.debug("Saving account changes.");
OperationResult result = new OperationResult(OPERATION_SAVE_ACCOUNT);
try {
WebComponentUtil.revive(accountModel, getPrismContext());
ObjectWrapper wrapper = accountModel.getObject();
ObjectDelta<ShadowType> delta = wrapper.getObjectDelta();
if (delta == null) {
return;
}
if (delta.getPrismContext() == null) {
getPrismContext().adopt(delta);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Account delta computed from form:\n{}", new Object[] { delta.debugDump(3) });
}
if (delta.isEmpty()) {
return;
}
WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
Task task = createSimpleTask(OPERATION_SAVE_ACCOUNT);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
deltas.add(delta);
getModelService().executeChanges(deltas, null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't save account.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save account", ex);
}
if (!result.isSuccess()) {
showResult(result);
target.add(getFeedbackPanel());
} else {
showResult(result);
redirectBack();
}
}
use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class PageAccount method initButtons.
private void initButtons(Form mainForm) {
AjaxSubmitButton save = new AjaxSubmitButton("save", createStringResource("pageAccount.button.save")) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(getFeedbackPanel());
}
};
save.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
ObjectWrapper wrapper = accountModel.getObject();
return !wrapper.isProtectedAccount();
}
});
mainForm.add(save);
AjaxButton back = new AjaxButton("back", createStringResource("pageAccount.button.back")) {
@Override
public void onClick(AjaxRequestTarget target) {
cancelPerformed(target);
}
};
mainForm.add(back);
}
use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class PageMyPasswordQuestions method loadUserWrapper.
private ObjectWrapper loadUserWrapper(PrismObject<UserType> userToEdit) {
OperationResult result = new OperationResult(OPERATION_LOAD_USER);
PrismObject<UserType> user = null;
Task task = createSimpleTask(OPERATION_LOAD_USER);
try {
Collection options = SelectorOptions.createCollection(UserType.F_CREDENTIALS, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
user = getModelService().getObject(UserType.class, SecurityUtils.getPrincipalUser().getOid(), options, task, result);
result.recordSuccess();
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user PageMyQuestions", ex);
}
showResult(result, false);
if (user == null) {
throw new RestartResponseException(PageDashboard.class);
}
ContainerStatus status = ContainerStatus.MODIFYING;
ObjectWrapperFactory owf = new ObjectWrapperFactory(this);
ObjectWrapper wrapper;
try {
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, status, task);
} catch (Exception ex) {
result.recordFatalError("Couldn't get user.", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load user", ex);
wrapper = owf.createObjectWrapper("pageMyPasswordQuestions.userDetails", null, user, null, null, status, false);
}
// ObjectWrapper wrapper = new ObjectWrapper("pageUser.userDetails", null, user, status);
showResult(wrapper.getResult(), false);
return wrapper;
}
use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class OrgMemberPanel method createManagerContainer.
private WebMarkupContainer createManagerContainer() {
WebMarkupContainer managerContainer = new WebMarkupContainer(ID_CONTAINER_MANAGER);
managerContainer.setOutputMarkupId(true);
managerContainer.setOutputMarkupPlaceholderTag(true);
RepeatingView view = new RepeatingView(ID_MANAGER_TABLE);
view.setOutputMarkupId(true);
ObjectQuery managersQuery = createManagerQuery();
OperationResult searchManagersResult = new OperationResult(OPERATION_SEARCH_MANAGERS);
Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(FocusType.F_JPEG_PHOTO, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE));
List<PrismObject<FocusType>> managers = WebModelServiceUtils.searchObjects(FocusType.class, managersQuery, options, searchManagersResult, getPageBase());
Task task = getPageBase().createSimpleTask(OPERATION_LOAD_MANAGERS);
for (PrismObject<FocusType> manager : managers) {
ObjectWrapper<FocusType> managerWrapper = ObjectWrapperUtil.createObjectWrapper(WebComponentUtil.getEffectiveName(manager, RoleType.F_DISPLAY_NAME), "", manager, ContainerStatus.MODIFYING, task, getPageBase());
WebMarkupContainer managerMarkup = new WebMarkupContainer(view.newChildId());
AjaxLink<String> link = new AjaxLink<String>(ID_EDIT_MANAGER) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
detailsPerformed(target, summary.getModelObject());
}
};
link.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_READ_ACTION_URL, AuthorizationPhaseType.REQUEST, managerWrapper.getObject(), null, null, null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #read operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
if (manager.getCompileTimeClass().equals(UserType.class)) {
managerMarkup.add(new UserSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<UserType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(RoleType.class)) {
managerMarkup.add(new RoleSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<RoleType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(OrgType.class)) {
managerMarkup.add(new OrgSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<OrgType>>((ObjectWrapper) managerWrapper)));
} else if (manager.getCompileTimeClass().equals(ServiceType.class)) {
managerMarkup.add(new ServiceSummaryPanel(ID_MANAGER_SUMMARY, new Model<ObjectWrapper<ServiceType>>((ObjectWrapper) managerWrapper)));
}
link.setOutputMarkupId(true);
managerMarkup.setOutputMarkupId(true);
managerMarkup.add(link);
view.add(managerMarkup);
AjaxButton removeManager = new AjaxButton(ID_REMOVE_MANAGER) {
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
removeManagerPerformed(summary.getModelObject(), target);
getParent().setVisible(false);
target.add(OrgMemberPanel.this);
}
};
removeManager.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_UNASSIGN_ACTION_URL, null, managerWrapper.getObject(), null, getModelObject().asPrismObject(), null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #unassign operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
removeManager.setOutputMarkupId(true);
managerMarkup.add(removeManager);
AjaxButton deleteManager = new AjaxButton(ID_DELETE_MANAGER) {
@Override
public void onClick(AjaxRequestTarget target) {
FocusSummaryPanel<FocusType> summary = (FocusSummaryPanel<FocusType>) getParent().get(ID_MANAGER_SUMMARY);
deleteManagerPerformed(summary.getModelObject(), this, target);
}
};
deleteManager.setOutputMarkupId(true);
deleteManager.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
boolean isVisible = false;
try {
isVisible = getPageBase().getSecurityEnforcer().isAuthorized(AuthorizationConstants.AUTZ_UI_DELETE_ACTION_URL, null, managerWrapper.getObject(), null, null, null);
} catch (Exception ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Failed to check authorization for #delete operation on object " + managerWrapper.getObject(), ex);
}
return isVisible;
}
});
managerMarkup.add(deleteManager);
}
managerContainer.add(view);
InlineMenu menupanel = new InlineMenu(ID_MANAGER_MENU, new Model<Serializable>((Serializable) createManagersHeaderInlineMenu()));
add(menupanel);
menupanel.setOutputMarkupId(true);
managerContainer.add(menupanel);
return managerContainer;
}
use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class PageAdminAbstractRole method loadInducements.
// TODO unify with loadAssignments
private List<AssignmentEditorDto> loadInducements() {
List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
ObjectWrapper focusWrapper = getObjectWrapper();
PrismObject<T> focus = focusWrapper.getObject();
List<AssignmentType> inducements = focus.asObjectable().getInducement();
for (AssignmentType inducement : inducements) {
list.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, inducement, this));
}
Collections.sort(list);
return list;
}
Aggregations