Search in sources :

Example 1 with ShadowWrapper

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;
}
Also used : ArrayList(java.util.ArrayList) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)

Example 2 with ShadowWrapper

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;
}
Also used : ReferenceDelta(com.evolveum.midpoint.prism.delta.ReferenceDelta) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 3 with ShadowWrapper

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;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)

Example 4 with ShadowWrapper

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);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)

Example 5 with ShadowWrapper

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);
}
Also used : ShadowSummaryPanel(com.evolveum.midpoint.web.page.admin.resources.ShadowSummaryPanel) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ShadowWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Aggregations

ShadowWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)10 ArrayList (java.util.ArrayList)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)2 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 Task (com.evolveum.midpoint.task.api.Task)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)1 CountableLoadableModel (com.evolveum.midpoint.gui.api.model.CountableLoadableModel)1 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ShadowWrapperImpl (com.evolveum.midpoint.gui.impl.prism.wrapper.ShadowWrapperImpl)1 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)1 ConfirmationPanel (com.evolveum.midpoint.web.component.dialog.ConfirmationPanel)1 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)1 FocusMainPanel (com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel)1