aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-common/src/main/java/at
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-05-14 11:35:43 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-05-14 11:35:43 +0200
commit87cd5e8be869b19e6b37dbb13056882efff976a0 (patch)
tree4941cc941b9a791037869967b47df6fa56effe30 /pdf-as-common/src/main/java/at
parent1d5e1f5f429d225e14f4ce9e6e82a403eac10b6b (diff)
downloadpdf-as-4-87cd5e8be869b19e6b37dbb13056882efff976a0.tar.gz
pdf-as-4-87cd5e8be869b19e6b37dbb13056882efff976a0.tar.bz2
pdf-as-4-87cd5e8be869b19e6b37dbb13056882efff976a0.zip
Added Verification Messages
Diffstat (limited to 'pdf-as-common/src/main/java/at')
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/messages/CodesResolver.java44
-rw-r--r--pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/TempFileHelper.java8
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;
}