<%-- - TopUpload1.jsp - by Ting@NTU - check the file: [dspace.dir]/data/TopUpload.html --%> <%@ page contentType="text/html;charset=UTF-8" %> <%@ page import="org.dspace.app.webui.util.FReader" %> <%@ page import="org.dspace.core.ConfigurationManager" %> <%@ page import="java.io.File" %> <%@ page import="java.util.Date" %> <%@ include file="/include/params_locale.jsp" %> <% //String strLocale = request.getParameter("locale")!=null?request.getParameter("locale"):session.getAttribute("locale")!=null?session.getAttribute("locale").toString():ConfigurationManager.getProperty("locale.default"); String filename = "TopUpload"; String filename1 = filename + (strLocale.length()>0?"_" + strLocale:""); boolean getNewContent = false; Date today = new Date(); File f = new File (ConfigurationManager.getProperty("dspace.dir") + "/reports/"+filename1+".html"); //out.println(today.getTime()-f.lastModified()); if (f.exists()) { if (today.getTime()-f.lastModified()>(24*60*60*100*5)) { getNewContent = true; } } else { getNewContent = true; } FReader fr = new FReader(); String content = (fr.readFileContent(f.getPath())).toString(); if (content.length()==0) getNewContent = true; if (getNewContent) { //String url = ConfigurationManager.getProperty("dspace.url"); java.net.URL url1 = new java.net.URL(request.getRequestURL().toString()); String url = "http://localhost:"+(url1.getPort())+request.getContextPath(); //String url = "http://localhost"+request.getContextPath(); if (url.indexOf(request.getContextPath())<0) url += url.endsWith("/")?request.getContextPath():("/"+request.getContextPath()); if (url!=null){ url = url.endsWith("/")?url :(url + "/"); url += "statistics/"+filename+".jsp" + (strLocale.length()>0?("?locale="+strLocale):""); content = FReader.getUrlContent(url, "utf-8"); String filepath = ConfigurationManager.getProperty("dspace.dir") + "/reports/"+filename1+".html"; FReader.writeUrlContentIntoFile(url, "UTF-8", filepath, content); } } content+=""; out.println(content.toString()); %>