Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/services/CacheInvalidationService.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/services/CacheInvalidationService.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts.services; | |
2 | |
3 import org.dive4elements.artifacts.CallMeta; | |
4 import org.dive4elements.artifacts.GlobalContext; | |
5 | |
6 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
7 | |
8 import org.dive4elements.artifactdatabase.XMLService; | |
9 | |
10 import org.dive4elements.river.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 : |