use of com.evolveum.midpoint.ninja.util.Log in project midpoint by Evolveum.
the class SearchProducerWorker method run.
@Override
public void run() {
Log log = context.getLog();
try {
GetOperationOptionsBuilder optionsBuilder = context.getSchemaService().getOperationOptionsBuilder();
if (options.isRaw()) {
optionsBuilder = optionsBuilder.raw();
}
optionsBuilder = NinjaUtils.addIncludeOptionsForExport(optionsBuilder, type.getClassDefinition());
ResultHandler<?> handler = (object, parentResult) -> {
try {
queue.put(object.asObjectable());
} catch (InterruptedException ex) {
log.error("Couldn't queue object {}, reason: {}", ex, object, ex.getMessage());
}
return true;
};
RepositoryService repository = context.getRepository();
repository.searchObjectsIterative(type.getClassDefinition(), query, handler, optionsBuilder.build(), true, 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();
}
}
}
}
use of com.evolveum.midpoint.ninja.util.Log in project midpoint by Evolveum.
the class ExportAuditProducerWorker method run.
@Override
public void run() {
Log log = context.getLog();
try {
GetOperationOptionsBuilder optionsBuilder = context.getSchemaService().getOperationOptionsBuilder();
optionsBuilder = NinjaUtils.addIncludeOptionsForExport(optionsBuilder, AuditEventRecordType.class);
AuditResultHandler handler = (object, parentResult) -> {
try {
queue.put(object);
} 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();
}
}
}
}
use of com.evolveum.midpoint.ninja.util.Log in project midpoint by Evolveum.
the class Action method init.
public void init(NinjaContext context, O options) {
this.context = context;
this.options = options;
LogTarget target = getInfoLogTarget();
log = new Log(target, this.context);
this.context.setLog(log);
ConnectionOptions connection = Objects.requireNonNull(NinjaUtils.getOptions(this.context.getJc(), ConnectionOptions.class));
this.context.init(connection);
}
use of com.evolveum.midpoint.ninja.util.Log in project midpoint by Evolveum.
the class AbstractWriterConsumerWorker method run.
@Override
public void run() {
Log log = context.getLog();
// todo handle split option
init();
try (Writer writer = createWriter()) {
while (!shouldConsumerStop()) {
T object = null;
try {
object = queue.poll(CONSUMER_POLL_TIMEOUT, TimeUnit.SECONDS);
if (object == null) {
continue;
}
write(writer, object);
writer.flush();
operation.incrementTotal();
} catch (Exception ex) {
log.error("Couldn't store object {}, reason: {}", ex, object, ex.getMessage());
operation.incrementError();
}
}
finalizeWriter(writer);
} catch (IOException ex) {
log.error("Unexpected exception, reason: {}", ex, ex.getMessage());
} catch (NinjaException ex) {
log.error(ex.getMessage(), ex);
} finally {
markDone();
if (isWorkersDone()) {
operation.finish();
}
}
}
use of com.evolveum.midpoint.ninja.util.Log in project midpoint by Evolveum.
the class ImportProducerWorker method run.
@Override
public void run() {
Log log = context.getLog();
log.info("Starting import");
operation.start();
try (InputStream input = openInputStream()) {
if (!options.isZip()) {
processStream(input);
} else {
ZipInputStream zis = new ZipInputStream(input);
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (entry.isDirectory()) {
continue;
}
if (!StringUtils.endsWith(entry.getName().toLowerCase(), ".xml")) {
continue;
}
log.info("Processing file {}", entry.getName());
processStream(zis);
}
}
} catch (IOException ex) {
log.error("Unexpected error occurred, reason: {}", ex, ex.getMessage());
} catch (NinjaException ex) {
log.error(ex.getMessage(), ex);
} finally {
markDone();
if (isWorkersDone()) {
if (!operation.isFinished()) {
operation.producerFinish();
}
}
}
}
Aggregations