# HG changeset patch # User Ingo Weinzierl # Date 1320684001 0 # Node ID f2277458823e33fa8e0ff2e4b6e9d2b8f1cab3e8 # Parent 16ab243507e0f6584113e19f4ccdf9f0e3db5998 Enabled 'post-describe' hooks for Artifacts. artifacts/trunk@3176 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 16ab243507e0 -r f2277458823e ChangeLog --- a/ChangeLog Fri Oct 28 10:08:35 2011 +0000 +++ b/ChangeLog Mon Nov 07 16:40:01 2011 +0000 @@ -1,3 +1,9 @@ +2011-11-07 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java, + artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java: + Enabled "post-describe" hooks for the Artifact's describe operation. + 2011-10-28 Felix Wolfsteller Let StateEngine compute a compatibiliy matrix based on given State diff -r 16ab243507e0 -r f2277458823e artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Fri Oct 28 10:08:35 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java Mon Nov 07 16:40:01 2011 +0000 @@ -444,6 +444,12 @@ */ protected List postAdvanceHooks; + /** + * Hooks that are executed after an artifact's describe() operation was + * called. + */ + protected List postDescribeHooks; + protected List lifetimeListeners; /** @@ -511,6 +517,10 @@ this.postAdvanceHooks = postAdvanceHooks; } + public void setPostDescribeHook(List postDescribeHooks) { + this.postDescribeHooks = postDescribeHooks; + } + /** * Used to extract the artifact collection factory from bootstrap. * @@ -558,6 +568,7 @@ protected void setupHooks(FactoryBootstrap bootstrap) { setPostFeedHook(bootstrap.getPostFeedHooks()); setPostAdvanceHook(bootstrap.getPostAdvanceHooks()); + setPostDescribeHook(bootstrap.getPostDescribeHooks()); } protected void setupBackendListeners(FactoryBootstrap bootstrap) { @@ -847,7 +858,16 @@ artifact); try { - return artifact.getArtifact().describe(data, cc); + Artifact art = artifact.getArtifact(); + Document res = art.describe(data, cc); + + if (postDescribeHooks != null) { + for (Hook hook: postDescribeHooks) { + hook.execute(art, cc, res); + } + } + + return res; } finally { cc.postCall(); diff -r 16ab243507e0 -r f2277458823e artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Fri Oct 28 10:08:35 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java Mon Nov 07 16:40:01 2011 +0000 @@ -170,6 +170,8 @@ protected List postAdvanceHooks; + protected List postDescribeHooks; + protected List lifetimeListeners; protected List backendListeners; @@ -542,8 +544,9 @@ protected void loadHooks() { logger.info("loading hooks"); - postFeedHooks = new ArrayList(); - postAdvanceHooks = new ArrayList(); + postFeedHooks = new ArrayList(); + postAdvanceHooks = new ArrayList(); + postDescribeHooks = new ArrayList(); NodeList nodes = Config.getNodeSetXPath(HOOKS); @@ -567,6 +570,9 @@ else if (a.equals("post-advance")) { postAdvanceHooks.add(hook); } + else if (a.equals("post-describe")) { + postDescribeHooks.add(hook); + } } } } @@ -703,6 +709,10 @@ return postAdvanceHooks; } + public List getPostDescribeHooks() { + return postDescribeHooks; + } + public HTTPServer getHTTPServer() { return httpServer; }