diff options
author | Christopher Lott (cl778h) <clott@research.att.com> | 2017-09-07 08:52:41 -0400 |
---|---|---|
committer | Christopher Lott (cl778h) <clott@research.att.com> | 2017-09-07 08:54:52 -0400 |
commit | 8cd208ebaa33627daf05d8ffff7b28e53a7067d0 (patch) | |
tree | 0b07ec3c6305c46f34eae69d8fb6fa824aaae256 /ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache | |
parent | b52d4cebc430a083ec1e6881c4f01dfe709ac726 (diff) |
Adjust code for Sonar issues
Made non-functional updates to address static code analysis issues.
Update license header with simple double-quote characters.
Issue: PORTAL-72, PORTAL-90
Change-Id: Ic2c330daea07d721f0e6b350ebf03da97073f7ce
Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache')
4 files changed, 108 insertions, 92 deletions
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/AbstractCacheManager.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/AbstractCacheManager.java index 8bbf34cd..16b763a1 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/AbstractCacheManager.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/AbstractCacheManager.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -37,42 +37,40 @@ */ package org.onap.portalsdk.core.objectcache; -import java.io.*; - -import org.onap.portalsdk.core.objectcache.support.*; +import java.io.IOException; +import org.onap.portalsdk.core.objectcache.support.FusionCacheManager; public abstract class AbstractCacheManager implements FusionCacheManager { - public AbstractCacheManager() { - super(); - // TODO Auto-generated constructor stub - } - public Object getObject(String key) { - // TODO Auto-generated method stub - return null; - } + public AbstractCacheManager() { + super(); + } - public void putObject(String key, Object objectToCache) { - // TODO Auto-generated method stub - } + @Override + public Object getObject(String key) { + return null; + } - public boolean isObjectInCache(String key) { - // TODO Auto-generated method stub - return false; - } + @Override + public void putObject(String key, Object objectToCache) { + } - public void removeObject(String key) { - // TODO Auto-generated method stub - } + @Override + public boolean isObjectInCache(String key) { + return false; + } - public void clearCache() { - // TODO Auto-generated method stub - } + @Override + public void removeObject(String key) { + } - public void configure() throws IOException { - // TODO Auto-generated method stub + @Override + public void clearCache() { + } - } -} + @Override + public void configure() throws IOException { + } +} diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheEventHandler.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheEventHandler.java index 8660d9f9..71357f34 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheEventHandler.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheEventHandler.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -43,36 +43,46 @@ import org.apache.jcs.engine.control.event.behavior.IElementEventHandler; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; public class JCSCacheEventHandler implements IElementEventHandler, IElementEventConstants { - - private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JCSCacheEventHandler.class); - - public JCSCacheEventHandler() { - super(); - } - public void handleElementEvent(IElementEvent event) { - // Handle code for various event notifications on cached elements by JCS. - switch (event.getElementEvent()) { - case ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND occurred for element " + event); - break; - case ELEMENT_EVENT_EXCEEDED_MAXLIFE_ONREQUEST: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_EXCEEDED_MAXLIFE_ONREQUEST occurred for element " + event); - break; - case ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND occurred for element " + event); - break; - case ELEMENT_EVENT_EXCEEDED_IDLETIME_ONREQUEST: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_EXCEEDED_IDLETIME_ONREQUEST occurred for element " + event); - break; - case ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE occurred for element " + event); - break; - case ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE occurred for element " + event); - break; - case ELEMENT_EVENT_SPOOLED_NOT_ALLOWED: - logger.error(EELFLoggerDelegate.errorLogger, "Event ELEMENT_EVENT_SPOOLED_NOT_ALLOWED occurred for element " + event); - } - } + private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JCSCacheEventHandler.class); + + public JCSCacheEventHandler() { + super(); + } + + @Override + public void handleElementEvent(IElementEvent event) { + // Handle code for various event notifications on cached elements by JCS. + switch (event.getElementEvent()) { + case ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND occurred for element " + event); + break; + case ELEMENT_EVENT_EXCEEDED_MAXLIFE_ONREQUEST: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_EXCEEDED_MAXLIFE_ONREQUEST occurred for element " + event); + break; + case ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND occurred for element " + event); + break; + case ELEMENT_EVENT_EXCEEDED_IDLETIME_ONREQUEST: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_EXCEEDED_IDLETIME_ONREQUEST occurred for element " + event); + break; + case ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE occurred for element " + event); + break; + case ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE occurred for element " + event); + break; + case ELEMENT_EVENT_SPOOLED_NOT_ALLOWED: + logger.error(EELFLoggerDelegate.errorLogger, + "Event ELEMENT_EVENT_SPOOLED_NOT_ALLOWED occurred for element " + event); + default: + logger.error(EELFLoggerDelegate.errorLogger, "handleElementEvent: unknown event " + event); + } + } } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheManager.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheManager.java index f169754f..2fa5e856 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheManager.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/jcs/JCSCacheManager.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -39,8 +39,9 @@ package org.onap.portalsdk.core.objectcache.jcs; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; -import java.util.Vector; import javax.annotation.PostConstruct; import javax.servlet.ServletContext; @@ -60,19 +61,19 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(JCSCacheManager.class); - public static String LOOKUP_OBJECT_CACHE_NAME = "lookUpObjectCache"; - public static String JCS_CONFIG_FILE_PATH = "cache_config_file_path"; - public static String CACHE_LOAD_ON_STARTUP = "cache_load_on_startup"; - public static String CACHE_PROPERTY_VALUE_TRUE = "true"; - public static String CACHE_CONTROL_SWITCH_ON = "1"; - public static String CACHE_CONTROL_SWITCH_OFF = "0"; - public static String CACHE_CONTROL_SWITCH = "cache_switch"; + public static final String LOOKUP_OBJECT_CACHE_NAME = "lookUpObjectCache"; + public static final String JCS_CONFIG_FILE_PATH = "cache_config_file_path"; + public static final String CACHE_LOAD_ON_STARTUP = "cache_load_on_startup"; + public static final String CACHE_PROPERTY_VALUE_TRUE = "true"; + public static final String CACHE_CONTROL_SWITCH_ON = "1"; + public static final String CACHE_CONTROL_SWITCH_OFF = "0"; + public static final String CACHE_CONTROL_SWITCH = "cache_switch"; - private static JCS lookUpCache; + private JCS lookUpCache; private ServletContext servletContext; private Properties cacheConfigProperties = null; - private final Vector<String> jscManagedCacheList = new Vector<String>(); + private final ArrayList<String> jscManagedCacheList = new ArrayList<>(); private DataAccessService dataAccessService; @@ -81,6 +82,7 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca jscManagedCacheList.add(LOOKUP_OBJECT_CACHE_NAME); } + @Override @PostConstruct public void configure() throws IOException { super.configure(); @@ -93,8 +95,8 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca if (jcsConfigInputStream == null) throw new IOException("configure: failed to open stream for config property " + JCS_CONFIG_FILE_PATH + " with name " + jcsConfigFilePath); - logger.debug(EELFLoggerDelegate.debugLogger, - "configure: loading cache properties from classpath resource {} ", jcsConfigFilePath); + logger.debug(EELFLoggerDelegate.debugLogger, "configure: loading cache properties from classpath resource {} ", + jcsConfigFilePath); Properties p = new Properties(); p.load(jcsConfigInputStream); jcsConfigInputStream.close(); @@ -126,6 +128,7 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca } } + @Override public Object getObject(String key) { if (CACHE_CONTROL_SWITCH_ON.equalsIgnoreCase(SystemProperties.getProperty(CACHE_CONTROL_SWITCH))) { if (lookUpCache == null) @@ -136,12 +139,12 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca return null; } + @Override public void putObject(String key, Object objectToCache) { try { - if (CACHE_CONTROL_SWITCH_ON.equalsIgnoreCase(SystemProperties.getProperty(CACHE_CONTROL_SWITCH))) { - if (lookUpCache != null) { - lookUpCache.put(key, objectToCache); - } + if (CACHE_CONTROL_SWITCH_ON.equalsIgnoreCase(SystemProperties.getProperty(CACHE_CONTROL_SWITCH)) + && lookUpCache != null) { + lookUpCache.put(key, objectToCache); } } catch (CacheException ce) { logger.error(EELFLoggerDelegate.errorLogger, "putObject: failed to put the object with key " + key, ce); @@ -158,6 +161,7 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca } } + @Override public void clearCache() { clearCache(LOOKUP_OBJECT_CACHE_NAME); } @@ -181,7 +185,7 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca this.cacheConfigProperties = cacheConfigProperties; } - public Vector<String> getJscManagedCacheList() { + public List<String> getJscManagedCacheList() { return jscManagedCacheList; } @@ -197,6 +201,7 @@ public abstract class JCSCacheManager extends AbstractCacheManager implements Ca return servletContext; } + @Override public void setServletContext(ServletContext servletContext) { this.servletContext = servletContext; } diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/support/FusionCacheManager.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/support/FusionCacheManager.java index e2a8ca14..af8b24b7 100644 --- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/support/FusionCacheManager.java +++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/objectcache/support/FusionCacheManager.java @@ -6,7 +6,7 @@ * =================================================================== * * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the “License”); + * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. * You may obtain a copy of the License at * @@ -19,7 +19,7 @@ * limitations under the License. * * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the “License”); + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at * @@ -37,18 +37,21 @@ */ package org.onap.portalsdk.core.objectcache.support; -import java.io.*; +import java.io.IOException; import org.onap.portalsdk.core.FusionObject; public interface FusionCacheManager extends FusionObject { - Object getObject(String key); - void putObject(String key, Object objectToCache); - boolean isObjectInCache(String key); + Object getObject(String key); - void removeObject(String key); - void clearCache(); - void configure() throws IOException; -} + void putObject(String key, Object objectToCache); + + boolean isObjectInCache(String key); + + void removeObject(String key); + void clearCache(); + + void configure() throws IOException; +} |