X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=plans%2Fso%2Fintegration-etsi-testing%2Fso-simulators%2Faai-simulator%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fso%2Faai%2Fsimulator%2Fservice%2Fproviders%2FProjectCacheServiceProviderImpl.java;h=4fca3119b198148a3a6fc8a29d9c52e6cfeaffbf;hb=bf6e301bdedc4285cdd05826e29bdcbd68f8a699;hp=a10478875411fdb7466569886e5cd5a1fbd4bd53;hpb=50e113e064e31aed7435ac814e4776b72f842c8f;p=integration%2Fcsit.git diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java index a1047887..4fca3119 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aai/simulator/service/providers/ProjectCacheServiceProviderImpl.java @@ -22,7 +22,6 @@ package org.onap.so.aai.simulator.service.providers; import static org.onap.so.aai.simulator.utils.Constants.PROJECT_CACHE; import static org.onap.so.aai.simulator.utils.Constants.SERVICE_RESOURCE_TYPE; import java.util.Optional; -import java.util.concurrent.ConcurrentHashMap; import org.onap.aai.domain.yang.Project; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; @@ -38,23 +37,23 @@ import org.springframework.stereotype.Service; * */ @Service -public class ProjectCacheServiceProviderImpl implements ProjectCacheServiceProvider { +public class ProjectCacheServiceProviderImpl extends AbstractCacheServiceProvider + implements ProjectCacheServiceProvider { private static final String RELATIONSHIPS_LABEL = "org.onap.relationships.inventory.Uses"; private static final Logger LOGGER = LoggerFactory.getLogger(ProjectCacheServiceProviderImpl.class); - public final CacheManager cacheManager; @Autowired public ProjectCacheServiceProviderImpl(final CacheManager cacheManager) { - this.cacheManager = cacheManager; + super(cacheManager); } @Override public void putProject(final String projectName, final Project project) { LOGGER.info("Adding project: {} with name to cache", project, projectName); - final Cache cache = cacheManager.getCache(PROJECT_CACHE); + final Cache cache = getCache(PROJECT_CACHE); cache.put(projectName, project); } @@ -62,7 +61,7 @@ public class ProjectCacheServiceProviderImpl implements ProjectCacheServiceProvi @Override public Optional getProject(final String projectName) { LOGGER.info("getting project from cache using key: {}", projectName); - final Cache cache = cacheManager.getCache(PROJECT_CACHE); + final Cache cache = getCache(PROJECT_CACHE); final Project value = cache.get(projectName, Project.class); if (value != null) { return Optional.of(value); @@ -72,7 +71,7 @@ public class ProjectCacheServiceProviderImpl implements ProjectCacheServiceProvi @Override public boolean putProjectRelationShip(final String projectName, final Relationship relationship) { - final Cache cache = cacheManager.getCache(PROJECT_CACHE); + final Cache cache = getCache(PROJECT_CACHE); final Project value = cache.get(projectName, Project.class); if (value != null) { RelationshipList relationshipList = value.getRelationshipList(); @@ -90,15 +89,13 @@ public class ProjectCacheServiceProviderImpl implements ProjectCacheServiceProvi return relationshipList.getRelationship().add(relationship); } + LOGGER.error("Project not found in cache for {}", projectName); return false; } @Override public void clearAll() { - final Cache cache = cacheManager.getCache(PROJECT_CACHE); - final ConcurrentHashMap nativeCache = (ConcurrentHashMap) cache.getNativeCache(); - LOGGER.info("Clear all entries from cahce: {}", cache.getName()); - nativeCache.clear(); + clearCahce(PROJECT_CACHE); } }