Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/CacheInvalidationService.java @ 3162:0d8146989012
Added labeling for Q/W points FixingsKMChartService.
flys-artifacts/trunk@4774 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 25 Jun 2012 11:38:33 +0000 |
parents | 5642a83420f2 |
children |
rev | line source |
---|---|
2092
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.artifacts.CallMeta; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.artifacts.GlobalContext; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import de.intevation.artifacts.common.utils.XMLUtils; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
2607
247f3e98a14b
Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2092
diff
changeset
|
8 import de.intevation.artifactdatabase.XMLService; |
2092
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.flys.artifacts.cache.CacheFactory; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import net.sf.ehcache.Cache; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 import org.w3c.dom.Document; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Element; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import org.w3c.dom.NodeList; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2607
diff
changeset
|
18 public class CacheInvalidationService |
2607
247f3e98a14b
Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2092
diff
changeset
|
19 extends XMLService |
2092
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 { |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 @Override |
2607
247f3e98a14b
Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2092
diff
changeset
|
22 public Document processXML( |
2092
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 Document data, |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 GlobalContext globalContext, |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 CallMeta callMeta |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 ) { |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 Document result = XMLUtils.newDocument(); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 Element all = result.createElement("caches"); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 NodeList caches = data.getElementsByTagName("cache"); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 for (int i = 0, C = caches.getLength(); i < C; ++i) { |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 Element c = (Element)caches.item(i); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 String name = c.getAttribute("name"); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 Element e = result.createElement("cache"); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 e.setAttribute("name", name); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 Cache cache = CacheFactory.getCache(name); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 if (cache != null) { |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 cache.removeAll(); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 e.setTextContent("All elements removed."); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 } |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 else { |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 e.setTextContent("Error: Cache not found."); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 all.appendChild(e); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 result.appendChild(all); |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 return result; |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
0ccabd82ec76
Added missing service to invalidate the caches via the REST interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |