aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/Pool.java23
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json8
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/generalBB.json6
-rw-r--r--common/pom.xml5
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java8
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java49
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAIObjectType.java166
-rw-r--r--common/src/main/java/org/onap/so/client/aai/entities/Relationships.java6
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java14
-rw-r--r--common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java20
-rw-r--r--common/src/test/resources/logback-test.xml4
12 files changed, 211 insertions, 106 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/Pool.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/Pool.java
index 1c82907f80..ca3a9c5a8d 100644
--- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/Pool.java
+++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/openstack/beans/Pool.java
@@ -20,14 +20,15 @@
package org.onap.so.openstack.beans;
+import java.io.Serializable;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.EqualsBuilder;
-
-
-
-public class Pool {
+public class Pool implements Serializable {
private String start;
private String end;
+ private static final long serialVersionUID = 768026109321305392L;
/**
* @return the start
@@ -58,5 +59,19 @@ public class Pool {
public String toString() {
return "Allocation_pool [start=" + start + ", end=" + end + "]";
}
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof Pool)) {
+ return false;
+ }
+ Pool castOther = (Pool) other;
+ return new EqualsBuilder().append(start, castOther.start).append(end, castOther.end).isEquals();
+ }
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(start).append(end).toHashCode();
+ }
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
index 4c84ee4003..f917aed39e 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java
@@ -283,6 +283,14 @@ public class NetworkAdapterObjectMapper {
//add host route to the list
openstackHostRouteList.add(openstackHostRoute);
}
+ if (subnet.getDhcpStart() != null && !subnet.getDhcpStart().equals("")) {
+ org.onap.so.openstack.beans.Pool openstackAllocationPool = new org.onap.so.openstack.beans.Pool();
+ openstackAllocationPool.setStart(subnet.getDhcpStart());
+ openstackAllocationPool.setEnd(subnet.getDhcpEnd());
+ List<org.onap.so.openstack.beans.Pool> allocationPools = new ArrayList<>();
+ allocationPools.add(openstackAllocationPool);
+ openstackSubnet.setAllocationPools(allocationPools);
+ }
openstackSubnet.setHostRoutes(openstackHostRouteList);
//add subnet to the list
subnetList.add(openstackSubnet);
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json
index a9cef565df..d7e282dda7 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/createNetworkRequest.json
@@ -13,9 +13,13 @@
"cidr": "107.244.64.2/20",
"gatewayIp": "107.244.64.1",
"ipVersion": "4",
- "enableDHCP": false,
+ "enableDHCP": true,
"addrFromStart": true,
- "hostRoutes": []
+ "hostRoutes": [],
+ "allocationPools": [{
+ "start": "107.244.64.2",
+ "end": "107.244.64.16"
+ }]
}
],
"providerVlanNetwork": {
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/generalBB.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/generalBB.json
index 6c6981b96a..e0b3bc4ff9 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/generalBB.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/NetworkMapper/generalBB.json
@@ -64,9 +64,9 @@
"cidr-mask" : "20",
"ip-version" : "4",
"orchestration-status" : null,
- "dhcp-enabled" : false,
- "dhcp-start" : "",
- "dhcp-end" : "",
+ "dhcp-enabled" : true,
+ "dhcp-start" : "107.244.64.2",
+ "dhcp-end" : "107.244.64.16",
"subnet-role" : "",
"ip-assignment-direction" : "true",
"subnet-sequence" : null,
diff --git a/common/pom.xml b/common/pom.xml
index 7d468fae3f..51c9ed3bcb 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -126,6 +126,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <version>0.9.11</version>
+ </dependency>
</dependencies>
<build>
<resources>
diff --git a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
index 242fd41b19..9d2c3a8b1b 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAINamespaceConstants.java
@@ -22,10 +22,10 @@ package org.onap.so.client.aai;
public class AAINamespaceConstants {
- protected static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
- protected static final String NETWORK = "/network";
- protected static final String BUSINESS = "/business";
- protected static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
+ public static final String CLOUD_INFRASTRUCTURE = "/cloud-infrastructure";
+ public static final String NETWORK = "/network";
+ public static final String BUSINESS = "/business";
+ public static final String SERVICE_DESIGN_AND_CREATION = "/service-design-and-creation";
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
index b3bfcc1648..12e0ebe691 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectPlurals.java
@@ -20,38 +20,43 @@
package org.onap.so.client.aai;
-import org.onap.aai.domain.yang.NetworkTechnologies;
+import java.io.Serializable;
+
import org.onap.so.client.graphinventory.GraphInventoryObjectPlurals;
import org.onap.so.constants.Defaults;
import com.google.common.base.CaseFormat;
-public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
+public class AAIObjectPlurals implements GraphInventoryObjectPlurals, Serializable {
- CUSTOMER(AAINamespaceConstants.BUSINESS, "/customers"),
- GENERIC_VNF(AAINamespaceConstants.NETWORK, "/generic-vnfs"),
- PORT_GROUP(AAIObjectType.VCE.uriTemplate(), "/port-groups"),
- PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers"),
- P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces"),
- L3_NETWORK(AAINamespaceConstants.NETWORK, "/l3-networks"),
- NETWORK_POLICY(AAINamespaceConstants.NETWORK, "/network-policies"),
- VPN_BINDING(AAINamespaceConstants.NETWORK, "/vpn-bindings"),
- SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions"),
- SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances"),
- OWNING_ENTITY(AAINamespaceConstants.BUSINESS, "/owning-entities"),
- VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups"),
- AVAILIBILITY_ZONE(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones"),
- VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules"),
- CONFIGURATION(AAINamespaceConstants.NETWORK, "/configurations"),
- DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants"),
- NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies"),
- LOGICAL_LINK(AAINamespaceConstants.NETWORK, "/logical-links");
+ private static final long serialVersionUID = 5312713297525740746L;
+
+ public static final AAIObjectPlurals CUSTOMER = new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/customers", "customer");
+ public static final AAIObjectPlurals GENERIC_VNF = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/generic-vnfs", "generic-vnf");
+ public static final AAIObjectPlurals PORT_GROUP = new AAIObjectPlurals(AAIObjectType.VCE.uriTemplate(), "/port-groups", "port-group");
+ public static final AAIObjectPlurals PSERVER = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/pservers", "pserver");
+ public static final AAIObjectPlurals P_INTERFACE = new AAIObjectPlurals(AAIObjectType.PSERVER.uriTemplate(), "/p-interfaces", "p-interface");
+ public static final AAIObjectPlurals L3_NETWORK = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/l3-networks", "l3-network");
+ public static final AAIObjectPlurals NETWORK_POLICY = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/network-policies", "network-policy");
+ public static final AAIObjectPlurals VPN_BINDING = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/vpn-bindings", "vpn-binding");
+ public static final AAIObjectPlurals SERVICE_SUBSCRIPTION = new AAIObjectPlurals(AAIObjectType.CUSTOMER.uriTemplate(), "/service-subscriptions", "service-subscription");
+ public static final AAIObjectPlurals SERVICE_INSTANCE = new AAIObjectPlurals(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), "/service-instances", "service-instance");
+ public static final AAIObjectPlurals OWNING_ENTITY = new AAIObjectPlurals(AAINamespaceConstants.BUSINESS, "/owning-entities", "owning-entity");
+ public static final AAIObjectPlurals VOLUME_GROUP = new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/volume-groups", "volume-group");
+ public static final AAIObjectPlurals AVAILIBILITY_ZONE = new AAIObjectPlurals(AAIObjectType.CLOUD_REGION.uriTemplate(), "/availability-zones", "availability-zone");
+ public static final AAIObjectPlurals VF_MODULE = new AAIObjectPlurals(AAIObjectType.GENERIC_VNF.uriTemplate(), "/vf-modules", "vf-module");
+ public static final AAIObjectPlurals CONFIGURATION = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/configurations", "configuration");
+ public static final AAIObjectPlurals DEFAULT_TENANT = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants", "default-tenant");
+ public static final AAIObjectPlurals NETWORK_TECHNOLOGY = new AAIObjectPlurals(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/network-technologies", "network-technology");
+ public static final AAIObjectPlurals LOGICAL_LINK = new AAIObjectPlurals(AAINamespaceConstants.NETWORK, "/logical-links", "logical-link");
private final String uriTemplate;
private final String partialUri;
- private AAIObjectPlurals(String parentUri, String partialUri) {
+ private final String name;
+ protected AAIObjectPlurals(String parentUri, String partialUri, String name) {
this.uriTemplate = parentUri + partialUri;
this.partialUri = partialUri;
+ this.name = name;
}
@Override
@@ -75,6 +80,6 @@ public enum AAIObjectPlurals implements GraphInventoryObjectPlurals {
}
@Override
public String typeName(CaseFormat format) {
- return CaseFormat.UPPER_UNDERSCORE.to(format, this.name());
+ return CaseFormat.LOWER_HYPHEN.to(format, this.name);
}
}
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
index 0237f91833..a6a9acfadd 100644
--- a/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
+++ b/common/src/main/java/org/onap/so/client/aai/AAIObjectType.java
@@ -20,18 +20,25 @@
package org.onap.so.client.aai;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Priority;
import org.onap.aai.annotations.Metadata;
-import org.onap.aai.domain.yang.AllottedResource;
import org.onap.aai.domain.yang.AggregateRoute;
+import org.onap.aai.domain.yang.AllottedResource;
import org.onap.aai.domain.yang.CloudRegion;
import org.onap.aai.domain.yang.Collection;
import org.onap.aai.domain.yang.Complex;
import org.onap.aai.domain.yang.Configuration;
import org.onap.aai.domain.yang.Connector;
import org.onap.aai.domain.yang.Customer;
+import org.onap.aai.domain.yang.Device;
import org.onap.aai.domain.yang.ExtAaiNetwork;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.InstanceGroup;
@@ -45,6 +52,7 @@ import org.onap.aai.domain.yang.OwningEntity;
import org.onap.aai.domain.yang.PInterface;
import org.onap.aai.domain.yang.PhysicalLink;
import org.onap.aai.domain.yang.Platform;
+import org.onap.aai.domain.yang.Pnf;
import org.onap.aai.domain.yang.PortGroup;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Pserver;
@@ -52,7 +60,6 @@ import org.onap.aai.domain.yang.RouteTableReference;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.ServiceSubscription;
import org.onap.aai.domain.yang.SpPartner;
-import org.onap.aai.domain.yang.Device;
import org.onap.aai.domain.yang.Subnet;
import org.onap.aai.domain.yang.Tenant;
import org.onap.aai.domain.yang.TunnelXconnect;
@@ -65,77 +72,115 @@ import org.onap.aai.domain.yang.VpnBinding;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.graphinventory.GraphInventoryObjectType;
import org.onap.so.constants.Defaults;
+import org.reflections.Reflections;
+import org.reflections.scanners.SubTypesScanner;
+import org.reflections.util.ClasspathHelper;
+import org.reflections.util.ConfigurationBuilder;
import com.google.common.base.CaseFormat;
-public enum AAIObjectType implements GraphInventoryObjectType {
+public class AAIObjectType implements GraphInventoryObjectType, Serializable {
- DEFAULT_CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}"),
- CUSTOMER(AAINamespaceConstants.BUSINESS, Customer.class),
- GENERIC_QUERY("/search", "/generic-query"),
- BULK_PROCESS("/bulkprocess", ""),
- SINGLE_TRANSACTION("/bulk/single-transaction", ""),
- GENERIC_VNF(AAINamespaceConstants.NETWORK, GenericVnf.class),
- VF_MODULE(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class),
- L3_NETWORK(AAINamespaceConstants.NETWORK, L3Network.class),
- NETWORK_POLICY(AAINamespaceConstants.NETWORK, NetworkPolicy.class),
- NODES_QUERY("/search", "/nodes-query"),
- CUSTOM_QUERY("/query", ""),
- ROUTE_TABLE_REFERENCE(AAINamespaceConstants.NETWORK, RouteTableReference.class),
- DEFAULT_TENANT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}"),
- VCE(AAINamespaceConstants.NETWORK, Vce.class),
- PORT_GROUP(AAIObjectType.VCE.uriTemplate(), PortGroup.class),
- VPN_BINDING(AAINamespaceConstants.NETWORK, VpnBinding.class),
- CONFIGURATION(AAINamespaceConstants.NETWORK, Configuration.class),
- PSERVER(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class),
- SERVICE_SUBSCRIPTION(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class),
- SERVICE_INSTANCE(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class),
- PROJECT(AAINamespaceConstants.BUSINESS, Project.class),
- LINE_OF_BUSINESS(AAINamespaceConstants.BUSINESS, LineOfBusiness.class),
- PLATFORM(AAINamespaceConstants.BUSINESS, Platform.class),
- OWNING_ENTITY(AAINamespaceConstants.BUSINESS, OwningEntity.class),
- ALLOTTED_RESOURCE(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class),
- PNF(AAINamespaceConstants.NETWORK, "/pnfs/pnf/{pnf-name}"),
- OPERATIONAL_ENVIRONMENT(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class),
- CLOUD_REGION(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class),
- TENANT(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class),
- VOLUME_GROUP(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class),
- VSERVER(AAIObjectType.TENANT.uriTemplate(), Vserver.class),
- MODEL_VER(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class),
- TUNNEL_XCONNECT(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class),
- P_INTERFACE(AAIObjectType.PSERVER.uriTemplate(), PInterface.class),
- PHYSICAL_LINK(AAINamespaceConstants.NETWORK, PhysicalLink.class),
- INSTANCE_GROUP(AAINamespaceConstants.NETWORK, InstanceGroup.class),
- COLLECTION(AAINamespaceConstants.NETWORK, Collection.class),
- VNFC(AAINamespaceConstants.NETWORK, Vnfc.class),
- VLAN_TAG(AAINamespaceConstants.NETWORK, VlanTag.class),
- COMPLEX(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class),
- CONNECTOR(AAINamespaceConstants.BUSINESS, Connector.class),
- NETWORK_TECHNOLOGY(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class),
- SUBNET(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class),
- SP_PARTNER(AAINamespaceConstants.BUSINESS, SpPartner.class),
- DEVICE(AAINamespaceConstants.NETWORK, Device.class),
- EXT_AAI_NETWORK(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class),
- AGGREGATE_ROUTE(AAINamespaceConstants.NETWORK, AggregateRoute.class),
- UNKNOWN("", "");
+ private static final long serialVersionUID = -2877184776691514600L;
+ private static Map<String, AAIObjectType> map = new HashMap<>();
+
+ public static final AAIObjectType DEFAULT_CLOUD_REGION = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/{cloud-region-id}", "default-cloud-region");
+ public static final AAIObjectType CUSTOMER = new AAIObjectType(AAINamespaceConstants.BUSINESS, Customer.class);
+ public static final AAIObjectType GENERIC_QUERY = new AAIObjectType("/search", "/generic-query", "generic-query");
+ public static final AAIObjectType BULK_PROCESS = new AAIObjectType("/bulkprocess", "", "bulkprocess");
+ public static final AAIObjectType SINGLE_TRANSACTION = new AAIObjectType("/bulk/single-transaction", "", "single-transaction");
+ public static final AAIObjectType GENERIC_VNF = new AAIObjectType(AAINamespaceConstants.NETWORK, GenericVnf.class);
+ public static final AAIObjectType VF_MODULE = new AAIObjectType(AAIObjectType.GENERIC_VNF.uriTemplate(), VfModule.class);
+ public static final AAIObjectType L3_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, L3Network.class);
+ public static final AAIObjectType NETWORK_POLICY = new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkPolicy.class);
+ public static final AAIObjectType NODES_QUERY = new AAIObjectType("/search", "/nodes-query", "nodes-query");
+ public static final AAIObjectType CUSTOM_QUERY = new AAIObjectType("/query", "", "query");
+ public static final AAIObjectType ROUTE_TABLE_REFERENCE = new AAIObjectType(AAINamespaceConstants.NETWORK, RouteTableReference.class);
+ public static final AAIObjectType DEFAULT_TENANT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE + "/cloud-regions/cloud-region/" + Defaults.CLOUD_OWNER + "/AAIAIC25", "/tenants/tenant/{tenant-id}", "default-tenant");
+ public static final AAIObjectType VCE = new AAIObjectType(AAINamespaceConstants.NETWORK, Vce.class);
+ public static final AAIObjectType PORT_GROUP = new AAIObjectType(AAIObjectType.VCE.uriTemplate(), PortGroup.class);
+ public static final AAIObjectType VPN_BINDING = new AAIObjectType(AAINamespaceConstants.NETWORK, VpnBinding.class);
+ public static final AAIObjectType CONFIGURATION = new AAIObjectType(AAINamespaceConstants.NETWORK, Configuration.class);
+ public static final AAIObjectType PSERVER = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Pserver.class);
+ public static final AAIObjectType SERVICE_SUBSCRIPTION = new AAIObjectType(AAIObjectType.CUSTOMER.uriTemplate(), ServiceSubscription.class);
+ public static final AAIObjectType SERVICE_INSTANCE = new AAIObjectType(AAIObjectType.SERVICE_SUBSCRIPTION.uriTemplate(), ServiceInstance.class);
+ public static final AAIObjectType PROJECT = new AAIObjectType(AAINamespaceConstants.BUSINESS, Project.class);
+ public static final AAIObjectType LINE_OF_BUSINESS = new AAIObjectType(AAINamespaceConstants.BUSINESS, LineOfBusiness.class);
+ public static final AAIObjectType PLATFORM = new AAIObjectType(AAINamespaceConstants.BUSINESS, Platform.class);
+ public static final AAIObjectType OWNING_ENTITY = new AAIObjectType(AAINamespaceConstants.BUSINESS, OwningEntity.class);
+ public static final AAIObjectType ALLOTTED_RESOURCE = new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), AllottedResource.class);
+ public static final AAIObjectType PNF = new AAIObjectType(AAINamespaceConstants.NETWORK, Pnf.class);
+ public static final AAIObjectType OPERATIONAL_ENVIRONMENT = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, OperationalEnvironment.class);
+ public static final AAIObjectType CLOUD_REGION = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, CloudRegion.class);
+ public static final AAIObjectType TENANT = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Tenant.class);
+ public static final AAIObjectType VOLUME_GROUP = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), VolumeGroup.class);
+ public static final AAIObjectType VSERVER = new AAIObjectType(AAIObjectType.TENANT.uriTemplate(), Vserver.class);
+ public static final AAIObjectType MODEL_VER = new AAIObjectType(AAINamespaceConstants.SERVICE_DESIGN_AND_CREATION + "/models/model/{model-invariant-id}", ModelVer.class);
+ public static final AAIObjectType TUNNEL_XCONNECT = new AAIObjectType(AAIObjectType.ALLOTTED_RESOURCE.uriTemplate(), TunnelXconnect.class);
+ public static final AAIObjectType P_INTERFACE = new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), PInterface.class);
+ public static final AAIObjectType PHYSICAL_LINK = new AAIObjectType(AAINamespaceConstants.NETWORK, PhysicalLink.class);
+ public static final AAIObjectType INSTANCE_GROUP = new AAIObjectType(AAINamespaceConstants.NETWORK, InstanceGroup.class);
+ public static final AAIObjectType COLLECTION = new AAIObjectType(AAINamespaceConstants.NETWORK, Collection.class);
+ public static final AAIObjectType VNFC = new AAIObjectType(AAINamespaceConstants.NETWORK, Vnfc.class);
+ public static final AAIObjectType VLAN_TAG = new AAIObjectType(AAINamespaceConstants.NETWORK, VlanTag.class);
+ public static final AAIObjectType COMPLEX = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, Complex.class);
+ public static final AAIObjectType CONNECTOR = new AAIObjectType(AAINamespaceConstants.BUSINESS, Connector.class);
+ public static final AAIObjectType NETWORK_TECHNOLOGY = new AAIObjectType(AAINamespaceConstants.CLOUD_INFRASTRUCTURE, NetworkTechnology.class);
+ public static final AAIObjectType SUBNET = new AAIObjectType(AAIObjectType.L3_NETWORK.uriTemplate(), Subnet.class);
+ public static final AAIObjectType SP_PARTNER = new AAIObjectType(AAINamespaceConstants.BUSINESS, SpPartner.class);
+ public static final AAIObjectType DEVICE = new AAIObjectType(AAINamespaceConstants.NETWORK, Device.class);
+ public static final AAIObjectType EXT_AAI_NETWORK = new AAIObjectType(AAINamespaceConstants.NETWORK, ExtAaiNetwork.class);
+ public static final AAIObjectType AGGREGATE_ROUTE = new AAIObjectType(AAINamespaceConstants.NETWORK, AggregateRoute.class);
+ public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown");
private final String uriTemplate;
private final String parentUri;
private final String partialUri;
private final Class<?> aaiObjectClass;
- private static Map<String, AAIObjectType> map = new HashMap<>();
- private AAIObjectType(String parentUri, String partialUri) {
+ private final String name;
+
+ static {
+ /* Locate any AAIObjectTypes on the classpath and add them to our map */
+ java.util.Collection<URL> packages = ClasspathHelper.forPackage("");
+ Reflections r = new Reflections(new ConfigurationBuilder().setUrls(packages).setScanners(new SubTypesScanner()));
+
+ Set<Class<? extends AAIObjectType>> resources =
+ r.getSubTypesOf(AAIObjectType.class);
+ try {
+ for (Class<? extends AAIObjectType> customTypeClass : resources) {
+ AAIObjectType customType;
+ customType = customTypeClass.newInstance();
+ }
+ } catch (InstantiationException | IllegalAccessException e) {
+ }
+ }
+ protected AAIObjectType() {
+ this.parentUri = null;
+ this.partialUri = null;
+ this.uriTemplate = null;
+ this.aaiObjectClass = null;
+ this.name = null;
+ }
+ protected AAIObjectType(String parentUri, String partialUri, String name) {
this.parentUri = parentUri;
this.partialUri = partialUri;
this.uriTemplate = parentUri + partialUri;
this.aaiObjectClass = null;
+ this.name = name;
+ if (!AAIObjectType.map.containsKey(name)) {
+ AAIObjectType.map.put(name, this);
+ }
}
- private AAIObjectType(String parentUri, Class<?> aaiObjectClass) {
+ protected AAIObjectType(String parentUri, Class<?> aaiObjectClass) {
this.parentUri = parentUri;
this.partialUri = removeParentUri(aaiObjectClass, parentUri);
this.uriTemplate = parentUri + partialUri;
this.aaiObjectClass = aaiObjectClass;
+ this.name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, aaiObjectClass.getSimpleName());
+ if (!AAIObjectType.map.containsKey(name)) {
+ AAIObjectType.map.put(name, this);
+ }
}
@Override
@@ -144,12 +189,6 @@ public enum AAIObjectType implements GraphInventoryObjectType {
}
public static AAIObjectType fromTypeName(String name) {
- if (map.isEmpty()) {
- for (AAIObjectType type : AAIObjectType.values()) {
- map.put(type.typeName(), type);
- }
- }
-
if (map.containsKey(name)) {
return map.get(name);
} else {
@@ -162,12 +201,7 @@ public enum AAIObjectType implements GraphInventoryObjectType {
}
@Override
public String typeName(CaseFormat format) {
- String enumName = this.name();
- if (this.equals(AAIObjectType.DEFAULT_CLOUD_REGION) || this.equals(AAIObjectType.DEFAULT_TENANT)) {
- enumName = enumName.replace("DEFAULT_", "");
- }
-
- return CaseFormat.UPPER_UNDERSCORE.to(format, enumName);
+ return CaseFormat.LOWER_HYPHEN.to(format, this.name.replace("default-", ""));
}
@Override
diff --git a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
index bab145b3fd..e907bc97d7 100644
--- a/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
+++ b/common/src/main/java/org/onap/so/client/aai/entities/Relationships.java
@@ -91,11 +91,7 @@ public class Relationships {
final String relatedTo = (String)relationship.get("related-to");
if (p.test(relatedTo)) {
AAIObjectType type;
- try {
- type = AAIObjectType.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, relatedTo));
- } catch (IllegalArgumentException e) {
- type = AAIObjectType.UNKNOWN;
- }
+ type = AAIObjectType.fromTypeName(relatedTo);
final String relatedLink = (String)relationship.get("related-link");
result.add(AAIUriFactory.createResourceFromExistingURI(type, UriBuilder.fromPath(relatedLink).build()));
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
index ea842719e8..d4eaf0873b 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
@@ -28,6 +28,20 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory;
public class AAIObjectTypeTest {
+
+ @Test
+ public void fromTypeNameTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException {
+ AAIObjectType type = AAIObjectType.fromTypeName("allotted-resource");
+ assertEquals("allotted-resource", type.typeName());
+
+ }
+
+ @Test
+ public void customTypeTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException {
+ AAIObjectType type = AAIObjectType.fromTypeName("my-custom-name");
+ assertEquals("my-custom-name", type.typeName());
+
+ }
@Test
public void verifyDefaultCase() {
assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName());
diff --git a/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java b/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java
new file mode 100644
index 0000000000..b964e905de
--- /dev/null
+++ b/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java
@@ -0,0 +1,20 @@
+package org.onap.so.client.aai.objects;
+
+import org.onap.so.client.aai.AAINamespaceConstants;
+import org.onap.so.client.aai.AAIObjectType;
+
+public class CustomAAIObjectType extends AAIObjectType {
+
+ private static final long serialVersionUID = 1919729212831978098L;
+
+ public static final AAIObjectType CUSTOM = new CustomAAIObjectType(AAINamespaceConstants.NETWORK, "my-url", "my-custom-name");
+
+ /* Default constructor automatically called by AAIObjectType */
+ public CustomAAIObjectType() {
+ super();
+ }
+ protected CustomAAIObjectType(String parent, String uri, String name) {
+ super(parent, uri, name);
+ }
+
+}
diff --git a/common/src/test/resources/logback-test.xml b/common/src/test/resources/logback-test.xml
index 772eeabeb6..b52e6be022 100644
--- a/common/src/test/resources/logback-test.xml
+++ b/common/src/test/resources/logback-test.xml
@@ -65,6 +65,10 @@
<appender-ref ref="STDOUT" />
</logger>
+ <logger name="org.reflections" level="ERROR" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
<root level="WARN">
<appender-ref ref="STDOUT" />