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;
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);
}
- 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);
return false;
}
return true;
- }
+ }*/
private void setMessage(String message) {
try {
}
public List<File> decompressed(String fileName) {
- List<File> filelist = new ArrayList<File>();
+ List<File> filelist = new ArrayList<>();
if (fileName.indexOf(".gz") > 1) {
try {
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
// 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 {
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];
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 {
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;
+ }
}