diff --git a/pom.xml b/pom.xml index 42e818d0..80fe4f9f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,7 +25,7 @@ au.gov.aims atlasmapper war - 2.1.2 + 2.1.3 AtlasMapper server and clients This application compiled as a single War, that can be deployed in Tomcat, without any other dependency.\n\ It contains:\n\ diff --git a/src/main/java/au/gov/aims/atlasmapperserver/cache/CacheDatabase.java b/src/main/java/au/gov/aims/atlasmapperserver/cache/CacheDatabase.java index b7599b2f..a0bb93dd 100644 --- a/src/main/java/au/gov/aims/atlasmapperserver/cache/CacheDatabase.java +++ b/src/main/java/au/gov/aims/atlasmapperserver/cache/CacheDatabase.java @@ -280,6 +280,8 @@ public synchronized void delete(URL url) throws SQLException { throw new IllegalArgumentException("URL is null."); } + this.deleteCacheUsage(url.toString()); + String deleteQuery = "DELETE FROM cache WHERE url = ?"; PreparedStatement deletePreparedStatement = null; @@ -308,13 +310,34 @@ public synchronized void deleteExpired() throws SQLException { throw new IllegalStateException("Database connection is closed."); } + long now = CacheEntry.getCurrentTimestamp(); + + String deleteCacheUsageQuery = "DELETE FROM cacheUsage WHERE url IN " + + "(SELECT DISTINCT c.url FROM cache c WHERE expiryTimestamp < ?)"; + + PreparedStatement deleteCacheUsageStmt = null; + try { + deleteCacheUsageStmt = this.connection.prepareStatement(deleteCacheUsageQuery); + deleteCacheUsageStmt.setLong(1, now); + deleteCacheUsageStmt.executeUpdate(); + } finally { + if (deleteCacheUsageStmt != null) { + try { + deleteCacheUsageStmt.close(); + } catch(SQLException ex) { + LOGGER.log(Level.SEVERE, String.format("Can not close the delete expired cache usage statement: %s", + Utils.getExceptionMessage(ex)), ex); + } + } + } + String deleteQuery = "DELETE FROM cache " + "WHERE expiryTimestamp < ?"; PreparedStatement deletePreparedStatement = null; try { deletePreparedStatement = this.connection.prepareStatement(deleteQuery); - deletePreparedStatement.setLong(1, CacheEntry.getCurrentTimestamp()); + deletePreparedStatement.setLong(1, now); deletePreparedStatement.executeUpdate(); } finally { @@ -502,6 +525,26 @@ private void saveCacheUsage(URL url, Set usage) throws SQLException { } } + private void deleteCacheUsage(String urlStr) throws SQLException { + String deleteCacheUsageQuery = "DELETE FROM cacheUsage WHERE url = ?"; + + PreparedStatement deleteCacheUsageStmt = null; + try { + deleteCacheUsageStmt = this.connection.prepareStatement(deleteCacheUsageQuery); + deleteCacheUsageStmt.setString(1, urlStr); + deleteCacheUsageStmt.executeUpdate(); + } finally { + if (deleteCacheUsageStmt != null) { + try { + deleteCacheUsageStmt.close(); + } catch(SQLException ex) { + LOGGER.log(Level.SEVERE, String.format("Can not close the delete cache usage statement: %s", + Utils.getExceptionMessage(ex)), ex); + } + } + } + } + private void deleteCacheUsage(String urlStr, String entityId) throws SQLException { String deleteCacheUsageQuery = "DELETE FROM cacheUsage WHERE url = ? AND entityId = ?"; diff --git a/src/main/webapp/admin/manualOverrideDoc.html b/src/main/webapp/admin/manualOverrideDoc.html index ca87e117..416c2b29 100644 --- a/src/main/webapp/admin/manualOverrideDoc.html +++ b/src/main/webapp/admin/manualOverrideDoc.html @@ -70,6 +70,9 @@ blockquote pre { margin: 0; } + pre { + white-space: pre-wrap; + } #workflowDiv, #settingsDiv,