Search in sources :

Example 26 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class DynamicFormPanel method initialize.

private void initialize(final PrismObject<O> prismObject, String formOid, Form<?> mainForm, final Task task, final PageBase parentPage, boolean enforceRequiredFields) {
    if (prismObject == null) {
        getSession().error(getString("DynamicFormPanel.object.must.not.be.null"));
        throw new RestartResponseException(parentPage);
    }
    // setParent(parentPage);
    form = loadForm(formOid, task, parentPage);
    if (form == null || form.getFormDefinition() == null) {
        LOGGER.debug("No form or form definition; form OID = {}", formOid);
        // to avoid wicket exceptions
        add(new Label(ID_FORM_FIELDS));
        return;
    }
    PrismObjectWrapperFactory<O> factory = parentPage.findObjectWrapperFactory(prismObject.getDefinition());
    PrismObjectWrapper<O> objectWrapper = createObjectWrapper(factory, task, prismObject, enforceRequiredFields);
    wrapperModel = LoadableModel.create(() -> objectWrapper, true);
    initLayout(mainForm, parentPage);
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) Label(org.apache.wicket.markup.html.basic.Label)

Example 27 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class DynamicFormPanel method instantiateObject.

private PrismObject<O> instantiateObject(QName objectType, PageBase parentPage) {
    PrismObjectDefinition<O> objectDef = parentPage.getPrismContext().getSchemaRegistry().findObjectDefinitionByType(objectType);
    PrismObject<O> prismObject;
    try {
        prismObject = objectDef.instantiate();
    } catch (SchemaException e) {
        LoggingUtils.logException(LOGGER, "Could not initialize model for forgot password", e);
        throw new RestartResponseException(parentPage);
    }
    return prismObject;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 28 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class PageForgotPassword method processResetPassword.

private void processResetPassword(AjaxRequestTarget target, Form<?> form) {
    UserType user = searchUser(form);
    if (user == null) {
        getSession().error(getString("pageForgetPassword.message.user.not.found"));
        throw new RestartResponseException(PageForgotPassword.class);
    }
    LOGGER.trace("Reset Password user: {}", user);
    if (getResetPasswordPolicy() == null) {
        LOGGER.debug("No policies for reset password defined");
        getSession().error(getString("pageForgetPassword.message.policy.not.found"));
        throw new RestartResponseException(PageForgotPassword.class);
    }
    switch(getResetPasswordPolicy().getResetMethod()) {
        case MAIL:
            OperationResult result = saveUserNonce(user, getResetPasswordPolicy().getNoncePolicy());
            if (result.getStatus() == OperationResultStatus.SUCCESS) {
                submited = true;
                target.add(PageForgotPassword.this);
            } else {
                getSession().error(getString("PageForgotPassword.send.nonce.failed"));
                LOGGER.error("Failed to send nonce to user: {} ", result.getMessage());
                throw new RestartResponseException(PageForgotPassword.this);
            }
            break;
        case SECURITY_QUESTIONS:
            LOGGER.trace("Forward to PageSecurityQuestions");
            PageParameters params = new PageParameters();
            params.add(PageSecurityQuestions.SESSION_ATTRIBUTE_POID, user.getOid());
            setResponsePage(PageSecurityQuestions.class, params);
            break;
        default:
            getSession().error(getString("pageForgetPassword.message.reset.method.not.supported"));
            LOGGER.error("Reset method {} not supported.", getResetPasswordPolicy().getResetMethod());
            throw new RestartResponseException(PageForgotPassword.this);
    }
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 29 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class PageAttorneySelection method getAttorneySelectionQuery.

private ObjectQuery getAttorneySelectionQuery() {
    ModelInteractionService service = getModelInteractionService();
    Task task = createSimpleTask(OPERATION_GET_DONOR_FILTER);
    try {
        ObjectQuery query = PageAttorneySelection.this.getPrismContext().queryFactory().createQuery();
        // todo target authorization action
        ObjectFilter filter = service.getDonorFilter(UserType.class, null, null, task, task.getResult());
        query.addFilter(filter);
        return query;
    } catch (CommonException ex) {
        LOGGER.error("Couldn't get donor filter, reason: {}", ex.getMessage());
        LOGGER.debug("Couldn't get donor filter", ex);
        PageError error = new PageError(ex);
        throw new RestartResponseException(error);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelInteractionService(com.evolveum.midpoint.model.api.ModelInteractionService) RestartResponseException(org.apache.wicket.RestartResponseException) PageError(com.evolveum.midpoint.web.page.error.PageError) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 30 with RestartResponseException

use of org.apache.wicket.RestartResponseException in project midpoint by Evolveum.

the class FlexibleLabelModel method getDefaultValue.

private String getDefaultValue() {
    C object = model.getObject();
    if (object == null) {
        return "";
    }
    PrismProperty<?> property;
    try {
        property = object.asPrismContainerValue().findOrCreateProperty(path);
    } catch (SchemaException ex) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create property in path {}", ex, path);
        // todo show message in page error [lazyman]
        throw new RestartResponseException(PageError.class);
    }
    if (property == null || property.getRealValue() == null) {
        return "";
    }
    if (property.getRealValue() instanceof PolyString) {
        return serviceLocator.getLocalizationService().translate((PolyString) property.getRealValue(), serviceLocator.getLocale(), true);
    }
    return property.getRealValue().toString();
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PageError(com.evolveum.midpoint.web.page.error.PageError)

Aggregations

RestartResponseException (org.apache.wicket.RestartResponseException)73 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)36 Task (com.evolveum.midpoint.task.api.Task)27 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)20 ArrayList (java.util.ArrayList)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)8 CommonException (com.evolveum.midpoint.util.exception.CommonException)8 SecurityPolicyType (com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)6 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)5 PageBase (com.evolveum.midpoint.gui.api.page.PageBase)5 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)5 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)5 PageError (com.evolveum.midpoint.web.page.error.PageError)5 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)4 Collection (java.util.Collection)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 IModel (org.apache.wicket.model.IModel)4 StringValue (org.apache.wicket.util.string.StringValue)4