-
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.
# Conflicts: # tools/ninja/src/main/java/com/evolveum/midpoint/ninja/action/worker/AbstractWriterConsumerWorker.java # tools/ninja/src/main/java/com/evolveum/midpoint/ninja/action/worker/ProgressReporterWorker.java
- Loading branch information
Showing
12 changed files
with
494 additions
and
44 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
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
8 changes: 5 additions & 3 deletions
8
tools/ninja/src/main/java/com/evolveum/midpoint/ninja/action/RepositoryAction.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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
/* | ||
* Copyright (c) 2010-2018 Evolveum and contributors | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.ninja.action; | ||
|
||
/** | ||
* Created by Viliam Repan (lazyman). | ||
* Base implementation class for action (Ninja command) running against the repository. | ||
* | ||
* @param <O> options class | ||
*/ | ||
public abstract class RepositoryAction<T> extends Action<T> { | ||
public abstract class RepositoryAction<O> extends Action<O> { | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...nja/src/main/java/com/evolveum/midpoint/ninja/action/audit/AuditExportProducerWorker.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,79 @@ | ||
/* | ||
* Copyright (C) 2010-2021 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
package com.evolveum.midpoint.ninja.action.audit; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.BlockingQueue; | ||
|
||
import com.evolveum.midpoint.audit.api.AuditResultHandler; | ||
import com.evolveum.midpoint.audit.api.AuditService; | ||
import com.evolveum.midpoint.ninja.action.worker.BaseWorker; | ||
import com.evolveum.midpoint.ninja.impl.NinjaContext; | ||
import com.evolveum.midpoint.ninja.impl.NinjaException; | ||
import com.evolveum.midpoint.ninja.opts.ExportOptions; | ||
import com.evolveum.midpoint.ninja.util.Log; | ||
import com.evolveum.midpoint.ninja.util.NinjaUtils; | ||
import com.evolveum.midpoint.ninja.util.OperationStatus; | ||
import com.evolveum.midpoint.prism.query.ObjectQuery; | ||
import com.evolveum.midpoint.schema.GetOperationOptionsBuilder; | ||
import com.evolveum.midpoint.util.exception.SchemaException; | ||
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType; | ||
|
||
/** | ||
* Producer worker for audit export operation. | ||
*/ | ||
public class AuditExportProducerWorker extends BaseWorker<ExportOptions, AuditEventRecordType> { | ||
|
||
private final ObjectQuery query; | ||
|
||
public AuditExportProducerWorker( | ||
NinjaContext context, ExportOptions options, BlockingQueue<AuditEventRecordType> queue, | ||
OperationStatus operation, List<AuditExportProducerWorker> producers, ObjectQuery query) { | ||
super(context, options, queue, operation, producers); | ||
|
||
this.query = query; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
Log log = context.getLog(); | ||
|
||
try { | ||
GetOperationOptionsBuilder optionsBuilder = context.getSchemaService().getOperationOptionsBuilder(); | ||
if (options.isRaw()) { | ||
optionsBuilder = optionsBuilder.raw(); | ||
} | ||
|
||
optionsBuilder = NinjaUtils.addIncludeOptionsForExport(optionsBuilder, AuditEventRecordType.class); | ||
|
||
AuditResultHandler handler = (object, parentResult) -> { | ||
try { | ||
//noinspection unchecked | ||
queue.put(object); // TODO no better way of conversion? | ||
} catch (InterruptedException ex) { | ||
log.error("Couldn't queue object {}, reason: {}", ex, object, ex.getMessage()); | ||
} | ||
return true; | ||
}; | ||
|
||
AuditService auditService = context.getAuditService(); | ||
auditService.searchObjectsIterative(query, handler, optionsBuilder.build(), operation.getResult()); | ||
} catch (SchemaException ex) { | ||
log.error("Unexpected exception, reason: {}", ex, ex.getMessage()); | ||
} catch (NinjaException ex) { | ||
log.error(ex.getMessage(), ex); | ||
} finally { | ||
markDone(); | ||
|
||
if (isWorkersDone()) { | ||
if (!operation.isFinished()) { | ||
operation.producerFinish(); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.