Search in sources :

Example 21 with ObjectNotFoundException

use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.

the class PageTasks method stopSchedulersPerformed.

private void stopSchedulersPerformed(AjaxRequestTarget target, List<String> identifiers) {
    OperationResult result = new OperationResult(OPERATION_STOP_SCHEDULERS);
    try {
        getTaskService().stopSchedulers(identifiers, result);
        result.computeStatus();
        if (result.isSuccess()) {
            result.recordStatus(OperationResultStatus.SUCCESS, "Selected node scheduler(s) have been successfully stopped.");
        }
    } catch (SecurityViolationException | ObjectNotFoundException | SchemaException | RuntimeException e) {
        result.recordFatalError("Couldn't stop the scheduler(s)", 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) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 22 with ObjectNotFoundException

use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.

the class WebModelServiceUtils method loadObject.

@Nullable
public static <T extends ObjectType> PrismObject<T> loadObject(Class<T> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options, boolean allowNotFound, PageBase page, Task task, OperationResult result) {
    LOGGER.debug("Loading {} with oid {}, options {}", type.getSimpleName(), oid, options);
    OperationResult subResult;
    if (result != null) {
        subResult = result.createMinorSubresult(OPERATION_LOAD_OBJECT);
    } else {
        subResult = new OperationResult(OPERATION_LOAD_OBJECT);
    }
    PrismObject<T> object = null;
    try {
        if (options == null) {
            options = SelectorOptions.createCollection(GetOperationOptions.createResolveNames());
        } else {
            GetOperationOptions getOpts = SelectorOptions.findRootOptions(options);
            if (getOpts == null) {
                options.add(new SelectorOptions<>(GetOperationOptions.createResolveNames()));
            } else {
                getOpts.setResolveNames(Boolean.TRUE);
            }
        }
        object = page.getModelService().getObject(type, oid, options, task, subResult);
    } catch (AuthorizationException e) {
        // Not authorized to access the object. This is probably caused by a reference that
        // point to an object that the current user cannot read. This is no big deal.
        // Just do not display that object.
        subResult.recordHandledError(e);
        LOGGER.debug("User {} is not authorized to read {} {}", task.getOwner() != null ? task.getOwner().getName() : null, type.getSimpleName(), oid);
        return null;
    } catch (ObjectNotFoundException e) {
        if (allowNotFound) {
            // Object does not exist. It was deleted in the meanwhile, or not created yet. This could happen quite often.
            subResult.recordHandledError(e);
            LOGGER.debug("{} {} does not exist", type.getSimpleName(), oid, e);
            return null;
        } else {
            subResult.recordFatalError("WebModelUtils.couldntLoadObject", e);
            LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", e);
        }
    } catch (Exception ex) {
        subResult.recordFatalError("WebModelUtils.couldntLoadObject", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load object", ex);
    } finally {
        subResult.computeStatus();
    }
    // TODO reconsider this part: until recently, the condition was always 'false'
    if (WebComponentUtil.showResultInPage(subResult)) {
        page.showResult(subResult);
    }
    LOGGER.debug("Loaded {} with result {}", object, subResult);
    return object;
}
Also used : GetOperationOptions(com.evolveum.midpoint.schema.GetOperationOptions) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) AuthorizationException(com.evolveum.midpoint.util.exception.AuthorizationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) RestartResponseException(org.apache.wicket.RestartResponseException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) Nullable(org.jetbrains.annotations.Nullable)

Example 23 with ObjectNotFoundException

use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.

the class WebModelServiceUtils method countObjects.

public static <T extends ObjectType> int countObjects(Class<T> type, ObjectQuery query, PageBase page) {
    LOGGER.debug("Count object: type => {}, query => {}", type, query);
    Task task = page.createSimpleTask(OPERATION_COUNT_OBJECT);
    OperationResult parentResult = new OperationResult(OPERATION_COUNT_OBJECT);
    int count = 0;
    try {
        count = page.getModelService().countObjects(type, query, null, task, parentResult);
    } catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | CommunicationException | ExpressionEvaluationException ex) {
        parentResult.recordFatalError("WebModelUtils.couldntCountObjects", ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't count objects", ex);
    }
    LOGGER.debug("Count objects with result {}", new Object[] { parentResult });
    return count;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 24 with ObjectNotFoundException

use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.

the class AssignmentCatalogPanel method getAssignmentConstraints.

private AssignmentConstraintsType getAssignmentConstraints() {
    OperationResult result = new OperationResult(OPERATION_LOAD_ASSIGNMENT_CONSTRAINTS);
    SystemConfigurationType systemConfig = null;
    try {
        systemConfig = pageBase.getModelInteractionService().getSystemConfiguration(result);
    } catch (ObjectNotFoundException | SchemaException e) {
        LOGGER.error("Error getting system configuration: {}", e.getMessage(), e);
        return null;
    }
    if (systemConfig != null && systemConfig.getRoleManagement() != null) {
        return systemConfig.getRoleManagement().getDefaultAssignmentConstraints();
    }
    return null;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 25 with ObjectNotFoundException

use of com.evolveum.midpoint.util.exception.ObjectNotFoundException in project midpoint by Evolveum.

the class PageAccounts method loadShadowOwner.

private <F extends FocusType> F loadShadowOwner(IModel<SelectableBean> model) {
    F owner = null;
    ShadowType shadow = getShadow(model);
    String shadowOid;
    if (shadow != null) {
        shadowOid = shadow.getOid();
    } else {
        return null;
    }
    Task task = createSimpleTask(OPERATION_LOAD_ACCOUNT_OWNER);
    OperationResult result = new OperationResult(OPERATION_LOAD_ACCOUNT_OWNER);
    try {
        PrismObject prismOwner = getModelService().searchShadowOwner(shadowOid, null, task, result);
        if (prismOwner != null) {
            owner = (F) prismOwner.asObjectable();
        }
    } catch (ObjectNotFoundException exception) {
    //owner was not found, it's possible and it's ok on unlinked accounts
    } catch (Exception ex) {
        result.recordFatalError(getString("PageAccounts.message.ownerNotFound", shadowOid), ex);
        LoggingUtils.logUnexpectedException(LOGGER, "Could not load owner of account with oid: " + shadowOid, ex);
    } finally {
        result.computeStatusIfUnknown();
    }
    if (WebComponentUtil.showResultInPage(result)) {
        showResult(result, false);
    }
    return owner;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) RestartResponseException(org.apache.wicket.RestartResponseException) IOException(java.io.IOException) CommonException(com.evolveum.midpoint.util.exception.CommonException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Aggregations

ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)291 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)214 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)200 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)100 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)93 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)90 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)88 Task (com.evolveum.midpoint.task.api.Task)75 SystemException (com.evolveum.midpoint.util.exception.SystemException)71 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)64 PrismObject (com.evolveum.midpoint.prism.PrismObject)52 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)42 Test (org.testng.annotations.Test)40 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38 ArrayList (java.util.ArrayList)35 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)33 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)32 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)30 QName (javax.xml.namespace.QName)29 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)28