diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java index af7d50ce2e5..1dd55f012f9 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/controller/ModelController.java @@ -293,7 +293,11 @@ public PrismObject getObject(Class clazz, String oi ModelUtils.recordFatalError(result, e); throw e; } catch (ObjectNotFoundException e) { - ModelUtils.recordFatalError(result, e); + if (GetOperationOptions.isAllowNotFound(rootOptions)){ + result.getLastSubresult().setStatus(OperationResultStatus.HANDLED_ERROR); + } else { + ModelUtils.recordFatalError(result, e); + } throw e; } catch (CommunicationException e) { ModelUtils.recordFatalError(result, e); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java index ca06280b947..4d0cbab6d70 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java @@ -52,6 +52,8 @@ import com.evolveum.midpoint.prism.query.QueryJaxbConvertor; import com.evolveum.midpoint.provisioning.api.ProvisioningService; import com.evolveum.midpoint.repo.api.RepositoryService; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.constants.ExpressionConstants; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; @@ -468,7 +470,7 @@ public static PrismObject getSystemConfiguration(Reposi PrismObject systemConfiguration = null; try { systemConfiguration = repositoryService.getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), - null, result); + SelectorOptions.createCollection(GetOperationOptions.createAllowNotFound()), result); } catch (ObjectNotFoundException e) { // just go on ... we will return and continue // This is needed e.g. to set up new system configuration is the old one gets deleted diff --git a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java index 3a46eed00b6..96ae257e639 100644 --- a/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java +++ b/repo/repo-sql-impl/src/main/java/com/evolveum/midpoint/repo/sql/SqlRepositoryServiceImpl.java @@ -238,7 +238,8 @@ private PrismObject getObjectAttempt(Class type, St session.getTransaction().commit(); } catch (ObjectNotFoundException ex) { - rollbackTransaction(session, ex, result, true); + GetOperationOptions rootOptions = SelectorOptions.findRootOptions(options); + rollbackTransaction(session, ex, result, !GetOperationOptions.isAllowNotFound(rootOptions)); throw ex; } catch (SchemaException ex) { rollbackTransaction(session, ex, "Schema error while getting object with oid: "