Search in sources :

Example 76 with OperationResult

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

the class AuditEventRecordProvider method internalSize.

protected int internalSize() {
    String query = generateFullQuery(AUDIT_RECORDS_QUERY_COUNT + auditEventQuery, false, true);
    long count;
    try {
        count = getAuditService().countObjects(query, parameters, new OperationResult("internalSize"));
    } catch (SecurityViolationException | SchemaException e) {
        // TODO: proper error handling (MID-3536)
        throw new SystemException(e.getMessage(), e);
    }
    int providerSize = ((Long) count).intValue();
    return !exportSize ? providerSize : (providerSize < MAX_EXPORT_ROWS_COUNT ? providerSize : MAX_EXPORT_ROWS_COUNT);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 77 with OperationResult

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

the class PageResources method deleteResourceConfirmedPerformed.

private void deleteResourceConfirmedPerformed(AjaxRequestTarget target) {
    List<ResourceType> selected = new ArrayList<>();
    if (singleDelete != null) {
        selected.add(singleDelete);
    } else {
        selected = getResourceTable().getSelectedObjects();
    }
    OperationResult result = new OperationResult(OPERATION_DELETE_RESOURCES);
    for (ResourceType resource : selected) {
        try {
            Task task = createSimpleTask(OPERATION_DELETE_RESOURCES);
            ObjectDelta<ResourceType> delta = ObjectDelta.createDeleteDelta(ResourceType.class, resource.getOid(), getPrismContext());
            getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
        } catch (Exception ex) {
            result.recordPartialError("Couldn't delete resource.", ex);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete resource", ex);
        }
    }
    result.recomputeStatus();
    if (result.isSuccess()) {
        result.recordStatus(OperationResultStatus.SUCCESS, "The resource(s) have been successfully deleted.");
    }
    getResourceTable().clearCache();
    showResult(result);
    target.add(getFeedbackPanel(), (Component) getResourceTable());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 78 with OperationResult

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

the class PageAccount method savePerformed.

private void savePerformed(AjaxRequestTarget target) {
    LOGGER.debug("Saving account changes.");
    OperationResult result = new OperationResult(OPERATION_SAVE_ACCOUNT);
    try {
        WebComponentUtil.revive(accountModel, getPrismContext());
        ObjectWrapper wrapper = accountModel.getObject();
        ObjectDelta<ShadowType> delta = wrapper.getObjectDelta();
        if (delta == null) {
            return;
        }
        if (delta.getPrismContext() == null) {
            getPrismContext().adopt(delta);
        }
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Account delta computed from form:\n{}", new Object[] { delta.debugDump(3) });
        }
        if (delta.isEmpty()) {
            return;
        }
        WebComponentUtil.encryptCredentials(delta, true, getMidpointApplication());
        Task task = createSimpleTask(OPERATION_SAVE_ACCOUNT);
        Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
        deltas.add(delta);
        getModelService().executeChanges(deltas, null, task, result);
        result.recomputeStatus();
    } catch (Exception ex) {
        result.recordFatalError("Couldn't save account.", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save account", ex);
    }
    if (!result.isSuccess()) {
        showResult(result);
        target.add(getFeedbackPanel());
    } else {
        showResult(result);
        redirectBack();
    }
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ObjectWrapper(com.evolveum.midpoint.web.component.prism.ObjectWrapper) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) RestartResponseException(org.apache.wicket.RestartResponseException)

Example 79 with OperationResult

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

the class ResourceContentRepositoryPanel method createTotalsModel.

private LoadableModel<Integer> createTotalsModel(final SynchronizationSituationType situation) {
    return new LoadableModel<Integer>(false) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Integer load() {
            ObjectFilter resourceFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_RESOURCE_REF).ref(ResourceContentRepositoryPanel.this.getResourceModel().getObject().getOid()).buildFilter();
            if (resourceFilter == null) {
                return 0;
            }
            ObjectFilter filter = createQuery().getFilter();
            if (filter == null) {
                return 0;
            }
            Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createRaw());
            Task task = getPageBase().createSimpleTask(OPERATION_GET_TOTALS);
            OperationResult result = new OperationResult(OPERATION_GET_TOTALS);
            try {
                ObjectFilter situationFilter = QueryBuilder.queryFor(ShadowType.class, getPageBase().getPrismContext()).item(ShadowType.F_SYNCHRONIZATION_SITUATION).eq(situation).buildFilter();
                ObjectQuery query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filter, situationFilter));
                return getPageBase().getModelService().countObjects(ShadowType.class, query, options, task, result);
            } catch (CommonException | RuntimeException ex) {
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count shadows", ex);
            }
            return 0;
        }
    };
}
Also used : Task(com.evolveum.midpoint.task.api.Task) SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 80 with OperationResult

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

the class TestUtil method assertSuccess.

public static void assertSuccess(String message, OperationResult result, OperationResult originalResult, int stopLevel, int currentLevel, boolean warningOk) {
    if (!checkResults) {
        return;
    }
    if (result.getStatus() == null || result.getStatus().equals(OperationResultStatus.UNKNOWN)) {
        String logmsg = message + ": undefined status (" + result.getStatus() + ") on operation " + result.getOperation();
        LOGGER.error(logmsg);
        LOGGER.trace(logmsg + "\n" + originalResult.debugDump());
        System.out.println(logmsg + "\n" + originalResult.debugDump());
        fail(logmsg);
    }
    if (result.isHandledError()) {
        // There may be errors deeper in this result, even fatal errors. that's ok, we can ignore them.
        return;
    } else if (result.isSuccess() || result.isNotApplicable()) {
    // OK ... expected error is as good as success
    } else if (warningOk && result.getStatus() == OperationResultStatus.WARNING) {
    // OK
    } else {
        String logmsg = message + ": " + result.getStatus() + ": " + result.getMessage();
        LOGGER.error(logmsg);
        LOGGER.trace(logmsg + "\n" + originalResult.debugDump());
        System.out.println(logmsg + "\n" + originalResult.debugDump());
        assert false : logmsg;
    }
    if (stopLevel == currentLevel) {
        return;
    }
    List<OperationResult> partialResults = result.getSubresults();
    for (OperationResult subResult : partialResults) {
        assertSuccess(message, subResult, originalResult, stopLevel, currentLevel + 1, warningOk);
    }
}
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