Merge "Code Smells in emsdriver conf"
[vfc/nfvo/driver/ems.git] / ems / boco / src / main / java / org / onap / vfc / nfvo / emsdriver / collector / TaskThread.java
index c7b87e9..30104f6 100644 (file)
@@ -43,7 +43,7 @@ import java.util.regex.Pattern;
 public class TaskThread implements Runnable {
 
        private static final Log log = LogFactory.getLog(TaskThread.class);
-       public MessageChannel pmResultChannel; //This should also be private. Need to change in TastThreadTest 
+       private MessageChannel pmResultChannel; 
        private MessageChannel cmResultChannel;
        private CollectMsg data;
 
@@ -104,9 +104,9 @@ public class TaskThread implements Runnable {
                        String nename = ma.group(1);
                        boolean parseResult = false;
                        if (Constant.COLLECT_TYPE_CM.equalsIgnoreCase(collectVo.getType())) {
-                               parseResult = processCMXml(tempfile, nename, "CM");
+                               //parseResult = processCMXml(tempfile, nename, "CM");//The logic is not exist now, but need to add in the future
                        } else {
-                               if (unfileName.indexOf(".csv") > 0) {
+                               if (unfileName.indexOf(".csv") > -1) {//changed to -1 for coding practice as having ".csv" must have some some legal name
                                        parseResult = processPMCsv(tempfile);
                                } else {
                                        parseResult = processPMXml(tempfile);
@@ -373,7 +373,7 @@ public class TaskThread implements Runnable {
 
        }
 
-       private boolean processCMXml(File tempfile, String nename, String type) {
+/*     private boolean processCMXml(File tempfile, String nename, String type) {
 
                String csvpath = localPath + nename + "/" + type + "/";
                File csvpathfile = new File(csvpath);
@@ -499,7 +499,7 @@ public class TaskThread implements Runnable {
                                return false;
                }
                return true;
-       }
+       }*/
 
        private void setMessage(String message) {
                try {
@@ -667,7 +667,7 @@ public class TaskThread implements Runnable {
        }
 
        public List<File> decompressed(String fileName) {
-               List<File> filelist = new ArrayList<File>();
+               List<File> filelist = new ArrayList<>();
 
                if (fileName.indexOf(".gz") > 1) {
                        try {
@@ -712,15 +712,13 @@ public class TaskThread implements Runnable {
                        unzip.deCompress();
                        file = new File(orgFile);
                }
-               File[] files = file.listFiles();
-
-               return files;
+               return file.listFiles();
 
        }
 
        private List<String> ftpDownload(CollectVo collectVo) {
 
-               List<String> fileList = new ArrayList<String>();
+               List<String> fileList = new ArrayList<>();
                // IP
                String ip = collectVo.getIP();
                // port
@@ -747,11 +745,11 @@ public class TaskThread implements Runnable {
 
                // download
                String dir = collectVo.getRemotepath();
-               List<String> searchExprList = new ArrayList<String>();
-               String[] FPath = dir.split(";");
-               for (int i = 0; i < FPath.length; i++) {
+               List<String> searchExprList = new ArrayList<>();
+               String[] fPath = dir.split(";");
+               for (int i = 0; i < fPath.length; i++) {
                        int oldSize = searchExprList.size();
-                       String conpath = FPath[i] + collectVo.getMatch();
+                       String conpath = fPath[i] + collectVo.getMatch();
                        HashMap<String, String> varMap = new HashMap<>();
                        long collectPeriod = 900;
                        try {
@@ -774,10 +772,10 @@ public class TaskThread implements Runnable {
                        log.error(" collect fail ", e1);
                        return fileList;
                }
-               List<AFtpRemoteFile> remoteFiles = new ArrayList<AFtpRemoteFile>();
+               List<AFtpRemoteFile> remoteFiles = new ArrayList<>();
                for (String expr : searchExprList) {
                        ftpClient.chdir(nowdir);
-                       String keys[] = parseExprKeys(expr);
+                       String[] keys = parseExprKeys(expr);
                        String ftpRegular = keys[1];
                        String ftpDir = keys[0];
 
@@ -879,7 +877,7 @@ public class TaskThread implements Runnable {
 
        public List<String> getPathNoRegular(List<String> searchExprList, FTPInterface ftpCache) throws IOException {
                boolean isregular = false;
-               List<String> regularList = new ArrayList<String>();
+               List<String> regularList = new ArrayList<>();
                for (String regular : searchExprList) {
                        Pattern lpattern = null;
                        try {
@@ -919,10 +917,17 @@ public class TaskThread implements Runnable {
                                regularList.add(regular);
                        }
                }
-               if (isregular == true) {
+               if (isregular) {
                        getPathNoRegular(regularList, ftpCache);
                }
                return regularList;
        }
+       
+       public MessageChannel getPmResultChannel() {
+               return pmResultChannel;
+       }
 
+       public void setPmResultChannel(MessageChannel pmResChannel) {
+               this.pmResultChannel = pmResChannel;
+       }
 }