summaryrefslogtreecommitdiffstats
path: root/nokia
diff options
context:
space:
mode:
Diffstat (limited to 'nokia')
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java4
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java6
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java7
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java5
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java5
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java36
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java3
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java40
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java51
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java38
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java2
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java59
12 files changed, 123 insertions, 133 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java
index c153095b..6034b55b 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java
@@ -155,11 +155,11 @@ public class Cbam2DriverResponseConverter {
if (OperationType.INSTANTIATE == oper.getOperationType()) {
double instantiateProgress = (nowTime - jobInfo.getOperateStartTime())
- / adaptorEnv.getInstantiateTimeInterval();
+ / (double)(adaptorEnv.getInstantiateTimeInterval());
initialProgress = (int) (instantiateProgress + initialProgress);
} else if (OperationType.TERMINATE == oper.getOperationType()) {
double terminateProgress = (nowTime - jobInfo.getOperateStartTime())
- / adaptorEnv.getTerminateTimeInterval();
+ / (double)(adaptorEnv.getTerminateTimeInterval());
initialProgress = (int) (terminateProgress + initialProgress);
} else {
initialProgress = 0;
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java
index 493033c9..8c60cc67 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Driver2CbamRequestConverter.java
@@ -54,11 +54,11 @@ public class Driver2CbamRequestConverter {
}
public CBAMInstantiateVnfRequest instantiateRequestConvert(InstantiateVnfRequest driverRequest,
- NslcmGrantVnfResponse nslc, GrantInfo grant, VimComputeResourceFlavour vimco) throws Exception {
- Gson gson = new Gson();
+ NslcmGrantVnfResponse nslc, GrantInfo grant, VimComputeResourceFlavour vimco) throws IOException{
+ Gson gson = new Gson();
String inputJson = readcbamInputInfoFromJsonFile();
CBAMInstantiateVnfRequest request = gson.fromJson(inputJson, CBAMInstantiateVnfRequest.class);
-
+
return request;
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java
index 3ffa0fb0..1f1eb1ca 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV2Info.java
@@ -14,10 +14,10 @@
* limitations under the License.
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity;
-
+import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
-public class OpenstackV2Info {
+public class OpenstackV2Info implements Serializable {
@JsonProperty("vimInfoType")
private VimInfoType vimInfoType;
@@ -52,7 +52,4 @@ public class OpenstackV2Info {
this.accessInfo = accessInfo;
}
-
-
-
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java
index 22de770e..7d4c53e6 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OpenstackV3Info.java
@@ -16,8 +16,9 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity;
import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
-public class OpenstackV3Info {
+public class OpenstackV3Info implements Serializable {
@JsonProperty("vimInfoType")
private VimInfoType vimInfoType;
@@ -52,6 +53,4 @@ public class OpenstackV3Info {
this.accessInfo = accessInfo;
}
-
-
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java
index 4b7fb072..1cedf98b 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/OtherVimInfo.java
@@ -15,9 +15,10 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity;
+import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
-public class OtherVimInfo {
+public class OtherVimInfo implements Serializable {
@JsonProperty("vimInfoType")
private VimInfoType vimInfoType;
@@ -40,6 +41,4 @@ public class OtherVimInfo {
this.id = id;
}
-
-
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java
index 779e2659..5be96a88 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VimInfoType.java
@@ -14,28 +14,22 @@
* limitations under the License.
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity;
+import java.io.Serializable;
-public enum VimInfoType {
-
- OPENSTACK_V2_INFO {
+public enum VimInfoType implements Serializable{
+
+ OPENSTACK_V2_INFO {
private OpenstackV2Info openstackv2;
-
- },
- OPENSTACK_V3_INFO{
- private OpenstackV3Info openstackv3;
- },
- VMWARE_VCLOUD_INFO{
- private VmwareVcloudInfo vmwareInfo;
- },
- OTHER_VIM_INFO{
- private OtherVimInfo other;
- }
-
-
-
-
-
-
-
+
+ },
+ OPENSTACK_V3_INFO{
+ private OpenstackV3Info openstackv3;
+ },
+ VMWARE_VCLOUD_INFO{
+ private VmwareVcloudInfo vmwareInfo;
+ },
+ OTHER_VIM_INFO{
+ private OtherVimInfo other;
+ }
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java
index 746cb007..73446461 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/VmwareVcloudInfo.java
@@ -15,9 +15,10 @@
*/
package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity;
+import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonProperty;
-public class VmwareVcloudInfo {
+public class VmwareVcloudInfo implements Serializable{
@JsonProperty("vimInfoType")
private VimInfoType vimInfoType;
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java
index f8f0c400..834c2a7b 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java
@@ -32,6 +32,8 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
+import java.security.NoSuchAlgorithmException;
+import java.security.KeyManagementException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@@ -74,7 +76,7 @@ public class MultipartUtility {
* @throws IOException
*/
public MultipartUtility(String requestURL, String charset)
- throws Exception {
+ throws CertificateException, IOException, NoSuchAlgorithmException, KeyManagementException{
this.charset = charset;
// creates a unique boundary based on time stamp
@@ -165,10 +167,10 @@ public class MultipartUtility {
KEY_STORE_TYPE = sslConf.getKeyStoreType();
}
// load jks file
- FileInputStream f_certStore = new FileInputStream(CommonUtil.getAppRoot() + CERT_STORE);
- KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE);
- ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray());
- f_certStore.close();
+ try(FileInputStream f_certStore = new FileInputStream(CommonUtil.getAppRoot() + CERT_STORE)){
+ KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE);
+ ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray());
+
// init and create
String alg = KeyManagerFactory.getDefaultAlgorithm();
@@ -176,6 +178,7 @@ public class MultipartUtility {
kmFact.init(ks, CERT_STORE_PASSWORD.toCharArray());
kms = kmFact.getKeyManagers();
+ }
} catch(Exception e) {
logger.error("create KeyManager fail!", e);
}
@@ -196,15 +199,16 @@ public class MultipartUtility {
}
String jksFilePath1 =CommonUtil.getAppRoot() + TRUST_STORE;
logger.info("jks path is " + jksFilePath1);
- FileInputStream f_trustStore = new FileInputStream(jksFilePath1);
- KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE);
- ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray());
- f_trustStore.close();
+ try(FileInputStream f_trustStore = new FileInputStream(jksFilePath1)){
+ KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE);
+ ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray());
+
String alg = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmFact = TrustManagerFactory.getInstance(alg);
tmFact.init(ks);
tms = tmFact.getTrustManagers();
+ }
} catch(Exception e) {
logger.error("create TrustManager fail!", e);
@@ -235,14 +239,14 @@ public class MultipartUtility {
writer.append(LINE_FEED);
writer.flush();
- FileInputStream inputStream = new FileInputStream(uploadFile);
- byte[] buffer = new byte[4096];
- int bytesRead = -1;
- while ((bytesRead = inputStream.read(buffer)) != -1) {
- outputStream.write(buffer, 0, bytesRead);
- }
- outputStream.flush();
- inputStream.close();
+ try(FileInputStream inputStream = new FileInputStream(uploadFile)){
+ byte[] buffer = new byte[4096];
+ int bytesRead = -1;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ }
+ outputStream.flush();
+ }
writer.append(LINE_FEED);
writer.flush();
@@ -289,4 +293,4 @@ public class MultipartUtility {
return response;
}
-} \ No newline at end of file
+}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java
index 47bb55f1..9ae3c940 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/common/util/CommonUtil.java
@@ -38,13 +38,10 @@ public final class CommonUtil {
}
public static String getJsonStrFromFilePath(String fileName) throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
String fileContent = "";
- try {
- ins = new FileInputStream(fileName);
- bins = new BufferedInputStream(ins);
+ try (InputStream ins = new FileInputStream(fileName);
+ BufferedInputStream bins = new BufferedInputStream(ins)){
byte[] contentByte = new byte[ins.available()];
int num = bins.read(contentByte);
@@ -54,14 +51,7 @@ public final class CommonUtil {
}
} catch(FileNotFoundException e) {
logger.error(fileName + " is not found!", e);
- } finally {
- if(ins != null) {
- ins.close();
- }
- if(bins != null) {
- bins.close();
- }
- }
+ }
return fileContent;
}
@@ -87,25 +77,22 @@ public final class CommonUtil {
}
public static byte[] getBytes(String filePath){
- byte[] buffer = null;
- try {
- File file = new File(filePath);
- FileInputStream fis = new FileInputStream(file);
- ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
- byte[] b = new byte[1000];
- int n;
- while ((n = fis.read(b)) != -1) {
- bos.write(b, 0, n);
- }
- fis.close();
- bos.close();
- buffer = bos.toByteArray();
- } catch (FileNotFoundException e) {
- logger.error("file " + filePath + " is not found.", e);
- } catch (IOException e) {
- logger.error("file " + filePath + " IOException.", e);
- }
- return buffer;
+ byte[] buffer = null;
+ File file = new File(filePath);
+ try(FileInputStream fis = new FileInputStream(file);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(1000)){
+ byte[] b = new byte[1000];
+ int n;
+ while ((n = fis.read(b)) != -1) {
+ bos.write(b, 0, n);
+ }
+ buffer = bos.toByteArray();
+ } catch (FileNotFoundException e) {
+ logger.error("file " + filePath + " is not found.", e);
+ } catch (IOException e) {
+ logger.error("file " + filePath + " IOException.", e);
+ }
+ return buffer;
}
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
index 489ab927..7878a00c 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
@@ -40,17 +40,22 @@ public class HttpClientProcessorImpl implements HttpClientProcessorInf{
@Autowired
private HttpClientBuilder httpClientBuilder;
- public HttpResult process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException
+ public HttpResult process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws IOException
{
HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, methodType);
+ //Map<String, String> headerMap = new HashMap<String, String>();
if(headerMap != null && !headerMap.isEmpty())
{
- for(String key : headerMap.keySet())
+ /*for(String key : headerMap.keySet())
{
processor.addHdeader(key, headerMap.get(key));
+ }*/
+
+ for (HashMap.Entry<String, String> entry : headerMap.entrySet()) {
+ processor.addHeader(entry.getKey(), entry.getValue());
}
- if(null != bodyString && bodyString.length() > 0 && !bodyString.equalsIgnoreCase("null"))
+ if(bodyString.length() > 0 && !"null".equalsIgnoreCase(bodyString))
{
processor.addPostEntity(bodyString);
}
@@ -59,15 +64,19 @@ public class HttpClientProcessorImpl implements HttpClientProcessorInf{
return processor.process(url);
}
- public HttpResult processBytes(String url, RequestMethod methodType, HashMap<String, String> headerMap, byte[] byteArray) throws ClientProtocolException, IOException
+ public HttpResult processBytes(String url, RequestMethod methodType, HashMap<String, String> headerMap, byte[] byteArray) throws IOException
{
HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, methodType);
if(headerMap != null && !headerMap.isEmpty())
{
- for(String key : headerMap.keySet())
+ for (HashMap.Entry<String, String> entry : headerMap.entrySet()) {
+ processor.addHeader(entry.getKey(), entry.getValue());
+ } //Iterate over the "entrySet" instead of the "keySet"
+
+ /*for(String key : headerMap.keySet())
{
- processor.addHdeader(key, headerMap.get(key));
- }
+ processor.addHeader(key, headerMap.get(key));
+ }*/
if(null != byteArray && byteArray.length > 0)
{
@@ -96,12 +105,11 @@ public class HttpClientProcessorImpl implements HttpClientProcessorInf{
if(!saveDir.exists()){
saveDir.mkdir();
}
- File file = new File(saveDir+File.separator+fileName);
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(getData);
- if(fos!=null){
- fos.close();
- }
+ File file = new File(saveDir+File.separator+fileName);
+ try(FileOutputStream fos = new FileOutputStream(file)){
+ fos.write(getData);
+ }
+
if(inputStream!=null){
inputStream.close();
}
@@ -119,11 +127,11 @@ public class HttpClientProcessorImpl implements HttpClientProcessorInf{
public static byte[] readInputStream(InputStream inputStream) throws IOException {
byte[] buffer = new byte[1024];
int len = 0;
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ try(ByteArrayOutputStream bos = new ByteArrayOutputStream()){
while((len = inputStream.read(buffer)) != -1) {
bos.write(buffer, 0, len);
}
- bos.close();
return bos.toByteArray();
+ }
}
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java
index 0d472fcb..6c6f27fa 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java
@@ -75,7 +75,7 @@ public class HttpRequestProcessor {
return httpResult;
}
- public void addHdeader(String key, String value) {
+ public void addHeader(String key, String value) {
httpRequest.setHeader(key, value);
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java
index 74fb4395..cd4c7e31 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImpl.java
@@ -115,42 +115,43 @@ public class MsbMgmrImpl implements IMsbMgmr {
}
- public String getServiceUrlInMsbBySeriveNameAndVersion(String serviceName, String version) throws ClientProtocolException, IOException {
- String url = adaptorEnv.getMsbApiUriFront() + String.format(CommonConstants.MSB_QUERY_SERVICE_PATH, serviceName, version);
-
- HttpResult httpResult = httpClientProcessor.process(url, RequestMethod.GET, null, null);
-
- String responseStr = httpResult.getContent();
- logger.info("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion, responseStr is " + responseStr);
- String serviceUrl = "";
- if(httpResult.getStatusCode() == 200)
- {
- MsbServiceInfo serviceInfo = gson.fromJson(responseStr, MsbServiceInfo.class);
- if (null == serviceInfo) {
- logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version);
+ public String getServiceUrlInMsbBySeriveNameAndVersion(String serviceName, String version) throws IOException {
+ try{
+ String url = adaptorEnv.getMsbApiUriFront() + String.format(CommonConstants.MSB_QUERY_SERVICE_PATH, serviceName, version);
+
+ HttpResult httpResult = httpClientProcessor.process(url, RequestMethod.GET, null, null);
+
+ String responseStr = httpResult.getContent();
+ logger.info("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion, responseStr is " + responseStr);
+ String serviceUrl = "";
+ if(httpResult.getStatusCode() == 200)
+ {
+ MsbServiceInfo serviceInfo = gson.fromJson(responseStr, MsbServiceInfo.class);
+ if (null == serviceInfo) {
+ logger.error("There is no service in MSB for serviceName = {} and version = {}", serviceName, version);
+ }
+ else{
+ serviceUrl = serviceInfo.getUrl();
+ logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl);
+ }
}
-
- serviceUrl = serviceInfo.getUrl();
- logger.info("Service Url in MSB for serviceName = {} and version = {} is {}", serviceName, version, serviceUrl);
- }
- else
- {
- logger.error("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion Error, statusCode = " + httpResult.getStatusCode());
- }
+ else
+ {
+ logger.error("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion Error, statusCode = " + httpResult.getStatusCode());
+ }
+
+ return serviceUrl;
+ }catch(Exception e){
+ logger.error("MsbMgmrImpl -> getServiceUrlInMsbBySeriveNameAndVersion Error", e);
+ throw new IOException("getServiceUrlInMsbBySeriveNameAndVersion", e);
- return serviceUrl;
+ }
+
}
public void setAdaptorEnv(AdaptorEnv env) {
this.adaptorEnv = env;
}
-// public static final void main(String[] args) {
-//// MsbMgmrImpl impl = new MsbMgmrImpl();
-//// impl.register();
-// System.setProperty("catalina.base", "D:\\Install\\apache-tomcat-9.0.0.M26");
-// System.out.println(System.getProperty("catalina.base"));
-// }
-
}