ddf464fe79d888f19a0da220517ae12725e580f0
[ccsdk/sli.git] /
1 package org.onap.ccsdk.sli.core.sli.provider.base;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Map;
7 import java.util.Properties;
8 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
9 import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
10 import org.onap.ccsdk.sli.core.sli.SvcLogicStore;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13
14 public class InMemorySvcLogicStore implements SvcLogicStore {
15     private static final Logger logger = LoggerFactory.getLogger(InMemorySvcLogicStore.class);
16     public Map<String, SvcLogicGraph> graphStore;
17
18     public InMemorySvcLogicStore() {
19         graphStore = new HashMap<String, SvcLogicGraph>();
20     }
21
22     @Override
23     public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
24         String storeId = new String(module + ":" + rpc);
25         return graphStore.containsKey(storeId);
26     }
27
28     @Override
29     public SvcLogicGraph fetch(String module, String rpc, String version, String mode) throws SvcLogicException {
30         String storeId = new String(module + ":" + rpc);
31         return graphStore.get(storeId);
32     }
33
34     @Override
35     public void store(SvcLogicGraph graph) throws SvcLogicException {
36         if (graph != null) {
37             String storeId = new String(graph.getModule() + ":" + graph.getRpc());
38             graphStore.put(storeId, graph);
39             logger.info(graph.toString() + " stored in InMemorySvcLogicStore.");
40         }
41     }
42
43     @Override
44     public void init(Properties props) throws SvcLogicException {
45         // noop
46     }
47
48     @Override
49     public void delete(String module, String rpc, String version, String mode) throws SvcLogicException {
50         String storeId = new String(module + ":" + rpc);
51         if (graphStore.containsKey(storeId)) {
52             graphStore.remove(storeId);
53         }
54     }
55
56     @Override
57     public void activate(SvcLogicGraph graph) throws SvcLogicException {
58         // noop
59     }
60
61     @Override
62     public void activate(String module, String rpc, String version, String mode) throws SvcLogicException {
63         // noop
64     }
65
66 }