Search in sources :

Example 71 with RestartResponseException

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

the class ContainerListDataProvider method internalSize.

@Override
protected int internalSize() {
    LOGGER.trace("begin::internalSize()");
    int count = 0;
    OperationResult result = new OperationResult(OPERATION_COUNT_CONTAINERS);
    try {
        count = WebModelServiceUtils.countContainers(getType(), getQuery(), options, getPageBase());
    } catch (Exception ex) {
        result.recordFatalError(getPageBase().createStringResource("ContainerListDataProvider.message.listContainers.fatalError").getString(), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count containers", ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (!WebComponentUtil.isSuccessOrHandledError(result)) {
        getPageBase().showResult(result);
        return 0;
    // throw new RestartResponseException(PageError.class);
    }
    LOGGER.trace("end::internalSize(): {}", count);
    return count;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 72 with RestartResponseException

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

the class ProgressPanel method executeChangesInBackground.

public void executeChangesInBackground(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ModelExecuteOptions options, Task task, OperationResult result, AjaxRequestTarget target) {
    PageBase page = getPageBase();
    ProgressReporter reporter = reporterModel.getProcessData();
    try {
        TaskManager taskManager = page.getTaskManager();
        MidPointPrincipal user = AuthUtil.getPrincipalUser();
        if (user == null) {
            throw new RestartResponseException(PageLogin.class);
        } else {
            task.setOwner(user.getFocus().asPrismObject());
        }
        task.setRootActivityDefinition(createNonIterativeChangeExecutionDef(deltas, toModelExecutionOptionsBean(options)));
        task.setChannel(SchemaConstants.CHANNEL_USER_URI);
        task.setName("Execute changes");
        task.setInitiallyRunnable();
        PrismObject<TaskType> taskType = task.getUpdatedTaskObject();
        AssignmentType archetypeAssignment = new AssignmentType();
        archetypeAssignment.setTargetRef(ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value(), ObjectTypes.ARCHETYPE));
        taskType.asObjectable().getAssignment().add(archetypeAssignment);
        taskType.asObjectable().getArchetypeRef().add(ObjectTypeUtil.createObjectRef(SystemObjectsType.ARCHETYPE_UTILITY_TASK.value(), ObjectTypes.ARCHETYPE));
        taskManager.switchToBackground(task, result);
        result.setBackgroundTaskOid(task.getOid());
    } catch (Exception e) {
        result.recordFatalError(e);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (page instanceof ProgressReportingAwarePage) {
        ProgressReportingAwarePage aware = (ProgressReportingAwarePage) page;
        aware.finishProcessing(target, reporter.getObjectDeltaOperation(), reporter.isAsynchronousExecution(), result);
    }
}
Also used : TaskManager(com.evolveum.midpoint.task.api.TaskManager) RestartResponseException(org.apache.wicket.RestartResponseException) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) RestartResponseException(org.apache.wicket.RestartResponseException) CommonException(com.evolveum.midpoint.util.exception.CommonException) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 73 with RestartResponseException

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

the class DynamicFieldGroupPanel method findItemWrapper.

@NotNull
private ItemWrapper<?, ?> findItemWrapper(AbstractFormItemType formField, PrismObjectWrapper<O> objectWrapper) {
    ItemPath path = GuiImplUtil.getItemPath(formField);
    if (path == null) {
        getSession().error("Bad form item definition. It has to contain reference to the real attribute");
        LOGGER.error("Bad form item definition. It has to contain reference to the real attribute");
        throw new RestartResponseException(getPageBase());
    }
    ItemWrapper<?, ?> itemWrapper;
    try {
        itemWrapper = objectWrapper.findItem(path, ItemWrapper.class);
    } catch (SchemaException e) {
        getSession().error("Bad form item definition. No attribute with path: " + path + " was found");
        LOGGER.error("Bad form item definition. No attribute with path: " + path + " was found");
        throw new RestartResponseException(getPageBase());
    }
    if (itemWrapper == null) {
        getSession().error("Bad form item definition. No attribute with path: " + path + " was found");
        LOGGER.error("Bad form item definition. No attribute with path: " + path + " was found");
        throw new RestartResponseException(getPageBase());
    }
    return itemWrapper;
}
Also used : ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) NotNull(org.jetbrains.annotations.NotNull)

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