BOSModular.jsp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <%@ page contentType="text/xml;charset=UTF-8" %>
  2. <%@ page import="java.io.PrintWriter,java.io.File,java.io.StringWriter,java.util.HashMap,java.util.ArrayList,com.kingdee.eas.cp.autoupdater.util.FileLists,com.twmacinta.util.MD5" %>
  3. <jsp:useBean id="resourceCache" scope="application" class="java.util.HashMap"/>
  4. <%
  5. System.out.println("RemoteClient["+request.getRemoteAddr()+"] check BOSModular resource....");
  6. //clear BOSModular resource cache ?
  7. if ("true".equalsIgnoreCase(request.getParameter("refreshCache"))) {
  8. System.out.println("RemoteClient["+request.getRemoteAddr()+"] request: refresh BOSModular resource cache....");
  9. }
  10. System.out.println("Begin generate BOSModular resource list .......");
  11. long startTime = System.currentTimeMillis();
  12. StringBuffer resultContent = new StringBuffer("");
  13. boolean success = false;
  14. try{
  15. String realPath = request.getRealPath("/");
  16. System.out.println("Find BOSModular real path["+ realPath+"/BOSModular]...");
  17. //BOSModular file list
  18. ArrayList fileList = new ArrayList();
  19. fileList = (ArrayList)FileLists.getFileLists(realPath+"/BOSModular", null, fileList);
  20. for(int i=0; i<fileList.size(); i++){
  21. File compFile = new File((String)fileList.get(i));
  22. resultContent.append("<file href=\"").append(((String)fileList.get(i)).substring(realPath.length()+1)).append("\" ");
  23. resultContent.append(" lastModified=\"").append(compFile.lastModified()).append("\" ");
  24. resultContent.append(" md5=\"").append(MD5.asHex(MD5.getHash(compFile))).append("\" ");
  25. resultContent.append("/>");
  26. }
  27. //metas list
  28. fileList = new ArrayList();
  29. fileList = (ArrayList)FileLists.getFileLists(realPath+"/metas", null, fileList);
  30. for(int i=0; i<fileList.size(); i++){
  31. File compFile = new File((String)fileList.get(i));
  32. resultContent.append("<metas href=\"").append(((String)fileList.get(i)).substring(realPath.length()+1)).append("\" ");
  33. resultContent.append(" lastModified=\"").append(compFile.lastModified()).append("\" ");
  34. resultContent.append(" md5=\"").append(MD5.asHex(MD5.getHash(compFile))).append("\" ");
  35. resultContent.append("/>");
  36. }
  37. success = true;
  38. }catch(Throwable ex){
  39. resultContent.delete(0,resultContent.length());
  40. StringWriter writer = new StringWriter();
  41. PrintWriter exceptionWriter = new PrintWriter(writer);
  42. ex.printStackTrace(exceptionWriter);
  43. Throwable causeEx = ex.getCause();
  44. while(causeEx!=null) {
  45. causeEx.printStackTrace(exceptionWriter);
  46. causeEx = causeEx.getCause();
  47. }
  48. resultContent.append(writer.toString());
  49. }
  50. StringBuffer resultString = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<BOSModularResource>\n");
  51. if(success){
  52. resultString.append("<Resources>\n").append(resultContent.toString()).append("\n</Resources>\n");
  53. }else {
  54. resultString.append("<Exception>\n").append(resultContent.toString()).append("\n</Exception>\n");
  55. }
  56. resultString.append("</BOSModularResource>");
  57. System.out.println("Generate BOSModular resource list finished, elapse time " + (System.currentTimeMillis() - startTime) +"ms");
  58. out.println(resultString);
  59. out.flush();
  60. %>