Mercurial > dive4elements > river
changeset 3019:484f3dad4bfd
Let Artifacts of type WMSDBArtifact remove produced files and directories when endOfLife() is called.
flys-artifacts/trunk@4586 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 05 Jun 2012 13:34:50 +0000 |
parents | fb07f936b5ad |
children | ce796f1db30e |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java |
diffstat | 2 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Jun 05 13:28:11 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Jun 05 13:34:50 2012 +0000 @@ -1,3 +1,8 @@ +2012-06-05 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java: Override + endOfLife() to remove files and directories produced for WMS output. + 2012-06-05 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/jfree/JFreeUtil.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java Tue Jun 05 13:28:11 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java Tue Jun 05 13:34:50 2012 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.artifacts; +import java.io.File; + import java.util.ArrayList; import java.util.List; @@ -18,6 +20,8 @@ import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.CallMeta; +import de.intevation.artifacts.common.utils.FileTools; + import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifactdatabase.state.State; @@ -29,6 +33,7 @@ import de.intevation.flys.artifacts.states.DefaultState; import de.intevation.flys.artifacts.model.WMSDBLayerFacet; import de.intevation.flys.utils.FLYSUtils; +import de.intevation.flys.utils.MapfileGenerator; public abstract class WMSDBArtifact extends StaticFLYSArtifact { @@ -81,6 +86,12 @@ } + @Override + protected State getState(Object context, String stateID) { + return getCurrentState(context); + } + + /** * Get a list containing the one and only State. * @param context ignored. @@ -284,6 +295,22 @@ } + @Override + public void endOfLife(Artifact owner, Object context) { + logger.info("Destroy WMSDBState: " + getID()); + + String p = FLYSUtils.getXPathString(FLYSUtils.XPATH_SHAPEFILE_DIR); + File dir = new File(p, owner.identifier()); + + if (dir != null && dir.exists()) { + logger.debug("Try to delete directory '" + dir + "'"); + + FileTools.deleteRecursive(dir); + MapfileGenerator.getInstance().update(); + } + } + + protected abstract String getFacetType(); protected abstract String getUrl();