-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
These options drive the whole "test resource" operation. Their use further streamlines the implementation and the API as well. Work in progress.
- Loading branch information
Showing
9 changed files
with
475 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
...sioning-api/src/main/java/com/evolveum/midpoint/provisioning/api/ResourceTestOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
package com.evolveum.midpoint.provisioning.api; | ||
|
||
import com.evolveum.midpoint.schema.AbstractOptions; | ||
import com.evolveum.midpoint.schema.result.OperationResult; | ||
import com.evolveum.midpoint.task.api.Task; | ||
import com.evolveum.midpoint.util.ShortDumpable; | ||
|
||
import java.io.Serializable; | ||
|
||
import static com.evolveum.midpoint.util.MiscUtil.stateCheck; | ||
|
||
/** | ||
* Options for {@link ProvisioningService#testResource(String, Task, OperationResult)} operation. | ||
*/ | ||
public class ResourceTestOptions extends AbstractOptions implements Serializable, Cloneable, ShortDumpable { | ||
|
||
/** Full or basic? */ | ||
private final TestMode testMode; | ||
|
||
/** Whether to update cached (in-definition) capabilities and schema. */ | ||
private final ResourceCompletionMode resourceCompletionMode; | ||
|
||
/** | ||
* If `true`, object in repository is not updated (not even by state change messages). | ||
* | ||
* The default is `false` for resources with non-null OID. | ||
*/ | ||
private final Boolean skipRepositoryUpdates; | ||
|
||
/** | ||
* If `true`, object in memory is not updated (not even by state change messages). | ||
* | ||
* The default is `false` for resources with null OID. | ||
*/ | ||
private final Boolean skipInMemoryUpdates; | ||
|
||
public static final ResourceTestOptions DEFAULT = new ResourceTestOptions(); | ||
|
||
public ResourceTestOptions() { | ||
this(null, null, null, null); | ||
} | ||
|
||
public ResourceTestOptions( | ||
TestMode testMode, | ||
ResourceCompletionMode resourceCompletionMode, | ||
Boolean skipRepositoryUpdates, | ||
Boolean skipInMemoryUpdates) { | ||
this.testMode = testMode; | ||
this.resourceCompletionMode = resourceCompletionMode; | ||
this.skipRepositoryUpdates = skipRepositoryUpdates; | ||
this.skipInMemoryUpdates = skipInMemoryUpdates; | ||
} | ||
|
||
public TestMode getTestMode() { | ||
return testMode; | ||
} | ||
|
||
public ResourceTestOptions testMode(TestMode testMode) { | ||
return new ResourceTestOptions(testMode, resourceCompletionMode, skipRepositoryUpdates, skipInMemoryUpdates); | ||
} | ||
|
||
public static ResourceTestOptions basic() { | ||
return new ResourceTestOptions().testMode(TestMode.BASIC); | ||
} | ||
|
||
public boolean isFullMode() { | ||
return testMode == null || testMode == TestMode.FULL; | ||
} | ||
|
||
public ResourceCompletionMode getResourceCompletionMode() { | ||
return resourceCompletionMode; | ||
} | ||
|
||
public ResourceTestOptions resourceCompletionMode(ResourceCompletionMode resourceCompletionMode) { | ||
return new ResourceTestOptions(testMode, resourceCompletionMode, skipRepositoryUpdates, skipInMemoryUpdates); | ||
} | ||
|
||
public Boolean isSkipRepositoryUpdates() { | ||
return skipRepositoryUpdates; | ||
} | ||
|
||
public ResourceTestOptions skipRepositoryUpdates(Boolean skipRepositoryUpdates) { | ||
return new ResourceTestOptions(testMode, resourceCompletionMode, skipRepositoryUpdates, skipInMemoryUpdates); | ||
} | ||
|
||
public Boolean isSkipInMemoryUpdates() { | ||
return skipInMemoryUpdates; | ||
} | ||
|
||
public ResourceTestOptions skipInMemoryUpdates(Boolean skipInMemoryUpdates) { | ||
return new ResourceTestOptions(testMode, resourceCompletionMode, skipRepositoryUpdates, skipInMemoryUpdates); | ||
} | ||
|
||
@Override | ||
public ResourceTestOptions clone() { | ||
try { | ||
return (ResourceTestOptions) super.clone(); | ||
} catch (CloneNotSupportedException e) { | ||
throw new AssertionError(); | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder("RepoAddOptions("); | ||
shortDump(sb); | ||
sb.append(")"); | ||
return sb.toString(); | ||
} | ||
|
||
@Override | ||
public void shortDump(StringBuilder sb) { | ||
appendVal(sb, "testMode", testMode); | ||
appendVal(sb, "resourceCompletionMode", resourceCompletionMode); | ||
appendFlag(sb, "skipRepositoryUpdates", skipRepositoryUpdates); | ||
appendFlag(sb, "skipInMemoryUpdates", skipInMemoryUpdates); | ||
removeLastComma(sb); | ||
} | ||
|
||
/** Checks we leave nothing set to default. */ | ||
public void checkAllValuesSet() { | ||
stateCheck(testMode != null, "Test mode not set in %s", this); | ||
stateCheck(resourceCompletionMode != null, "Completion mode not set in %s", this); | ||
stateCheck(skipRepositoryUpdates != null, "Repository updates not set in %s", this); | ||
stateCheck(skipInMemoryUpdates != null, "In memory updates not set in %s", this); | ||
} | ||
|
||
public enum TestMode { | ||
/** | ||
* Traditional (full) test. This is the default. | ||
*/ | ||
FULL, | ||
|
||
/** | ||
* Only the basic connectivity on the main connector is tested. Corresponds to "testPartialConfiguration" method. | ||
* Resource in repository is never updated in this mode. Resource is never completed. (Attempt to set these | ||
* options to enable this behavior leads to a failure.) In-memory updates are disabled by default, but can be | ||
* enabled. | ||
*/ | ||
BASIC | ||
} | ||
|
||
/** Whether capabilities and schema should be written back to the resource (into repository or in-memory version). */ | ||
public enum ResourceCompletionMode { | ||
|
||
/** Never do the completion. */ | ||
NEVER, | ||
|
||
/** | ||
* Complete the resource if it's not complete. This updates both capabilities and schema | ||
* if either one of them is missing. This is the legacy (pre-4.6) behavior, and is currently | ||
* the default when repository update is carried out. TODO determine for in-memory updates only. | ||
*/ | ||
IF_NOT_COMPLETE, | ||
|
||
/** Always updates capabilities and schema. */ | ||
ALWAYS | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.