Search in sources :

Example 81 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class Clockwork method recordOperationExecution.

private <F extends ObjectType> void recordOperationExecution(PrismObject<F> object, boolean deletedOk, List<LensObjectDeltaOperation<F>> executedDeltas, XMLGregorianCalendar now, String channel, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    OperationExecutionType operation = new OperationExecutionType(prismContext);
    OperationResult summaryResult = new OperationResult("dummy");
    String oid = object.getOid();
    for (LensObjectDeltaOperation<F> deltaOperation : executedDeltas) {
        operation.getOperation().add(createObjectDeltaOperation(deltaOperation));
        if (deltaOperation.getExecutionResult() != null) {
            summaryResult.addSubresult(deltaOperation.getExecutionResult());
        }
        if (oid == null && deltaOperation.getObjectDelta() != null) {
            oid = deltaOperation.getObjectDelta().getOid();
        }
    }
    if (oid == null) {
        // e.g. if there is an exception in provisioning.addObject method
        return;
    }
    summaryResult.computeStatus();
    OperationResultStatusType overallStatus = summaryResult.getStatus().createStatusType();
    setOperationContext(operation, overallStatus, now, channel, task);
    storeOperationExecution(object, oid, operation, deletedOk, result);
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 82 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class LensContext method fromLensContextType.

@SuppressWarnings({ "unchecked", "raw" })
public static LensContext fromLensContextType(LensContextType lensContextType, PrismContext prismContext, ProvisioningService provisioningService, Task task, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException {
    OperationResult result = parentResult.createSubresult(DOT_CLASS + "fromLensContextType");
    String focusClassString = lensContextType.getFocusClass();
    if (StringUtils.isEmpty(focusClassString)) {
        throw new SystemException("Focus class is undefined in LensContextType");
    }
    LensContext lensContext;
    try {
        lensContext = new LensContext(Class.forName(focusClassString), prismContext, provisioningService);
    } catch (ClassNotFoundException e) {
        throw new SystemException("Couldn't instantiate LensContext because focus or projection class couldn't be found", e);
    }
    lensContext.setState(ModelState.fromModelStateType(lensContextType.getState()));
    lensContext.setChannel(lensContextType.getChannel());
    lensContext.setFocusContext(LensFocusContext.fromLensFocusContextType(lensContextType.getFocusContext(), lensContext, task, result));
    for (LensProjectionContextType lensProjectionContextType : lensContextType.getProjectionContext()) {
        lensContext.addProjectionContext(LensProjectionContext.fromLensProjectionContextType(lensProjectionContextType, lensContext, task, result));
    }
    lensContext.setDoReconciliationForAllProjections(lensContextType.isDoReconciliationForAllProjections() != null ? lensContextType.isDoReconciliationForAllProjections() : false);
    lensContext.setExecutionPhaseOnly(lensContextType.isExecutionPhaseOnly() != null ? lensContextType.isExecutionPhaseOnly() : false);
    lensContext.setProjectionWave(lensContextType.getProjectionWave() != null ? lensContextType.getProjectionWave() : 0);
    lensContext.setExecutionWave(lensContextType.getExecutionWave() != null ? lensContextType.getExecutionWave() : 0);
    lensContext.setOptions(ModelExecuteOptions.fromModelExecutionOptionsType(lensContextType.getOptions()));
    if (lensContextType.isLazyAuditRequest() != null) {
        lensContext.setLazyAuditRequest(lensContextType.isLazyAuditRequest());
    }
    if (lensContextType.isRequestAudited() != null) {
        lensContext.setRequestAudited(lensContextType.isRequestAudited());
    }
    if (lensContextType.isExecutionAudited() != null) {
        lensContext.setExecutionAudited(lensContextType.isExecutionAudited());
    }
    lensContext.setRequestAuthorized(Boolean.TRUE.equals(lensContextType.isRequestAuthorized()));
    lensContext.setStats(lensContextType.getStats());
    lensContext.setRequestMetadata(lensContextType.getRequestMetadata());
    for (LensObjectDeltaOperationType eDeltaOperationType : lensContextType.getRottenExecutedDeltas()) {
        LensObjectDeltaOperation objectDeltaOperation = LensObjectDeltaOperation.fromLensObjectDeltaOperationType(eDeltaOperationType, lensContext.getPrismContext());
        if (objectDeltaOperation.getObjectDelta() != null) {
            lensContext.fixProvisioningTypeInDelta(objectDeltaOperation.getObjectDelta(), task, result);
        }
        lensContext.rottenExecutedDeltas.add(objectDeltaOperation);
    }
    if (result.isUnknown()) {
        result.computeStatus();
    }
    return lensContext;
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 83 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class PageTasks method synchronizeTasksPerformed.

private void synchronizeTasksPerformed(AjaxRequestTarget target) {
    OperationResult result = new OperationResult(OPERATION_SYNCHRONIZE_TASKS);
    try {
        getTaskService().synchronizeTasks(result);
        result.computeStatus();
        if (result.isSuccess()) {
            // brutal hack - the subresult's message contains statistics
            result.recordStatus(OperationResultStatus.SUCCESS, result.getLastSubresult().getMessage());
        }
    } catch (RuntimeException | SchemaException | SecurityViolationException e) {
        result.recordFatalError("Couldn't synchronize tasks", e);
    }
    showResult(result);
    //refresh feedback and table
    refreshTables(target);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 84 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class PageTasks method deleteNodesPerformed.

private void deleteNodesPerformed(AjaxRequestTarget target, List<NodeDto> nodes) {
    OperationResult result = new OperationResult(OPERATION_DELETE_NODES);
    Task task = createSimpleTask(OPERATION_DELETE_NODES);
    for (NodeDto nodeDto : nodes) {
        Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
        deltas.add(ObjectDelta.createDeleteDelta(NodeType.class, nodeDto.getOid(), getPrismContext()));
        try {
            getModelService().executeChanges(deltas, null, task, result);
        } catch (Exception e) {
            // until java 7 we do it in this way
            result.recordFatalError("Couldn't delete the node " + nodeDto.getNodeIdentifier(), e);
        }
    }
    result.computeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, "Selected node(s) have been successfully deleted.");
    }
    showResult(result);
    NodeDtoProvider provider = (NodeDtoProvider) getNodeTable().getDataTable().getDataProvider();
    provider.clearCache();
    //refresh feedback and table
    refreshTables(target);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException)

Example 85 with OperationResult

use of com.evolveum.midpoint.schema.result.OperationResult in project midpoint by Evolveum.

the class CertificationManagerImpl method closeCampaign.

@Override
public void closeCampaign(String campaignOid, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, SecurityViolationException, ObjectAlreadyExistsException {
    Validate.notNull(campaignOid, "campaignOid");
    Validate.notNull(task, "task");
    Validate.notNull(parentResult, "parentResult");
    OperationResult result = parentResult.createSubresult(OPERATION_CLOSE_CAMPAIGN);
    try {
        AccessCertificationCampaignType campaign = generalHelper.getCampaign(campaignOid, null, task, result);
        securityEnforcer.authorize(ModelAuthorizationAction.CLOSE_CERTIFICATION_CAMPAIGN.getUrl(), null, campaign.asPrismObject(), null, null, null, result);
        updateHelper.closeCampaign(campaign, task, result);
    } catch (RuntimeException e) {
        result.recordFatalError("Couldn't close certification campaign: unexpected exception: " + e.getMessage(), e);
        throw e;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3475 Test (org.testng.annotations.Test)2435 Task (com.evolveum.midpoint.task.api.Task)2390 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1059 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)725 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)637 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)414 PrismObject (com.evolveum.midpoint.prism.PrismObject)388 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)376 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)320 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)288 ArrayList (java.util.ArrayList)262 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)252 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)250 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)231 QName (javax.xml.namespace.QName)198 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)197 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)182 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)171 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)149