summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler/provider/src
diff options
context:
space:
mode:
authorPatrick Brady <patrick.brady@att.com>2019-02-22 13:37:19 -0800
committerPatrick Brady <patrick.brady@att.com>2019-02-25 22:33:05 +0000
commit13c0353d0f637ec88ca4cdbeb64c4de3917e6a2b (patch)
treea9d1561322f2f66556aa7c8a6e3ddae592a23d08 /appc-inbound/appc-artifact-handler/provider/src
parent356dba9fb407b1df3fe89a4c8f082a09aa564d36 (diff)
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 <patrick.brady@att.com> Issue-ID: APPC-1370
Diffstat (limited to 'appc-inbound/appc-artifact-handler/provider/src')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/ArtifactHandlerProvider.java91
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivator.java59
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler.xml (renamed from appc-inbound/appc-artifact-handler/provider/src/main/resources/org/opendaylight/blueprint/artifact-handler-blueprint.xml)6
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/ArtifactHandlerProviderTest.java7
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/test/java/org/onap/appc/artifact/handler/SdcArtifactHandlerActivatorTest.java55
5 files changed, 14 insertions, 204 deletions
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<DataChangeListener> dclServices;
-
- protected BindingAwareBroker.RpcRegistration<ArtifactHandlerService> 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<Void, TransactionCommitFailedException> 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<InstanceIdentifier<?>, 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<UploadartifactOutput> buildResponse1(
String svcRequestId,
@@ -158,9 +87,8 @@ public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerSe
.withResult(responseBuilder.build()).build();
return rpcResult;
}
-
@Override
- public Future<RpcResult<UploadartifactOutput>> uploadartifact(UploadartifactInput input) {
+ public ListenableFuture<RpcResult<UploadartifactOutput>> uploadartifact(UploadartifactInput input) {
if (input == null || input.getDocumentParameters() == null || input.getDocumentParameters().getArtifactContents() == null ) {
RpcResult<UploadartifactOutput> rpcResult =
@@ -201,7 +129,12 @@ public class ArtifactHandlerProvider implements AutoCloseable, ArtifactHandlerSe
responseBuilder.setConfigDocumentResponse(configResponseBuilder.build());
RpcResult<UploadartifactOutput> rpcResult = RpcResultBuilder.<UploadartifactOutput> 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<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>();
-
- @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.xml
index d74724ce7..8185e6c5b 100644
--- 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.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.
@@ -22,8 +22,6 @@
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
-
-
<reference id="dataBroker"
interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
odl:type="default" />
@@ -44,4 +42,4 @@
<odl:rpc-implementation ref="artifact-handler"/>
-</blueprint> \ No newline at end of file
+</blueprint>
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<ServiceRegistration> 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<ServiceRegistration> 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();
- }
-}