[Policy-8 ,Policy-23] Updated Matchid for policies
[policy/engine.git] / ECOMP-PAP-REST / src / main / java / org / openecomp / policy / pap / xacml / rest / service / ImportService.java
index 3ff279d..0b3e313 100644 (file)
@@ -35,7 +35,7 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.openecomp.policy.common.logging.eelf.PolicyLogger;
 import org.openecomp.policy.pap.xacml.rest.components.CreateBRMSRuleTemplate;
-import org.openecomp.policy.pap.xacml.rest.components.CreateNewMicroSerivceModel;
+import org.openecomp.policy.pap.xacml.rest.components.CreateNewMicroServiceModel;
 
 public class ImportService {
 
@@ -65,7 +65,7 @@ public class ImportService {
                        successMap = brmsRuleTemplate.addRule(builder.toString(), serviceName, description, "API");
                        break;
                case "MICROSERVICE":
-                       CreateNewMicroSerivceModel newMS = null;
+                       CreateNewMicroServiceModel newMS = null;
                        String randomID = UUID.randomUUID().toString();
                        if ( fileName != null) {
                                File extracDir = new File("ExtractDir");
@@ -95,32 +95,27 @@ public class ImportService {
                                        }
                                }else{ 
                                        InputStream inputStream = null;
-                                       FileOutputStream outputStream = null;
-                                       try {   
+                                       try(FileOutputStream outputStream = new FileOutputStream("ExtractDir" + File.separator + randomID+".zip")) {    
                                                inputStream = request.getInputStream();
-                                               outputStream = new FileOutputStream("ExtractDir" + File.separator + randomID+".zip"); 
                                                byte[] buffer = new byte[4096];
                                                int bytesRead = -1 ; 
                                                while ((bytesRead = inputStream.read(buffer)) != -1) { 
                                                        outputStream.write(buffer, 0, bytesRead) ; 
                                                }
                                        } catch (IOException e) {
-                                               PolicyLogger.error("Error in reading in Zip File from API call");
+                                               PolicyLogger.error("Error in reading in Zip File from API call"+e);
                                                return;
                                        }finally{
                                                try {
                                                        if(inputStream != null){
                                                                inputStream.close();
                                                        }
-                                                       if(outputStream != null){
-                                                               outputStream.close();
-                                                       }
                                                } catch (IOException e) {
                                                        PolicyLogger.error("Exception Occured while closing the input/output stream"+e);
                                                }
                                        }
                                }
-                               newMS =  new CreateNewMicroSerivceModel(fileName, serviceName, "API", version, randomID);
+                               newMS =  new CreateNewMicroServiceModel(fileName, serviceName, "API", version, randomID);
                                successMap = newMS.addValuesToNewModel();
                                if (successMap.containsKey("success")) {
                                        successMap.clear();