diff options
Diffstat (limited to 'pdf-as-common/src/main/java/at/gv/egiz/pdfas/common')
-rw-r--r-- | pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java | 44 | ||||
-rw-r--r-- | pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java | 8 |
2 files changed, 50 insertions, 2 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java new file mode 100644 index 00000000..f98e8d07 --- /dev/null +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java @@ -0,0 +1,44 @@ +package at.gv.egiz.pdfas.common.messages; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class CodesResolver { + private static final String messageResource = "resources.messages.verify"; + private static final String missingMsg = "Unknown "; + + private static final Logger logger = LoggerFactory.getLogger(MessageResolver.class); + + private static ResourceBundle bundle; + + static { + bundle = ResourceBundle.getBundle(messageResource); + if(bundle == null) { + logger.error("Failed to load resource bundle!!"); + System.err.println("Failed to load resource bundle!!"); + //Runtime.getRuntime().exit(-1); + } + } + + public static void forceLocale(Locale locale) { + bundle = ResourceBundle.getBundle(messageResource, locale); + } + + public static String resolveMessage(String msgId) { + if(bundle == null) { + return missingMsg + msgId; + } + if(bundle.containsKey(msgId)) { + String value = bundle.getString(msgId); + if(value == null) { + return missingMsg + msgId; + } + return value; + } + return missingMsg + msgId; + } + +} diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java index 3a9284cc..0a1c0c1a 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java @@ -70,7 +70,7 @@ public class TempFileHelper implements IProfileConstants { needsDeletion = true; } - logger.info("TempDirHelper for TempDirectory: " + tmpDir); + logger.debug("TempDirHelper for TempDirectory: " + tmpDir); createTmpDir(); } @@ -81,6 +81,10 @@ public class TempFileHelper implements IProfileConstants { super.finalize(); } + public void clear() { + this.deleteTmpDir(); + } + private void deleteTmpDir() { try { File tmpdir = new File(tmpDir); @@ -133,7 +137,7 @@ public class TempFileHelper implements IProfileConstants { String uuidString = UUID.randomUUID().toString(); logger.debug("Generated UUID " + uuidString); String tmpFilename = tmpDir + getHashedHexString(uuidString) + tmpFileSuffix; - logger.info("Temporary filename " + tmpFilename); + logger.debug("Temporary filename " + tmpFilename); tmpFiles.add(tmpFilename); return tmpFilename; } |