Merge "vfc adapter authentication bug fix"
authorSteve Smokowski <ss835w@att.com>
Wed, 12 Dec 2018 12:49:56 +0000 (12:49 +0000)
committerGerrit Code Review <gerrit@onap.org>
Wed, 12 Dec 2018 12:49:56 +0000 (12:49 +0000)
1  2 
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java

@@@ -22,7 -22,6 +22,7 @@@ package org.onap.so.bpmn.common.resourc
  
  import java.io.File;
  import java.io.IOException;
 +import java.nio.file.Paths;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.LinkedHashMap;
@@@ -262,17 -261,20 +262,20 @@@ public class ResourceRequestBuilder 
                String catalogEndPoint = UrnPropertiesReader.getVariable("mso.catalog.db.endpoint");
        HttpClient client = new HttpClient(UriBuilder.fromUri(catalogEndPoint).path(SERVICE_URL_TOSCA_CSAR).queryParam("serviceModelUuid", uuid).build().toURL(), "application/json", TargetEntity.CATALOG_DB);
        
+       client.addAdditionalHeader("Accept", "application/json");
+ //            client.addBasicAuthHeader (UrnPropertiesReader.getVariable("mso.adapters.db.auth"), UrnPropertiesReader.getVariable("mso.msoKey"));
+       client.addAdditionalHeader("Authorization", UrnPropertiesReader.getVariable("mso.db.auth"));
          Response response = client.get();
          String value = response.readEntity(String.class);
  
          HashMap<String, String> map = new Gson().fromJson(value, new TypeToken<HashMap<String, String>>() {}.getType());
  
 -        String filePath = System.getProperty("mso.config.path") + "/ASDC/" +  map.get("version") + "/" + map.get("name");
 +        String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC",  map.get("version"), map.get("name")).normalize().toString();
  
          File csarFile = new File(filePath);
  
          if(!csarFile.exists()) {
-             throw new Exception("csar file does not exist.");
+             throw new Exception("csar file does not exist in filePath:" + csarFile.getAbsolutePath());
          }
  
          return csarFile.getAbsolutePath();
          try {
              return mapper.readValue(jsonstr, type);
          } catch(IOException e) {
-             LOGGER.error(MessageEnum.RA_NS_EXC, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "fail to unMarshal json", e);
+             LOGGER.error("fail to unMarshal json" + e.getMessage ());
          }
          return null;
      }