From 13c0353d0f637ec88ca4cdbeb64c4de3917e6a2b Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Fri, 22 Feb 2019 13:37:19 -0800 Subject: Changes for new odl version Changes required to update to latest opendaylight version. Some powermock tests have been temporarily removed due to an powermock incompatibility. They will be fixed and re-added. Change-Id: I418d44913fcd42423d2d9bd37b189f6301eaab81 Signed-off-by: Patrick Brady Issue-ID: APPC-1370 --- .../features/onap-appc-artifact-handler/pom.xml | 2 +- .../features/src/main/resources/features.xml | 47 --------- .../appc-artifact-handler/installer/pom.xml | 5 +- appc-inbound/appc-artifact-handler/model/pom.xml | 13 +-- .../model/src/main/yang/artifact-handler.yang | 1 - appc-inbound/appc-artifact-handler/pom.xml | 116 ++++++++------------- .../appc-artifact-handler/provider/pom.xml | 23 +--- .../artifact/handler/ArtifactHandlerProvider.java | 91 +++------------- .../handler/SdcArtifactHandlerActivator.java | 59 ----------- .../blueprint/artifact-handler-blueprint.xml | 47 --------- .../opendaylight/blueprint/artifact-handler.xml | 45 ++++++++ .../handler/ArtifactHandlerProviderTest.java | 7 -- .../handler/SdcArtifactHandlerActivatorTest.java | 55 ---------- 13 files changed, 111 insertions(+), 400 deletions(-) delete mode 100644 appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml delete mode 100644 appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java delete mode 100644 appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml create mode 100644 appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml delete mode 100644 appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java (limited to 'appc-inbound/appc-artifact-handler') diff --git a/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml b/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml index 1fd78b0c7..07337e89b 100644 --- a/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml +++ b/appc-inbound/appc-artifact-handler/features/onap-appc-artifact-handler/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2018-2019 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. diff --git a/appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml b/appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml deleted file mode 100644 index 3909d1c4b..000000000 --- a/appc-inbound/appc-artifact-handler/features/src/main/resources/features.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - odl-mdsal-broker - ccsdk-sli - - wrap:mvn:org.openecomp.sdc.common/openecomp-tosca-datatype/${tosca.datatype.version} - mvn:org.onap.appc/appc-config-params-provider/${project.version} - mvn:org.onap.appc/appc-artifact-handler-model/${project.version} - mvn:org.onap.appc/appc-artifact-handler-provider/${project.version} - wrap:mvn:org.onap.appc/appc-yang-generator/${project.version} - mvn:org.onap.appc/appc-artifact-handler-provider/${project.version}/xml/config - - - diff --git a/appc-inbound/appc-artifact-handler/installer/pom.xml b/appc-inbound/appc-artifact-handler/installer/pom.xml index 8f5f0b728..e6b4babf8 100755 --- a/appc-inbound/appc-artifact-handler/installer/pom.xml +++ b/appc-inbound/appc-artifact-handler/installer/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ - Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. Copyright (C) 2017 Amdocs ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,8 +45,8 @@ org.onap.appc onap-appc-artifact-handler - features ${project.version} + features xml @@ -60,7 +60,6 @@ appc-artifact-handler-provider ${project.version} - diff --git a/appc-inbound/appc-artifact-handler/model/pom.xml b/appc-inbound/appc-artifact-handler/model/pom.xml index 2fef74457..48f058096 100755 --- a/appc-inbound/appc-artifact-handler/model/pom.xml +++ b/appc-inbound/appc-artifact-handler/model/pom.xml @@ -30,8 +30,8 @@ org.onap.appc appc-artifact-handler-model - APPC Artifact Handler - Model bundle + APPC Artifact Handler - Model @@ -42,7 +42,7 @@ true - !com.google.common.collect,* + com.google.common.collect,com.google.common.base,* guava @@ -76,6 +76,7 @@ + org.apache.maven.plugins maven-install-plugin @@ -110,15 +111,11 @@ org.opendaylight.mdsal.model - ietf-inet-types + ietf-inet-types-2013-07-15 org.opendaylight.mdsal.model - ietf-yang-types - - - com.google.guava - guava + ietf-yang-types-20130715 1.5.0-SNAPSHOT diff --git a/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang b/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang index f9bf7ae10..0aa8082d4 100644 --- a/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang +++ b/appc-inbound/appc-artifact-handler/model/src/main/yang/artifact-handler.yang @@ -28,7 +28,6 @@ module artifact-handler { namespace "org.onap.appc:artifacthandler"; prefix artifacthandler; - import ietf-inet-types { prefix "ietf"; revision-date "2010-09-24"; } organization "AT&T, Inc."; description diff --git a/appc-inbound/appc-artifact-handler/pom.xml b/appc-inbound/appc-artifact-handler/pom.xml index 2a9f7f2af..5c642df5c 100755 --- a/appc-inbound/appc-artifact-handler/pom.xml +++ b/appc-inbound/appc-artifact-handler/pom.xml @@ -1,72 +1,44 @@ - - - - - - org.onap.appc.parent - odlparent-lite - 1.5.0-SNAPSHOT - - - org.onap.appc - 4.0.0 - pom - appc-artifact-handler - - - - - org.onap.appc - appc-artifact-handler-features - features - xml - ${project.version} - - - org.onap.appc - appc-artifact-handler-model - ${project.version} - - - org.onap.appc - appc-artifact-handler-provider - ${project.version} - config - xml - - - org.onap.appc - appc-artifact-handler-provider - ${project.version} - - - - - - model - provider - features - installer - - 1.5.0-SNAPSHOT - + + + + 4.0.0 + + + org.onap.appc.parent + odlparent-lite + 1.5.0-SNAPSHOT + + + + pom + org.onap.appc + appc-artifact-handler + + + model + features + provider + installer + + + 1.5.0-SNAPSHOT + diff --git a/appc-inbound/appc-artifact-handler/provider/pom.xml b/appc-inbound/appc-artifact-handler/provider/pom.xml index 4b0fe415b..8c465cc1c 100755 --- a/appc-inbound/appc-artifact-handler/provider/pom.xml +++ b/appc-inbound/appc-artifact-handler/provider/pom.xml @@ -3,7 +3,7 @@ ============LICENSE_START======================================================= ONAP : APPC ================================================================================ -Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. +Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. ================================================================================ Copyright (C) 2017 Amdocs ============================================================================= @@ -43,9 +43,8 @@ limitations under the License. org.onap.appc.artifact.handler - org.onap.appc.artifact.handler.SdcArtifactHandlerActivator org.onap.appc.artifact.handler,org.opendaylight.controller.config.yang.config.artifact-handler_provider.impl - !com.google,!org.apache.commons.configuration,*;resolution:=optional + com.google.common.base,com.google.common.collect,!com.google,!org.apache.commons.configuration,*;resolution:=optional commons-configuration,guava,jackson-databind,jackson-annotations,jackson-core,jackson-dataformat-yaml,json @@ -68,11 +67,6 @@ limitations under the License. appc-yang-generator ${project.version} - - - org.opendaylight.controller - sal-binding-config - org.opendaylight.controller sal-binding-api @@ -108,19 +102,6 @@ limitations under the License. org.opendaylight.controller test - - org.opendaylight.controller - sal-binding-broker-impl - test - - - org.opendaylight.controller - sal-binding-broker-impl - ${odl.mdsal.version} - tests - test-jar - test - com.att.eelf eelf-core diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java index 3246ef1ff..065bdd69a 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java +++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP : APPC * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Copyright (C) 2017 Amdocs * ================================================================================ @@ -25,20 +25,10 @@ package org.onap.appc.artifact.handler; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - +import org.onap.appc.artifact.handler.utils.ArtifactHandlerProviderUtil; +import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants; import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.ArtifactHandlerService; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.UploadartifactInput; @@ -46,101 +36,40 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.Uplo import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.UploadartifactOutput; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.UploadartifactOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.appc.artifacthandler.rev170321.uploadartifact.output.ConfigDocumentResponseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.Services; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.ServicesBuilder; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.onap.appc.artifact.handler.utils.ArtifactHandlerProviderUtil; -import org.onap.appc.artifact.handler.utils.SdcArtifactHandlerConstants; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; - - -public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerService, DataChangeListener { +public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerService { private static final EELFLogger log = EELFManager.getInstance().getLogger(ArtifactHandlerProvider.class); private final String appName = "ArtifactsHandler"; - private final ExecutorService executor; protected DataBroker dataBroker; protected NotificationPublishService notificationService; protected RpcProviderRegistry rpcRegistry; - private ListenerRegistration dclServices; - - protected BindingAwareBroker.RpcRegistration rpcRegistration; - public ArtifactHandlerProvider(DataBroker dataBroker2, - NotificationPublishService notificationProviderService, + public ArtifactHandlerProvider(DataBroker dataBroker2, NotificationPublishService notificationProviderService, RpcProviderRegistry rpcProviderRegistry) { this.log.info("Creating provider for " + appName); - executor = Executors.newFixedThreadPool(10); dataBroker = dataBroker2; notificationService = notificationProviderService; rpcRegistry = rpcProviderRegistry; initialize(); - } public void initialize() { log.info("Initializing provider for " + appName); - // Create the top level containers - createContainers(); try { ArtifactHandlerProviderUtil.loadProperties(); } catch (Exception e) { log.error("Caught exception while trying to load properties file", e); } - // Listener for changes to Services tree - log.info("Initialization complete for " + appName); } - private void createContainers() { - final WriteTransaction t = dataBroker.newReadWriteTransaction(); - // Create the Services container - t.merge(LogicalDatastoreType.CONFIGURATION,InstanceIdentifier.create(Services.class),new ServicesBuilder().build()); - t.merge(LogicalDatastoreType.OPERATIONAL,InstanceIdentifier.create(Services.class),new ServicesBuilder().build()); - - try { - CheckedFuture checkedFuture = t.submit(); - checkedFuture.get(); - log.info("Create containers succeeded!"); - - } catch (InterruptedException e) { - log.error("Create containers failed", e); - Thread.currentThread().interrupt(); - } catch (ExecutionException e) { - log.error("Create containers failed", e); - } - } - - - @Override - public void onDataChanged(AsyncDataChangeEvent, DataObject> arg0) { - // TODO Auto-generated method stub - - } - - - - @Override - public void close() throws Exception { - - log.info("Closing provider for " + appName); - if(this.executor != null){ - executor.shutdown(); - } - if(this.rpcRegistration != null){ - rpcRegistration.close(); - } - log.info("Successfully closed provider for " + appName); - - } private RpcResult buildResponse1( String svcRequestId, @@ -158,9 +87,8 @@ public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerSe .withResult(responseBuilder.build()).build(); return rpcResult; } - @Override - public Future> uploadartifact(UploadartifactInput input) { + public ListenableFuture> uploadartifact(UploadartifactInput input) { if (input == null || input.getDocumentParameters() == null || input.getDocumentParameters().getArtifactContents() == null ) { RpcResult rpcResult = @@ -201,7 +129,12 @@ public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerSe responseBuilder.setConfigDocumentResponse(configResponseBuilder.build()); RpcResult rpcResult = RpcResultBuilder. status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); + } + @Override + public void close() throws Exception { + log.info("Closing provider for " + appName); + log.info("Successfully closed provider for " + appName); } protected ArtifactHandlerProviderUtil getArtifactHandlerProviderUtil(UploadartifactInput input) { diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java deleted file mode 100644 index 58f4a12ed..000000000 --- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ================================================================================ - * Modifications Copyright (C) 2019 Ericsson - * ============================================================================= - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.artifact.handler; - -import java.util.LinkedList; -import java.util.List; - -import org.onap.appc.artifact.handler.node.ArtifactHandlerNode; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class SdcArtifactHandlerActivator implements BundleActivator { - - private static final EELFLogger log = EELFManager.getInstance().getLogger(SdcArtifactHandlerActivator.class); - private List registrations = new LinkedList(); - - @Override - public void start(BundleContext ctx) throws Exception { - ArtifactHandlerNode artifactHandlerNode = new ArtifactHandlerNode(); - log.info("Registering service-- " + artifactHandlerNode.getClass().getName()); - registrations.add(ctx.registerService(artifactHandlerNode.getClass().getName(), artifactHandlerNode, null)); - - } - - @Override - public void stop(BundleContext arg0) throws Exception { - for (ServiceRegistration registration : registrations) { - registration.unregister(); - registration = null; - } - } -} diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml b/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml deleted file mode 100644 index d74724ce7..000000000 --- a/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml b/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml new file mode 100644 index 000000000..8185e6c5b --- /dev/null +++ b/appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java index 56a999126..aa1c86ad2 100644 --- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java +++ b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java @@ -65,13 +65,6 @@ public class ArtifactHandlerProviderTest { Mockito.doReturn(checkedFuture).when(writeTransaction).submit(); } - @Test - public void testClose() throws Exception { - artifactHandlerProvider = new ArtifactHandlerProvider(dataBroker, notificationService, rpcRegistry); - Whitebox.setInternalState(artifactHandlerProvider, "rpcRegistration", rpcRegistration); - artifactHandlerProvider.close(); - Mockito.verify(rpcRegistration).close(); - } @Test public void testUploadArtifactNullInput() throws InterruptedException, ExecutionException { diff --git a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java b/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java deleted file mode 100644 index 995ffecc6..000000000 --- a/appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2019 Ericsson - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.artifact.handler; - -import java.util.LinkedList; -import org.junit.Test; -import org.mockito.Mockito; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.powermock.reflect.Whitebox; - - -public class SdcArtifactHandlerActivatorTest { - - @Test - public void testStart() throws Exception { - SdcArtifactHandlerActivator activator = new SdcArtifactHandlerActivator(); - BundleContext ctx = Mockito.mock(BundleContext.class); - LinkedList list = Mockito.spy(new LinkedList<>()); - Whitebox.setInternalState(activator, "registrations", list); - activator.start(ctx); - Mockito.verify(list).add(Mockito.any()); - } - - @Test - public void testStop() throws Exception { - SdcArtifactHandlerActivator activator = new SdcArtifactHandlerActivator(); - BundleContext ctx = Mockito.mock(BundleContext.class); - LinkedList list = Mockito.spy(new LinkedList<>()); - ServiceRegistration serviceRegistration = Mockito.mock(ServiceRegistration.class); - list.add(serviceRegistration); - Whitebox.setInternalState(activator, "registrations", list); - activator.stop(ctx); - Mockito.verify(serviceRegistration).unregister(); - } -} -- cgit