From f7bf1c998895e1599e861a4bf7a56270552245ea Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Thu, 21 Feb 2019 13:28:55 +0100 Subject: Change interface name to be more suitable Change-Id: Ifb4f6bc7f3e18974e9a11a17d474ad989c043673 Issue-ID: SO-1274 Signed-off-by: Lukasz Muszkieta --- .../infrastructure/pnf/aai/AaiConnectionImpl.java | 55 ---------------------- .../delegate/CheckAaiForCorrelationIdDelegate.java | 10 ++-- .../pnf/delegate/CreatePnfEntryInAaiDelegate.java | 10 ++-- .../pnf/delegate/CreateRelation.java | 10 ++-- .../pnf/implementation/AaiConnection.java | 34 ------------- .../pnf/management/PnfManagement.java | 34 +++++++++++++ .../pnf/management/PnfManagementImpl.java | 54 +++++++++++++++++++++ 7 files changed, 103 insertions(+), 104 deletions(-) delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap') 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 deleted file mode 100644 index 1bf2a290cb..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/aai/AaiConnectionImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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. - * 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.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 -public class AaiConnectionImpl implements AaiConnection { - - @Override - public Optional getEntryFor(String correlationId) { - AAIRestClientImpl restClient = new AAIRestClientImpl(); - return restClient.getPnfByName(correlationId); - } - - @Override - public void createEntry(String correlationId, Pnf entry) { - 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/CheckAaiForCorrelationIdDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java index 8d353f134d..a8fb21540a 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java @@ -28,7 +28,7 @@ import java.io.IOException; 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.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -46,11 +46,11 @@ public class CheckAaiForCorrelationIdDelegate implements JavaDelegate { private static final Logger logger = LoggerFactory.getLogger(CheckAaiForCorrelationIdDelegate.class); - private AaiConnection aaiConnection; + private PnfManagement pnfManagement; @Autowired - public void setAaiConnection(AaiConnection aaiConnection) { - this.aaiConnection = aaiConnection; + public void setPnfManagement(PnfManagement pnfManagement) { + this.pnfManagement = pnfManagement; } @Override @@ -60,7 +60,7 @@ public class CheckAaiForCorrelationIdDelegate implements JavaDelegate { new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set"); } try { - boolean isEntry = aaiConnection.getEntryFor(correlationId).isPresent(); + boolean isEntry = pnfManagement.getEntryFor(correlationId).isPresent(); logger.debug("AAI entry is found for pnf correlation id {}: {}", CORRELATION_ID, isEntry); execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry); } catch (IOException e) { diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java index 2268d22bd2..c31041fbf7 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegate.java @@ -28,7 +28,7 @@ import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableName import org.camunda.bpm.engine.delegate.DelegateExecution; import org.camunda.bpm.engine.delegate.JavaDelegate; import org.onap.aai.domain.yang.Pnf; -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -45,11 +45,11 @@ import org.springframework.stereotype.Component; public class CreatePnfEntryInAaiDelegate implements JavaDelegate { private static final Logger logger = LoggerFactory.getLogger(CreatePnfEntryInAaiDelegate.class); - private AaiConnection aaiConnection; + private PnfManagement pnfManagement; @Autowired - public void setAaiConnection(AaiConnection aaiConnection) { - this.aaiConnection = aaiConnection; + public void setPnfManagement(PnfManagement pnfManagement) { + this.pnfManagement = pnfManagement; } @Override @@ -59,7 +59,7 @@ public class CreatePnfEntryInAaiDelegate implements JavaDelegate { Pnf pnf = new Pnf(); pnf.setPnfId(pnfUuid); pnf.setPnfName(correlationId); - aaiConnection.createEntry(correlationId, pnf); + pnfManagement.createEntry(correlationId, pnf); logger.debug("AAI entry is created for pnf correlation id: {}, pnf uuid: {}", correlationId, pnfUuid); } } 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 index 21d43964f8..7b6706f820 100644 --- 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 @@ -23,7 +23,7 @@ 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.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,11 +34,11 @@ public class CreateRelation implements JavaDelegate { private static final Logger logger = LoggerFactory.getLogger(CreateRelation.class); - private AaiConnection aaiConnectionImpl; + private PnfManagement pnfManagementImpl; @Autowired - public CreateRelation(AaiConnection aaiConnectionImpl) { - this.aaiConnectionImpl = aaiConnectionImpl; + public CreateRelation(PnfManagement pnfManagementImpl) { + this.pnfManagementImpl = pnfManagementImpl; } @Override @@ -46,7 +46,7 @@ public class CreateRelation implements JavaDelegate { String serviceInstanceId = (String) delegateExecution.getVariable("serviceInstanceId"); String pnfName = (String) delegateExecution.getVariable("correlationId"); try { - aaiConnectionImpl.createRelation(serviceInstanceId, pnfName); + pnfManagementImpl.createRelation(serviceInstanceId, pnfName); } catch (Exception e) { new ExceptionUtil().buildAndThrowWorkflowException(delegateExecution, 9999, "An exception occurred when making service and pnf relation. Exception: " + e.getMessage()); 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 deleted file mode 100644 index eaabb2bfbb..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/implementation/AaiConnection.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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. - * 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.implementation; - -import java.io.IOException; -import java.util.Optional; -import org.onap.aai.domain.yang.Pnf; - -public interface AaiConnection { - - Optional getEntryFor(String correlationId) throws IOException; - - void createEntry(String correlationId, Pnf entry) throws IOException; - - void createRelation(String serviceInstanceId, String pnfName) throws IOException; -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java new file mode 100644 index 0000000000..b66bb5f61b --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagement.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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. + * 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.management; + +import java.io.IOException; +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; + +public interface PnfManagement { + + Optional getEntryFor(String correlationId) throws IOException; + + void createEntry(String correlationId, Pnf entry) throws IOException; + + void createRelation(String serviceInstanceId, String pnfName) throws IOException; +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java new file mode 100644 index 0000000000..3d8da2a106 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/management/PnfManagementImpl.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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. + * 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.management; + +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; +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 +public class PnfManagementImpl implements PnfManagement { + + @Override + public Optional getEntryFor(String correlationId) { + AAIRestClientImpl restClient = new AAIRestClientImpl(); + return restClient.getPnfByName(correlationId); + } + + @Override + public void createEntry(String correlationId, Pnf entry) { + 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); + } +} -- cgit 1.2.3-korg