[Minor] Code cleanup
This commit is contained in:
parent
89dc892172
commit
79bc086e24
|
@ -85,10 +85,13 @@ public class XmlExportModelCommand extends Command {
|
||||||
|
|
||||||
private void cleanUpExisting(final String exportName) {
|
private void cleanUpExisting(final String exportName) {
|
||||||
File parentFile = this.modelFile.getParentFile();
|
File parentFile = this.modelFile.getParentFile();
|
||||||
File[] existingFiles = parentFile.listFiles((dir, name) -> name.startsWith(exportName) && name.endsWith(".xml"));
|
File[] existingFiles = parentFile.listFiles(
|
||||||
|
(dir, name) -> name.startsWith(exportName) && name.endsWith(".xml"));
|
||||||
|
if (existingFiles != null) {
|
||||||
for (File file : existingFiles) {
|
for (File file : existingFiles) {
|
||||||
file.delete();
|
if (!file.delete())
|
||||||
|
throw new IllegalStateException("Failed to delete file " + file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,8 +256,8 @@ public class XmlExportModelCommand extends Command {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
for (File createdFile : createdFiles) {
|
for (File createdFile : createdFiles) {
|
||||||
if (createdFile.exists())
|
if (createdFile.exists() && !createdFile.delete())
|
||||||
createdFile.delete();
|
throw new IllegalStateException("Failed to delete file " + createdFile);
|
||||||
}
|
}
|
||||||
String msg = "Failed to write model to file {0} due to {1}";
|
String msg = "Failed to write model to file {0} due to {1}";
|
||||||
msg = MessageFormat.format(msg, this.modelFile, e.getMessage());
|
msg = MessageFormat.format(msg, this.modelFile, e.getMessage());
|
||||||
|
|
Loading…
Reference in New Issue