Search in sources :

Example 56 with RestartResponseException

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

the class PageAccountActivation method loadUser.

private UserType loadUser(PageParameters params) {
    String userOid = getOidFromParameter(params);
    if (userOid == null) {
        getSession().error(getString("PageAccountActivation.user.not.found"));
        throw new RestartResponseException(PageLogin.class);
    }
    Task task = createAnonymousTask(LOAD_USER);
    OperationResult result = new OperationResult(LOAD_USER);
    return runPrivileged(new Producer<UserType>() {

        private static final long serialVersionUID = 1L;

        @Override
        public UserType run() {
            Collection<SelectorOptions<GetOperationOptions>> options = getOperationOptionsBuilder().item(UserType.F_LINK_REF).resolve().item(UserType.F_LINK_REF, ShadowType.F_RESOURCE_REF).resolve().build();
            PrismObject<UserType> user = WebModelServiceUtils.loadObject(UserType.class, userOid, options, PageAccountActivation.this, task, result);
            if (user == null) {
                return null;
            }
            return user.asObjectable();
        }
    });
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) RestartResponseException(org.apache.wicket.RestartResponseException) Collection(java.util.Collection) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 57 with RestartResponseException

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

the class PageAccountActivation method initLayout.

private void initLayout() {
    WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
    activationContainer.setOutputMarkupId(true);
    add(activationContainer);
    activationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !activated;
        }
    });
    Form<?> form = new MidpointForm<>(ID_MAIN_FORM);
    activationContainer.add(form);
    Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", userModel != null && userModel.getObject() != null && userModel.getObject().getName() != null ? getLocalizationService().translate(userModel.getObject().getName().toPolyString()) : ""));
    usernamePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return false;
        }
    });
    form.add(usernamePanel);
    PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
    form.add(passwordPanel);
    AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            propagatePassword(target, getForm());
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            getSession().error(getString("PageAccountActivation.account.activation.failed"));
            target.add(getFeedbackPanel());
        }
    };
    form.setDefaultButton(confirmPasswrod);
    form.add(confirmPasswrod);
    WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
    confirmationContainer.setOutputMarkupId(true);
    confirmationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return activated;
        }
    });
    add(confirmationContainer);
    AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    confirmationContainer.add(linkToLogin);
    RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
    confirmationContainer.add(activatedShadows);
    List<ShadowType> shadowsToActivate = getShadowsToActivate();
    if (shadowsToActivate.isEmpty()) {
        LOGGER.error("No accounts to validate for user {}", userModel.getObject());
        getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
        throw new RestartResponseException(PageLogin.class);
    }
    for (ShadowType shadow : shadowsToActivate) {
        Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
        activatedShadows.add(shadowDesc);
    }
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Label(org.apache.wicket.markup.html.basic.Label) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 58 with RestartResponseException

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

the class TreeTablePanel method deleteNodeConfirmedPerformed.

private void deleteNodeConfirmedPerformed(SelectableBeanImpl<OrgType> orgToDelete, AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_DELETE_OBJECT);
    PageBase page = getPageBase();
    if (orgToDelete == null) {
        orgToDelete = getTreePanel().getRootFromProvider();
    }
    if (orgToDelete.getValue() == null) {
        return;
    }
    if (CollectionUtils.isEmpty(orgToDelete.getValue().getParentOrgRef())) {
        OrgTreeStateStorage storage = getTreePanel().getOrgTreeStateStorage();
        if (storage != null) {
            storage.setSelectedTabId(-1);
        }
        getTreePanel().setSelectedItem(null, storage);
    }
    String oidToDelete = orgToDelete.getValue().getOid();
    WebModelServiceUtils.deleteObject(OrgType.class, oidToDelete, result, page);
    result.computeStatusIfUnknown();
    page.showResult(result);
    target.add(getPageBase().getFeedbackPanel());
    // TODO is this ok? [pmed]
    throw new RestartResponseException(getPage().getClass());
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) OrgTreeStateStorage(com.evolveum.midpoint.web.session.OrgTreeStateStorage) PageBase(com.evolveum.midpoint.gui.api.page.PageBase)

Example 59 with RestartResponseException

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

the class PageAuthenticationBase method createDynamicFormQuery.

protected ObjectQuery createDynamicFormQuery() {
    DynamicFormPanel<UserType> userDynamicPanel = getDynamicForm();
    List<ItemPath> filledItems = userDynamicPanel.getChangedItems();
    PrismObject<UserType> user;
    try {
        user = userDynamicPanel.getObject();
    } catch (SchemaException e1) {
        getSession().error(getString("pageForgetPassword.message.usernotfound"));
        throw new RestartResponseException(PageForgotPassword.class);
    }
    List<EqualFilter> filters = new ArrayList<>();
    QueryFactory queryFactory = getPrismContext().queryFactory();
    for (ItemPath path : filledItems) {
        PrismProperty<?> property = user.findProperty(path);
        EqualFilter filter = queryFactory.createEqual(path, property.getDefinition(), null);
        filter.setValue(property.getAnyValue().clone());
        filters.add(filter);
    }
    return queryFactory.createQuery(queryFactory.createAnd((List) filters));
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ArrayList(java.util.ArrayList) PageForgotPassword(com.evolveum.midpoint.web.page.forgetpassword.PageForgotPassword) RestartResponseException(org.apache.wicket.RestartResponseException) EqualFilter(com.evolveum.midpoint.prism.query.EqualFilter) ArrayList(java.util.ArrayList) List(java.util.List) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 60 with RestartResponseException

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

the class PageAuthenticationBase method initSelfRegistrationConfiguration.

private void initSelfRegistrationConfiguration() {
    SecurityPolicyType securityPolicy = resolveSecurityPolicy();
    this.selfRegistrationDto = new SelfRegistrationDto();
    try {
        this.selfRegistrationDto.initSelfRegistrationDto(securityPolicy);
    } catch (SchemaException e) {
        LOGGER.error("Failed to initialize self registration configuration.", e);
        getSession().error(createStringResource("PageSelfRegistration.selfRegistration.configuration.init.failed").getString());
        throw new RestartResponseException(PageLogin.class);
    }
}
Also used : RestartResponseException(org.apache.wicket.RestartResponseException) SecurityPolicyType(com.evolveum.midpoint.xml.ns._public.common.common_3.SecurityPolicyType)

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