diff options
author | Dan Timoney <dtimoney@att.com> | 2022-08-03 15:29:55 -0400 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2022-08-16 12:31:43 +0000 |
commit | d8a243cd5d8a66025a7d25b92186c8f7fa1adea0 (patch) | |
tree | 38ad42edf3dac94fb34589569926167eabe062c0 /a1-adapter/a1-adapter-api | |
parent | ca315932268e1c5da6a12201db4cfaef35df69bb (diff) |
Update ccsdk/oran for ODL Sulfur
Updated ccsdk/oran to use ODL Sulfur version of parent poms,
and made changes to deal with removal of Builder abstract
class in Sulfur.
Issue-ID: CCSDK-3694
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I67aa78d8e0f5641c6acbfe5892966bad5346ca20
Diffstat (limited to 'a1-adapter/a1-adapter-api')
7 files changed, 249 insertions, 28 deletions
diff --git a/a1-adapter/a1-adapter-api/feature/pom.xml b/a1-adapter/a1-adapter-api/feature/pom.xml index 56096162..ad1405b3 100644 --- a/a1-adapter/a1-adapter-api/feature/pom.xml +++ b/a1-adapter/a1-adapter-api/feature/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>single-feature-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1</version> <relativePath/> </parent> diff --git a/a1-adapter/a1-adapter-api/installer/pom.xml b/a1-adapter/a1-adapter-api/installer/pom.xml index 299121b9..b9406ac2 100644 --- a/a1-adapter/a1-adapter-api/installer/pom.xml +++ b/a1-adapter/a1-adapter-api/installer/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1</version> <relativePath/> </parent> diff --git a/a1-adapter/a1-adapter-api/model/pom.xml b/a1-adapter/a1-adapter-api/model/pom.xml index 8c46a2f5..3fe07d91 100644 --- a/a1-adapter/a1-adapter-api/model/pom.xml +++ b/a1-adapter/a1-adapter-api/model/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1</version> <relativePath/> </parent> diff --git a/a1-adapter/a1-adapter-api/pom.xml b/a1-adapter/a1-adapter-api/pom.xml index 4b314ac2..b56e5b9a 100644 --- a/a1-adapter/a1-adapter-api/pom.xml +++ b/a1-adapter/a1-adapter-api/pom.xml @@ -24,7 +24,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.4.0</version> + <version>2.4.1</version> <relativePath/> </parent> diff --git a/a1-adapter/a1-adapter-api/provider/pom.xml b/a1-adapter/a1-adapter-api/provider/pom.xml index 407bceca..fdb3836b 100644 --- a/a1-adapter/a1-adapter-api/provider/pom.xml +++ b/a1-adapter/a1-adapter-api/provider/pom.xml @@ -25,7 +25,7 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1</version> <relativePath/> </parent> diff --git a/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java b/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java index 40dfcbc5..b6950247 100644 --- a/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java +++ b/a1-adapter/a1-adapter-api/provider/src/main/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProvider.java @@ -53,7 +53,6 @@ import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyInp import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutput; import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutputBuilder; -import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -179,7 +178,7 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { return Futures.immediateFuture(putPolicyResult); } - private <T> boolean hasGraph(final String svcOperation, Builder<T> response) { + private boolean hasGraph(final String svcOperation, DeleteA1PolicyOutputBuilder response) { try { return a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC); } catch (Exception e) { @@ -189,8 +188,65 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { return false; } - private <U, T> void setUpAndExecuteOperation(final String svcOperation, Builder<U> inputBuilder, - Builder<T> responseBuilder) { + private boolean hasGraph(final String svcOperation, GetA1PolicyOutputBuilder response) { + try { + return a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC); + } catch (Exception e) { + log.error("Caught exception looking for service logic, {}", e.getMessage()); + setHttpResponse(response, SC_INTERNAL_SERVER_ERROR); + } + return false; + } + + private boolean hasGraph(final String svcOperation, GetA1PolicyStatusOutputBuilder response) { + try { + return a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC); + } catch (Exception e) { + log.error("Caught exception looking for service logic, {}", e.getMessage()); + setHttpResponse(response, SC_INTERNAL_SERVER_ERROR); + } + return false; + } + + private boolean hasGraph(final String svcOperation, GetA1PolicyTypeOutputBuilder response) { + try { + return a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC); + } catch (Exception e) { + log.error("Caught exception looking for service logic, {}", e.getMessage()); + setHttpResponse(response, SC_INTERNAL_SERVER_ERROR); + } + return false; + } + + private boolean hasGraph(final String svcOperation, PutA1PolicyOutputBuilder response) { + try { + return a1AdapterClient.hasGraph(A1_ADAPTER_API, svcOperation, null, SYNC); + } catch (Exception e) { + log.error("Caught exception looking for service logic, {}", e.getMessage()); + setHttpResponse(response, SC_INTERNAL_SERVER_ERROR); + } + return false; + } + + private void setUpAndExecuteOperation(final String svcOperation, DeleteA1PolicyInputBuilder inputBuilder, + DeleteA1PolicyOutputBuilder responseBuilder) { + log.info("Adding INPUT data for {} input: {}", svcOperation, inputBuilder); + // add input to parms + Properties parms = new Properties(); + MdsalHelper.toProperties(parms, inputBuilder.build()); + logSliParameters(parms); + // Call SLI sync method + if (hasGraph(svcOperation, responseBuilder)) { + log.info("A1AdapterClient has a Directed Graph for '{}'", svcOperation); + executeOperation(svcOperation, parms, responseBuilder); + } else { + log.error("No service logic active for A1Adapter: '{}'", svcOperation); + setHttpResponse(responseBuilder, Integer.valueOf(SC_SERVICE_UNAVAILABLE)); + } + } + + private void setUpAndExecuteOperation(final String svcOperation, GetA1PolicyInputBuilder inputBuilder, + GetA1PolicyOutputBuilder responseBuilder) { log.info("Adding INPUT data for {} input: {}", svcOperation, inputBuilder); // add input to parms Properties parms = new Properties(); @@ -206,7 +262,58 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { } } - private <T> void executeOperation(final String svcOperation, Properties parms, Builder<T> response) { + private void setUpAndExecuteOperation(final String svcOperation, GetA1PolicyStatusInputBuilder inputBuilder, + GetA1PolicyStatusOutputBuilder responseBuilder) { + log.info("Adding INPUT data for {} input: {}", svcOperation, inputBuilder); + // add input to parms + Properties parms = new Properties(); + MdsalHelper.toProperties(parms, inputBuilder.build()); + logSliParameters(parms); + // Call SLI sync method + if (hasGraph(svcOperation, responseBuilder)) { + log.info("A1AdapterClient has a Directed Graph for '{}'", svcOperation); + executeOperation(svcOperation, parms, responseBuilder); + } else { + log.error("No service logic active for A1Adapter: '{}'", svcOperation); + setHttpResponse(responseBuilder, Integer.valueOf(SC_SERVICE_UNAVAILABLE)); + } + } + + private void setUpAndExecuteOperation(final String svcOperation, GetA1PolicyTypeInputBuilder inputBuilder, + GetA1PolicyTypeOutputBuilder responseBuilder) { + log.info("Adding INPUT data for {} input: {}", svcOperation, inputBuilder); + // add input to parms + Properties parms = new Properties(); + MdsalHelper.toProperties(parms, inputBuilder.build()); + logSliParameters(parms); + // Call SLI sync method + if (hasGraph(svcOperation, responseBuilder)) { + log.info("A1AdapterClient has a Directed Graph for '{}'", svcOperation); + executeOperation(svcOperation, parms, responseBuilder); + } else { + log.error("No service logic active for A1Adapter: '{}'", svcOperation); + setHttpResponse(responseBuilder, Integer.valueOf(SC_SERVICE_UNAVAILABLE)); + } + } + + private void setUpAndExecuteOperation(final String svcOperation, PutA1PolicyInputBuilder inputBuilder, + PutA1PolicyOutputBuilder responseBuilder) { + log.info("Adding INPUT data for {} input: {}", svcOperation, inputBuilder); + // add input to parms + Properties parms = new Properties(); + MdsalHelper.toProperties(parms, inputBuilder.build()); + logSliParameters(parms); + // Call SLI sync method + if (hasGraph(svcOperation, responseBuilder)) { + log.info("A1AdapterClient has a Directed Graph for '{}'", svcOperation); + executeOperation(svcOperation, parms, responseBuilder); + } else { + log.error("No service logic active for A1Adapter: '{}'", svcOperation); + setHttpResponse(responseBuilder, Integer.valueOf(SC_SERVICE_UNAVAILABLE)); + } + } + + private void executeOperation(final String svcOperation, Properties parms, DeleteA1PolicyOutputBuilder response) { try { Properties responseParms = a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, response, parms); @@ -219,7 +326,95 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { } } - private <T> void setBody(Builder<T> responseBuilder, String body) { + private void executeOperation(final String svcOperation, Properties parms, GetA1PolicyOutputBuilder response) { + try { + Properties responseParms = + a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, response, parms); + logResponse(responseParms); + setBody(response, responseParms.getProperty(RESPONSE_BODY)); + setHttpResponse(response, Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); + } catch (Exception e) { + log.error("Caught exception executing service logic for {}, {}", svcOperation, e.getMessage()); + setHttpResponse(response, Integer.valueOf(SC_INTERNAL_SERVER_ERROR)); + } + } + + private void executeOperation(final String svcOperation, Properties parms, GetA1PolicyStatusOutputBuilder response) { + try { + Properties responseParms = + a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, response, parms); + logResponse(responseParms); + setBody(response, responseParms.getProperty(RESPONSE_BODY)); + setHttpResponse(response, Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); + } catch (Exception e) { + log.error("Caught exception executing service logic for {}, {}", svcOperation, e.getMessage()); + setHttpResponse(response, Integer.valueOf(SC_INTERNAL_SERVER_ERROR)); + } + } + + private void executeOperation(final String svcOperation, Properties parms, GetA1PolicyTypeOutputBuilder response) { + try { + Properties responseParms = + a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, response, parms); + logResponse(responseParms); + setBody(response, responseParms.getProperty(RESPONSE_BODY)); + setHttpResponse(response, Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); + } catch (Exception e) { + log.error("Caught exception executing service logic for {}, {}", svcOperation, e.getMessage()); + setHttpResponse(response, Integer.valueOf(SC_INTERNAL_SERVER_ERROR)); + } + } + + private void executeOperation(final String svcOperation, Properties parms, PutA1PolicyOutputBuilder response) { + try { + Properties responseParms = + a1AdapterClient.execute(A1_ADAPTER_API, svcOperation, null, SYNC, response, parms); + logResponse(responseParms); + setBody(response, responseParms.getProperty(RESPONSE_BODY)); + setHttpResponse(response, Integer.valueOf(responseParms.getProperty(RESPONSE_CODE))); + } catch (Exception e) { + log.error("Caught exception executing service logic for {}, {}", svcOperation, e.getMessage()); + setHttpResponse(response, Integer.valueOf(SC_INTERNAL_SERVER_ERROR)); + } + } + + private void setBody(DeleteA1PolicyOutputBuilder responseBuilder, String body) { + try { + Method method = responseBuilder.getClass().getMethod("setBody", String.class); + method.invoke(responseBuilder, body); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setBody(GetA1PolicyOutputBuilder responseBuilder, String body) { + try { + Method method = responseBuilder.getClass().getMethod("setBody", String.class); + method.invoke(responseBuilder, body); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setBody(GetA1PolicyStatusOutputBuilder responseBuilder, String body) { + try { + Method method = responseBuilder.getClass().getMethod("setBody", String.class); + method.invoke(responseBuilder, body); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setBody(GetA1PolicyTypeOutputBuilder responseBuilder, String body) { + try { + Method method = responseBuilder.getClass().getMethod("setBody", String.class); + method.invoke(responseBuilder, body); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setBody(PutA1PolicyOutputBuilder responseBuilder, String body) { try { Method method = responseBuilder.getClass().getMethod("setBody", String.class); method.invoke(responseBuilder, body); @@ -228,7 +423,43 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService { } } - private <T> void setHttpResponse(Builder<T> responseBuilder, Integer response) { + private void setHttpResponse(DeleteA1PolicyOutputBuilder responseBuilder, Integer response) { + try { + Method method = responseBuilder.getClass().getMethod("setHttpStatus", Integer.class); + method.invoke(responseBuilder, response); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setHttpResponse(GetA1PolicyOutputBuilder responseBuilder, Integer response) { + try { + Method method = responseBuilder.getClass().getMethod("setHttpStatus", Integer.class); + method.invoke(responseBuilder, response); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setHttpResponse(GetA1PolicyStatusOutputBuilder responseBuilder, Integer response) { + try { + Method method = responseBuilder.getClass().getMethod("setHttpStatus", Integer.class); + method.invoke(responseBuilder, response); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setHttpResponse(GetA1PolicyTypeOutputBuilder responseBuilder, Integer response) { + try { + Method method = responseBuilder.getClass().getMethod("setHttpStatus", Integer.class); + method.invoke(responseBuilder, response); + } catch (Exception reflectionException) { + throw new MissingResponseMethodRuntimeException(reflectionException); + } + } + + private void setHttpResponse(PutA1PolicyOutputBuilder responseBuilder, Integer response) { try { Method method = responseBuilder.getClass().getMethod("setHttpStatus", Integer.class); method.invoke(responseBuilder, response); diff --git a/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java index 890ff72c..b68a99e5 100644 --- a/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java +++ b/a1-adapter/a1-adapter-api/provider/src/test/java/org/onap/ccsdk/features/a1/adapter/A1AdapterProviderTest.java @@ -35,17 +35,7 @@ import org.mockito.Mockito; import org.mockito.junit.jupiter.MockitoExtension; import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.mdsal.binding.api.RpcProviderService; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.DeleteA1PolicyOutput; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyOutput; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyStatusOutput; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.GetA1PolicyTypeOutput; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.PutA1PolicyOutput; -import org.opendaylight.yangtools.concepts.Builder; +import org.opendaylight.yang.gen.v1.org.onap.a1.adapter.rev200122.*; import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -82,7 +72,7 @@ class A1AdapterProviderTest { DeleteA1PolicyInputBuilder inputBuilder = new DeleteA1PolicyInputBuilder(); when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true); when( - a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class))) + a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(DeleteA1PolicyOutputBuilder.class), any(Properties.class))) .thenReturn(respProps); ListenableFuture<RpcResult<DeleteA1PolicyOutput>> result = a1AdapterProviderMock.deleteA1Policy(inputBuilder.build()); @@ -97,7 +87,7 @@ class A1AdapterProviderTest { GetA1PolicyInputBuilder inputBuilder = new GetA1PolicyInputBuilder(); when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true); when( - a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class))) + a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetA1PolicyOutputBuilder.class), any(Properties.class))) .thenReturn(respProps); ListenableFuture<RpcResult<GetA1PolicyOutput>> result = a1AdapterProviderMock.getA1Policy(inputBuilder.build()); assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus())); @@ -111,7 +101,7 @@ class A1AdapterProviderTest { GetA1PolicyTypeInputBuilder inputBuilder = new GetA1PolicyTypeInputBuilder(); when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true); when( - a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class))) + a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetA1PolicyTypeOutputBuilder.class), any(Properties.class))) .thenReturn(respProps); ListenableFuture<RpcResult<GetA1PolicyTypeOutput>> result = a1AdapterProviderMock.getA1PolicyType(inputBuilder.build()); @@ -126,7 +116,7 @@ class A1AdapterProviderTest { GetA1PolicyStatusInputBuilder inputBuilder = new GetA1PolicyStatusInputBuilder(); when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true); when( - a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class))) + a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetA1PolicyStatusOutputBuilder.class), any(Properties.class))) .thenReturn(respProps); ListenableFuture<RpcResult<GetA1PolicyStatusOutput>> result = a1AdapterProviderMock.getA1PolicyStatus(inputBuilder.build()); @@ -141,7 +131,7 @@ class A1AdapterProviderTest { PutA1PolicyInputBuilder inputBuilder = new PutA1PolicyInputBuilder(); when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true); when( - a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(Builder.class), any(Properties.class))) + a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(PutA1PolicyOutputBuilder.class), any(Properties.class))) .thenReturn(respProps); ListenableFuture<RpcResult<PutA1PolicyOutput>> result = a1AdapterProviderMock.putA1Policy(inputBuilder.build()); assertEquals(OK_RESPONSE, String.valueOf(result.get().getResult().getHttpStatus())); |