summaryrefslogtreecommitdiffstats
path: root/pomba/network-discovery/src
diff options
context:
space:
mode:
authorTait,Trevor(rt0435) <rtait@amdocs.com>2018-07-31 15:48:07 -0400
committerTait,Trevor(rt0435) <rtait@amdocs.com>2018-08-01 14:04:24 -0400
commit74f9d832beba72c1121bef875b8e36ddb3cd5740 (patch)
tree16961ab8598f3e3b916d7a8fd97ccfdea0057dca /pomba/network-discovery/src
parent46c24a62f6931364075e9bd1cd33446dfdc9575b (diff)
Fixing issues from SONAR report
Change-Id: I69e042690f464303fed0c9188b1555adf1f06481 Issue-ID: SDNC-317 Signed-off-by: Tait,Trevor(rt0435) <rtait@amdocs.com>
Diffstat (limited to 'pomba/network-discovery/src')
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/ApplicationException.java2
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/CallbackConfiguration.java2
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java82
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/JerseyConfiguration.java17
-rw-r--r--pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/rs/RestServiceImpl.java5
5 files changed, 54 insertions, 54 deletions
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/ApplicationException.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/ApplicationException.java
index 6cc3592..fa29645 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/ApplicationException.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/ApplicationException.java
@@ -20,7 +20,7 @@ package org.onap.sdnc.apps.pomba.networkdiscovery;
import javax.ws.rs.core.Response.Status;
public class ApplicationException extends Exception {
- public static enum Error {
+ public enum Error {
GENERAL_FAILURE("NET.0001", "An error occurred: %s"),
MISSING_PARAM("NET.0002", "Missing required parameter %s"),
UNAUTHORIZED("NET.0003", "Unauthorized");
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/CallbackConfiguration.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/CallbackConfiguration.java
index 30d872f..1d2bdab 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/CallbackConfiguration.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/CallbackConfiguration.java
@@ -53,7 +53,7 @@ public class CallbackConfiguration {
private String basicAuthPassword;
@Bean(name="callbackClient")
- public Client getClient() throws Exception {
+ public Client getClient() {
ClientConfig configuration = new ClientConfig()
.property(ClientProperties.CONNECT_TIMEOUT, this.connectionTimeout)
.property(ClientProperties.READ_TIMEOUT, this.readTimeout)
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java
index 0a08577..9b2db05 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/EnricherConfiguration.java
@@ -29,58 +29,58 @@ import org.springframework.core.env.Environment;
@Configuration
public class EnricherConfiguration {
- @Autowired
+ @Autowired
private Environment env;
-
- @Value("${enricher.url}")
- private String url;
- @Value("${enricher.keyStorePath}")
- private String keyStorePath;
+ @Value("${enricher.url}")
+ private String url;
- @Value("${enricher.keyStorePassword}")
- private String keyStorePassword;
+ @Value("${enricher.keyStorePath}")
+ private String keyStorePath;
- @Value("${enricher.connectionTimeout:5000}")
- private int connectionTimeout;
+ @Value("${enricher.keyStorePassword}")
+ private String keyStorePassword;
- @Value("${enricher.readTimeout:60000}")
- private int readTimeout;
+ @Value("${enricher.connectionTimeout:5000}")
+ private int connectionTimeout;
- @Bean(name="enricherClient")
- public RestClient restClient() {
- return new RestClient()
- .validateServerHostname(false)
- .validateServerCertChain(false)
- .connectTimeoutMs(this.connectionTimeout)
- .readTimeoutMs(this.readTimeout)
+ @Value("${enricher.readTimeout:60000}")
+ private int readTimeout;
+
+ @Bean(name="enricherClient")
+ public RestClient restClient() {
+ return new RestClient()
+ .validateServerHostname(false)
+ .validateServerCertChain(false)
+ .connectTimeoutMs(this.connectionTimeout)
+ .readTimeoutMs(this.readTimeout)
.clientCertFile(this.keyStorePath)
.clientCertPassword(this.keyStorePassword);
- }
+ }
+
+ @Bean(name="enricherBaseUrl")
+ public String getURL() {
+ return this.url;
+ }
+
+ @Bean(name="enricherTypeURLs")
+ public Map<String, String> enricherTypeURLs() {
+
+ Map<String, String> result = new HashMap<>();
+ String types = this.env.getProperty("enricher.types");
+ if (types == null) {
+ return result;
+ }
- @Bean(name="enricherBaseUrl")
- public String getURL() {
- return this.url;
- }
-
- @Bean(name="enricherTypeURLs")
- public Map<String, String> enricherTypeURLs() {
+ StringTokenizer tokenizer = new StringTokenizer(types, ", ");
+ while (tokenizer.hasMoreTokens()) {
+ String type = tokenizer.nextToken();
+ String enricherUrl = this.env.getProperty("enricher.type." + type + ".url");
+ result.put(type, enricherUrl);
+ }
- Map<String, String> result = new HashMap<>();
- String types = this.env.getProperty("enricher.types");
- if (types == null) {
- return result;
- }
-
- StringTokenizer tokenizer = new StringTokenizer(types, ", ");
- while (tokenizer.hasMoreTokens()) {
- String type = tokenizer.nextToken();
- String url = this.env.getProperty("enricher.type." + type + ".url");
- result.put(type, url);
- }
-
return result;
- }
+ }
}
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/JerseyConfiguration.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/JerseyConfiguration.java
index 5d93f64..b4488db 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/JerseyConfiguration.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/JerseyConfiguration.java
@@ -17,17 +17,14 @@
*/
package org.onap.sdnc.apps.pomba.networkdiscovery;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
import java.util.logging.Logger;
+
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
+
import org.glassfish.jersey.client.ClientConfig;
-import org.glassfish.jersey.filter.LoggingFilter;
+import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletProperties;
import org.onap.sdnc.apps.pomba.networkdiscovery.service.rs.RestServiceImpl;
@@ -36,6 +33,12 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
@Component
@ApplicationPath("/")
public class JerseyConfiguration extends ResourceConfig {
@@ -56,7 +59,7 @@ public class JerseyConfiguration extends ResourceConfig {
public JerseyConfiguration() {
register(RestServiceImpl.class);
property(ServletProperties.FILTER_FORWARD_ON_404, true);
- register(new LoggingFilter(log, true));
+ register(new LoggingFeature(log));
}
@Bean
diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/rs/RestServiceImpl.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/rs/RestServiceImpl.java
index 94c7492..4e6fdcb 100644
--- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/rs/RestServiceImpl.java
+++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/rs/RestServiceImpl.java
@@ -51,9 +51,6 @@ public class RestServiceImpl implements RestService {
@Resource(name="basicAuthHeader")
private String basicAuthHeader;
- public RestServiceImpl() {
- }
-
@Override
public Response findbyResourceIdAndType(HttpServletRequest request,
String version,
@@ -76,7 +73,7 @@ public class RestServiceImpl implements RestService {
version = "v1";
}
- if (!this.basicAuthHeader.equals(authorization)) {
+ if (authorization == null || !this.basicAuthHeader.equals(authorization)) {
throw new ApplicationException(UNAUTHORIZED, Status.UNAUTHORIZED);
}
if ((fromAppId == null) || fromAppId.trim().isEmpty()) {