Search in sources :

Example 1 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class PagePostAuthentication method initStaticLayout.

@Override
protected WebMarkupContainer initStaticLayout() {
    Task task = createSimpleTask(OPERATION_LOAD_WRAPPER);
    OperationResult result = new OperationResult(OPERATION_LOAD_WRAPPER);
    PrismObjectWrapperFactory<UserType> factory = findObjectWrapperFactory(userModel.getObject().asPrismObject().getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    try {
        objectWrapper = factory.createObjectWrapper(userModel.getObject().asPrismObject(), ItemStatus.NOT_CHANGED, context);
    } catch (SchemaException e) {
        result.recordFatalError(getString("PagePostAuthentication.message.couldntPerformPostAuth.fatalError"));
        showResult(result);
        throw new RestartResponseException(PageLogin.class);
    }
    WebMarkupContainer wrappers = new WebMarkupContainer(ID_WRAPPER_CONTENT);
    try {
        Panel main = initItemPanel(ID_MAIN_PANEL, UserType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(Model.of(objectWrapper), ItemPath.EMPTY_PATH), null);
        wrappers.add(main);
        Panel password = initItemPanel(ID_PASSWORD_PANEL, PasswordType.COMPLEX_TYPE, PrismContainerWrapperModel.fromContainerWrapper(Model.of(objectWrapper), ItemPath.create(UserType.F_CREDENTIALS, CredentialsType.F_PASSWORD)), null);
        wrappers.add(password);
    } catch (SchemaException e) {
        LOGGER.error("Cannot create panel, {}", e.getMessage(), e);
        getSession().error("Unexpected error occurred. Please contact system administrator.");
        throw new RestartResponseException(PageLogin.class);
    }
    return wrappers;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Panel(org.apache.wicket.markup.html.panel.Panel) Task(com.evolveum.midpoint.task.api.Task) RestartResponseException(org.apache.wicket.RestartResponseException) PageLogin(com.evolveum.midpoint.web.page.login.PageLogin) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 2 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class FocusProjectionsPanel method loadShadowWrapper.

@NotNull
public ShadowWrapper loadShadowWrapper(PrismObject<ShadowType> projection, Task task, OperationResult result) throws SchemaException {
    PrismObjectWrapperFactory<ShadowType> factory = getPageBase().findObjectWrapperFactory(projection.getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    context.setCreateIfEmpty(true);
    context.setDetailsPageTypeConfiguration(findShadowDetailsPageConfiguration(projection.asObjectable()));
    ShadowWrapper wrapper = (ShadowWrapper) factory.createObjectWrapper(projection, ItemStatus.NOT_CHANGED, context);
    wrapper.setProjectionStatus(UserDtoStatus.MODIFY);
    return wrapper;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class DynamicFormPanel method createObjectWrapper.

private PrismObjectWrapper<O> createObjectWrapper(PrismObjectWrapperFactory<O> factory, Task task, PrismObject<O> prismObject, boolean enforceRequiredFields) {
    FormAuthorizationType formAuthorization = form.getFormDefinition().getAuthorization();
    AuthorizationPhaseType authorizationPhase = formAuthorization != null && formAuthorization.getPhase() != null ? formAuthorization.getPhase() : AuthorizationPhaseType.REQUEST;
    OperationResult result = task.getResult();
    WrapperContext context = new WrapperContext(task, result);
    context.setShowEmpty(true);
    context.setAuthzPhase(authorizationPhase);
    // TODO: enforce required fields???? what is it?
    PrismObjectWrapper<O> objectWrapper = null;
    try {
        objectWrapper = factory.createObjectWrapper(prismObject, prismObject.getOid() == null ? ItemStatus.ADDED : ItemStatus.NOT_CHANGED, context);
        result.recordSuccess();
    } catch (SchemaException e) {
        result.recordFatalError(createStringResource("DynamicFormPanel.message.createObjectWrapper.fatalError", e.getMessage()).getString());
        getPageBase().showResult(result);
    }
    return objectWrapper;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AuthorizationPhaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuthorizationPhaseType) FormAuthorizationType(com.evolveum.midpoint.xml.ns._public.common.common_3.FormAuthorizationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 4 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class PageAdminFocus method loadShadowWrapper.

@NotNull
public ShadowWrapper loadShadowWrapper(PrismObject<ShadowType> projection, Task task, OperationResult result) throws SchemaException {
    PrismObjectWrapperFactory<ShadowType> factory = getRegistry().getObjectWrapperFactory(projection.getDefinition());
    WrapperContext context = new WrapperContext(task, result);
    context.setCreateIfEmpty(false);
    ShadowWrapper wrapper = (ShadowWrapper) factory.createObjectWrapper(projection, ItemStatus.NOT_CHANGED, context);
    wrapper.setProjectionStatus(UserDtoStatus.MODIFY);
    return wrapper;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with WrapperContext

use of com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext in project midpoint by Evolveum.

the class PageValuePolicy method loadValuePolicy.

private PrismObjectWrapper<ValuePolicyType> loadValuePolicy(String policyOid) {
    Task task = createSimpleTask(OPERATION_LOAD_DEFINITION);
    OperationResult result = task.getResult();
    PrismObjectWrapper<ValuePolicyType> valuePolicyWrapper = null;
    try {
        PrismObject<ValuePolicyType> valuePolicyObject = WebModelServiceUtils.loadObject(ValuePolicyType.class, policyOid, PageValuePolicy.this, task, result);
        PrismObjectWrapperFactory<ValuePolicyType> owf = getRegistry().getObjectWrapperFactory(valuePolicyObject.getDefinition());
        WrapperContext context = new WrapperContext(task, result);
        valuePolicyWrapper = owf.createObjectWrapper(valuePolicyObject, ItemStatus.NOT_CHANGED, context);
        result.recordSuccessIfUnknown();
    } catch (Exception ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get definition", ex);
        result.recordFatalError(getString("PageValuePolicy.message.loadValuePolicy.fatalError"), ex);
    }
    result.recomputeStatus();
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        showResult(result);
    }
    return valuePolicyWrapper;
}
Also used : WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) Task(com.evolveum.midpoint.task.api.Task) ValuePolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.ValuePolicyType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException)

Aggregations

WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)46 Task (com.evolveum.midpoint.task.api.Task)32 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)15 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)15 Test (org.testng.annotations.Test)15 ModelServiceLocator (com.evolveum.midpoint.gui.api.util.ModelServiceLocator)11 ItemStatus (com.evolveum.midpoint.gui.api.prism.ItemStatus)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)7 RestartResponseException (org.apache.wicket.RestartResponseException)5 PrismObjectWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper)4 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 QName (javax.xml.namespace.QName)4 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 NotNull (org.jetbrains.annotations.NotNull)3 PrismObjectWrapperFactory (com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory)2 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)2 ShadowWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ShadowWrapper)2 PrismPropertyValueWrapper (com.evolveum.midpoint.gui.impl.prism.wrapper.PrismPropertyValueWrapper)2