support for v20 16/109616/1
authorLaMont, William (wl2432) <wl2432@att.com>
Fri, 26 Jun 2020 21:24:51 +0000 (17:24 -0400)
committerLaMont, William (wl2432) <wl2432@att.com>
Fri, 26 Jun 2020 21:25:39 +0000 (17:25 -0400)
Issue-ID: AAI-2965
Change-Id: I87737d2cfcf6b499af6083c2355042d66278e73c
Signed-off-by: LaMont, William (wl2432) <wl2432@att.com>
22 files changed:
aai-resources/pom.xml
aai-resources/src/main/assembly/descriptor.xml
aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
aai-resources/src/main/java/org/onap/aai/rest/LegacyMoxyConsumer.java
aai-resources/src/main/java/org/onap/aai/rest/URLFromVertexIdConsumer.java
aai-resources/src/main/resources/application.properties
aai-resources/src/main/resources/etc/appprops/aaiconfig.properties
aai-resources/src/main/resources/etc/appprops/error.properties
aai-resources/src/main/scripts/bulkprocess.sh
aai-resources/src/main/scripts/common_functions.sh
aai-resources/src/main/scripts/deleteTool.sh
aai-resources/src/main/scripts/getTool.sh
aai-resources/src/main/scripts/install/addManualData.sh
aai-resources/src/main/scripts/putTool.sh
aai-resources/src/main/scripts/rshipTool.sh
aai-resources/src/main/scripts/updateTool.sh
aai-resources/src/main/scripts/vmExportCloudRegions.sh
aai-resources/src/main/scripts/vmUpdateExport.sh
aai-resources/src/main/scripts/vmValidateCloudRegions.sh
aai-resources/src/test/java/org/onap/aai/rest/LegacyMoxyConsumerTest.java
aai-resources/src/test/resources/etc/appprops/aaiconfig.properties
pom.xml

index e3141dd..828b91a 100644 (file)
@@ -70,8 +70,8 @@
         <schema.version.app.root.start>v11</schema.version.app.root.start>
         <schema.version.namespace.change.start>v12</schema.version.namespace.change.start>
         <schema.version.edge.label.start>v12</schema.version.edge.label.start>
-        <schema.version.api.default>v19</schema.version.api.default>
-        <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v17,v18,v19</schema.version.list>
+        <schema.version.api.default>v20</schema.version.api.default>
+        <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20</schema.version.list>
         <schema.uri.base.path>/aai</schema.uri.base.path>
         <!-- <schema.translator.list>config</schema.translator.list> -->
         <schema.ingest.file>${project.basedir}/src/main/resources/application.properties</schema.ingest.file>
index 08e253f..1c3d166 100644 (file)
@@ -13,6 +13,7 @@
             <includes>
                 <include>**/*</include>
             </includes>
+            <fileMode>755</fileMode>
         </fileSet>
         <fileSet>
             <directory>${project.basedir}/src/main/scripts</directory>
@@ -20,6 +21,7 @@
             <includes>
                 <include>**/*</include>
             </includes>
+            <fileMode>777</fileMode>
         </fileSet>
         <fileSet>
             <directory>${project.build.directory}</directory>
@@ -27,6 +29,7 @@
             <includes>
                 <include>${project.artifactId}-${project.version}.jar</include>
             </includes>
+            <fileMode>755</fileMode>
         </fileSet>
     </fileSets>
 </assembly>
index 3f595d1..4bd1a0d 100644 (file)
@@ -354,8 +354,7 @@ public abstract class BulkConsumer extends RESTAPI {
                                                        throw new AAIException("AAI_6111", String.format("input payload does not follow %s interface", module));
                                                } 
                                        }
-                                       
-                                       Gson gson = new Gson();
+                                       Gson gson = new GsonBuilder().serializeNulls().create();
                                        
                                        String bodyStr = gson.toJson(bodyObj);
                                        bulkOperation.setRawReq(bodyStr);
index e6dcc77..8939d04 100644 (file)
@@ -227,7 +227,8 @@ public class LegacyMoxyConsumer extends RESTAPI {
                        SchemaVersion version = new SchemaVersion(versionParam);
 
                        final HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
-                       traversalUriHttpEntry.setHttpEntryProperties(version);
+                       String serverBase = req.getRequestURL().toString().replaceAll("/(v[0-9]+|latest)/.*", "/");
+                       traversalUriHttpEntry.setHttpEntryProperties(version, serverBase);
                        dbEngine = traversalUriHttpEntry.getDbEngine();
                        loader = traversalUriHttpEntry.getLoader();
                        MultivaluedMap<String, String> params = info.getQueryParameters();
@@ -438,7 +439,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
        @Path("/{uri: .+}/relationship-list")
        @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
        @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
-       public Response getRelationshipList (@DefaultValue("-1") @QueryParam("resultIndex") String resultIndex, @DefaultValue("-1") @QueryParam("resultSize") String resultSize, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("false") @QueryParam("cleanup") String cleanUp, @Context HttpHeaders headers, @Context UriInfo info) {
+       public Response getRelationshipList (@DefaultValue("-1") @QueryParam("resultIndex") String resultIndex, @DefaultValue("-1") @QueryParam("resultSize") String resultSize, @PathParam("version")String versionParam, @PathParam("uri") @Encoded String uri, @DefaultValue("false") @QueryParam("cleanup") String cleanUp, @Context HttpHeaders headers, @Context HttpServletRequest req,@Context UriInfo info) {
                return runner(AAIConstants.AAI_CRUD_TIMEOUT_ENABLED,
                                AAIConstants.AAI_CRUD_TIMEOUT_APP,
                                AAIConstants.AAI_CRUD_TIMEOUT_LIMIT,
@@ -448,7 +449,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
                                new AaiCallable<Response>() {
                                        @Override
                                        public Response process() {
-                                               return getRelationshipList(versionParam, uri, cleanUp, headers, info, resultIndex, resultSize);
+                                               return getRelationshipList(versionParam, req, uri, cleanUp, headers, info, resultIndex, resultSize);
                                        }
                                }
                );
@@ -463,7 +464,7 @@ public class LegacyMoxyConsumer extends RESTAPI {
         * @param info
         * @return
         */
-       public Response getRelationshipList(String versionParam, String uri, String cleanUp, HttpHeaders headers, UriInfo info, String resultIndex, String resultSize) {
+       public Response getRelationshipList(String versionParam, HttpServletRequest req, String uri, String cleanUp, HttpHeaders headers, UriInfo info, String resultIndex, String resultSize) {
                String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
                String transId = headers.getRequestHeaders().getFirst("X-TransactionId");
                Response response = null;
@@ -475,7 +476,8 @@ public class LegacyMoxyConsumer extends RESTAPI {
                        SchemaVersion version = new SchemaVersion(versionParam);
 
                        final HttpEntry traversalUriHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
-                       traversalUriHttpEntry.setHttpEntryProperties(version);
+                       String serverBase = req.getRequestURL().toString().replaceAll("/(v[0-9]+|latest)/.*", "/");
+                       traversalUriHttpEntry.setHttpEntryProperties(version, serverBase);
                        dbEngine = traversalUriHttpEntry.getDbEngine();
                        loader = traversalUriHttpEntry.getLoader();
                        MultivaluedMap<String, String> params = info.getQueryParameters();
index 041952b..9293569 100644 (file)
@@ -74,7 +74,8 @@ public class URLFromVertexIdConsumer extends RESTAPI {
                TransactionalGraphEngine dbEngine = null;
                try {
                        HttpEntry resourceHttpEntry = SpringContextAware.getBean("traversalUriHttpEntry", HttpEntry.class);
-                       resourceHttpEntry.setHttpEntryProperties(version);
+                       String serverBase = req.getRequestURL().toString().replaceAll("/(v[0-9]+|latest)/.*", "/");
+                       resourceHttpEntry.setHttpEntryProperties(version, serverBase);
                        dbEngine = resourceHttpEntry.getDbEngine();
                        
                        DBSerializer serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth);
@@ -88,7 +89,7 @@ public class URLFromVertexIdConsumer extends RESTAPI {
 
                        result.append(uri.getRawPath());
                        result.insert(0, version);
-                       result.insert(0, AAIConfig.get("aai.server.url.base"));
+                       result.insert(0, serverBase);
                        response = Response.ok().entity(result.toString()).status(Status.OK).type(MediaType.TEXT_PLAIN).build();
                } catch (AAIException e) {
                        //TODO check that the details here are sensible
index 7dee2b2..e26199c 100644 (file)
@@ -40,10 +40,13 @@ server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
 server.ssl.client-auth=want
 server.ssl.key-store-type=JKS
 
+null.db.serialization.enabled=true
+
 # JMS bind address host port
 jms.bind.address=tcp://localhost:61647
 
 dmaap.ribbon.listOfServers=localhost:3904
+
 # Schema related attributes for the oxm and edges
 # Any additional schema related attributes should start with prefix schema
 schema.configuration.location=N/A
index f53fca0..42fbbfc 100644 (file)
@@ -45,7 +45,7 @@ aai.tools.username=AAI
 aai.tools.password=AAI
 
 aai.server.url.base=https://localhost:8443/aai/
-aai.server.url=https://localhost:8443/aai/v19/
+aai.server.url=https://localhost:8443/aai/v20/
 aai.global.callback.url=https://localhost:8443/aai/
 
 aai.truststore.filename=aai_keystore
@@ -53,18 +53,18 @@ aai.truststore.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
 aai.keystore.filename=aai-client-cert.p12
 aai.keystore.passwd.x=
 
-aai.notification.current.version=v19
+aai.notification.current.version=v20
 aai.notificationEvent.default.status=UNPROCESSED
 aai.notificationEvent.default.eventType=AAI-EVENT
 aai.notificationEvent.default.domain=devINT1
 aai.notificationEvent.default.sourceName=aai
 aai.notificationEvent.default.sequenceNumber=0
 aai.notificationEvent.default.severity=NORMAL
-aai.notificationEvent.default.version=v19
+aai.notificationEvent.default.version=v20
 # This one lets us enable/disable resource-version checking on updates/deletes
 aai.resourceversion.enableflag=true
 aai.logging.maxStackTraceEntries=10
-aai.default.api.version=v19
+aai.default.api.version=v20
 
 # Used by Model-processing code
 aai.model.delete.sleep.per.vtx.msec=500
@@ -156,3 +156,5 @@ aai.implied.delete.log.enabled=false
 #################################################################################
 aai.implied.delete.whitelist.sdnc='vce'
 aai.implied.delete.whitelist.ro='vserver'
+
+property.null.validation.enabled=true
\ No newline at end of file
index b2dc448..6e5630c 100644 (file)
@@ -125,6 +125,7 @@ AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead
 AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload:300
 AAI_6148=5:4:ERROR:6148:400:3000:More than one node found %1:300
 AAI_6149=5:4:ERROR:6149:404:3000:No relationship was found:300
+AAI_6150=5:4:ERROR:6150:200:3000:DB object with required field serialized with empty or null value
 
 #--- aaicsvp: 7101-7199
 AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing:900
index c4bca27..7366bf2 100644 (file)
 inputFolder=$1
 if [ -z "$1" ]; then
        echo "Input folder string is empty."
-   exit 1
+    exit 1
 fi
 
-if [ ! -d "/opt/bulkprocess_load/$1" ]; then
-       echo "Input folder could not be found."
-   exit 1
+if [ ! -d "$inputFolder" ]; then 
+       if [ ! -d "/opt/bulkprocess_load/$1" ]; then
+               echo "Input folder could not be found."
+               exit 1
+       else
+               inputFolder="/opt/bulkprocess_load/$1"  
+       fi
 fi
 
 XFROMAPPID=$2
@@ -50,7 +54,7 @@ esac
 
 XTRANSID=$3
 
-for input_file in $(ls -v /opt/bulkprocess_load/${inputFolder}/*);
+for input_file in $(ls -v ${inputFolder}/*);
 do
     output_file=$(basename $input_file | sed 's/.json//g');
     /opt/app/aai-resources/scripts/putTool.sh /bulkprocess ${input_file} -display $XFROMAPPID  $XTRANSID > /tmp/${output_file}.$(date +"%Y%m%d%H%M%S").results.json;
index 14358d9..d5bebac 100644 (file)
@@ -36,7 +36,6 @@ check_user(){
 
 # Sources the profile and sets the project home
 source_profile(){
-    . /etc/profile.d/aai.sh
     PROJECT_HOME=/opt/app/aai-resources
 }
 
index 3d7f923..c2dc05c 100644 (file)
@@ -63,7 +63,7 @@ if [ "${userid}" != "aaiadmin" ]; then
     exit 1
 fi
 
-. /etc/profile.d/aai.sh
+
 PROJECT_HOME=/opt/app/aai-resources
 prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
 log_dir=$PROJECT_HOME/logs/misc
index e2ca220..8ff502b 100644 (file)
@@ -58,7 +58,7 @@ if [ "${userid}" != "aaiadmin" ]; then
                exit 1
 fi
 
-. /etc/profile.d/aai.sh
+
 PROJECT_HOME=/opt/app/aai-resources
 prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
 log_dir=$PROJECT_HOME/logs/misc
index bd7f7bd..645f7c8 100644 (file)
@@ -43,7 +43,6 @@ contains() {
     fi
 }
 
-. /etc/profile.d/aai.sh
 PROJECT_HOME=/opt/app/aai-resources
 
 PROGNAME=$(basename $0)
index 4e55b0c..bc84010 100644 (file)
@@ -90,7 +90,7 @@ if [ "${userid}" != "aaiadmin" ]; then
     exit 1
 fi
 
-. /etc/profile.d/aai.sh
+
 PROJECT_HOME=/opt/app/aai-resources
 prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
 log_dir=$PROJECT_HOME/logs/misc
index 3952d44..3ee1c04 100644 (file)
@@ -111,7 +111,7 @@ if [ "${userid}" != "aaiadmin" ]; then
     exit 1
 fi 
 
-. /etc/profile.d/aai.sh
+
 PROJECT_HOME=/opt/app/aai-resources
 prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
 log_dir=$PROJECT_HOME/logs/misc
index ce0a8f6..347640e 100644 (file)
@@ -94,7 +94,7 @@ if [ "${userid}" != "aaiadmin" ]; then
     exit 1
 fi
 
-. /etc/profile.d/aai.sh
+
 PROJECT_HOME=/opt/app/aai-resources
 prop_file=$PROJECT_HOME/resources/etc/appprops/aaiconfig.properties
 log_dir=$PROJECT_HOME/logs/misc
index 95ec969..a8d14e3 100644 (file)
@@ -337,7 +337,7 @@ addValidateVserver() {
 COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
 . ${COMMON_ENV_PATH}/common_functions.sh
 
-. /etc/profile.d/aai.sh
+
 
 PROJECT_HOME=/opt/app/aai-resources
 PROGNAME=$(basename $0)
index f492d2c..6bd4ca9 100644 (file)
@@ -21,8 +21,7 @@
 ###
 
 #
-# vmUpdateExport.sh  -- This tool updates the files generated in A&AI to
-# match what is expected in narad
+# vmUpdateExport.sh  -- This tool updates the files generated in A&AI
 # The script takes no arguments
 
 addTemplates() {
@@ -33,7 +32,7 @@ addTemplates() {
 COMMON_ENV_PATH=$( cd "$(dirname "$0")" ; pwd -P )
 . ${COMMON_ENV_PATH}/common_functions.sh
 
-. /etc/profile.d/aai.sh
+
 
 PROJECT_HOME=/opt/app/aai-resources
 PROGNAME=$(basename $0)
index a8189e3..b7e30ee 100644 (file)
@@ -56,7 +56,7 @@ renamefiles() {
        
 }
 
-. /etc/profile.d/aai.sh
+
 PROJECT_HOME=/opt/app/aai-resources
 
 PROGNAME=$(basename $0)
index 748b032..84ac1a8 100644 (file)
@@ -43,14 +43,17 @@ import org.skyscreamer.jsonassert.JSONAssert;
 import org.springframework.mock.web.MockHttpServletRequest;
 import org.springframework.test.annotation.DirtiesContext;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.core.*;
 import java.io.IOException;
 import java.util.*;
 
 import static org.junit.Assert.*;
 import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+// TODO: Change the following test to use spring boot
 public class LegacyMoxyConsumerTest extends AAISetup {
 
     protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json");
@@ -594,7 +597,9 @@ public class LegacyMoxyConsumerTest extends AAISetup {
         when(uriInfo.getPath()).thenReturn(uri);
         when(uriInfo.getPath(false)).thenReturn(uri);
 
-        MockHttpServletRequest mockReqGet = new MockHttpServletRequest("GET", uri);
+        HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
+        when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8447/aai/v15/" + uri));
+
         Response response = legacyMoxyConsumer.getLegacy(
                 "",
                 null,
@@ -605,21 +610,20 @@ public class LegacyMoxyConsumerTest extends AAISetup {
                 "false",
                 httpHeaders,
                 uriInfo,
-                mockReqGet
+                mockRequest
         );
 
         assertNotNull("Response from the legacy moxy consumer returned null", response);
         assertEquals("Expected to not have the data already in memory",
                 Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
 
-        MockHttpServletRequest mockReq = new MockHttpServletRequest("PUT", uri);
         response = legacyMoxyConsumer.update(
                 payload,
                 schemaVersions.getDefaultVersion().toString(),
                 uri,
                 httpHeaders,
                 uriInfo,
-                mockReq
+                mockRequest
         );
 
         assertNotNull("Response from the legacy moxy consumer returned null", response);
@@ -641,7 +645,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
                 "false",
                 httpHeaders,
                 uriInfo,
-                mockReqGet
+                mockRequest
         );
 
         assertNotNull("Response from the legacy moxy consumer returned null", response);
@@ -838,6 +842,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
                 "cloud-infrastructure/pservers/pserver/%s/relationship-list", hostname);
         String getRelationshipUri = String.format(
                 "cloud-infrastructure/pservers/pserver/%s", hostname);
+        HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
+        when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8447/aai/v15/" + getRelationshipUri));
         response = legacyMoxyConsumer.getRelationshipList(
                 "1",
                 "1",
@@ -845,6 +851,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
                 getRelationshipUri,
                 "false",
                 httpHeaders,
+                mockRequest,
                 uriInfo
         );
 
@@ -902,6 +909,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
         String getRelationshipUri = String.format(
                 "cloud-infrastructure/pservers/pserver/%s", hostname);
         queryParameters.add("format", "resource");
+        HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
+        when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8447/aai/v15/" + getRelationshipUri));
         response = legacyMoxyConsumer.getRelationshipList(
                 "1",
                 "1",
@@ -909,6 +918,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
                 getRelationshipUri,
                 "false",
                 httpHeaders,
+                mockRequest,
                 uriInfo
         );
         queryParameters.remove("format");
@@ -971,6 +981,8 @@ public class LegacyMoxyConsumerTest extends AAISetup {
         String getRelationshipUri = String.format(
                 "cloud-infrastructure/pservers/pserver/%s", hostname);
         MockHttpServletRequest mockReq = new MockHttpServletRequest("GET_RELATIONSHIP", getRelationshipMockRequestUri);
+        HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
+        when(mockRequest.getRequestURL()).thenReturn(new StringBuffer("https://localhost:8447/aai/v15/" + getRelationshipUri));
         Response response = legacyMoxyConsumer.getRelationshipList(
                 "1",
                 "1",
@@ -978,6 +990,7 @@ public class LegacyMoxyConsumerTest extends AAISetup {
                 getRelationshipUri,
                 "false",
                 httpHeaders,
+                mockRequest,
                 uriInfo
         );
 
diff --git a/pom.xml b/pom.xml
index a9f9547..18edd1d 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
         <staging.path>/content/repositories/staging/</staging.path>
         <!-- GMaven plugin uses this property to figure out the name of the docker tag -->
         <aai.project.version>${project.version}</aai.project.version>
-        <aai.common.version>1.6.10</aai.common.version>
+        <aai.common.version>1.7.0-SNAPSHOT</aai.common.version>
        <aai.schema.service.version>1.6.6</aai.schema.service.version>
     </properties>
     <build>