Fix release artifacts 37/34037/2
authorDenes Nemeth <denes.nemeth@nokia.com>
Mon, 5 Mar 2018 10:34:34 +0000 (11:34 +0100)
committerDenes Nemeth <denes.nemeth@nokia.com>
Mon, 5 Mar 2018 10:46:33 +0000 (11:46 +0100)
Change-Id: Ic61a50d8c7b9c2121b7ebbac5324b1c2b99e1f3a
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728

12 files changed:
nokiav2/docs/sample/cbam.collectConnectionPoints.js
nokiav2/docs/sampleVnfs/simple/simple.csar
nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/ConverterApi.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SwaggerApi.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/StoreLoader.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/SystemFunctions.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/ct/CTReal.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java
nokiav2/generatedapis/pom.xml

index f5cfc67..c721c93 100644 (file)
@@ -26,21 +26,7 @@ function collectPorts(resourceModel, diff){
         transformedPort.macAddress = port.attributes.mac_address;
         transformedPort.serverProviderId = port.attributes.device_id;
         transformedPort.networkProviderId = port.attributes.network_id;
-        transformedPort.changeType = 'untouched';
-        var added = contains(diff.add, path);
-        var removed = contains(diff.remove, path);
-        if(added && removed){
-            transformedPort.changeType = "MODIFIED";
-        }
-        else{
-            if(removed){
-                transformedPort.changeType = "REMOVED";
-            }
-            if(added){
-                transformedPort.changeType = "ADDED";
-            }
-        }
-        if('untouched' != transformedPort.changeType && managedPort){
+        if(managedPort){
             transformedPorts.push(transformedPort)
         }
     })
index 3d87246..13d3562 100644 (file)
Binary files a/nokiav2/docs/sampleVnfs/simple/simple.csar and b/nokiav2/docs/sampleVnfs/simple/simple.csar differ
index 32c3f89..3545d23 100644 (file)
Binary files a/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar and b/nokiav2/docs/sampleVnfs/simpleDual/simpleDual.csar differ
index 2013a7b..4a73748 100644 (file)
@@ -28,9 +28,16 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.Part;
 
+import java.io.IOException;
+
+import static org.apache.http.entity.ContentType.APPLICATION_OCTET_STREAM;
 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions.systemFunctions;
 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
 import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.HttpHeaders.CONTENT_DISPOSITION;
+import static org.springframework.http.HttpHeaders.CONTENT_LENGTH;
+import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
+import static org.springframework.http.HttpStatus.OK;
 import static org.springframework.http.MediaType.TEXT_HTML_VALUE;
 import static org.springframework.web.bind.annotation.RequestMethod.GET;
 import static org.springframework.web.bind.annotation.RequestMethod.POST;
@@ -56,10 +63,10 @@ public class ConverterApi {
         logger.info("REST: convert package");
         Part part = request.getParts().iterator().next();
         byte[] bytes = vnfPackageConverter.covert(part.getInputStream());
-        httpResponse.addHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_OCTET_STREAM.getMimeType());
-        httpResponse.setStatus(HttpStatus.OK.value());
-        httpResponse.addHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(bytes.length));
-        httpResponse.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + "core.csar" + "\"");
+        httpResponse.addHeader(CONTENT_TYPE, APPLICATION_OCTET_STREAM.getMimeType());
+        httpResponse.setStatus(OK.value());
+        httpResponse.addHeader(CONTENT_LENGTH, Integer.toString(bytes.length));
+        httpResponse.addHeader(CONTENT_DISPOSITION, "attachment; filename=\"" + "core.csar" + "\"");
         httpResponse.getOutputStream().write(bytes);
         httpResponse.getOutputStream().flush();
     }
@@ -72,10 +79,10 @@ public class ConverterApi {
      */
     @RequestMapping(value = "/convert", method = GET, produces = TEXT_HTML_VALUE)
     @ResponseBody
-    public void getUploadPageForConvertingVnfd(HttpServletResponse httpResponse) throws Exception {
+    public void getUploadPageForConvertingVnfd(HttpServletResponse httpResponse) throws IOException {
         logger.info("REST: get converter main page");
         byte[] bytes = systemFunctions().loadFile("upload.html");
-        httpResponse.addHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(bytes.length));
+        httpResponse.addHeader(CONTENT_LENGTH, Integer.toString(bytes.length));
         httpResponse.getOutputStream().write(bytes);
     }
 }
index 6d4d19e..659e82f 100644 (file)
@@ -26,8 +26,13 @@ import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletResponse;
 
+import java.io.IOException;
+
 import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.DriverProperties.BASE_URL;
 import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.HttpHeaders.CONTENT_LENGTH;
+import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
 import static org.springframework.web.bind.annotation.RequestMethod.GET;
 
 /**
@@ -52,11 +57,11 @@ public class SwaggerApi {
      */
     @RequestMapping(value = "/swagger.json", method = GET)
     @ResponseBody
-    public void getSwaggerApiDefinition(HttpServletResponse httpResponse) throws Exception {
+    public void getSwaggerApiDefinition(HttpServletResponse httpResponse) throws IOException {
         logger.info("REST: get swagger definition");
-        httpResponse.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
+        httpResponse.addHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE);
         byte[] bytes = selfRegistrationManager.getSwaggerApiDefinition();
-        httpResponse.addHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(bytes.length));
+        httpResponse.addHeader(CONTENT_LENGTH, Integer.toString(bytes.length));
         httpResponse.getOutputStream().write(bytes);
     }
 }
index 7377abf..ebd4234 100644 (file)
@@ -20,8 +20,20 @@ import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import org.slf4j.Logger;
 
+/**
+ * Collection of utility functions
+ */
 public class CbamUtils {
 
+    private static class OperationMustBeAborted extends RuntimeException{
+        OperationMustBeAborted(String msg){
+            super(msg);
+        }
+        OperationMustBeAborted(Exception e, String msg){
+            super(msg, e);
+        }
+    }
+
     private CbamUtils() {
         //use static way
     }
@@ -43,7 +55,7 @@ public class CbamUtils {
     public static JsonElement childElement(JsonObject parent, String name) {
         JsonElement child = parent.get(name);
         if (child == null) {
-            throw new RuntimeException("Missing child " + name);
+            throw new OperationMustBeAborted("Missing child " + name);
         }
         return child;
     }
@@ -58,7 +70,7 @@ public class CbamUtils {
      */
     public static RuntimeException fatalFailure(Logger logger, String msg, Exception e) {
         logger.error(msg, e);
-        throw new RuntimeException(msg, e);
+        throw new OperationMustBeAborted(e, msg);
     }
 
     /**
@@ -70,6 +82,6 @@ public class CbamUtils {
      */
     public static RuntimeException fatalFailure(Logger logger, String msg) {
         logger.error(msg);
-        throw new RuntimeException(msg);
+        throw new OperationMustBeAborted(msg);
     }
 }
index faa436e..249925e 100644 (file)
@@ -18,6 +18,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util;
 
 import org.apache.commons.codec.binary.Base64;
 
+import javax.swing.text.html.Option;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.security.KeyFactory;
@@ -34,6 +35,9 @@ import java.util.HashSet;
 import java.util.Optional;
 import java.util.Set;
 
+import static java.util.Optional.empty;
+import static java.util.Optional.of;
+import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.fatalFailure;
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -41,7 +45,7 @@ import static org.slf4j.LoggerFactory.getLogger;
  */
 public final class StoreLoader {
 
-    public static final String PASSWORD = "password";
+    public static final String PASS_ALIAS = "password";
     private static final String RSA = "RSA";
     private static final String X_509 = "X.509";
     private static final String SUN = "SUN";
@@ -59,8 +63,7 @@ public final class StoreLoader {
         if (rindex == -1 || lindex == -1) {
             return "";
         }
-        String substring = content.substring(rindex, lindex) + end(scope);
-        return substring;
+        return content.substring(rindex, lindex) + end(scope);
     }
 
     /**
@@ -105,17 +108,17 @@ public final class StoreLoader {
      */
     public static KeyStore loadStore(String pem, String storePassword, String keyPassword) {
         Optional<PrivateKey> privateKey = generatePrivateKey(pem);
-        Certificate[] certs = createCertificates(pem);
+        Optional<Certificate[]> certs = createCertificates(pem);
         try {
             KeyStore ks = KeyStore.getInstance(JKS, SUN);
             ks.load(null, storePassword.toCharArray());
             if (privateKey.isPresent()) {
-                ks.setKeyEntry(PASSWORD, privateKey.get(), keyPassword.toCharArray(), certs);
-            } else if (certs != null) {
+                ks.setKeyEntry(PASS_ALIAS, privateKey.get(), keyPassword.toCharArray(), certs.orElse(null));
+            } else if (certs.isPresent()) {
                 int index = 0;
-                for (Certificate cert : certs) {
+                for (Certificate cert : certs.get()) {
                     TrustedCertificateEntry ts = new TrustedCertificateEntry(cert);
-                    ks.setEntry(PASSWORD + index, ts, null);
+                    ks.setEntry(PASS_ALIAS + index, ts, null);
                     index++;
                 }
             }
@@ -125,7 +128,7 @@ public final class StoreLoader {
         }
     }
 
-    private static Certificate[] createCertificates(String pem) {
+    private static Optional<Certificate[]> createCertificates(String pem) {
         Set<Certificate> certificates = new HashSet<>();
         try {
             for (String certificate : getCertifacates(pem)) {
@@ -136,14 +139,13 @@ public final class StoreLoader {
                 certificates.addAll(c);
             }
         } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            throw new RuntimeException("Unable to load certificates", e);
+            throw fatalFailure(logger, "Unable to load certificates", e);
         }
 
         if (certificates.size() > 0) {
-            return certificates.toArray(new Certificate[certificates.size()]);
+            return of(certificates.toArray(new Certificate[certificates.size()]));
         } else {
-            return null;
+            return empty();
         }
     }
 
@@ -153,12 +155,11 @@ public final class StoreLoader {
             if (!key.isEmpty()) {
                 KeyFactory keyFactory = KeyFactory.getInstance(RSA);
                 PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(toDer(key, RSA_PRIVATE_KEY));
-                return Optional.of(keyFactory.generatePrivate(keySpec));
+                return of(keyFactory.generatePrivate(keySpec));
             }
-            return Optional.empty();
+            return empty();
         } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
-            logger.error("Unable to load key", e);
-            throw new RuntimeException("Unable to load key", e);
+            throw fatalFailure(logger, "Unable to load key", e);
         }
     }
 
index e2a2e66..805be64 100644 (file)
@@ -28,19 +28,19 @@ import java.io.PrintStream;
  * the classes that uses static calls.
  */
 public class SystemFunctions {
-    private static SystemFunctions INSTANCE;
+    private static SystemFunctions singletonInstance;
 
     /**
      * @return singleton instance
      */
     public static SystemFunctions systemFunctions() {
-        if (INSTANCE != null) {
-            return INSTANCE;
+        if (singletonInstance != null) {
+            return singletonInstance;
         } else {
             synchronized (SystemFunctions.class) {
-                INSTANCE = new SystemFunctions();
+                singletonInstance = new SystemFunctions();
             }
-            return INSTANCE;
+            return singletonInstance;
         }
     }
 
@@ -56,6 +56,7 @@ public class SystemFunctions {
         try {
             Thread.sleep(millis);
         } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
             throw new RuntimeException(e);
         }
     }
@@ -108,7 +109,7 @@ public class SystemFunctions {
      * destination that is typically not continuously monitored.
      */
     public PrintStream err() {
-        return System.err;
+        return System.err; //NO SONAR (intentional wrapping of system err
     }
 
     /**
@@ -137,7 +138,7 @@ public class SystemFunctions {
      * @see java.io.PrintStream#println(java.lang.String)
      */
     public PrintStream out() {
-        return System.out;
+        return System.out; //NO SONAR (intentional wrapping of system out)
     }
 
     /**
@@ -147,7 +148,7 @@ public class SystemFunctions {
      * the host environment or user.
      */
     public InputStream in() {
-        return System.in;
+        return System.in; //NO SONAR (intentional wrapping of system in)
     }
 
     /**
index e013142..c40dcfb 100644 (file)
@@ -19,6 +19,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.ct;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.NokiaSvnfmApplication;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
@@ -33,10 +34,8 @@ public class CTReal {
      * It takes parameters from application-real.properties
      */
     @Test
-    public void testBasicWorkflow() throws Exception {
-
-
-        Thread.sleep(10000000 * 1000L);
+    public void testBasicWorkflow() {
+        SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
     }
 
 }
index 4426383..ea1afe5 100644 (file)
@@ -77,7 +77,9 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
         assertEquals(expectedVnfmInfo, vnfmInfo);
         //when
         //sleeping is required to make time pass (for cache to notice the change)
-        Thread.sleep(10);
+        //cache is configured with 1 ms cache eviction without sleep it is not
+        //deterministic that at least 1 ms time will pass between calls
+        Thread.sleep(10);  //NO SONAR
         VnfmInfo vnfmInfo2 = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
         //verify source system called again
         verify(logger, times(2)).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
index 99e95b4..5f1d600 100644 (file)
@@ -116,7 +116,7 @@ public class TestBase {
     @Before
     public void genericSetup() throws Exception {
         MockitoAnnotations.initMocks(this);
-        ReflectionTestUtils.setField(SystemFunctions.class, "INSTANCE", systemFunctions);
+        ReflectionTestUtils.setField(SystemFunctions.class, "singletonInstance", systemFunctions);
         when(cbamRestApiProvider.getCbamLcmApi(VNFM_ID)).thenReturn(vnfApi);
         when(cbamRestApiProvider.getCbamOperationExecutionApi(VNFM_ID)).thenReturn(operationExecutionApi);
         when(cbamRestApiProvider.getCbamLcnApi(VNFM_ID)).thenReturn(lcnApi);
@@ -133,7 +133,7 @@ public class TestBase {
 
     @After
     public void tearGeneric() {
-        ReflectionTestUtils.setField(SystemFunctions.class, "INSTANCE", null);
+        ReflectionTestUtils.setField(SystemFunctions.class, "singletonInstance", null);
     }
 
     protected void assertFileInZip(byte[] zip, String path, byte[] expectedContent) throws Exception {
index 3dfeba3..1e2c7d9 100644 (file)
             </configuration>
           </execution>
         </executions>
-        <dependencies>
-          <dependency>
-            <groupId>org.onap.vfc.nfvo.driver.vnfm.svnfm.nokiav2</groupId>
-            <artifactId>generatortools</artifactId>
-            <version>1.1.0-SNAPSHOT</version>
-          </dependency>
-        </dependencies>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>