use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.
the class FocusDetailsModels method prepareShadowObject.
private List<ShadowType> prepareShadowObject(List<ShadowWrapper> projections) throws SchemaException {
List<ShadowType> projectionsToAdd = new ArrayList<>();
for (ShadowWrapper projection : projections) {
if (UserDtoStatus.MODIFY.equals(projection.getProjectionStatus())) {
// TODO do we need more specific checks here?
continue;
}
if (!UserDtoStatus.ADD.equals(projection.getProjectionStatus())) {
getPageBase().warn(getPageBase().getString("pageAdminFocus.message.illegalAccountState", projection.getStatus()));
continue;
}
ObjectDelta<ShadowType> delta = projection.getObjectDelta();
PrismObject<ShadowType> proj = delta.getObjectToAdd();
WebComponentUtil.encryptCredentials(proj, true, getPageBase());
projectionsToAdd.add(proj.asObjectable());
}
return projectionsToAdd;
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.
the class FocusDetailsModels method prepareUserAccountsDeltaForModify.
private ReferenceDelta prepareUserAccountsDeltaForModify(PrismReferenceDefinition refDef) throws SchemaException {
ReferenceDelta refDelta = getPrismContext().deltaFactory().reference().create(refDef);
List<ShadowWrapper> accounts = projectionModel.getObject();
for (ShadowWrapper accountWrapper : accounts) {
accountWrapper.revive(getPrismContext());
ObjectDelta delta = accountWrapper.getObjectDelta();
PrismReferenceValue refValue = getPrismContext().itemFactory().createReferenceValue(null, OriginType.USER_ACTION, null);
PrismObject<ShadowType> account;
switch(accountWrapper.getProjectionStatus()) {
case ADD:
account = delta.getObjectToAdd();
if (skipAddShadow(account.asObjectable().getResourceRef(), accounts)) {
break;
}
addDefaultKindAndIntent(account);
WebComponentUtil.encryptCredentials(account, true, getPageBase());
refValue.setObject(account);
refDelta.addValueToAdd(refValue);
break;
case DELETE:
account = accountWrapper.getObject();
if (skipDeleteShadow(account.asObjectable().getResourceRef(), accounts)) {
break;
}
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:
getPageBase().warn(getPageBase().getString("pageAdminFocus.message.illegalAccountState", accountWrapper.getProjectionStatus()));
}
// }
}
return refDelta;
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.
the class FocusDetailsModels method loadShadowWrappers.
private List<ShadowWrapper> loadShadowWrappers() {
LOGGER.trace("Loading shadow wrapper");
long start = System.currentTimeMillis();
List<ShadowWrapper> list = new ArrayList<>();
PrismObjectWrapper<F> focusWrapper = getObjectWrapperModel().getObject();
PrismObject<F> focus = focusWrapper.getObject();
PrismReference prismReference = focus.findReference(UserType.F_LINK_REF);
if (prismReference == null || prismReference.isEmpty()) {
return new ArrayList<>();
}
List<PrismReferenceValue> references = prismReference.getValues();
Task task = getModelServiceLocator().createSimpleTask(OPERATION_LOAD_SHADOW);
for (PrismReferenceValue reference : references) {
if (reference == null || (reference.getOid() == null && reference.getTargetType() == null)) {
LOGGER.trace("Skiping reference for shadow with null oid");
// default value
continue;
}
long shadowTimestampBefore = System.currentTimeMillis();
OperationResult subResult = task.getResult().createMinorSubresult(OPERATION_LOAD_SHADOW);
PrismObject<ShadowType> projection = getPrismObjectForShadowWrapper(reference.getOid(), true, task, subResult, createLoadOptionForShadowWrapper());
long shadowTimestampAfter = System.currentTimeMillis();
LOGGER.trace("Got shadow: {} in {}", projection, shadowTimestampAfter - shadowTimestampBefore);
if (projection == null) {
LOGGER.error("Couldn't load shadow projection");
continue;
}
long timestampWrapperStart = System.currentTimeMillis();
try {
ShadowWrapper wrapper = loadShadowWrapper(projection, true, task, subResult);
wrapper.setLoadWithNoFetch(true);
list.add(wrapper);
} catch (Throwable e) {
getPageBase().showResult(subResult, "pageAdminFocus.message.couldntCreateShadowWrapper");
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create shadow wrapper", e);
}
long timestampWrapperEnd = System.currentTimeMillis();
LOGGER.trace("Load wrapper in {}", timestampWrapperEnd - timestampWrapperStart);
}
long end = System.currentTimeMillis();
LOGGER.trace("Load projctions in {}", end - start);
return list;
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.
the class PageAccount method initButtons.
private void initButtons(Form mainForm) {
AjaxSubmitButton save = new AjaxSubmitButton(ID_SAVE, createStringResource("pageAccount.button.save")) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit(AjaxRequestTarget target) {
savePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target) {
target.add(getFeedbackPanel());
}
};
save.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
ShadowWrapper wrapper = accountModel.getObject();
return !wrapper.isProtected();
}
});
mainForm.add(save);
AjaxButton back = new AjaxButton(ID_BACK, createStringResource("pageAccount.button.back")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
cancelPerformed(target);
}
};
mainForm.add(back);
AjaxButton editXmlButton = new AjaxButton(ID_EDIT_XML, createStringResource("AbstractObjectMainPanel.editXmlButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ConfirmationPanel confirmationPanel = new ConfirmationPanel(getMainPopupBodyId(), createStringResource("AbstractObjectMainPanel.confirmEditXmlRedirect")) {
private static final long serialVersionUID = 1L;
@Override
public void yesPerformed(AjaxRequestTarget target) {
PageParameters parameters = new PageParameters();
parameters.add(PageDebugView.PARAM_OBJECT_ID, accountModel.getObject().getOid());
parameters.add(PageDebugView.PARAM_OBJECT_TYPE, "ShadowType");
navigateToNext(PageDebugView.class, parameters);
}
};
showMainPopup(confirmationPanel, target);
}
};
editXmlButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_CONFIGURATION_URL, AuthorizationConstants.AUTZ_UI_CONFIGURATION_DEBUG_URL) && !accountModel.getObject().isReadOnly();
}
});
mainForm.add(editXmlButton);
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper in project midpoint by Evolveum.
the class PageAccount method initLayout.
private void initLayout() {
add(new ShadowSummaryPanel(ID_SUMMARY, Model.of(accountModel.getObject().getObject().asObjectable()), WebComponentUtil.getSummaryPanelSpecification(ShadowType.class, getCompiledGuiProfile())));
WebMarkupContainer protectedMessage = new WebMarkupContainer(ID_PROTECTED_MESSAGE);
protectedMessage.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
ShadowWrapper wrapper = accountModel.getObject();
return wrapper.isProtected();
}
});
add(protectedMessage);
MidpointForm mainForm = new MidpointForm(ID_MAIN_FORM);
mainForm.setMultiPart(true);
add(mainForm);
mainForm.add(createTabsPanel(mainForm));
initButtons(mainForm);
}
Aggregations