sascha@2092: package de.intevation.flys.artifacts.services; sascha@2092: sascha@2092: import de.intevation.artifacts.CallMeta; sascha@2092: import de.intevation.artifacts.GlobalContext; sascha@2092: sascha@2092: import de.intevation.artifacts.common.utils.XMLUtils; sascha@2092: sascha@2607: import de.intevation.artifactdatabase.XMLService; sascha@2092: sascha@2092: import de.intevation.flys.artifacts.cache.CacheFactory; sascha@2092: sascha@2092: import net.sf.ehcache.Cache; sascha@2092: sascha@2092: import org.w3c.dom.Document; sascha@2092: import org.w3c.dom.Element; sascha@2092: import org.w3c.dom.NodeList; sascha@2092: sascha@3076: public class CacheInvalidationService sascha@2607: extends XMLService sascha@2092: { sascha@2092: @Override sascha@2607: public Document processXML( sascha@2092: Document data, sascha@2092: GlobalContext globalContext, sascha@2092: CallMeta callMeta sascha@2092: ) { sascha@2092: Document result = XMLUtils.newDocument(); sascha@2092: sascha@2092: Element all = result.createElement("caches"); sascha@2092: sascha@2092: NodeList caches = data.getElementsByTagName("cache"); sascha@2092: sascha@2092: for (int i = 0, C = caches.getLength(); i < C; ++i) { sascha@2092: Element c = (Element)caches.item(i); sascha@2092: String name = c.getAttribute("name"); sascha@2092: Element e = result.createElement("cache"); sascha@2092: e.setAttribute("name", name); sascha@2092: Cache cache = CacheFactory.getCache(name); sascha@2092: if (cache != null) { sascha@2092: cache.removeAll(); sascha@2092: e.setTextContent("All elements removed."); sascha@2092: } sascha@2092: else { sascha@2092: e.setTextContent("Error: Cache not found."); sascha@2092: } sascha@2092: all.appendChild(e); sascha@2092: } sascha@2092: sascha@2092: result.appendChild(all); sascha@2092: sascha@2092: return result; sascha@2092: } sascha@2092: } sascha@2092: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :