| margaretha | efc18a4 | 2018-03-01 16:01:42 +0100 | [diff] [blame^] | 1 | package de.ids_mannheim.korap.cache; |
| 2 | |
| 3 | import de.ids_mannheim.korap.config.KustvaktCacheable; |
| 4 | import de.ids_mannheim.korap.exceptions.EmptyResultException; |
| 5 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
| 6 | import de.ids_mannheim.korap.exceptions.NotAuthorizedException; |
| 7 | import de.ids_mannheim.korap.exceptions.StatusCodes; |
| 8 | import de.ids_mannheim.korap.resources.KustvaktResource; |
| 9 | import de.ids_mannheim.korap.resources.Permissions; |
| 10 | import de.ids_mannheim.korap.resources.ResourceFactory; |
| 11 | import de.ids_mannheim.korap.user.User; |
| 12 | import net.sf.ehcache.CacheManager; |
| 13 | import net.sf.ehcache.Element; |
| 14 | import org.slf4j.Logger; |
| 15 | import org.slf4j.LoggerFactory; |
| 16 | |
| 17 | import java.util.Collection; |
| 18 | |
| 19 | /** |
| 20 | * @author hanl |
| 21 | * @date 23/03/2014 |
| 22 | * |
| 23 | * @author margaretha |
| 24 | * @date 01/03/2018 |
| 25 | * |
| 26 | * EM: removed resource related code, keep cache |
| 27 | */ |
| 28 | |
| 29 | //todo: use interface (maybe a cachable interface?) and bean instanceing |
| 30 | // todo: if cachable, data integrity needs to be checked! either remove caching or check integrity! |
| 31 | @SuppressWarnings("all") |
| 32 | public class ResourceCache extends KustvaktCacheable { |
| 33 | |
| 34 | private static Logger jlog = LoggerFactory.getLogger(ResourceCache.class); |
| 35 | |
| 36 | public ResourceCache () { |
| 37 | super("resources", "key:resources"); |
| 38 | } |
| 39 | |
| 40 | |
| 41 | @Deprecated |
| 42 | public <T extends KustvaktResource> T getCache (Object id, Class<T> cz) { |
| 43 | Element e = CacheManager.getInstance().getCache("resources").get(id); |
| 44 | if (e != null) |
| 45 | return (T) e.getObjectValue(); |
| 46 | else |
| 47 | return null; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | @Deprecated |
| 52 | public <R extends KustvaktResource> void cache (R resource) { |
| 53 | CacheManager.getInstance().getCache("resources") |
| 54 | .put(new Element(resource.getPersistentID(), resource)); |
| 55 | } |
| 56 | } |