Skip to content

Commit

Permalink
MID-7913: Audit Import should use compat mode
Browse files Browse the repository at this point in the history
Because audit import may be importing old legacy data, compat
parser mode should be enabled to preserve that data and do not
fail on them.
  • Loading branch information
tonydamage committed May 2, 2022
1 parent e850457 commit a17f354
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private ImportProducerWorker<AuditEventRecordType> importByFilter(
BlockingQueue<AuditEventRecordType> queue, OperationStatus status) {
ImportProducerWorker ret = new ImportProducerWorker<>(context, options, queue, status, filter, stopAfterFound, false);
ret.setConvertMissingType(true);
ret.setCompatMode(true);
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ImportProducerWorker<T extends Containerable>

private String currentOid = null;
private boolean convertMissingType = false;
private boolean compatMode = false;

public ImportProducerWorker(
NinjaContext context, BasicImportOptions options, BlockingQueue<T> queue,
Expand Down Expand Up @@ -162,14 +163,12 @@ public void handleGlobalError(OperationResult currentResult, Exception cause) {
// Should we log error?
operation.incrementError();
String message = getErrorMessage();
if (continueOnInputError) {

if (context.isVerbose()) {
context.getLog().error(message, cause);
} else {
context.getLog().error(message + ", reason: {}", cause.getMessage());
}
if (context.isVerbose()) {
context.getLog().error(message, cause);
} else {
context.getLog().error(message + ", reason: {}", cause.getMessage());
}
if (!continueOnInputError) {
// We need to throw runtime exception in order to stop validator, otherwise validator will continue
// fill queue and this may result in deadlock
operation.finish();
Expand All @@ -181,6 +180,7 @@ public void handleGlobalError(OperationResult currentResult, Exception cause) {
// FIXME: MID-5151: If validateSchema is false we are not validating unknown attributes on import
LegacyValidator<?> validator = new LegacyValidator<>(prismContext, handler);
validator.setValidateSchema(false);
validator.setCompatMode(compatMode);
validator.setConvertMissingType(isConvertMissingType());
OperationResult result = operation.getResult();

Expand Down Expand Up @@ -218,4 +218,8 @@ public boolean isConvertMissingType() {
public void setConvertMissingType(boolean convertMissingType) {
this.convertMissingType = convertMissingType;
}

public void setCompatMode(boolean mode) {
this.compatMode = mode;
}
}

0 comments on commit a17f354

Please sign in to comment.