* @since NFVO 0.5
*/
public static String readJujuAdapterInfoFromJson() 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) + Constant.JUJUADAPTERINFO;
- 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);
}
} catch(FileNotFoundException e) {
LOG.error(fileName + "is not found!", e, JujuAdapterMgrService.class);
- } finally {
- if(null != ins) {
- ins.close();
- }
-
- if(null != bins) {
- bins.close();
- }
- }
+ }
return fileContent;
}
* @since NFVO 0.5
*/
public static PyObjectFactory build(String envName) {
- PythonInterpreter interpreter = new PythonInterpreter();
+ try(PythonInterpreter interpreter = new PythonInterpreter()){
interpreter.exec("from jujuclient import Environment");
PyObject env = environmentClass.__call__();
environmentObj = env.invoke("connect", new PyString(envName));
return new PyObjectFactory();
+ }
}
/**
@POST
@Path("/vnfminfo")
- public String setVNFMInfo(@Context HttpServletRequest context, @Context HttpServletResponse resp)
+ public static String setVNFMInfo(@Context HttpServletRequest context, @Context HttpServletResponse resp)
throws ServiceException {
JSONObject result = new JSONObject();
result.put("retCode", Constant.REST_SUCCESS);