/*
- * jSite - Project.java - Copyright © 2006–2011 David Roden
+ * jSite - Project.java - Copyright © 2006–2012 David Roden
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import de.todesbaum.util.mime.DefaultMIMETypes;
}
/**
- * Copies the current hashes of all file options to the last insert hashes,
- * updating the hashes for the next insert. This method should only be
- * called after the insert has finished successfully.
+ * Performs some post-processing on the project after it was inserted
+ * successfully. At the moment it copies the current hashes of all file
+ * options to the last insert hashes, updating the hashes for the next
+ * insert.
*/
- public void copyHashes() {
- for (FileOption fileOption : fileOptions.values()) {
- if ((fileOption.getCurrentHash() != null) && (fileOption.getCurrentHash().length() > 0) && !fileOption.getCurrentHash().equals(fileOption.getLastInsertHash())) {
+ public void onSuccessfulInsert() {
+ for (Entry<String, FileOption> fileOptionEntry : fileOptions.entrySet()) {
+ FileOption fileOption = fileOptionEntry.getValue();
+ if ((fileOption.getCurrentHash() != null) && (fileOption.getCurrentHash().length() > 0) && (!fileOption.getCurrentHash().equals(fileOption.getLastInsertHash()) || fileOption.isForceInsert())) {
fileOption.setLastInsertEdition(edition);
fileOption.setLastInsertHash(fileOption.getCurrentHash());
+ fileOption.setLastInsertFilename(fileOption.hasChangedName() ? fileOption.getChangedName() : fileOptionEntry.getKey());
}
+ fileOption.setForceInsert(false);
}
}