slub.team team mailing list archive
-
slub.team team
-
Mailing list archive
-
Message #00217
[Merge] lp:~henning-gerhardt/goobi-production/bug-994026 into lp:goobi-production
Henning Gerhardt has proposed merging lp:~henning-gerhardt/goobi-production/bug-994026 into lp:goobi-production.
Requested reviews:
Ralf Claussnitzer (ralf-claussnitzer)
Related bugs:
Bug #994026 in Goobi.Production: "mets anchor file has wrong filename"
https://bugs.launchpad.net/goobi-production/+bug/994026
For more details, see:
https://code.launchpad.net/~henning-gerhardt/goobi-production/bug-994026/+merge/105057
--
https://code.launchpad.net/~henning-gerhardt/goobi-production/bug-994026/+merge/105057
Your team Saxon State Library Team is subscribed to branch lp:goobi-production.
=== modified file 'src/de/sub/goobi/beans/Prozess.java'
--- src/de/sub/goobi/beans/Prozess.java 2012-04-13 13:17:45 +0000
+++ src/de/sub/goobi/beans/Prozess.java 2012-05-08 11:18:19 +0000
@@ -99,6 +99,8 @@
private DisplayPropertyList displayProperties;
private String wikifield;
+ private static final String TEMPORARY_FILENAME_PREFIX = "temporary_";
+
public Prozess() {
swappedOut = false;
titel = "";
@@ -735,12 +737,39 @@
oldFile.renameTo(newFile);
}
}
-
+
+ private String getTemporaryMetadataFileName(String fileName) {
+ File temporaryFile = new File(fileName);
+ String directoryPath = temporaryFile.getParentFile().getPath();
+ String temporaryFileName = TEMPORARY_FILENAME_PREFIX + temporaryFile.getName();
+
+ return directoryPath + File.separator + temporaryFileName;
+ }
+
+ private void removePrefixFromRelatedMetsAnchorFileFor(String temporaryMetadataFilename) {
+ File temporaryFile = new File(temporaryMetadataFilename);
+ File temporaryAnchorFile;
+
+ String directoryPath = temporaryFile.getParentFile().getPath();
+ String temporaryAnchorFileName = temporaryFile.getName().replace("meta.xml", "meta_anchor.xml");
+
+ temporaryAnchorFile = new File(directoryPath + File.separator + temporaryAnchorFileName);
+
+ if (temporaryAnchorFile.exists()) {
+ String anchorFileName = temporaryAnchorFileName.replace(TEMPORARY_FILENAME_PREFIX, "");
+
+ temporaryAnchorFileName = directoryPath + File.separator + temporaryAnchorFileName;
+ anchorFileName = directoryPath + File.separator + anchorFileName;
+
+ renameMetadataFile(temporaryAnchorFileName, anchorFileName);
+ }
+ }
+
public void writeMetadataFile(Fileformat gdzfile) throws IOException, InterruptedException, SwapException, DAOException, WriteException,
PreferencesException {
Fileformat ff;
String metadataFileName;
- String metadataFileNameNew;
+ String temporaryMetadataFileName;
boolean writeResult;
switch (MetadataFormat.findFileFormatsHelperByName(projekt.getFileFormatInternal())) {
@@ -758,13 +787,14 @@
}
metadataFileName = getMetadataFilePath();
- metadataFileNameNew = metadataFileName + ".new";
+ temporaryMetadataFileName = getTemporaryMetadataFileName(metadataFileName);
ff.setDigitalDocument(gdzfile.getDigitalDocument());
- writeResult = ff.write(metadataFileNameNew);
+ writeResult = ff.write(temporaryMetadataFileName);
if (writeResult) {
createBackupFile();
- renameMetadataFile(metadataFileNameNew, metadataFileName);
+ renameMetadataFile(temporaryMetadataFileName, metadataFileName);
+ removePrefixFromRelatedMetsAnchorFileFor(temporaryMetadataFileName);
}
}
Follow ups