fix ping communication with search to datarouter 15/51215/1
authorrenealr <reneal.rogers@amdocs.com>
Tue, 12 Jun 2018 14:15:26 +0000 (10:15 -0400)
committerrenealr <reneal.rogers@amdocs.com>
Tue, 12 Jun 2018 14:17:12 +0000 (10:17 -0400)
Add the fix needed in order for the search ping to communicate with data
router as well as add some  fixes to the start script and dockerfile

Issue-ID: AAI-1224
Change-Id: I74ab3b8def4b85513401b7329d33dc6a3bc518bc
Signed-off-by: renealr <reneal.rogers@amdocs.com>
pom.xml
src/main/bin/start.sh
src/main/docker/Dockerfile
src/main/java/org/onap/aai/sa/Application.java
src/main/java/org/onap/aai/sa/rest/AnalyzerApi.java
src/main/java/org/onap/aai/sa/searchdbabstraction/JaxrsUserService.java [deleted file]
src/main/java/org/onap/aai/sa/searchdbabstraction/RestEchoService.java [moved from src/main/java/org/onap/aai/sa/searchdbabstraction/JaxrsEchoService.java with 73% similarity]
src/main/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchHttpController.java
src/main/resources/application.properties
version.properties

diff --git a/pom.xml b/pom.xml
index afd2fa5..43391af 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@ limitations under the License.
     </parent>
     <groupId>org.onap.aai</groupId>
     <artifactId>search-data-service</artifactId>
-    <version>1.3.0-SNAPSHOT</version>
+    <version>1.3.1-SNAPSHOT</version>
     <name>aai-search-data-service</name>
 
     <properties>
@@ -124,12 +124,6 @@ limitations under the License.
             <version>2.7.8</version>
         </dependency>
 
-        <dependency>
-          <groupId>javax.ws.rs</groupId>
-          <artifactId>javax.ws.rs-api</artifactId>
-          <version>2.0</version>
-        </dependency>
-
         <dependency>
           <groupId>org.apache.directory.studio</groupId>
           <artifactId>org.apache.commons.lang</artifactId>
@@ -154,10 +148,31 @@ limitations under the License.
           <version>20180130</version>
         </dependency>
 
-       <dependency>
+               <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>
-        </dependency>
+       </dependency>
+       
+       <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-jetty</artifactId>
+               </dependency>
+               
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter</artifactId>
+                       <exclusions>
+                               <exclusion>
+                                       <groupId>ch.qos.logback</groupId>
+                                       <artifactId>logback-classic</artifactId>
+                               </exclusion>
+                       </exclusions>
+               </dependency>
+               
+               <dependency>
+                       <groupId>org.springframework.boot</groupId>
+                       <artifactId>spring-boot-starter-jersey</artifactId>
+               </dependency>
 
         <dependency>
           <groupId>org.springframework.boot</groupId>
@@ -169,12 +184,7 @@ limitations under the License.
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
-
-        <dependency>
-            <groupId>org.eclipse.jetty</groupId>
-            <artifactId>jetty-security</artifactId>
-        </dependency>
-
+        
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-security</artifactId>
index 3d6036f..69550c6 100644 (file)
@@ -12,28 +12,14 @@ fi
 if [ -z "$KEY_STORE_PASSWORD" ]; then
        echo "KEY_STORE_PASSWORD must be set in order to start up process"
        exit 1
-else
-       ## Extract java jar to DEOBFUSCATE the password.
-       CURR_D=`pwd`
-       cd $BASEDIR
-       jar xf search-data-service-package.jar
-       sudo java -cp ./BOOT-INF/lib/jetty-util-9.4.8.v20171121.jar org.eclipse.jetty.util.security.Password $KEY_STORE_PASSWORD > pass.txt 2>> pass.txt
-       PASS=`sed "2q;d" pass.txt`
-       sudo rm pass.txt
-       cd $CURR_D
 fi
 
-## tomcat_keystore to p12
-keytool -importkeystore -noprompt -deststorepass $PASS -destkeypass $PASS -srckeystore $BASEDIR/config/auth/tomcat_keystore -destkeystore $BASEDIR/config/auth/onap.p12 -deststoretype PKCS12 -srcstorepass $PASS
-
-## import into cacerts
-sudo keytool -importkeystore -noprompt -deststorepass changeit -destkeypass changeit -destkeystore /$JAVA_HOME/jre/lib/security/cacerts -srckeystore $BASEDIR/config/auth/onap.p12 -srcstoretype PKCS12 -srcstorepass $PASS -alias tomcat
-
 PROPS="-DAJSC_HOME=$AJSC_HOME"
 PROPS="$PROPS -DAJSC_CONF_HOME=$AJSC_CONF_HOME"
 PROPS="$PROPS -Dlogging.config=$BASEDIR/bundleconfig/etc/logback.xml"
 PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
 PROPS="$PROPS -DKEY_STORE_PASSWORD=$KEY_STORE_PASSWORD"
+
 JVM_MAX_HEAP=${MAX_HEAP:-1024}
 
 java $PROPS -jar $BASEDIR/search-data-service-package.jar
\ No newline at end of file
index 8578ef6..27073a5 100644 (file)
@@ -22,6 +22,15 @@ COPY bundleconfig-local/etc/logback.xml $MICRO_HOME/bundleconfig/etc
 RUN chmod 755 $BIN_HOME/*
 RUN ln -s /logs $MICRO_HOME/logs
 
+# Create the aai user
+RUN mkdir /opt/aaihome && \
+     groupadd -g 492381 aaiadmin && \
+     useradd -r -u 341790 -g 492381 -ms /bin/bash -d /opt/aaihome/aaiadmin aaiadmin && \
+     chown -R aaiadmin:aaiadmin $MICRO_HOME
+RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
+RUN sudo usermod -a -G sudo aaiadmin
+USER aaiadmin
+
 EXPOSE 9509 9509
 
 CMD ["/opt/app/search-data-service/bin/start.sh"]
index 69dab1e..03f8690 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.aai.sa;\r
 \r
 import org.eclipse.jetty.util.security.Password;\r
-import org.springframework.boot.SpringApplication;\r
 import org.springframework.boot.autoconfigure.SpringBootApplication;\r
 import org.springframework.boot.builder.SpringApplicationBuilder;\r
 import org.springframework.boot.web.support.SpringBootServletInitializer;\r
index 8db9a42..86be0fd 100644 (file)
@@ -30,11 +30,8 @@ import org.onap.aai.sa.rest.AnalyzerSchema;
 
 import java.util.concurrent.atomic.AtomicBoolean;
 import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Context;
 
-import org.springframework.beans.factory.annotation.Autowired;
+
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
diff --git a/src/main/java/org/onap/aai/sa/searchdbabstraction/JaxrsUserService.java b/src/main/java/org/onap/aai/sa/searchdbabstraction/JaxrsUserService.java
deleted file mode 100644 (file)
index 5452ce3..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.aai.sa.searchdbabstraction;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-
-@Path("/user")
-public class JaxrsUserService {
-
-  private static final Map<String, String> userIdToNameMap;
-
-  static {
-    userIdToNameMap = new HashMap<String, String>();
-    userIdToNameMap.put("dw113c", "Doug Wait");
-    userIdToNameMap.put("so401q", "Stuart O'Day");
-  }
-
-  @GET
-  @Path("/{userId}")
-  @Produces("text/plain")
-  public String lookupUser(@PathParam("userId") String userId) {
-    String name = userIdToNameMap.get(userId);
-    return name != null ? name : "unknown id";
-  }
-
-}
\ No newline at end of file
  */
 package org.onap.aai.sa.searchdbabstraction;
 
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
+
+
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 
 /**
  * Exposes REST endpoints for a simple echo service.
  */
-@Path("/jaxrs-services")
-public class JaxrsEchoService {
+@RestController
+@RequestMapping("/services/search-data-service/v1")
+public class RestEchoService {
 
   /**
    * REST endpoint for a simple echo service.
@@ -38,11 +41,9 @@ public class JaxrsEchoService {
    * @param input - The value to be echoed back.
    * @return - The input value.
    */
-  @GET
-  @Path("/echo/{input}")
-  @Produces("text/plain")
-  public String ping(@PathParam("input") String input) {
+  @RequestMapping(value = "/echo/{input}", method = {RequestMethod.GET})
+  public String ping(@PathVariable("input") String input) {
     return "[Search Database Abstraction Micro Service] - Echo Service: " + input + ".";
   }
 
-}
\ No newline at end of file
+}
index 019d867..626ea8c 100644 (file)
@@ -79,7 +79,9 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
-import javax.ws.rs.core.Response.Status;
+
+import org.springframework.http.HttpStatus;
+
 
 
 /**
@@ -440,7 +442,7 @@ public class ElasticSearchHttpController implements DocumentStoreInterface {
       if ((indexExistsResult.getResultCode() < 200) || (indexExistsResult.getResultCode() >= 300)) {
 
         DocumentOperationResult opResult = new DocumentOperationResult();
-        opResult.setResultCode(Status.NOT_FOUND.getStatusCode());
+        opResult.setResultCode(HttpStatus.NOT_FOUND.value());
         opResult.setResult("Document Index '" + indexName + "' does not exist.");
         opResult.setFailureCause("Document Index '" + indexName + "' does not exist.");
         return opResult;
@@ -461,13 +463,13 @@ public class ElasticSearchHttpController implements DocumentStoreInterface {
     DocumentOperationResult opResult = checkDocumentExistence(indexName, document.getId());
 
 
-    if (opResult.getResultCode() != Status.NOT_FOUND.getStatusCode()) {
-      if (opResult.getResultCode() == Status.OK.getStatusCode()) {
+    if (opResult.getResultCode() != HttpStatus.NOT_FOUND.value()) {
+      if (opResult.getResultCode() == HttpStatus.CONFLICT.value()) {
         opResult.setFailureCause("A document with the same id already exists.");
       } else {
         opResult.setFailureCause("Failed to verify a document with the specified id does not already exist.");
       }
-      opResult.setResultCode(Status.CONFLICT.getStatusCode());
+      opResult.setResultCode(HttpStatus.CONFLICT.value());
       return opResult;
     }
 
@@ -626,7 +628,7 @@ public class ElasticSearchHttpController implements DocumentStoreInterface {
       if ((indexExistsResult.getResultCode() < 200) || (indexExistsResult.getResultCode() >= 300)) {
 
         DocumentOperationResult opResult = new DocumentOperationResult();
-        opResult.setResultCode(Status.NOT_FOUND.getStatusCode());
+        opResult.setResultCode(HttpStatus.NOT_FOUND.value());
         opResult.setResult("Document Index '" + indexName + "' does not exist.");
         opResult.setFailureCause("Document Index '" + indexName + "' does not exist.");
         return opResult;
@@ -979,8 +981,8 @@ public class ElasticSearchHttpController implements DocumentStoreInterface {
       throw new DocumentStoreOperationException("Failed getting the response body payload.", e);
     }
 
-    if (resultCode == Status.CONFLICT.getStatusCode()) {
-      opResult.setResultCode(Status.PRECONDITION_FAILED.getStatusCode());
+    if (resultCode == HttpStatus.CONFLICT.value()) {
+      opResult.setResultCode(HttpStatus.PRECONDITION_FAILED.value());
     } else {
       opResult.setResultCode(resultCode);
     }
index 6106535..20dc028 100644 (file)
@@ -2,3 +2,4 @@ server.ssl.key-store=/opt/app/search-data-service/config/auth/tomcat_keystore
 server.ssl.enabled=true\r
 server.port=9509\r
 server.ssl.client-auth=need\r
+server.ssl.enabled-protocols=TLSv1.1,TLSv1.2\r
index a254b21..fb21064 100644 (file)
@@ -4,7 +4,7 @@
 
 major=1
 minor=3
-patch=0
+patch=1
 
 base_version=${major}.${minor}.${patch}