# HG changeset patch # User Ingo Weinzierl # Date 1338903290 0 # Node ID 484f3dad4bfd31a607361623005e1edd0eac2eb0 # Parent fb07f936b5ad509f05022d35c7d7b098ab5dfa8d Let Artifacts of type WMSDBArtifact remove produced files and directories when endOfLife() is called. flys-artifacts/trunk@4586 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r fb07f936b5ad -r 484f3dad4bfd flys-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/jfree/JFreeUtil.java: diff -r fb07f936b5ad -r 484f3dad4bfd flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.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();