static void splitZipByFeed(final Path sourceDir,
                               final NumberedDirProvider splitZipDirProvider,
                               final Consumer<Path> splitDirConsumer) {
        LOGGER.debug("splitZipByFeed() - sourceDir: {}", sourceDir);
        Path splitZipDir = null;
        try {
            Objects.requireNonNull(sourceDir);

            final FileGroup fileGroup = new FileGroup(sourceDir);
            // Read in the attribute map from the client's headers
            final AttributeMap attributeMap = readMetaFile(fileGroup.getMeta());

            // These are all the entries in the zip that have been allowed by the attrMapFilter,
            // so may be less than the number of entries in the zip
            final Map<FeedKey, List<ZipEntryGroup>> allowedEntries = readEntriesFile(fileGroup.getEntries());
            LOGGER.debug(() -> LogUtil.message("allowedEntries size: {}", allowedEntries.size()));

            // Create a dir to put the all splits into
            splitZipDir = splitZipDirProvider.get();
            final List<Path> groupDirs = splitZip(
                    fileGroup.getZip(),
                    attributeMap,
                    allowedEntries,
                    splitZipDir);

            // Move each group dir to onward destination
            for (final Path groupDir : groupDirs) {
                LOGGER.debug("Pass {}, sourceDir: {}, to destination {}",
                        groupDir, sourceDir, splitDirConsumer);
                splitDirConsumer.accept(groupDir);
            }
            // Passed all the splits on, so delete the source
            deleteDir(sourceDir);
        } catch (Exception e) {
            LOGGER.error("Error splitting zip in {}: {}", sourceDir, LogUtil.exceptionMessage(e), e);
            throw new RuntimeException(e);
        } finally {
            // Whatever happens delete the splits as they can always be re-created from source.
            FileUtil.deleteDir(splitZipDir);
        }
    }
Pkg private to ease testing. splitDirConsumer also there to aid testing.
stroom-proxy/stroom-proxy-app/src/main/java/stroom/proxy/app/handler/ZipSplitter.java