Skip to content

Commit

Permalink
fixing incorrect behaviour while handling not found error.
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jul 24, 2014
1 parent ff80f2a commit 8bac2c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Expand Up @@ -293,7 +293,11 @@ public <T extends ObjectType> PrismObject<T> getObject(Class<T> 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);
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -468,7 +470,7 @@ public static PrismObject<SystemConfigurationType> getSystemConfiguration(Reposi
PrismObject<SystemConfigurationType> 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
Expand Down
Expand Up @@ -238,7 +238,8 @@ private <T extends ObjectType> PrismObject<T> getObjectAttempt(Class<T> 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: "
Expand Down

0 comments on commit 8bac2c3

Please sign in to comment.