aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-06-17 11:54:29 -0400
committerJim Hahn <jrh3@att.com>2021-06-17 11:56:38 -0400
commit2bcb3ad9fe35ec2a1428f8b6e23ace6b796d9a98 (patch)
tree2537cbc5ce402554d1db1710a0362b2c55440b0c /policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http
parent8bec395a3d4ddff8bd0daca685f3e2162a9b5193 (diff)
Use lombok in policy-endpoints
Issue-ID: POLICY-3394 Change-Id: I8dfb0814d5cc544b2c334dc11a3e69ef407f163f Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java10
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java49
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java11
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java8
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java50
6 files changed, 22 insertions, 114 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
index c2921640..f64be30e 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,11 @@
package org.onap.policy.common.endpoints.http.client;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class HttpClientFactoryInstance {
/**
@@ -29,9 +32,4 @@ public class HttpClientFactoryInstance {
*/
@Getter
private static final HttpClientFactory clientFactory = new IndexedHttpClientFactory();
-
-
- private HttpClientFactoryInstance() {
- // do nothing
- }
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
index 709b1487..753994a6 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/internal/JerseyClient.java
@@ -38,13 +38,13 @@ import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import lombok.Getter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
-import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +52,7 @@ import org.slf4j.LoggerFactory;
/**
* Http Client implementation using a Jersey Client.
*/
+@Getter
@ToString
public class JerseyClient implements HttpClient {
private static final Pattern COMMA_PAT = Pattern.compile(",");
@@ -266,52 +267,6 @@ public class JerseyClient implements HttpClient {
return this.alive;
}
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public boolean isHttps() {
- return https;
- }
-
- @Override
- public boolean isSelfSignedCerts() {
- return selfSignedCerts;
- }
-
- @Override
- public String getHostname() {
- return hostname;
- }
-
- @Override
- public int getPort() {
- return port;
- }
-
- @Override
- public String getBasePath() {
- return basePath;
- }
-
- @Override
- public String getUserName() {
- return userName;
- }
-
- @GsonJsonIgnore
- @Override
- public String getPassword() {
- return password;
- }
-
- @Override
- public String getBaseUrl() {
- return baseUrl;
- }
-
private Builder getBuilder(String path, Map<String, Object> headers) {
var builder = getWebTarget().path(path).request();
for (Entry<String, Object> header : headers.entrySet()) {
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
index a56be701..58e27cbf 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,8 +20,11 @@
package org.onap.policy.common.endpoints.http.server;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class HttpServletServerFactoryInstance {
/**
@@ -29,10 +32,4 @@ public class HttpServletServerFactoryInstance {
*/
@Getter
private static final HttpServletServerFactory serverFactory = new IndexedHttpServletServerFactory();
-
-
- private HttpServletServerFactoryInstance() {
- // do nothing
- }
-
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java
index 55b3a0d5..d0df156f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/JsonExceptionMapper.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,11 +47,8 @@ public class JsonExceptionMapper implements ExceptionMapper<JsonSyntaxException>
}
@Getter
+ @AllArgsConstructor
private static class SimpleResponse {
private String errorDetails;
-
- public SimpleResponse(String errorDetails) {
- this.errorDetails = errorDetails;
- }
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java
index 7eac932a..15a584fb 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/YamlExceptionMapper.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,11 +46,8 @@ public class YamlExceptionMapper implements ExceptionMapper<YAMLException> {
}
@Getter
+ @AllArgsConstructor
private static class SimpleResponse {
private String errorDetails;
-
- public SimpleResponse(String errorDetails) {
- this.errorDetails = errorDetails;
- }
}
}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
index 4afe2c04..e4b51372 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/internal/JettyServletServer.java
@@ -24,6 +24,7 @@ package org.onap.policy.common.endpoints.http.server.internal;
import java.util.EnumSet;
import javax.servlet.DispatcherType;
+import lombok.Getter;
import lombok.ToString;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
@@ -44,7 +45,6 @@ import org.eclipse.jetty.util.security.Credential;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.onap.aaf.cadi.filter.CadiFilter;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,26 +72,31 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
/**
* Server name.
*/
+ @Getter
protected final String name;
/**
* Server host address.
*/
+ @Getter
protected final String host;
/**
* Server port to bind.
*/
+ @Getter
protected final int port;
/**
* Server auth user name.
*/
+ @Getter
protected String user;
/**
* Server auth password name.
*/
+ @Getter
protected String password;
/**
@@ -462,49 +467,6 @@ public abstract class JettyServletServer implements HttpServletServer, Runnable
}
@Override
- public int getPort() {
- return this.port;
- }
-
- /**
- * Get name.
- *
- * @return the name
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * Get host.
- *
- * @return the host
- */
- public String getHost() {
- return host;
- }
-
- /**
- * Get user.
- *
- * @return the user
- */
- public String getUser() {
- return user;
- }
-
- /**
- * Get password.
- *
- * @return the password
- */
- @GsonJsonIgnore
- public String getPassword() {
- return password;
- }
-
- @Override
public void setSerializationProvider(String provider) {
throw new UnsupportedOperationException("setSerializationProvider()" + NOT_SUPPORTED);
}