X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Frepository%2FInfoTypes.java;fp=enrichment-coordinator-service%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fenrichment%2Frepository%2FEiTypes.java;h=e3089f92d3d725346d78ceb4aff5f42845f09a21;hb=8fd8e9fc86a24be49d61841e381423120a41296d;hp=6a1b8a114566831ff96f2ebf5306fc0a435a5a26;hpb=367608a9f6c71c2aaae45ed8b1099b9c8e51c0f7;p=nonrtric.git diff --git a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoTypes.java similarity index 84% rename from enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java rename to enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoTypes.java index 6a1b8a11..e3089f92 100644 --- a/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/EiTypes.java +++ b/enrichment-coordinator-service/src/main/java/org/oransc/enrichment/repository/InfoTypes.java @@ -45,16 +45,16 @@ import org.slf4j.LoggerFactory; import org.springframework.util.FileSystemUtils; /** - * Dynamic representation of all EI types in the system. + * Dynamic representation of all Information Types in the system. */ @SuppressWarnings("squid:S2629") // Invoke method(s) only conditionally -public class EiTypes { +public class InfoTypes { private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Map allEiTypes = new HashMap<>(); + private final Map allEiTypes = new HashMap<>(); private final ApplicationConfig config; private final Gson gson; - public EiTypes(ApplicationConfig config) { + public InfoTypes(ApplicationConfig config) { this.config = config; GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); @@ -67,33 +67,33 @@ public class EiTypes { for (File file : dbDir.listFiles()) { String json = Files.readString(file.toPath()); - EiType type = gson.fromJson(json, EiType.class); + InfoType type = gson.fromJson(json, InfoType.class); allEiTypes.put(type.getId(), type); } } - public synchronized void put(EiType type) { + public synchronized void put(InfoType type) { allEiTypes.put(type.getId(), type); storeInFile(type); } - public synchronized Collection getAllInfoTypes() { + public synchronized Collection getAllInfoTypes() { return new Vector<>(allEiTypes.values()); } - public synchronized EiType getType(String id) throws ServiceException { - EiType type = allEiTypes.get(id); + public synchronized InfoType getType(String id) throws ServiceException { + InfoType type = allEiTypes.get(id); if (type == null) { throw new ServiceException("Information type not found: " + id); } return type; } - public synchronized EiType get(String id) { + public synchronized InfoType get(String id) { return allEiTypes.get(id); } - public synchronized void remove(EiType type) { + public synchronized void remove(InfoType type) { allEiTypes.remove(type.getId()); try { Files.delete(getPath(type)); @@ -120,7 +120,7 @@ public class EiTypes { } } - private void storeInFile(EiType type) { + private void storeInFile(InfoType type) { try { try (PrintStream out = new PrintStream(new FileOutputStream(getFile(type)))) { out.print(gson.toJson(type)); @@ -130,11 +130,11 @@ public class EiTypes { } } - private File getFile(EiType type) { + private File getFile(InfoType type) { return getPath(type).toFile(); } - private Path getPath(EiType type) { + private Path getPath(InfoType type) { return getPath(type.getId()); }