Search in sources :

Example 1 with VrfBondingServiceException

use of org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException in project so by onap.

the class ServiceEBBLoader method getExistingAAIVrfConfiguration.

protected String getExistingAAIVrfConfiguration(RelatedInstance relatedVpnBinding, org.onap.aai.domain.yang.L3Network aaiLocalNetwork) throws JsonProcessingException, VrfBondingServiceException {
    Optional<Relationships> relationshipsOp = new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(aaiLocalNetwork)).getRelationships();
    if (relationshipsOp.isPresent()) {
        List<AAIResultWrapper> configurationsRelatedToLocalNetwork = relationshipsOp.get().getByType(AAIFluentTypeBuilder.Types.CONFIGURATION);
        if (configurationsRelatedToLocalNetwork.size() > 1) {
            throw new VrfBondingServiceException("Network: " + aaiLocalNetwork.getNetworkId() + " has more than 1 configuration related to it");
        }
        if (configurationsRelatedToLocalNetwork.size() == 1) {
            AAIResultWrapper configWrapper = configurationsRelatedToLocalNetwork.get(0);
            Optional<Configuration> relatedConfiguration = configWrapper.asBean(Configuration.class);
            if (relatedConfiguration.isPresent() && vrfConfigurationAlreadyExists(relatedVpnBinding, relatedConfiguration.get(), configWrapper)) {
                return relatedConfiguration.get().getConfigurationId();
            }
        }
    }
    return null;
}
Also used : Relationships(org.onap.aaiclient.client.aai.entities.Relationships) Configuration(org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration) AAICommonObjectMapperProvider(org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider) VrfBondingServiceException(org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException) AAIResultWrapper(org.onap.aaiclient.client.aai.entities.AAIResultWrapper)

Aggregations

AAICommonObjectMapperProvider (org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider)1 AAIResultWrapper (org.onap.aaiclient.client.aai.entities.AAIResultWrapper)1 Relationships (org.onap.aaiclient.client.aai.entities.Relationships)1 VrfBondingServiceException (org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException)1 Configuration (org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration)1