use of com.netsteadfast.greenstep.model.SystemFtpClientData in project bamboobsc by billchen198318.
the class SystemFtpClientUtils method processText.
private static void processText(SystemFtpClientResultObj resultObj) throws Exception {
SysFtpTranVO tran = resultObj.getSysFtpTran();
List<SystemFtpClientData> datas = new LinkedList<SystemFtpClientData>();
List<TbSysFtpTranSegm> segms = resultObj.getSysFtpTranSegms();
for (File file : resultObj.getFiles()) {
SystemFtpClientData ftpData = new SystemFtpClientData();
List<Map<String, String>> fillDataList = new LinkedList<Map<String, String>>();
logWarnFileSize(file);
List<String> strLines = FileUtils.readLines(file, resultObj.getSysFtpTran().getEncoding());
if (YesNo.YES.equals(resultObj.getSysFtpTran().getUseSegm())) {
for (int i = 0; i < strLines.size(); i++) {
String strData = strLines.get(i);
if (strData.length() < 1) {
logger.warn("The file: " + file.getPath() + " found zero line.");
continue;
}
if (i < tran.getBeginLen()) {
// not begin line.
continue;
}
Map<String, String> dataMap = new HashMap<String, String>();
fillStrLine2Map(resultObj.getSysFtpTran(), segms, dataMap, strData);
fillDataList.add(dataMap);
}
}
ftpData.setContent(getContent(strLines));
ftpData.setDatas(fillDataList);
ftpData.setFile(file);
datas.add(ftpData);
}
resultObj.setDatas(datas);
}
use of com.netsteadfast.greenstep.model.SystemFtpClientData in project bamboobsc by billchen198318.
the class SystemFtpClientUtils method processXml.
private static void processXml(SystemFtpClientResultObj resultObj) throws Exception {
SysFtpTranVO tran = resultObj.getSysFtpTran();
List<SystemFtpClientData> datas = new LinkedList<SystemFtpClientData>();
JAXBContext jaxbContext = null;
Unmarshaller jaxbUnmarshaller = null;
if (!StringUtils.isBlank(tran.getXmlClassName())) {
Class<?> xmlBeanClazz = Class.forName(tran.getXmlClassName());
jaxbContext = JAXBContext.newInstance(xmlBeanClazz);
jaxbUnmarshaller = jaxbContext.createUnmarshaller();
}
for (File file : resultObj.getFiles()) {
SystemFtpClientData ftpData = new SystemFtpClientData();
logWarnFileSize(file);
// xml 原則上都是用utf-8
String content = FileUtils.readFileToString(file, Constants.BASE_ENCODING);
ftpData.setContent(content);
ftpData.setDatas(null);
ftpData.setFile(file);
if (jaxbUnmarshaller != null) {
Object obj = jaxbUnmarshaller.unmarshal(// xml 原則上都是用utf-8
new ByteArrayInputStream(content.getBytes(Constants.BASE_ENCODING)));
ftpData.setXmlBean(obj);
}
datas.add(ftpData);
}
resultObj.setDatas(datas);
}
Aggregations