summaryrefslogtreecommitdiffstats
path: root/asdcApi/provider/src/main/java/org
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2017-07-18 20:32:15 -0400
committerDan Timoney <dtimoney@att.com>2017-08-01 15:10:25 -0400
commitea5bf0a1c8a4e525d2cee03841b8e8f9b3563ed0 (patch)
tree5b85db0e570d86a2d3a7f5db5880196e45d8fe6f /asdcApi/provider/src/main/java/org
parentb658ce359742d141428a068ba5ebff876ada3d0a (diff)
[CCSDK-6] Populate seed code
Add seed code for sli/northbound repository Update groupId to org.onap.ccsdk.sli.northbound Update to use CCSDK version of sli core Change-Id: Id3a154a53150a74f4b65060544e76f3e0cad932e Signed-off-by: Dan Timoney <dtimoney@att.com>
Diffstat (limited to 'asdcApi/provider/src/main/java/org')
-rw-r--r--asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java57
-rw-r--r--asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java34
-rw-r--r--asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java415
-rw-r--r--asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java111
-rw-r--r--asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java48
5 files changed, 665 insertions, 0 deletions
diff --git a/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java
new file mode 100644
index 000000000..c9223a15c
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523;
+
+import org.openecomp.sdnc.asdcapi.AsdcApiProvider;
+
+public class AsdcApiProviderModule extends org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523.AbstractAsdcApiProviderModule {
+ public AsdcApiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public AsdcApiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523.AsdcApiProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+
+ final AsdcApiProvider provider = new AsdcApiProvider(getDataBrokerDependency()
+ , getNotificationServiceDependency()
+ , getRpcRegistryDependency());
+
+ return new AutoCloseable() {
+
+ @Override
+ public void close() throws Exception {
+
+ provider.close();
+ }
+ };
+ }
+
+}
diff --git a/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java
new file mode 100644
index 000000000..6a1d8068e
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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=========================================================
+ */
+
+/*
+* Generated file
+*
+* Generated from: yang module name: asdcApi-provider-impl yang module local name: asdcApi-provider-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 02 03:46:08 EDT 2016
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523;
+public class AsdcApiProviderModuleFactory extends org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523.AbstractAsdcApiProviderModuleFactory {
+
+}
diff --git a/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java
new file mode 100644
index 000000000..28e59c8d7
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java
@@ -0,0 +1,415 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.openecomp.sdnc.asdcapi;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+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.http.xmlns.openecomp.org.asdc.license.model._1._0.rev160427.vf.license.model.grouping.VfLicenseModel;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.ASDCAPIService;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.Artifacts;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.ArtifactsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelVersions;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelVersionsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.artifacts.Artifact;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.artifacts.ArtifactBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.artifacts.ArtifactKey;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.vf.license.model.versions.VfLicenseModelVersion;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+
+/**
+ * Defines a base implementation for your provider. This class extends from a helper class
+ * which provides storage for the most commonly used components of the MD-SAL. Additionally the
+ * base class provides some basic logging and initialization / clean up methods.
+ *
+ * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule
+ * class which is auto generated under src/main/java in this project
+ * (created only once during first compilation):
+ *
+ * <pre>
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+
+ final asdcApiProvider provider = new asdcApiProvider();
+ provider.setDataBroker( getDataBrokerDependency() );
+ provider.setNotificationService( getNotificationServiceDependency() );
+ provider.setRpcRegistry( getRpcRegistryDependency() );
+ provider.initialize();
+ return new AutoCloseable() {
+
+ @Override
+ public void close() throws Exception {
+ //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION
+ //SERVIE/RPC REGISTRY
+ provider.close();
+ }
+ };
+ }
+
+
+ </pre>
+ */
+public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
+
+ private static final String ACTIVE_VERSION = "active";
+
+ private final Logger log = LoggerFactory.getLogger( AsdcApiProvider.class );
+ private final String appName = "asdcApi";
+
+ private final ExecutorService executor;
+ protected DataBroker dataBroker;
+ protected NotificationProviderService notificationService;
+ protected RpcProviderRegistry rpcRegistry;
+
+ protected BindingAwareBroker.RpcRegistration<ASDCAPIService> rpcRegistration;
+
+ public AsdcApiProvider(DataBroker dataBroker2,
+ NotificationProviderService notificationProviderService,
+ RpcProviderRegistry rpcProviderRegistry) {
+ this.log.info( "Creating provider for " + appName );
+ executor = Executors.newFixedThreadPool(1);
+ dataBroker = dataBroker2;
+ notificationService = notificationProviderService;
+ rpcRegistry = rpcProviderRegistry;
+ initialize();
+ }
+
+ public void initialize(){
+ log.info( "Initializing provider for " + appName );
+
+
+ createContainers();
+
+ if (rpcRegistration == null) {
+ if (rpcRegistry != null) {
+ rpcRegistration = rpcRegistry.addRpcImplementation(
+ ASDCAPIService.class, this);
+ log.info("Initialization complete for " + appName);
+ } else {
+ log.warn("Error initializing " + appName
+ + " : rpcRegistry unset");
+ }
+ }
+ }
+
+ private void createContainers() {
+
+ if (dataBroker != null) {
+ final WriteTransaction t = dataBroker.newReadWriteTransaction();
+
+ // Create the vf-model-license-versions and artifacts containers
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(VfLicenseModelVersions.class),
+ new VfLicenseModelVersionsBuilder().build());
+
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Artifacts.class), new ArtifactsBuilder().build());
+
+
+ try {
+ CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
+ checkedFuture.get();
+ log.info("Create Containers succeeded!: ");
+
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("Create Containers Failed: " + e);
+ e.printStackTrace();
+ }
+ } else {
+ log.warn("createContainers : cannot find dataBroker to create containers");
+ }
+ }
+ protected void initializeChild() {
+ //Override if you have custom initialization intelligence
+ }
+
+ @Override
+ public void close() throws Exception {
+ log.info( "Closing provider for " + appName );
+ executor.shutdown();
+ rpcRegistration.close();
+ log.info( "Successfully closed provider for " + appName );
+ }
+
+ public void setDataBroker(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ if( log.isDebugEnabled() ){
+ log.debug( "DataBroker set to " + (dataBroker==null?"null":"non-null") + "." );
+ }
+ }
+
+ public void setNotificationService(
+ NotificationProviderService notificationService) {
+ this.notificationService = notificationService;
+ if( log.isDebugEnabled() ){
+ log.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." );
+ }
+ }
+
+ public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
+ this.rpcRegistry = rpcRegistry;
+
+ rpcRegistration = rpcRegistry.addRpcImplementation(ASDCAPIService.class, this);
+
+ if( log.isDebugEnabled() ){
+ log.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":"non-null") + "." );
+ }
+ }
+
+
+ protected boolean artifactVersionExists(String aName, String aVersion) {
+ InstanceIdentifier artifactInstanceId =
+ InstanceIdentifier.<Artifacts>builder(Artifacts.class)
+ .child(Artifact.class, new ArtifactKey(aName, aVersion)).toInstance();
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<Artifact> data = null;
+ try {
+ data = (Optional<Artifact>) readTx.read(LogicalDatastoreType.CONFIGURATION, artifactInstanceId).get();
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("Caught Exception reading MD-SAL for ["+aName+","+ aVersion+"] " ,e);
+ return false;
+
+ }
+
+ if (data.isPresent()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected void addArtifactVersion(String aName, String aVersion) {
+
+
+ try {
+ ArtifactBuilder aBuilder = new ArtifactBuilder();
+
+ aBuilder.setArtifactName(aName);
+ aBuilder.setArtifactVersion(aVersion);
+
+ Artifact artifact = aBuilder.build();
+
+ InstanceIdentifier.InstanceIdentifierBuilder<Artifact> aIdBuilder = InstanceIdentifier
+ .<Artifacts> builder(Artifacts.class)
+ .child(Artifact.class, artifact.getKey());
+
+ InstanceIdentifier<Artifact> path = aIdBuilder
+ .toInstance();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+
+ tx.merge(LogicalDatastoreType.CONFIGURATION, path,
+ artifact);
+ tx.submit().checkedGet();
+ } catch (Exception e) {
+ log.error("Caught exception trying to add artifact entry", e);
+ }
+
+ }
+
+
+ private void applyVfLicenseModelUpdate(VfLicenseModelUpdateInput input) {
+
+ String aName = input.getArtifactName();
+ String aVersion = input.getArtifactVersion();
+ VfLicenseModel vfLicenseModel = input.getVfLicenseModel();
+
+
+ // Add new version (version = artifact-version)
+ try {
+
+ VfLicenseModelVersionBuilder vBuilder = new VfLicenseModelVersionBuilder();
+ vBuilder.setArtifactName(aName);
+ vBuilder.setArtifactVersion(aVersion);
+ vBuilder.setVfLicenseModel(vfLicenseModel);
+
+ VfLicenseModelVersion version = vBuilder.build();
+
+ InstanceIdentifier.InstanceIdentifierBuilder<VfLicenseModelVersion> versionIdBuilder = InstanceIdentifier
+ .<VfLicenseModelVersions> builder(VfLicenseModelVersions.class)
+ .child(VfLicenseModelVersion.class, version.getKey());
+
+ InstanceIdentifier<VfLicenseModelVersion> path = versionIdBuilder
+ .toInstance();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.merge(LogicalDatastoreType.CONFIGURATION, path,
+ version);
+ tx.submit().checkedGet();
+ } catch (Exception e) {
+ log.error(
+ "Caught exception trying to save entry to MD-SAL",
+ e);
+ }
+
+
+ // Add "active" version (version = "active")
+ try {
+
+ VfLicenseModelVersionBuilder vBuilder = new VfLicenseModelVersionBuilder();
+ vBuilder.setArtifactName(aName);
+ vBuilder.setArtifactVersion(ACTIVE_VERSION);
+ vBuilder.setVfLicenseModel(vfLicenseModel);
+
+ VfLicenseModelVersion version = vBuilder.build();
+ InstanceIdentifier.InstanceIdentifierBuilder<VfLicenseModelVersion> versionIdBuilder = InstanceIdentifier
+ .<VfLicenseModelVersions> builder(VfLicenseModelVersions.class)
+ .child(VfLicenseModelVersion.class, version.getKey());
+
+ InstanceIdentifier<VfLicenseModelVersion> path = versionIdBuilder
+ .toInstance();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+
+ tx.merge(LogicalDatastoreType.CONFIGURATION, path,
+ version);
+ tx.submit().checkedGet();
+ } catch (Exception e) {
+ log.error(
+ "Caught exception trying to save entry to MD-SAL",
+ e);
+ }
+
+}
+
+@Override
+public Future<RpcResult<VfLicenseModelUpdateOutput>> vfLicenseModelUpdate(VfLicenseModelUpdateInput input) {
+ final String SVC_OPERATION = "vf-license-model-update";
+
+ Properties parms = new Properties();
+
+ log.info( SVC_OPERATION +" called." );
+
+ if(input == null ) {
+ log.debug("exiting " +SVC_OPERATION+ " because of invalid input");
+ return null;
+ }
+
+ VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(input);
+ input = inputBuilder.build();
+
+ String errorMessage = "Success";
+ String errorCode = "200";
+
+ // If this artifact already exists, reject this update
+ if (artifactVersionExists(input.getArtifactName(), input.getArtifactVersion())) {
+ errorCode = "409";
+ errorMessage = "Artifact version already exists";
+ } else {
+ // Translate input object into SLI-consumable properties
+ log.info("Adding INPUT data for "+SVC_OPERATION+" input: " + input);
+ AsdcApiUtil.toProperties(parms, input);
+
+
+ // Call directed graph
+
+ Properties respProps = null;
+
+
+ AsdcApiSliClient sliClient = new AsdcApiSliClient();
+ try
+ {
+ if (sliClient.hasGraph("ASDC-API", SVC_OPERATION , null, "sync"))
+ {
+
+ try
+ {
+ respProps = sliClient.execute("ASDC-API", SVC_OPERATION, null, "sync", parms);
+ }
+ catch (Exception e)
+ {
+ log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ }
+ } else {
+ errorMessage = "No service logic active for ASDC-API: '" + SVC_OPERATION + "'";
+ errorCode = "503";
+ }
+ }
+ catch (Exception e)
+ {
+ errorCode = "500";
+ errorMessage = e.getMessage();
+ log.error("Caught exception looking for service logic", e);
+ }
+
+
+ if (respProps != null)
+ {
+ errorCode = respProps.getProperty("error-code");
+ errorMessage = respProps.getProperty("error-message", "");
+ }
+ }
+
+
+ if ("200".equals(errorCode)) {
+ log.info("ASDC update succeeded");
+
+ // Update config tree
+ applyVfLicenseModelUpdate(input);
+ addArtifactVersion(input.getArtifactName(), input.getArtifactVersion());
+
+ } else {
+ log.info("ASDC update failed ("+errorCode+" : "+errorMessage);
+ }
+
+ // Send response
+ VfLicenseModelUpdateOutputBuilder respBuilder = new VfLicenseModelUpdateOutputBuilder();
+ respBuilder.setAsdcApiResponseCode(errorCode);
+ if (errorMessage != null && errorMessage.length() > 0) {
+ respBuilder.setAsdcApiResponseText(errorMessage);
+ }
+
+ RpcResult<VfLicenseModelUpdateOutput> rpcResult;
+
+
+ rpcResult = RpcResultBuilder.<VfLicenseModelUpdateOutput> status(true).withResult(respBuilder.build()).build();
+
+
+
+ return Futures.immediateFuture(rpcResult);
+}
+
+
+}
diff --git a/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java
new file mode 100644
index 000000000..2f3a783ba
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.openecomp.sdnc.asdcapi;
+
+import java.util.Properties;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AsdcApiSliClient {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(AsdcApiSliClient.class);
+
+ private SvcLogicService svcLogic = null;
+
+ public AsdcApiSliClient()
+ {
+ BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
+
+ // Get SvcLogicService reference
+ ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
+ if (sref != null)
+ {
+ svcLogic = (SvcLogicService) bctx.getService(sref);
+ }
+ else
+ {
+ LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
+
+ }
+ }
+
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
+ {
+ return(svcLogic.hasGraph(module, rpc, version, mode));
+ }
+
+
+ public Properties execute(String module, String rpc, String version, String mode, Properties parms)
+ throws SvcLogicException {
+
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Parameters passed to SLI");
+
+ for (Object key : parms.keySet()) {
+ String parmName = (String) key;
+ String parmValue = parms.getProperty(parmName);
+
+ LOG.debug(parmName+" = "+parmValue);
+
+ }
+ }
+
+ Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Parameters returned by SLI");
+
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
+
+ LOG.debug(parmName+" = "+parmValue);
+
+ }
+ }
+
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+
+ if (!respProps.containsKey("error-code")) {
+ respProps.setProperty("error-code", "500");
+ }
+ } else {
+ if (!respProps.containsKey("error-code")) {
+ respProps.setProperty("error-code", "200");
+ }
+ }
+
+
+ return (respProps);
+ }
+
+}
diff --git a/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java
new file mode 100644
index 000000000..240c939b4
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.openecomp.sdnc.asdcapi;
+
+import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.ArtifactsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelVersionsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder;
+
+public class AsdcApiUtil extends MdsalHelper {
+
+ static {
+
+ // Input objects
+
+ VfLicenseModelUpdateInput i13 = new VfLicenseModelUpdateInputBuilder().build();
+
+
+ // Other builders
+ ArtifactsBuilder b1 = new ArtifactsBuilder();
+
+ VfLicenseModelVersionsBuilder b14a = new VfLicenseModelVersionsBuilder();
+ VfLicenseModelVersionBuilder b26a = new VfLicenseModelVersionBuilder();
+
+
+ }
+}