Files in archive order finished

change_data_scheme
Terekhin Alexander 5 years ago
parent 4ddb56e211
commit e7dd1a131e
  1. 20
      src/main/java/me/bearns/fias/helpers/ThrowingBiConsumer.java
  2. 13
      src/main/java/me/bearns/fias/helpers/UpdaterImpl.java

@ -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");
}
}
}

Loading…
Cancel
Save