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) {
repository.getArtifact(new ArtifactIdentifier(printPath, revision - 1, "")).setObsoleteDate(newRevisionDate);
}
repository.addArtifact(new ArtifactIdentifier(printPath, revision, ""),
new Date(file.lastModified()),
newRevisionContent,
authorWhoDeleted);
repository.commit();
}