Skip to content

Commit

Permalink
MID-7669: During import of audit enable support for missing legacy types
Browse files Browse the repository at this point in the history
  • Loading branch information
tonydamage committed Mar 9, 2022
1 parent b4e7e28 commit 1a6349b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class LegacyValidator<T extends Containerable> {
private long errors = 0;
private long stopAfterErrors = 0;
private boolean compatMode = false;
private boolean convertMissingType = false;

public LegacyValidator(PrismContext prismContext) {
this.prismContext = prismContext;
Expand Down Expand Up @@ -383,6 +384,9 @@ private EventResult validateObjectInternal(Element objectElement, OperationResul
if (compatMode) {
parser = parser.compat();
}
if (convertMissingType) {
parser = parser.convertMissingTypes();
}
T containerable = parser.parseRealValue();

objectResult.addContext(OperationResult.CONTEXT_OBJECT, containerable.toString());
Expand Down Expand Up @@ -533,4 +537,12 @@ private void error(String message, Objectable object, String propertyName, Opera
subResult.addContext(OperationResult.CONTEXT_ITEM, propertyName);
subResult.recordFatalError("<" + propertyName + ">: " + message);
}

public boolean isConvertMissingType() {
return convertMissingType;
}

public void setConvertMissingType(boolean convertMissingType) {
this.convertMissingType = convertMissingType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public LogTarget getInfoLogTarget() {
private ImportProducerWorker<AuditEventRecordType> importByFilter(
ObjectFilter filter, boolean stopAfterFound,
BlockingQueue<AuditEventRecordType> queue, OperationStatus status) {
return new ImportProducerWorker<>(context, options, queue, status, filter, stopAfterFound, false);
ImportProducerWorker ret = new ImportProducerWorker<>(context, options, queue, status, filter, stopAfterFound, false);
ret.setConvertMissingType(true);
return ret;
}

private List<ImportAuditConsumerWorker> createConsumers(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class ImportProducerWorker<T extends Containerable>
private boolean continueOnInputError;

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

public ImportProducerWorker(
NinjaContext context, BasicImportOptions options, BlockingQueue<T> queue,
Expand Down Expand Up @@ -180,6 +181,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.setConvertMissingType(isConvertMissingType());
OperationResult result = operation.getResult();

Charset charset = context.getCharset();
Expand Down Expand Up @@ -208,4 +210,12 @@ private String getErrorMessage() {
return "Couldn't import object";
}
}

public boolean isConvertMissingType() {
return convertMissingType;
}

public void setConvertMissingType(boolean convertMissingType) {
this.convertMissingType = convertMissingType;
}
}

0 comments on commit 1a6349b

Please sign in to comment.