修改xml上传解析的返回值

parent fcc703ca
......@@ -54,10 +54,12 @@ public class ReadXmlApi {
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@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();
MDC.put("ip", remoteAddr);
YXJSONResponse yxresp = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
String filename = "";
DiskFileItemFactory factory = new DiskFileItemFactory();
......@@ -97,27 +99,31 @@ public class ReadXmlApi {
idcardsFactory(idCardFactory.extractIDCard(str, date));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
logger.error("上传文件名" + filename);
logger.error("上传文件名" + filename );
logger.error("UnsupportedEncodingException 上传文件时发现文件编码错误", e);
yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
errList.add("上传文件名:" + filename+",上传文件时发现文件编码错误");
continue;
} catch (IOException e) {
e.printStackTrace();
logger.error("上传文件名" + filename);
logger.error("上传文件名" + filename );
logger.error("IOException 上传文件时发生IO错误", e);
yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage());
errList.add("上传文件名:" + filename+",上传文件时发生IO错误");
continue;
} catch (DocumentException e) {
e.printStackTrace();
logger.error("上传文件名" + filename);
logger.error("DocumentException 上传文件时发生IO错误", e);
logger.error("上传文件名" + filename );
logger.error("DocumentException 上传文件时发生错误,非法XML文件", e);
yxresp.outPutError("DocumentException", "上传文件时发生IO错误:" + e.getMessage());
errList.add("上传文件名:" + filename+",上传文件时发生错误,非法XML文件");
continue;
} catch (Exception e) {
e.printStackTrace();
logger.error("上传文件名" + filename);
logger.error("Exception 上传文件时发生错误,非法XML文件", e);
logger.error("上传文件名" + filename );
logger.error("Exception 上传文件时发生错误", e);
yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
errList.add("上传文件名:" + filename+",上传文件时发生错误");
continue;
}
}
......@@ -125,13 +131,20 @@ public class ReadXmlApi {
}
} catch (Exception e) {
e.printStackTrace();
logger.error("上传文件名" + filename);
logger.error("上传文件名" + filename );
logger.error("FileUploadException 文件上传发生异常", e);
yxresp.outPutError("FileUploadException", "文件上传发生异常:" + e.getMessage());
} finally {
return true;
errList.add("上传文件名:" + filename+",上传文件时发生错误");
}
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) {
......
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