summaryrefslogtreecommitdiffstats
path: root/huawei
diff options
context:
space:
mode:
Diffstat (limited to 'huawei')
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java29
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java27
-rw-r--r--huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java4
3 files changed, 23 insertions, 37 deletions
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java
index fb5e5b81..535053bf 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapter2DriverMgrService.java
@@ -40,7 +40,7 @@ import net.sf.json.JSONObject;
* <br>
* <p>
* </p>
- *
+ *
* @author
* @version VFC 1.0 Jan 23, 2017
*/
@@ -77,38 +77,29 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi
/**
* Retrieve VIM driver information.
- *
+ *
* @return
* @throws IOException
*/
public static String readVnfmAdapterInfoFromJson() throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
String fileContent = "";
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot()
+ System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR)
+ "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + VNFMADAPTER2DRIVERMGR;
- try {
- ins = new FileInputStream(fileName);
- bins = new BufferedInputStream(ins);
+ try (InputStream ins = new FileInputStream(fileName)){
+ try(BufferedInputStream bins = new BufferedInputStream(ins)){
- byte[] contentByte = new byte[ins.available()];
- int num = bins.read(contentByte);
+ byte[] contentByte = new byte[ins.available()];
+ int num = bins.read(contentByte);
- if(num > 0) {
- fileContent = new String(contentByte);
+ if(num > 0) {
+ fileContent = new String(contentByte);
+ }
}
} catch(FileNotFoundException e) {
LOG.error(fileName + "is not found!", e);
- } finally {
- if(ins != null) {
- ins.close();
- }
- if(bins != null) {
- bins.close();
- }
}
return fileContent;
@@ -167,6 +158,8 @@ public class VnfmAdapter2DriverMgrService implements IVnfmAdapter2DriverMgrServi
}
} catch(InterruptedException e) {
LOG.error(e.getMessage(), e);
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
}
sendRequest(this.paramsMap, this.adapterInfo);
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java
index 3afdafeb..28c018cb 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/api/internalsvc/impl/VnfmAdapterMgrService.java
@@ -76,38 +76,29 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService {
/**
* Retrieve VIM driver information.
- *
+ *
* @return
* @throws IOException
*/
public String readVnfmAdapterInfoFromJson() throws IOException {
- InputStream ins = null;
- BufferedInputStream bins = null;
String fileContent = "";
String fileName = SystemEnvVariablesFactory.getInstance().getAppRoot()
+ System.getProperty(Constant.FILE_SEPARATOR) + "etc" + System.getProperty(Constant.FILE_SEPARATOR)
+ "adapterInfo" + System.getProperty(Constant.FILE_SEPARATOR) + VNFMADAPTERINFO;
- try {
- ins = new FileInputStream(fileName);
- bins = new BufferedInputStream(ins);
+ try (InputStream ins = new FileInputStream(fileName)) {
+ try (BufferedInputStream bins = new BufferedInputStream(ins)){
- byte[] contentByte = new byte[ins.available()];
- int num = bins.read(contentByte);
+ byte[] contentByte = new byte[ins.available()];
+ int num = bins.read(contentByte);
- if(num > 0) {
- fileContent = new String(contentByte);
+ if(num > 0) {
+ fileContent = new String(contentByte);
+ }
}
} catch(FileNotFoundException e) {
LOG.error(fileName + "is not found!", e);
- } finally {
- if(ins != null) {
- ins.close();
- }
- if(bins != null) {
- bins.close();
- }
}
return fileContent;
@@ -166,6 +157,8 @@ public class VnfmAdapterMgrService implements IVnfmAdapterMgrService {
}
} catch(InterruptedException e) {
LOG.error(e.getMessage(), e);
+ // Restore interrupted state...
+ Thread.currentThread().interrupt();
}
sendRequest(this.paramsMap, this.adapterInfo);
diff --git a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java
index 3b1036e2..d26f849d 100644
--- a/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java
+++ b/huawei/vnfmadapter/VnfmadapterService/service/src/main/java/org/onap/vfc/nfvo/vnfm/svnfm/vnfmadapter/service/constant/Constant.java
@@ -152,11 +152,11 @@ public class Constant {
public static final String FILE_SEPARATOR = "file.separator";
- public static final String PASSWORD = "password";
+ public static final String PASSWORD = "password"; // NOSONAR
public static final String USERNAME = "userName";
- public static final String LOCAL_HOST = "127.0.0.1";
+ public static final String LOCAL_HOST = "127.0.0.1"; // NOSONAR
private Constant() {
// private constructor