# HG changeset patch # User Sascha L. Teichmann # Date 1302694013 0 # Node ID b35d32e507b610d0bc2641ba4cb21c72ab34a4e9 # Parent 4253995c970ea902bf13884958070aeda7bf84eb Fix for flys/issue9 artifacts/trunk@1677 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4253995c970e -r b35d32e507b6 ChangeLog --- a/ChangeLog Wed Apr 13 10:57:45 2011 +0000 +++ b/ChangeLog Wed Apr 13 11:26:53 2011 +0000 @@ -1,3 +1,15 @@ +2011-04-13 Sascha L. Teichmann + + Fix for flys/issue9 + + * artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java: + Removed code that checks for outdated artifact in user land. + + * artifact-database/src/main/resources/sql/org-h2-driver.properties, + artifact-database/src/main/resources/sql/org-postgresql-driver.properties: + Do the check in the database and take into account if artifact + is in a collection. XXX: Maybe this needs some speedup! + 2011-04-13 Sascha L. Teichmann Fix for flys/issue8 (part 3) diff -r 4253995c970e -r b35d32e507b6 artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Wed Apr 13 10:57:45 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java Wed Apr 13 11:26:53 2011 +0000 @@ -499,19 +499,10 @@ } int id = result.getInt(1); - long ttlX = result.getLong(3); - - Long ttl = result.wasNull() ? null : Long.valueOf(ttlX); + long ttlX = result.getLong(2); + Long ttl = result.wasNull() ? null : ttlX; - if (ttl != null) { // real time to life - long last_access = result.getTimestamp(2).getTime(); - if (last_access + ttlX < System.currentTimeMillis()) { - artifactOutdated(id); - return false; - } - } - - String factoryName = result.getString(4); + String factoryName = result.getString(3); if (factoryLookup == null) { logger.error("factory lookup == null"); @@ -526,7 +517,7 @@ return false; } - byte [] bytes = result.getBytes(5); + byte [] bytes = result.getBytes(4); loaded[0] = loader.load(factory, ttl, bytes, id); return true; diff -r 4253995c970e -r b35d32e507b6 artifact-database/src/main/resources/sql/org-h2-driver.properties --- a/artifact-database/src/main/resources/sql/org-h2-driver.properties Wed Apr 13 10:57:45 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-h2-driver.properties Wed Apr 13 11:26:53 2011 +0000 @@ -15,7 +15,10 @@ AND id NOT IN ($LOCKED_IDS$) \ LIMIT 50 -artifacts.select.gid=SELECT id, last_access, ttl, factory, data FROM artifacts WHERE gid = ? +artifacts.select.gid=SELECT id, factory, data FROM artifacts WHERE gid = ?::uuid \ + AND (ttl IS NULL \ + OR (DATEDIFF('MILLISECOND', last_access, CURRENT_TIMESTAMP) <= ttl) \ + OR id IN (SELECT artifact_id FROM collection_items)) \ artifacts.get.id=SELECT id FROM artifacts WHERE gid = ? diff -r 4253995c970e -r b35d32e507b6 artifact-database/src/main/resources/sql/org-postgresql-driver.properties --- a/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Wed Apr 13 10:57:45 2011 +0000 +++ b/artifact-database/src/main/resources/sql/org-postgresql-driver.properties Wed Apr 13 11:26:53 2011 +0000 @@ -15,7 +15,10 @@ AND id NOT IN ($LOCKED_IDS$) \ LIMIT 50 -artifacts.select.gid=SELECT id, last_access, ttl, factory, data FROM artifacts WHERE gid = ?::uuid +artifacts.select.gid=SELECT id, ttl, factory, data FROM artifacts WHERE gid = ?::uuid \ + AND (ttl IS NULL \ + OR (CURRENT_TIMESTAMP - last_access <= (ttl || ' microseconds')::interval) \ + OR id IN (SELECT artifact_id FROM collection_items)) artifacts.get.id=SELECT id FROM artifacts WHERE gid = ?::uuid