123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <%@ page contentType="text/xml;charset=UTF-8" %>
- <%@ 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" %>
- <jsp:useBean id="resourceCache" scope="application" class="java.util.HashMap"/>
- <%
- System.out.println("RemoteClient["+request.getRemoteAddr()+"] check BOSModular resource....");
-
-
- //clear BOSModular resource cache ?
- if ("true".equalsIgnoreCase(request.getParameter("refreshCache"))) {
- System.out.println("RemoteClient["+request.getRemoteAddr()+"] request: refresh BOSModular resource cache....");
- }
-
- System.out.println("Begin generate BOSModular resource list .......");
- long startTime = System.currentTimeMillis();
-
- StringBuffer resultContent = new StringBuffer("");
- boolean success = false;
- try{
- String realPath = request.getRealPath("/");
- System.out.println("Find BOSModular real path["+ realPath+"/BOSModular]...");
-
- //BOSModular file list
- ArrayList fileList = new ArrayList();
- fileList = (ArrayList)FileLists.getFileLists(realPath+"/BOSModular", null, fileList);
- for(int i=0; i<fileList.size(); i++){
- File compFile = new File((String)fileList.get(i));
- resultContent.append("<file href=\"").append(((String)fileList.get(i)).substring(realPath.length()+1)).append("\" ");
- resultContent.append(" lastModified=\"").append(compFile.lastModified()).append("\" ");
- resultContent.append(" md5=\"").append(MD5.asHex(MD5.getHash(compFile))).append("\" ");
- resultContent.append("/>");
- }
-
- //metas list
- fileList = new ArrayList();
- fileList = (ArrayList)FileLists.getFileLists(realPath+"/metas", null, fileList);
- for(int i=0; i<fileList.size(); i++){
- File compFile = new File((String)fileList.get(i));
- resultContent.append("<metas href=\"").append(((String)fileList.get(i)).substring(realPath.length()+1)).append("\" ");
- resultContent.append(" lastModified=\"").append(compFile.lastModified()).append("\" ");
- resultContent.append(" md5=\"").append(MD5.asHex(MD5.getHash(compFile))).append("\" ");
- resultContent.append("/>");
- }
-
- success = true;
- }catch(Throwable ex){
- resultContent.delete(0,resultContent.length());
- StringWriter writer = new StringWriter();
- PrintWriter exceptionWriter = new PrintWriter(writer);
- ex.printStackTrace(exceptionWriter);
- Throwable causeEx = ex.getCause();
- while(causeEx!=null) {
- causeEx.printStackTrace(exceptionWriter);
- causeEx = causeEx.getCause();
- }
- resultContent.append(writer.toString());
- }
- StringBuffer resultString = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<BOSModularResource>\n");
- if(success){
- resultString.append("<Resources>\n").append(resultContent.toString()).append("\n</Resources>\n");
- }else {
- resultString.append("<Exception>\n").append(resultContent.toString()).append("\n</Exception>\n");
- }
- resultString.append("</BOSModularResource>");
- System.out.println("Generate BOSModular resource list finished, elapse time " + (System.currentTimeMillis() - startTime) +"ms");
-
- out.println(resultString);
- out.flush();
- %>
|