Mercurial > dive4elements > framework
diff artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 17:5a6b6a3debc7
Integrated logging into artifact database.
artifacts/trunk@33 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 08 Sep 2009 06:29:52 +0000 |
parents | 9ad6ec2d09c3 |
children | 72abee95fd64 |
line wrap: on
line diff
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Mon Sep 07 13:22:48 2009 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Tue Sep 08 06:29:52 2009 +0000 @@ -25,11 +25,15 @@ import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.Artifact; +import org.apache.log4j.Logger; + /** * @author Sascha L. Teichmann */ public class Backend { + private static Logger logger = Logger.getLogger(Backend.class); + public static final String SQL_NEXT_ID = SQL.get("artifacts.id.nextval"); @@ -140,6 +144,7 @@ return bos.toByteArray(); } catch (IOException ioe) { + logger.error(ioe.getLocalizedMessage(), ioe); throw new RuntimeException(ioe); } } @@ -155,6 +160,7 @@ uuid = UUID.fromString(idenitfier); } catch (IllegalArgumentException iae) { + logger.warn(iae.getLocalizedMessage()); return null; } @@ -219,7 +225,7 @@ return new ArtifactProxy(original, id, false); } catch (SQLException sqle) { - sqle.printStackTrace(System.err); + logger.error(sqle.getLocalizedMessage(), sqle); } finally { if (load_result != null) { @@ -250,13 +256,13 @@ return (Artifact)ois.readObject(); } catch (IOException ioe) { - ioe.printStackTrace(System.err); + logger.error(ioe.getLocalizedMessage(), ioe); } catch (ClassNotFoundException cnfe) { - cnfe.printStackTrace(System.err); + logger.error(cnfe.getLocalizedMessage(), cnfe); } catch (ClassCastException cce) { - cce.printStackTrace(System.err); + logger.error(cce.getLocalizedMessage(), cce); } finally { if (ois != null) { @@ -269,7 +275,7 @@ } protected void artifactOutdated(int id) { - System.err.println("artifactOutdated: id = " + id); + logger.info("artifactOutdated: id = " + id); } protected int insertDatabase(UUID uuid, Long ttl) { @@ -316,7 +322,7 @@ } } catch (SQLException sqle) { - sqle.printStackTrace(System.err); + logger.error(sqle.getLocalizedMessage(), sqle); } finally { if (res_id != null) { @@ -340,7 +346,7 @@ } public void touch(ArtifactProxy proxy) { - System.err.println("touch: " + proxy); + logger.info("touch: " + proxy); if (proxy.isUnwritten()) { store(proxy); return; @@ -362,7 +368,7 @@ } } catch (SQLException sqle) { - sqle.printStackTrace(System.err); + logger.error(sqle.getLocalizedMessage(), sqle); } finally { if (stmnt_touch != null) { @@ -377,7 +383,7 @@ } public void store(ArtifactProxy proxy) { - System.err.println("store: " + proxy); + logger.info("store: " + proxy); Connection connection = null; PreparedStatement stmnt_update = null; DataSource dataSource = DBConnection.getDataSource(); @@ -396,7 +402,7 @@ } } catch (SQLException sqle) { - sqle.printStackTrace(System.err); + logger.error(sqle.getLocalizedMessage(), sqle); } finally { if (stmnt_update != null) {