Search in sources :

Example 1 with TaskManager

use of com.evolveum.midpoint.task.api.TaskManager in project midpoint by Evolveum.

the class TaskCurrentStateDtoModel method refresh.

public void refresh(PageBase page) {
    object = null;
    if (taskModel == null || taskModel.getObject() == null) {
        LOGGER.warn("Null or empty taskModel");
        return;
    }
    TaskManager taskManager = page.getTaskManager();
    OperationResult result = new OperationResult("refresh");
    Task operationTask = taskManager.createTaskInstance("refresh");
    String oid = taskModel.getObject().getOid();
    try {
        LOGGER.debug("Refreshing task {}", taskModel.getObject());
        Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.createRetrieveAttributesOptions(TaskType.F_SUBTASK, TaskType.F_NODE_AS_OBSERVED);
        PrismObject<TaskType> task = page.getModelService().getObject(TaskType.class, oid, options, operationTask, result);
        TaskDto taskDto = new TaskDto(task.asObjectable(), page.getModelService(), page.getTaskService(), page.getModelInteractionService(), taskManager, page.getWorkflowManager(), TaskDtoProviderOptions.fullOptions(), operationTask, result, page);
        taskModel.setObject(taskDto);
    } catch (CommunicationException | ObjectNotFoundException | SchemaException | SecurityViolationException | ConfigurationException | ExpressionEvaluationException | RuntimeException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, taskModel.getObject());
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskManager(com.evolveum.midpoint.task.api.TaskManager) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 2 with TaskManager

use of com.evolveum.midpoint.task.api.TaskManager in project midpoint by Evolveum.

the class PageTaskEdit method refreshTaskModels.

public void refreshTaskModels() {
    TaskDto oldTaskDto = taskDtoModel.getObject();
    if (oldTaskDto == null) {
        LOGGER.warn("Null or empty taskModel");
        return;
    }
    TaskManager taskManager = getTaskManager();
    OperationResult result = new OperationResult("refresh");
    Task operationTask = taskManager.createTaskInstance("refresh");
    try {
        LOGGER.debug("Refreshing task {}", oldTaskDto);
        TaskType taskType = loadTaskType(oldTaskDto.getOid(), operationTask, result);
        TaskDto newTaskDto = prepareTaskDto(taskType, operationTask, result);
        final ObjectWrapper<TaskType> newWrapper = loadObjectWrapper(taskType.asPrismObject(), operationTask, result);
        previousTaskDto = currentTaskDto;
        currentTaskDto = newTaskDto;
        taskDtoModel.setObject(newTaskDto);
        objectWrapperModel.setObject(newWrapper);
    } catch (ObjectNotFoundException | SchemaException | ExpressionEvaluationException | RuntimeException | Error e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, oldTaskDto);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) TaskManager(com.evolveum.midpoint.task.api.TaskManager) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) TaskDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)

Example 3 with TaskManager

use of com.evolveum.midpoint.task.api.TaskManager in project midpoint by Evolveum.

the class PageAbout method reindexRepositoryObjectsPerformed.

private void reindexRepositoryObjectsPerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_SUBMIT_REINDEX);
    try {
        TaskManager taskManager = getTaskManager();
        Task task = taskManager.createTaskInstance();
        MidPointPrincipal user = SecurityUtils.getPrincipalUser();
        if (user == null) {
            throw new RestartResponseException(PageLogin.class);
        } else {
            task.setOwner(user.getUser().asPrismObject());
        }
        getSecurityEnforcer().authorize(AuthorizationConstants.AUTZ_ALL_URL, null, null, null, null, null, result);
        task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
        task.setHandlerUri(ModelPublicConstants.REINDEX_TASK_HANDLER_URI);
        task.setName("Reindex repository objects");
        taskManager.switchToBackground(task, result);
        result.setBackgroundTaskOid(task.getOid());
    } catch (SecurityViolationException | SchemaException | RuntimeException e) {
        result.recordFatalError(e);
    } finally {
        result.computeStatusIfUnknown();
    }
    showResult(result);
    target.add(getFeedbackPanel());
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) TaskManager(com.evolveum.midpoint.task.api.TaskManager) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) RestartResponseException(org.apache.wicket.RestartResponseException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal)

Example 4 with TaskManager

use of com.evolveum.midpoint.task.api.TaskManager in project midpoint by Evolveum.

the class PageBase method createAnonymousTask.

public Task createAnonymousTask(String operation) {
    TaskManager manager = getTaskManager();
    Task task = manager.createTaskInstance(operation);
    task.setChannel(SchemaConstants.CHANNEL_GUI_USER_URI);
    return task;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskManager(com.evolveum.midpoint.task.api.TaskManager)

Example 5 with TaskManager

use of com.evolveum.midpoint.task.api.TaskManager in project midpoint by Evolveum.

the class PageDebugList method deleteObjectsAsync.

private String deleteObjectsAsync(QName type, ObjectQuery objectQuery, boolean raw, String taskName, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    Task task = createSimpleTask(result.getOperation());
    task.setHandlerUri(ModelPublicConstants.DELETE_TASK_HANDLER_URI);
    if (objectQuery == null) {
        objectQuery = new ObjectQuery();
    }
    QueryType query = QueryJaxbConvertor.createQueryType(objectQuery, getPrismContext());
    PrismPropertyDefinition queryDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY, QueryType.COMPLEX_TYPE, getPrismContext());
    PrismProperty<QueryType> queryProp = queryDef.instantiate();
    queryProp.setRealValue(query);
    task.setExtensionProperty(queryProp);
    PrismPropertyDefinition typeDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE, DOMUtil.XSD_QNAME, getPrismContext());
    PrismProperty<QName> typeProp = typeDef.instantiate();
    typeProp.setRealValue(type);
    task.setExtensionProperty(typeProp);
    PrismPropertyDefinition rawDef = new PrismPropertyDefinitionImpl(SchemaConstants.MODEL_EXTENSION_OPTION_RAW, DOMUtil.XSD_BOOLEAN, getPrismContext());
    PrismProperty<QName> rawProp = rawDef.instantiate();
    rawProp.setRealValue(raw);
    task.setExtensionProperty(rawProp);
    task.setName(taskName);
    task.savePendingModifications(result);
    TaskManager taskManager = getTaskManager();
    taskManager.switchToBackground(task, result);
    result.setBackgroundTaskOid(task.getOid());
    return task.getOid();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) TaskManager(com.evolveum.midpoint.task.api.TaskManager) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType)

Aggregations

Task (com.evolveum.midpoint.task.api.Task)5 TaskManager (com.evolveum.midpoint.task.api.TaskManager)5 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)1 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)1 TaskDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskDto)1 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)1 QName (javax.xml.namespace.QName)1 RestartResponseException (org.apache.wicket.RestartResponseException)1