Skip to content

Commit

Permalink
Consistency update: core part of the rework done (MID-3603)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 20, 2018
1 parent 35a5552 commit 62488e5
Show file tree
Hide file tree
Showing 11 changed files with 1,786 additions and 547 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -709,4 +709,20 @@ public static URL toUrlUnchecked(URI uri) {
}
}

public static <T> List<T> join(Collection<T> a, Collection<T> b) {
if (a == null && b == null) {
return new ArrayList<>();
}
if (a == null) {
return new ArrayList<>(b);
}
if (b == null) {
return new ArrayList<>(a);
}
List<T> list = new ArrayList<>(a.size() + b.size());
list.addAll(a);
list.addAll(b);
return list;
}

}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Expand Up @@ -135,7 +135,7 @@ public OperationResultStatus handleAddError(ProvisioningContext ctx,
}

@Override
public void handleModifyError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
public OperationResultStatus handleModifyError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
Collection<? extends ItemDelta> modifications, ProvisioningOperationOptions options,
ProvisioningOperationState<AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>>> opState,
Exception cause, OperationResult failedOperationResult, Task task, OperationResult parentResult)
Expand All @@ -148,18 +148,11 @@ public void handleModifyError(ProvisioningContext ctx, PrismObject<ShadowType> r
ResourceType resource = ctx.getResource();
markResourceDown(resource, result);
handleRetriesAndAttempts(ctx, opState, options, cause, result);
LOGGER.trace("Postponing MODIFY operation for {}: ", repoShadow, modifications);
opState.setExecutionStatus(PendingOperationExecutionStatusType.EXECUTING);
AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>> asyncResult = new AsynchronousOperationReturnValue<>();
asyncResult.setOperationResult(failedOperationResult);
opState.setAsyncResult(asyncResult);
result.recordInProgress();
return postponeModify(ctx, repoShadow, modifications, opState, failedOperationResult, result);
}



@Override
public void handleDeleteError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
public OperationResultStatus handleDeleteError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
ProvisioningOperationOptions options,
ProvisioningOperationState<AsynchronousOperationResult> opState, Exception cause,
OperationResult failedOperationResult, Task task, OperationResult parentResult)
Expand All @@ -171,12 +164,7 @@ public void handleDeleteError(ProvisioningContext ctx, PrismObject<ShadowType> r
ResourceType resource = ctx.getResource();
markResourceDown(resource, result);
handleRetriesAndAttempts(ctx, opState, options, cause, result);
LOGGER.trace("Postponing DELETE operation for {}: ", repoShadow);
opState.setExecutionStatus(PendingOperationExecutionStatusType.EXECUTING);
AsynchronousOperationResult asyncResult = new AsynchronousOperationResult();
asyncResult.setOperationResult(failedOperationResult);
opState.setAsyncResult(asyncResult);
result.recordInProgress();
return postponeDelete(ctx, repoShadow, opState, failedOperationResult, result);
}

private void handleRetriesAndAttempts(ProvisioningContext ctx, ProvisioningOperationState<? extends AsynchronousOperationResult> opState, ProvisioningOperationOptions options, Exception cause, OperationResult result) throws CommunicationException, ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException {
Expand Down
Expand Up @@ -75,7 +75,7 @@ public abstract class ErrorHandler {

@Autowired protected ChangeNotificationDispatcher changeNotificationDispatcher;
@Autowired private ResourceManager resourceManager;
protected PrismContext prismContext;
@Autowired protected PrismContext prismContext;

public abstract PrismObject<ShadowType> handleGetError(ProvisioningContext ctx,
PrismObject<ShadowType> repositoryShadow,
Expand Down Expand Up @@ -117,8 +117,7 @@ protected OperationResultStatus postponeAdd(ProvisioningContext ctx,
return OperationResultStatus.IN_PROGRESS;
}


public abstract void handleModifyError(ProvisioningContext ctx,
public abstract OperationResultStatus handleModifyError(ProvisioningContext ctx,
PrismObject<ShadowType> repoShadow,
Collection<? extends ItemDelta> modifications,
ProvisioningOperationOptions options,
Expand All @@ -130,8 +129,43 @@ public abstract void handleModifyError(ProvisioningContext ctx,
throws SchemaException, GenericFrameworkException, CommunicationException,
ObjectNotFoundException, ObjectAlreadyExistsException, ConfigurationException,
SecurityViolationException, ExpressionEvaluationException;

protected OperationResultStatus postponeModify(ProvisioningContext ctx,
PrismObject<ShadowType> repoShadow,
Collection<? extends ItemDelta> modifications,
ProvisioningOperationState<AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>>> opState,
OperationResult failedOperationResult,
OperationResult result) {
LOGGER.trace("Postponing MODIFY operation for {}", repoShadow);
opState.setExecutionStatus(PendingOperationExecutionStatusType.EXECUTING);
AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>> asyncResult = new AsynchronousOperationReturnValue<>();
asyncResult.setOperationResult(failedOperationResult);
opState.setAsyncResult(asyncResult);
if (opState.getAttemptNumber() == null) {
opState.setAttemptNumber(1);
}
result.recordInProgress();
return OperationResultStatus.IN_PROGRESS;
}

protected OperationResultStatus postponeDelete(ProvisioningContext ctx,
PrismObject<ShadowType> repoShadow,
ProvisioningOperationState<AsynchronousOperationResult> opState,
OperationResult failedOperationResult,
OperationResult result) {
LOGGER.trace("Postponing DELETE operation for {}", repoShadow);
opState.setExecutionStatus(PendingOperationExecutionStatusType.EXECUTING);
AsynchronousOperationResult asyncResult = new AsynchronousOperationResult();
asyncResult.setOperationResult(failedOperationResult);
opState.setAsyncResult(asyncResult);
if (opState.getAttemptNumber() == null) {
opState.setAttemptNumber(1);
}
result.recordInProgress();
return OperationResultStatus.IN_PROGRESS;
}

public abstract void handleDeleteError(ProvisioningContext ctx,
public abstract OperationResultStatus handleDeleteError(ProvisioningContext ctx,
PrismObject<ShadowType> repoShadow,
ProvisioningOperationOptions options,
ProvisioningOperationState<AsynchronousOperationResult> opState,
Expand Down
Expand Up @@ -96,7 +96,7 @@ public OperationResultStatus handleAddError(ProvisioningContext ctx, PrismObject
}

@Override
public void handleModifyError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
public OperationResultStatus handleModifyError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
Collection<? extends ItemDelta> modifications, ProvisioningOperationOptions options,
ProvisioningOperationState<AsynchronousOperationReturnValue<Collection<PropertyDelta<PrismPropertyValue>>>> opState,
Exception cause, OperationResult failedOperationResult, Task task, OperationResult parentResult)
Expand All @@ -105,10 +105,11 @@ public void handleModifyError(ProvisioningContext ctx, PrismObject<ShadowType> r
SecurityViolationException, ExpressionEvaluationException {

throwException(cause, opState, parentResult);
return OperationResultStatus.FATAL_ERROR; // not reached
}

@Override
public void handleDeleteError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
public OperationResultStatus handleDeleteError(ProvisioningContext ctx, PrismObject<ShadowType> repoShadow,
ProvisioningOperationOptions options,
ProvisioningOperationState<AsynchronousOperationResult> opState, Exception cause,
OperationResult failedOperationResult, Task task, OperationResult parentResult)
Expand All @@ -117,6 +118,7 @@ public void handleDeleteError(ProvisioningContext ctx, PrismObject<ShadowType> r
SecurityViolationException, ExpressionEvaluationException {

throwException(cause, opState, parentResult);
return OperationResultStatus.FATAL_ERROR; // not reached
}

}

0 comments on commit 62488e5

Please sign in to comment.