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 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 PageAdminFocus method getForceDeleteDelta.
private ObjectDelta getForceDeleteDelta(ObjectWrapper focusWrapper) throws SchemaException {
List<FocusSubwrapperDto<ShadowType>> accountDtos = getFocusShadows();
List<ReferenceDelta> refDeltas = new ArrayList<ReferenceDelta>();
ObjectDelta<F> forceDeleteDelta = null;
for (FocusSubwrapperDto<ShadowType> accDto : accountDtos) {
if (!accDto.isLoadedOK()) {
continue;
}
if (accDto.getStatus() == UserDtoStatus.DELETE) {
ObjectWrapper accWrapper = accDto.getObject();
ReferenceDelta refDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, focusWrapper.getObject().getDefinition(), accWrapper.getObject());
refDeltas.add(refDelta);
} else if (accDto.getStatus() == UserDtoStatus.UNLINK) {
ObjectWrapper accWrapper = accDto.getObject();
ReferenceDelta refDelta = ReferenceDelta.createModificationDelete(UserType.F_LINK_REF, focusWrapper.getObject().getDefinition(), accWrapper.getObject().getOid());
refDeltas.add(refDelta);
}
}
if (!refDeltas.isEmpty()) {
forceDeleteDelta = ObjectDelta.createModifyDelta(focusWrapper.getObject().getOid(), refDeltas, getCompileTimeClass(), getPrismContext());
}
PrismContainerDefinition def = focusWrapper.getObject().findContainer(UserType.F_ASSIGNMENT).getDefinition();
if (forceDeleteDelta == null) {
forceDeleteDelta = ObjectDelta.createEmptyModifyDelta(getCompileTimeClass(), focusWrapper.getObject().getOid(), getPrismContext());
}
handleAssignmentDeltas(forceDeleteDelta, getFocusAssignments(), def);
return forceDeleteDelta;
}
use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class PageAdminFocus method getShadowModifyDeltas.
private List<ObjectDelta<? extends ObjectType>> getShadowModifyDeltas(OperationResult result) {
List<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
List<FocusSubwrapperDto<ShadowType>> accounts = getFocusShadows();
OperationResult subResult = null;
for (FocusSubwrapperDto<ShadowType> account : accounts) {
if (!account.isLoadedOK()) {
continue;
}
try {
ObjectWrapper accountWrapper = account.getObject();
ObjectDelta delta = accountWrapper.getObjectDelta();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Account delta computed from {} as:\n{}", new Object[] { accountWrapper, delta.debugDump(3) });
}
if (!UserDtoStatus.MODIFY.equals(account.getStatus())) {
continue;
}
if (delta.isEmpty() && (accountWrapper.getOldDelta() == null || accountWrapper.getOldDelta().isEmpty())) {
continue;
}
if (accountWrapper.getOldDelta() != null) {
delta = ObjectDelta.summarize(delta, accountWrapper.getOldDelta());
}
// what is this???
// subResult = result.createSubresult(OPERATION_MODIFY_ACCOUNT);
WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Modifying account:\n{}", new Object[] { delta.debugDump(3) });
}
deltas.add(delta);
// subResult.recordSuccess();
} catch (Exception ex) {
// if (subResult != null) {
result.recordFatalError("Couldn't compute account delta.", ex);
// }
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't compute account delta", ex);
}
}
return deltas;
}
use of com.evolveum.midpoint.web.component.prism.ObjectWrapper in project midpoint by Evolveum.
the class PageAdminFocus method prepareUserAccountsDeltaForModify.
private ReferenceDelta prepareUserAccountsDeltaForModify(PrismReferenceDefinition refDef) throws SchemaException {
ReferenceDelta refDelta = new ReferenceDelta(refDef, getPrismContext());
List<FocusSubwrapperDto<ShadowType>> accounts = getFocusShadows();
for (FocusSubwrapperDto<ShadowType> accDto : accounts) {
if (accDto.isLoadedOK()) {
ObjectWrapper accountWrapper = accDto.getObject();
accountWrapper.revive(getPrismContext());
ObjectDelta delta = accountWrapper.getObjectDelta();
PrismReferenceValue refValue = new PrismReferenceValue(null, OriginType.USER_ACTION, null);
PrismObject<ShadowType> account;
switch(accDto.getStatus()) {
case ADD:
account = delta.getObjectToAdd();
addDefaultKindAndIntent(account);
WebComponentUtil.encryptCredentials(account, true, getMidpointApplication());
refValue.setObject(account);
refDelta.addValueToAdd(refValue);
break;
case DELETE:
account = accountWrapper.getObject();
refValue.setObject(account);
refDelta.addValueToDelete(refValue);
break;
case MODIFY:
// before
continue;
case UNLINK:
refValue.setOid(delta.getOid());
refValue.setTargetType(ShadowType.COMPLEX_TYPE);
refDelta.addValueToDelete(refValue);
break;
default:
warn(getString("pageAdminFocus.message.illegalAccountState", accDto.getStatus()));
}
}
}
return refDelta;
}
Aggregations