Мддаааа, разобрался в своем коде.
Переписал, протестировал, работает.
И все таки - валидатор не принимает: Метод добавляет новые файлы в архив некорректно.
public void addFiles(List<Path> absolutePathList) throws Exception {
if (!Files.isRegularFile(zipFile)) {
throw new WrongZipFileException();
}
Path tempZipFile = Files.createTempFile(null, null);
List<String> list = new ArrayList<>();
try(ZipOutputStream outputStream = new ZipOutputStream(Files.newOutputStream(tempZipFile));
ZipInputStream inputStream = new ZipInputStream(Files.newInputStream(zipFile))){
ZipEntry zipEntry = inputStream.getNextEntry();
while (zipEntry!=null){
String fileName = zipEntry.getName();
list.add(fileName);
outputStream.putNextEntry(new ZipEntry(fileName));
copyData(inputStream, outputStream);
outputStream.closeEntry();
inputStream.closeEntry();
zipEntry = inputStream.getNextEntry();
}
for(Path ph: absolutePathList){
if(!Files.exists(ph))
throw new PathIsNotFoundException();
if (list.contains(ph.getFileName().toString())){
ConsoleHelper.writeMessage(ph.getFileName().toString()+" уже есть в архиве");
} else {
addNewZipEntry(outputStream,ph,ph.getFileName());
ConsoleHelper.writeMessage(ph.getFileName().toString()+" файл добавлен в архив");
}
}
inputStream.close();
outputStream.close();
Files.move(tempZipFile, zipFile, StandardCopyOption.REPLACE_EXISTING);
}
}