annotate gnv-artifacts/src/main/java/de/intevation/gnv/state/cache/ThematicDataCacheCleaner.java @ 1102:aaacced2a0cc

Fixed an ArrayIndexOutOfBounds exception that occured while initializing the ParameterMatrix (issue281). gnv-artifacts/trunk@1228 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 28 Jun 2010 10:25:55 +0000
parents dfd02f8d3602
children f953c9a559d8
rev   line source
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
1 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
2 *
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
3 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
4 package de.intevation.gnv.state.cache;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
5
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
6 import java.util.ArrayList;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
7 import java.util.Collection;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
8 import java.util.Iterator;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
9 import java.util.List;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
10
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
11 import net.sf.ehcache.Cache;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
12
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.Document;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
15 import org.w3c.dom.Element;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
16 import org.w3c.dom.NodeList;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
17
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
18 import de.intevation.artifactdatabase.Config;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
19 import de.intevation.gnv.artifacts.cache.CacheFactory;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
20 import de.intevation.gnv.geobackend.base.query.cache.CacheCleaner;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
21 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
22 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
23 import de.intevation.gnv.geobackend.base.query.exception.QueryException;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
24 import de.intevation.gnv.state.StateBase;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
25 import de.intevation.gnv.utils.ArtifactXMLUtilities;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
26
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
27
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
28 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
29 * Extended Class of the CacheCleaner.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
30 * This Cleaner has the job to cleanup the ThematicData-Cache if it
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
31 * is necessary.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
32 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a>
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
33 *
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
34 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
35 public class ThematicDataCacheCleaner extends CacheCleaner {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
36
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
37 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
38 * the logger, used to log exceptions and additonaly information
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
39 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
40 private static Logger log = Logger.getLogger(ThematicDataCacheCleaner.class);
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
41
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
42 private final static String XPATH_ARTIFACTS =
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
43 "/artifact-database/artifacts/artifact";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
44 private final static String XPATH_STATES = "states/state";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
45 private final static String XPATH_STATEID = "id";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
46 private final static String XPATH_QUERYID = "queryID";
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
47
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
48 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
49 * The Queries that should be Cleaned with its links to the
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
50 * StateIds.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
51 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
52 private Collection<QueryObject> queryObjects = null;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
53
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
54 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
55 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
56 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
57 public ThematicDataCacheCleaner() {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
58 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
59 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
60
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
61 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
62 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
63 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
64 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
65 public ThematicDataCacheCleaner(Runnable arg0) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
66 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
67 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
68
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
69 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
70 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
72 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
73 public ThematicDataCacheCleaner(String arg0) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
74 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
75 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
76
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
77 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
78 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
79 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
80 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
81 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
82 public ThematicDataCacheCleaner(ThreadGroup arg0, Runnable arg1) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
83 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
84 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
85
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
86 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
87 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
88 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
89 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
90 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
91 public ThematicDataCacheCleaner(ThreadGroup arg0, String arg1) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
92 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
93 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
94
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
95 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
96 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
97 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
98 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
99 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
100 public ThematicDataCacheCleaner(Runnable arg0, String arg1) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
101 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
102 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
103
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
104 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
105 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
106 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
107 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
108 * @param arg2
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
109 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
110 public ThematicDataCacheCleaner(ThreadGroup arg0, Runnable arg1, String arg2) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
111 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
112 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
113
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
114 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
115 * Constructor
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
116 * @param arg0
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
117 * @param arg1
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
118 * @param arg2
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
119 * @param arg3
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
120 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
121 public ThematicDataCacheCleaner(ThreadGroup arg0, Runnable arg1,
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
122 String arg2, long arg3) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
123 this.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
124 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
125
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
126 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
127 * Initializes the QueryObjects.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
128 * The Queryobjects will be read from the Configuration.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
129 * Only Queries which are defined in <code>queryID</code>-Elements
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
130 * are used.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
131 * The other Queries are currently not put into the Cache.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
132 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
133 @Override
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
134 protected void setUp(){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
135 super.setUp();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
136 this.queryObjects = new ArrayList<QueryObject>();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
137 Document configuration = Config.getConfig();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
138 NodeList artifactList = Config.getNodeSetXPath(configuration,
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
139 XPATH_ARTIFACTS);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
140 log.debug("ThematicDataCacheCleaner.setUp()");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
141 if (artifactList != null && artifactList.getLength() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
142 for (int i = 0; i < artifactList.getLength(); i++){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
143 Element currentArtifactNode = (Element)artifactList.item(i);
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
144
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
145 String link = currentArtifactNode.getAttribute("xlink:href");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
146 if (link != null && link.length() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
147 String absolutFileName = Config.replaceConfigDir(link);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
148 currentArtifactNode = (Element)new ArtifactXMLUtilities()
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
149 .readConfiguration(absolutFileName);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
150 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
151 NodeList stateList = Config.getNodeSetXPath(currentArtifactNode,
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
152 XPATH_STATES);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
153 if (stateList != null && stateList.getLength() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
154 for (int j = 0; j < stateList.getLength() ; j++){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
155 Element currentStateNode = (Element)stateList.item(j);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
156 String stateId = currentStateNode
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
157 .getAttribute(XPATH_STATEID);
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
158 String queryID = Config.getStringXPath(currentStateNode,
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
159 XPATH_QUERYID);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
160 try {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
161 if (queryID != null){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
162 String query = QueryContainerFactory
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
163 .getInstance()
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
164 .getQueryContainer()
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
165 .getQuery(queryID);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
166 QueryObject qo = new QueryObject(stateId, query);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
167 queryObjects.add(qo);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
168 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
169 } catch (QueryContainerException e) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
170 log.error(e,e);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
171 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
172 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
173 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
174 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
175 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
176 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
177
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
178 @Override
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
179 protected void cleanup() {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
180 log.debug("ThematicDataCacheCleaner.cleanup");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
181 try {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
182 if (queryObjects != null && queryObjects.size() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
183 String[] tableNames = this.getUpdatedTableNames();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
184 if (tableNames != null && tableNames.length > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
185 Iterator<QueryObject> it = queryObjects.iterator();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
186 while (it.hasNext()){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
187 QueryObject qo = it.next();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
188 for (int i = 0; i < tableNames.length; i++){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
189 if (qo.queryContainsTableName(tableNames[i])){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
190 String stateId = qo.getStateId();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
191 this.cleanUpCache(stateId);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
192 break;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
193 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
194 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
195 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
196 }else{
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
197 log.debug("No Tables found to cleanup.");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
198 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
199 }else{
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
200 log.warn("No Queries to clean");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
201 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
202 } catch (QueryException e) {
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
203 log.error(e,e);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
204 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
205 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
206
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
207 /**
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
208 * Removes the Entries which Keys matches to the <code>stateId</code>
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
209 * from the Cache.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
210 * @param stateId The Id of the State which Entries has to be removed.
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
211 */
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
212 private void cleanUpCache(String stateId){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
213 log.debug("ThematicDataCacheCleaner.cleanUpCache "+stateId);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
214 CacheFactory factory = CacheFactory.getInstance();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
215 Cache cache = factory.getCache();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
216 List<String> keys = cache.getKeys();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
217 String keySample = StateBase.HASH_ID_SEPARATOR +
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
218 stateId +
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
219 StateBase.HASH_ID_SEPARATOR;
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
220 if (keys != null && keys.size() > 0){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
221 Iterator<String> it = keys.iterator();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
222 while (it.hasNext()){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
223 String key = it.next();
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
224 if (key != null && key.contains(keySample)){
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
225 boolean removed = cache.remove(key);
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
226 if (!removed){
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
227 log.warn("Object with Key " +
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
228 key + "could not be removed from Cache");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
229 }else{
870
dfd02f8d3602 Removed trailing whitespace.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 845
diff changeset
230 log.debug("Object with Key " +
845
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
231 key + "has been removed from Cache");
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
232 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
233 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
234 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
235 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
236 }
797a6264b89b Integrated the CacheCleaner for the ThematicDataCache
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
237 }

http://dive4elements.wald.intevation.org