修改xml上传解析的返回值

parent fcc703ca
...@@ -54,10 +54,12 @@ public class ReadXmlApi { ...@@ -54,10 +54,12 @@ public class ReadXmlApi {
@Consumes(MediaType.MULTIPART_FORM_DATA) @Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean getXMLToCheck(@Context HttpServletResponse resp, @Context HttpServletRequest requ) { public Map<String,Object> getXMLToCheck(@Context HttpServletResponse resp, HttpServletRequest requ) {
YXJSONResponse yxresp = new YXJSONResponse();
Map<String,Object> map = new HashMap<>();
List<String> errList = new ArrayList<>();
String remoteAddr = requ.getRemoteAddr(); String remoteAddr = requ.getRemoteAddr();
MDC.put("ip", remoteAddr); MDC.put("ip", remoteAddr);
YXJSONResponse yxresp = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8");
String filename = ""; String filename = "";
DiskFileItemFactory factory = new DiskFileItemFactory(); DiskFileItemFactory factory = new DiskFileItemFactory();
...@@ -97,27 +99,31 @@ public class ReadXmlApi { ...@@ -97,27 +99,31 @@ public class ReadXmlApi {
idcardsFactory(idCardFactory.extractIDCard(str, date)); idcardsFactory(idCardFactory.extractIDCard(str, date));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {
e.printStackTrace(); e.printStackTrace();
logger.error("上传文件名" + filename); logger.error("上传文件名" + filename );
logger.error("UnsupportedEncodingException 上传文件时发现文件编码错误", e); logger.error("UnsupportedEncodingException 上传文件时发现文件编码错误", e);
yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage()); yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
errList.add("上传文件名:" + filename+",上传文件时发现文件编码错误");
continue; continue;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
logger.error("上传文件名" + filename); logger.error("上传文件名" + filename );
logger.error("IOException 上传文件时发生IO错误", e); logger.error("IOException 上传文件时发生IO错误", e);
yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage()); yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage());
errList.add("上传文件名:" + filename+",上传文件时发生IO错误");
continue; continue;
} catch (DocumentException e) { } catch (DocumentException e) {
e.printStackTrace(); e.printStackTrace();
logger.error("上传文件名" + filename); logger.error("上传文件名" + filename );
logger.error("DocumentException 上传文件时发生IO错误", e); logger.error("DocumentException 上传文件时发生错误,非法XML文件", e);
yxresp.outPutError("DocumentException", "上传文件时发生IO错误:" + e.getMessage()); yxresp.outPutError("DocumentException", "上传文件时发生IO错误:" + e.getMessage());
errList.add("上传文件名:" + filename+",上传文件时发生错误,非法XML文件");
continue; continue;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("上传文件名" + filename); logger.error("上传文件名" + filename );
logger.error("Exception 上传文件时发生错误,非法XML文件", e); logger.error("Exception 上传文件时发生错误", e);
yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename); yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
errList.add("上传文件名:" + filename+",上传文件时发生错误");
continue; continue;
} }
} }
...@@ -125,13 +131,20 @@ public class ReadXmlApi { ...@@ -125,13 +131,20 @@ public class ReadXmlApi {
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
logger.error("上传文件名" + filename); logger.error("上传文件名" + filename );
logger.error("FileUploadException 文件上传发生异常", e); logger.error("FileUploadException 文件上传发生异常", e);
yxresp.outPutError("FileUploadException", "文件上传发生异常:" + e.getMessage()); yxresp.outPutError("FileUploadException", "文件上传发生异常:" + e.getMessage());
} finally { errList.add("上传文件名:" + filename+",上传文件时发生错误");
return true;
} }
if (errList.size() == 0){
map.put("msg","文件上传成功!");
map.put("code","200");
}else {
map.put("msg","文件上传失败!");
map.put("code","500");
map.put("errMsg",errList);
}
return map;
} }
private Boolean idcardsFactory(Map<String, Object> map1) { private Boolean idcardsFactory(Map<String, Object> map1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment