Set<String> incrementBySameOwner = new TreeSet<String>(filesInOldVersion);
if (addedFiles.size() > 0) {
logger.debug("Files were added to \"" + printPath + "\": " + addedFiles);
}
String owner = null;
AuthorManager authorManager = importer.getCollabReview().getAuthorManager();
while (addedFiles.size() > 0) {
Iterator<String> iterator = addedFiles.iterator();
String addedFileName = iterator.next();
File addedFile = new File(file, addedFileName);
owner = getOwnerOfFile(addedFile);
incrementBySameOwner.add(addedFileName);
while (iterator.hasNext()) {
addedFileName = iterator.next();
if (owner.equals(getOwnerOfFile(new File(file, addedFileName)))) {
incrementBySameOwner.add(addedFileName);
}
}
addedFiles.removeAll(incrementBySameOwner);
Author ownerAuthor = authorManager.getAuthor(owner);
if (ownerAuthor == null) {
ownerAuthor = authorManager.createAuthor(owner);
authorManager.storeAuthor(ownerAuthor);
authorManager.commit();
}
if (revision > 1) {
repository.getArtifact(new ArtifactIdentifier(printPath, revision - 1, "")).setObsoleteDate(newRevisionDate);
}
repository.addArtifact(new ArtifactIdentifier(printPath, revision, ""),
newRevisionDate,
contentFromSetOfFileNames(incrementBySameOwner),
ownerAuthor);
repository.commit();
revision++;
}
// => remove directory names from artifact in repository
Set<String> removedFiles = new TreeSet<String>(filesInOldVersion);
removedFiles.removeAll(filesInNewVersion);
if (removedFiles.size() > 0) {
logger.debug("Files were removed from " + printPath + ": " + removedFiles);
Author authorWhoDeleted;
if (owner != null) {
// we don't know who removed the files but let's guess it was one of those who also added files, otherwise assume it was the owner of the directory himself
authorWhoDeleted = authorManager.getAuthor(owner);
} else {
owner = getOwnerOfFile(file);
if (owner == null) {
logger.warn("Assuming someone else as owner of " + file + " instead.");
owner = authorManager.listAuthorNames().iterator().next();
}
authorWhoDeleted = authorManager.getAuthor(owner);
if (authorWhoDeleted == null) {
logger.error("That's weird, there is still no author...");
}
}
if (revision > 1) {