Files in archive order finished
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package me.bearns.fias.helpers;
|
||||
|
||||
import me.bearns.fias.exceptions.UnmarshallingException;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public interface ThrowingBiConsumer<K extends UnmarshallerParameters, V extends ZipArchiveEntry, E extends Throwable> {
|
||||
void accept(K k, V v) throws E;
|
||||
|
||||
static <K extends UnmarshallerParameters, V extends ZipArchiveEntry, E extends Throwable> BiConsumer<K,V> unchecked(ThrowingBiConsumer<K, V, E> f) {
|
||||
return (k,v) -> {
|
||||
try {
|
||||
f.accept(k,v);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -135,18 +135,27 @@ public class UpdaterImpl implements UpdateHelper {
|
||||
}
|
||||
}
|
||||
|
||||
map.forEach((config, entry) -> {
|
||||
map.forEach(ThrowingBiConsumer.unchecked((config, entry) -> {
|
||||
try (InputStream is = zipFile.getInputStream(entry)) {
|
||||
log.debug("Process '{}' in zip", entry.getName());
|
||||
unmarshaller.process(is, config, filter);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
log.debug("Completed Zip file");
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("IO Unzip Exception");
|
||||
throw new UnzipException(e);
|
||||
} catch (RuntimeException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
|
||||
if(cause instanceof CommonException) {
|
||||
log.error("Probably unmarshalling exception");
|
||||
throw (CommonException) cause;
|
||||
} else {
|
||||
log.error("Unknown exception occured");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user