use of com.evolveum.midpoint.ninja.impl.NinjaException 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.impl.NinjaException 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();
}
}
}
}
use of com.evolveum.midpoint.ninja.impl.NinjaException in project midpoint by Evolveum.
the class ImportProducerWorker method openInputStream.
private InputStream openInputStream() throws IOException {
File input = options.getInput();
InputStream is;
if (input != null) {
if (!input.exists()) {
throw new NinjaException("Import file '" + input.getPath() + "' doesn't exist");
}
is = new FileInputStream(input);
} else {
is = System.in;
}
return is;
}
Aggregations