Mercurial > dive4elements > framework
changeset 242:b35d32e507b6
Fix for flys/issue9
artifacts/trunk@1677 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 13 Apr 2011 11:26:53 +0000 |
parents | 4253995c970e |
children | 33b9cc23ac9b |
files | ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java artifact-database/src/main/resources/sql/org-h2-driver.properties artifact-database/src/main/resources/sql/org-postgresql-driver.properties |
diffstat | 4 files changed, 24 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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 <sascha.teichmann@intevation.de> + + 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 <sascha.teichmann@intevation.de> Fix for flys/issue8 (part 3)
--- 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;
--- 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 = ?
--- 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