Merge "ClientEndpoint needs to be instantiabe"
[policy/engine.git] / ONAP-PAP-REST / src / main / java / org / onap / policy / pap / xacml / rest / components / CreateNewMicroServiceModel.java
index fd9e49c..d5233ce 100644 (file)
@@ -70,7 +70,7 @@ public class CreateNewMicroServiceModel {
                this.newModel.setUserCreatedBy(userInfo);
                String cleanUpFile = null;
        
-           HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
+           Map<String, MSAttributeObject> tempMap = new HashMap<>();
            //Need to delete the file
            if (importFile.contains(".zip")){
                extractFolder(randomID + ".zip");
@@ -90,7 +90,7 @@ public class CreateNewMicroServiceModel {
                                File deleteFile = new File(cleanUpFile); 
                                FileUtils.forceDelete(deleteFile);
                        } catch (IOException e) {
-                               logger.error("Failed to unzip model file " + randomID);
+                               logger.error("Failed to unzip model file " + randomID, e);
                        }
            }else {
                    tempMap = utils.processEpackage("ExtractDir" + File.separator + randomID+".xmi", MODEL_TYPE.XMI);
@@ -143,16 +143,14 @@ public class CreateNewMicroServiceModel {
                            int currentByte;
 
                            byte data[] = new byte[BUFFER];
-       
-                           FileOutputStream fos = new FileOutputStream(destFile);
-                           BufferedOutputStream dest = new BufferedOutputStream(fos,
-                           BUFFER);
-       
-                           while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
-                               dest.write(data, 0, currentByte);
-                           }
-                           dest.flush();
-                           dest.close();
+                                       try(FileOutputStream fos = new FileOutputStream(destFile);
+                                               BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) {
+
+                                               while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
+                                                       dest.write(data, 0, currentByte);
+                                               }
+                                               dest.flush();
+                                       }
                            is.close();
                        }
        
@@ -177,7 +175,7 @@ public class CreateNewMicroServiceModel {
                
                Map<String, String> successMap = new HashMap<>();
                MSAttributeObject mainClass  = null;
-               ArrayList<String> dependency = null;
+               List<String> dependency = null;
                String subAttribute = null;
                
                if (!classMap.containsKey(this.newModel.getModelName())){
@@ -194,7 +192,7 @@ public class CreateNewMicroServiceModel {
                        dependency = utils.getFullDependencyList(dependency, classMap);
                        if (!dependency.isEmpty()){
                                for (String element : dependency){
-                                       MSAttributeObject temp = new MSAttributeObject();
+                                   MSAttributeObject temp;
                                        if (classMap.containsKey(element)){
                                                temp = classMap.get(element);
                                                mainClass.addAllRefAttribute(temp.getRefAttribute());