summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-01-16 11:29:46 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2019-02-13 09:42:00 +0100
commit4e9403e734752e5d8728b73591bb407c71f83dc1 (patch)
tree6b14e8a90566732db1af36f58e8c9661663d79e8 /bpmn/so-bpmn-infrastructure-common/src/main
parent1ffa4a397fb51acb09273e2b04b47281f7eb4840 (diff)
Associate PNF instance with Service
Change-Id: I19e25e0daae042b30138bbfc074b0e651b8b1c01 Issue-ID: SO-1274 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java12
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java58
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java2
3 files changed, 72 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
index d57e48781d..1bf2a290cb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java
@@ -23,7 +23,11 @@ package org.onap.so.bpmn.infrastructure.pnf.aai;
import java.util.Optional;
import org.onap.aai.domain.yang.Pnf;
import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.AAIRestClientImpl;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.springframework.stereotype.Component;
@Component
@@ -40,4 +44,12 @@ public class AaiConnectionImpl implements AaiConnection {
AAIRestClientImpl restClient = new AAIRestClientImpl();
restClient.createPnf(correlationId, entry);
}
+
+ @Override
+ public void createRelation(String serviceInstanceId, String pnfName) {
+ AAIResourceUri serviceInstanceURI = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ serviceInstanceId);
+ AAIResourceUri pnfUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName);
+ new AAIResourcesClient().connect(serviceInstanceURI, pnfUri);
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java
new file mode 100644
index 0000000000..21d43964f8
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelation.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Nokia.
+ * ================================================================================
+ * 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.so.bpmn.infrastructure.pnf.delegate;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.engine.delegate.JavaDelegate;
+import org.onap.so.bpmn.common.scripts.ExceptionUtil;
+import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class CreateRelation implements JavaDelegate {
+
+ private static final Logger logger = LoggerFactory.getLogger(CreateRelation.class);
+
+ private AaiConnection aaiConnectionImpl;
+
+ @Autowired
+ public CreateRelation(AaiConnection aaiConnectionImpl) {
+ this.aaiConnectionImpl = aaiConnectionImpl;
+ }
+
+ @Override
+ public void execute(DelegateExecution delegateExecution) {
+ String serviceInstanceId = (String) delegateExecution.getVariable("serviceInstanceId");
+ String pnfName = (String) delegateExecution.getVariable("correlationId");
+ try {
+ aaiConnectionImpl.createRelation(serviceInstanceId, pnfName);
+ } catch (Exception e) {
+ new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999,
+ "An exception occurred when making service and pnf relation. Exception: " + e.getMessage());
+ }
+ logger.debug("The relation has been made between service with id: {} and pnf with name: {}",
+ serviceInstanceId, pnfName);
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java
index 5165912653..eaabb2bfbb 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java
@@ -29,4 +29,6 @@ public interface AaiConnection {
Optional<Pnf> getEntryFor(String correlationId) throws IOException;
void createEntry(String correlationId, Pnf entry) throws IOException;
+
+ void createRelation(String serviceInstanceId, String pnfName) throws IOException;
}