From 3d982813b34f6f230baf4a467cdc37ec92a77595 Mon Sep 17 00:00:00 2001 From: netconomy Date: Fri, 17 Aug 2007 06:10:56 +0000 Subject: Performance git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@167 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../at/knowcenter/wag/egov/egiz/tools/CodingHelper.java | 12 ++++++++++++ .../java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java | 14 ++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/tools') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java index 7908486..fe0cfcb 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java @@ -17,12 +17,17 @@ */ package at.knowcenter.wag.egov.egiz.tools; +import java.io.IOException; +import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import org.apache.commons.codec.binary.Base64; +import at.gv.egiz.pdfas.framework.input.DataSource; +import at.gv.egiz.pdfas.impl.input.helper.DataSourceHelper; + /** * This class provides encoding and decoding methods and other coding methods. * All methods are static! @@ -215,6 +220,13 @@ public class CodingHelper } } + public static byte[] buildDigest(DataSource input) throws IOException + { + // PERF: digesting needs data source. + byte [] data = DataSourceHelper.convertDataSourceToByteArray(input); + return buildDigest(data); + } + /** * This method escapes a given string with HTML entities. * diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java index 7420b18..397f910 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/Normalizer.java @@ -139,9 +139,7 @@ public class Normalizer implements Serializable { if (logger_.isEnabledFor(Level.FATAL)) { logger_.fatal("Class not found:" + class_name); } - NormalizeException ne = new NormalizeException(400, "Can not load normalizer library"); - ne.setErrorCode(400); - throw ne; + throw new NormalizeException("Can not load normalizer library"); } try { normalize_ = (Normalize) normalize_class.newInstance(); @@ -149,16 +147,12 @@ public class Normalizer implements Serializable { if (logger_.isEnabledFor(Level.FATAL)) { logger_.fatal("Can not instantiate:" + class_name); } - NormalizeException ne = new NormalizeException(400, "Can not load normalizer library"); - ne.setErrorCode(400); - throw ne; + throw new NormalizeException("Can not load normalizer library"); } catch (IllegalAccessException e) { if (logger_.isEnabledFor(Level.FATAL)) { logger_.fatal("Can not access:" + class_name); } - NormalizeException ne = new NormalizeException(400, "Can not load normalizer library"); - ne.setErrorCode(400); - throw ne; + throw new NormalizeException("Can not load normalizer library"); } } @@ -271,7 +265,7 @@ public class Normalizer implements Serializable { } catch (SettingsException e) { String log_message = "Can not load normalizer settings. Cause:\n" + e.getMessage(); logger_.error(log_message); - throw new NormalizeException(400, log_message, e); + throw new NormalizeException(log_message, e); } } } -- cgit v1.2.3