Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/CacheInvalidationService.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | 5642a83420f2 |
children |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.services; | |
2 | |
3 import de.intevation.artifacts.CallMeta; | |
4 import de.intevation.artifacts.GlobalContext; | |
5 | |
6 import de.intevation.artifacts.common.utils.XMLUtils; | |
7 | |
8 import de.intevation.artifactdatabase.XMLService; | |
9 | |
10 import de.intevation.flys.artifacts.cache.CacheFactory; | |
11 | |
12 import net.sf.ehcache.Cache; | |
13 | |
14 import org.w3c.dom.Document; | |
15 import org.w3c.dom.Element; | |
16 import org.w3c.dom.NodeList; | |
17 | |
18 public class CacheInvalidationService | |
19 extends XMLService | |
20 { | |
21 @Override | |
22 public Document processXML( | |
23 Document data, | |
24 GlobalContext globalContext, | |
25 CallMeta callMeta | |
26 ) { | |
27 Document result = XMLUtils.newDocument(); | |
28 | |
29 Element all = result.createElement("caches"); | |
30 | |
31 NodeList caches = data.getElementsByTagName("cache"); | |
32 | |
33 for (int i = 0, C = caches.getLength(); i < C; ++i) { | |
34 Element c = (Element)caches.item(i); | |
35 String name = c.getAttribute("name"); | |
36 Element e = result.createElement("cache"); | |
37 e.setAttribute("name", name); | |
38 Cache cache = CacheFactory.getCache(name); | |
39 if (cache != null) { | |
40 cache.removeAll(); | |
41 e.setTextContent("All elements removed."); | |
42 } | |
43 else { | |
44 e.setTextContent("Error: Cache not found."); | |
45 } | |
46 all.appendChild(e); | |
47 } | |
48 | |
49 result.appendChild(all); | |
50 | |
51 return result; | |
52 } | |
53 } | |
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |