/** * @param context the Servlet context. * @deprecated Now handled in TdsContext.init(). */ public static void initContext(ServletContext context) { // setContextPath(context); if (contextPath == null) { // Servlet 2.5 allows the following. // contextPath = servletContext.getContextPath(); String tmpContextPath = context.getInitParameter("ContextPath"); // cannot be overridden in the ThreddsConfig file if (tmpContextPath == null) tmpContextPath = "thredds"; contextPath = "/" + tmpContextPath; } // setRootPath(context); if (rootPath == null) { rootPath = context.getRealPath("/"); rootPath = rootPath.replace('\\', '/'); } // setContentPath(); if (contentPath == null) { String tmpContentPath = "../../content" + getContextPath() + "/"; File cf = new File(getRootPath(), tmpContentPath); try { contentPath = cf.getCanonicalPath() + "/"; contentPath = contentPath.replace('\\', '/'); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } } // initDebugging(context); initDebugging(context); }
public File doAttachment(HttpServletRequest request) throws ServletException, IOException { File file = null; DiskFileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); try { List<?> items = upload.parseRequest(request); Iterator<?> itr = items.iterator(); while (itr.hasNext()) { FileItem item = (FileItem) itr.next(); if (item.isFormField()) { parameters .put(item.getFieldName(), item.getString("UTF-8")); } else { File tempFile = new File(item.getName()); file = new File(sc.getRealPath("/") + savePath, tempFile .getName()); item.write(file); } } } catch (Exception e) { Logger logger = Logger.getLogger(SendAttachmentMailServlet.class); logger.error("邮件发送出了异常", e); } return file; }
/** * Initializes the servlet context, based on the servlet context. Parses all context parameters * and passes them on to the database context. * * @param sc servlet context * @throws IOException I/O exception */ static synchronized void init(final ServletContext sc) throws IOException { // skip process if context has already been initialized if (context != null) return; // set servlet path as home directory final String path = sc.getRealPath("/"); System.setProperty(Prop.PATH, path); // parse all context parameters final HashMap<String, String> map = new HashMap<String, String>(); // store default web root map.put(MainProp.HTTPPATH[0].toString(), path); final Enumeration<?> en = sc.getInitParameterNames(); while (en.hasMoreElements()) { final String key = en.nextElement().toString(); if (!key.startsWith(Prop.DBPREFIX)) continue; // only consider parameters that start with "org.basex." String val = sc.getInitParameter(key); if (eq(key, DBUSER, DBPASS, DBMODE, DBVERBOSE)) { // store servlet-specific parameters as system properties System.setProperty(key, val); } else { // prefix relative paths with absolute servlet path if (key.endsWith("path") && !new File(val).isAbsolute()) { val = path + File.separator + val; } // store remaining parameters (without project prefix) in map map.put(key.substring(Prop.DBPREFIX.length()).toUpperCase(Locale.ENGLISH), val); } } context = new Context(map); if (SERVER.equals(System.getProperty(DBMODE))) { new BaseXServer(context); } else { context.log = new Log(context); } }
/** * Initializes the database context, based on the initial servlet context. Parses all context * parameters and passes them on to the database context. * * @param sc servlet context * @throws IOException I/O exception */ public static synchronized void init(final ServletContext sc) throws IOException { // check if HTTP context has already been initialized if (init) return; init = true; // set web application path as home directory and HTTPPATH final String webapp = sc.getRealPath("/"); Options.setSystem(Prop.PATH, webapp); Options.setSystem(GlobalOptions.WEBPATH, webapp); // bind all parameters that start with "org.basex." to system properties final Enumeration<String> en = sc.getInitParameterNames(); while (en.hasMoreElements()) { final String key = en.nextElement(); if (!key.startsWith(Prop.DBPREFIX)) continue; String val = sc.getInitParameter(key); if (key.endsWith("path") && !new File(val).isAbsolute()) { // prefix relative path with absolute servlet path Util.debug(key.toUpperCase(Locale.ENGLISH) + ": " + val); val = new IOFile(webapp, val).path(); } Options.setSystem(key, val); } // create context, update options if (context == null) { context = new Context(false); } else { context.globalopts.setSystem(); context.options.setSystem(); } // start server instance if (!context.globalopts.get(GlobalOptions.HTTPLOCAL)) new BaseXServer(context); }
public synchronized void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpSession dbSession = request.getSession(); JspFactory _jspxFactory = JspFactory.getDefaultFactory(); PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true); ServletContext dbApplication = dbSession.getServletContext(); try { // 实例化 HttpSession session = request.getSession(); ServletContext context = session.getServletContext(); String path = context.getRealPath("/"); counter count = new counter(dbApplication); SmartUpload mySmartUpload = new SmartUpload(); mySmartUpload.setCharset("UTF-8"); nseer_db_backup1 qcs_db = new nseer_db_backup1(dbApplication); if (qcs_db.conn((String) dbSession.getAttribute("unit_db_name"))) { mySmartUpload.initialize(pageContext); String file_type = getFileLength.getFileType((String) session.getAttribute("unit_db_name")); long d = getFileLength.getFileLength((String) session.getAttribute("unit_db_name")); mySmartUpload.setMaxFileSize(d); mySmartUpload.setAllowedFilesList(file_type); try { mySmartUpload.upload(); String qcs_id = mySmartUpload.getRequest().getParameter("qcs_id"); String config_id = mySmartUpload.getRequest().getParameter("config_id"); String[] item = mySmartUpload.getRequest().getParameterValues("item"); if (item != null) { String[] file_name = new String[mySmartUpload.getFiles().getCount()]; String[] not_change = new String[mySmartUpload.getFiles().getCount()]; java.util.Date now = new java.util.Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); String time = formatter.format(now); String standard_id = mySmartUpload.getRequest().getParameter("standard_id"); String sqla = "select attachment1 from qcs_intrmanufacture where qcs_id='" + qcs_id + "' and (check_tag='5' or check_tag='9')"; ResultSet rs = qcs_db.executeQuery(sqla); if (!rs.next()) { response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=1"); } else { String[] attachment = mySmartUpload.getRequest().getParameterValues("attachment"); String[] delete_file_name = new String[0]; if (attachment != null) { delete_file_name = new String[attachment.length]; for (int i = 0; i < attachment.length; i++) { delete_file_name[i] = rs.getString(attachment[i]); } } for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) { com.jspsmart.upload.SmartFile file = mySmartUpload.getFiles().getFile(i); if (file.isMissing()) { file_name[i] = ""; int q = i + 1; String field_name = "attachment" + q; if (!rs.getString(field_name).equals("")) not_change[i] = "yes"; continue; } int filenum = count.read( (String) dbSession.getAttribute("unit_db_name"), "qcsAttachmentcount"); count.write( (String) dbSession.getAttribute("unit_db_name"), "qcsAttachmentcount", filenum); file_name[i] = filenum + file.getFileName(); file.saveAs(path + "qcs/file_attachments/" + filenum + file.getFileName()); } String apply_id = mySmartUpload.getRequest().getParameter("apply_id"); String product_id = mySmartUpload.getRequest().getParameter("product_id"); String product_name = mySmartUpload.getRequest().getParameter("product_name"); String qcs_amount = mySmartUpload.getRequest().getParameter("qcs_amount"); String qcs_time = mySmartUpload.getRequest().getParameter("qcs_time"); String quality_way = mySmartUpload.getRequest().getParameter("quality_way"); String quality_solution = mySmartUpload.getRequest().getParameter("quality_solution"); String sampling_standard = mySmartUpload.getRequest().getParameter("sampling_standard"); String sampling_amount = mySmartUpload.getRequest().getParameter("sampling_amount"); String accept = mySmartUpload.getRequest().getParameter("accept"); String reject = mySmartUpload.getRequest().getParameter("reject"); String qualified = mySmartUpload.getRequest().getParameter("qualified"); String unqualified = mySmartUpload.getRequest().getParameter("unqualified"); String qcs_result = mySmartUpload.getRequest().getParameter("qcs_result"); String checker = mySmartUpload.getRequest().getParameter("checker"); String checker_id = mySmartUpload.getRequest().getParameter("checker_id"); String check_time = mySmartUpload.getRequest().getParameter("check_time"); String changer = mySmartUpload.getRequest().getParameter("changer"); String changer_id = mySmartUpload.getRequest().getParameter("changer_id"); String change_time = mySmartUpload.getRequest().getParameter("change_time"); String bodyab = new String( mySmartUpload.getRequest().getParameter("remark").getBytes("UTF-8"), "UTF-8"); String remark = exchange.toHtml(bodyab); sqla = "update qcs_intrmanufacture set apply_id='" + apply_id + "',product_id='" + product_id + "',product_name='" + product_name + "',qcs_amount='" + qcs_amount + "',qcs_time='" + qcs_time + "',quality_way='" + quality_way + "',quality_solution='" + quality_solution + "',sampling_standard='" + sampling_standard + "',sampling_amount='" + sampling_amount + "',accept='" + accept + "',reject='" + reject + "',qualified='" + qualified + "',unqualified='" + unqualified + "',changer_id='" + changer_id + "',qcs_result='" + qcs_result + "',changer='" + changer + "',change_time='" + change_time + "',remark='" + remark + "',check_tag='5'"; String sqlb = " where qcs_id='" + qcs_id + "'"; if (attachment != null) { for (int i = 0; i < attachment.length; i++) { sqla = sqla + "," + attachment[i] + "=''"; java.io.File file = new java.io.File(path + "qcs/file_attachments/" + delete_file_name[i]); file.delete(); } } for (int i = 0; i < mySmartUpload.getFiles().getCount(); i++) { if (not_change[i] != null && not_change[i].equals("yes")) continue; int p = i + 1; sqla = sqla + ",attachment" + p + "='" + file_name[i] + "'"; } String sql = sqla + sqlb; qcs_db.executeUpdate(sql); sql = "delete from qcs_intrmanufacture_details where qcs_id='" + qcs_id + "'"; qcs_db.executeUpdate(sql); String[] default_basis = mySmartUpload.getRequest().getParameterValues("default_basis"); String[] ready_basis = mySmartUpload.getRequest().getParameterValues("ready_basis"); String[] quality_method = mySmartUpload.getRequest().getParameterValues("quality_method"); String[] analyse_method = mySmartUpload.getRequest().getParameterValues("analyse_method"); String[] standard_value = mySmartUpload.getRequest().getParameterValues("standard_value"); String[] standard_max = mySmartUpload.getRequest().getParameterValues("standard_max"); String[] standard_min = mySmartUpload.getRequest().getParameterValues("standard_min"); String[] quality_value = mySmartUpload.getRequest().getParameterValues("quality_value"); String[] sampling_amount_d = mySmartUpload.getRequest().getParameterValues("sampling_amount_d"); String[] qualified_d = mySmartUpload.getRequest().getParameterValues("qualified_d"); String[] unqualified_d = mySmartUpload.getRequest().getParameterValues("unqualified_d"); String[] quality_result = mySmartUpload.getRequest().getParameterValues("quality_result"); String[] unqualified_reason = mySmartUpload.getRequest().getParameterValues("unqualified_reason"); for (int i = 0; i < item.length; i++) { if (!item[i].equals("")) { sql = "insert into qcs_intrmanufacture_details(qcs_id,item,default_basis,ready_basis,quality_method,analyse_method,standard_value,standard_max,standard_min,quality_value,sampling_amount_d,qualified_d,unqualified_d,quality_result,unqualified_reason,details_number) values('" + qcs_id + "','" + item[i] + "','" + default_basis[i] + "','" + ready_basis[i] + "','" + quality_method[i] + "','" + analyse_method[i] + "','" + standard_value[i] + "','" + standard_max[i] + "','" + standard_min[i] + "','" + quality_value[i] + "','" + sampling_amount_d[i] + "','" + qualified_d[i] + "','" + unqualified_d[i] + "','" + quality_result[i] + "','" + unqualified_reason[i] + "','" + i + "')"; qcs_db.executeUpdate(sql); } } response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=0"); } qcs_db.commit(); qcs_db.close(); } else { response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=7"); } } catch (Exception ex) { response.sendRedirect("draft/qcs/intrmanufacture_ok.jsp?finished_tag=6"); } } else { response.sendRedirect("error_conn.htm"); } } catch (Exception ex) { ex.printStackTrace(); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType("text/html; charset=ISO-8859-1"); pageContext = _jspxFactory.getPageContext(this, request, response, null, false, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); out = pageContext.getOut(); _jspx_out = out; out.write("<!--\n"); out.write("Copyright 2012 The Infinit.e Open Source Project\n"); out.write("\n"); out.write("Licensed under the Apache License, Version 2.0 (the \"License\");\n"); out.write("you may not use this file except in compliance with the License.\n"); out.write("You may obtain a copy of the License at\n"); out.write("\n"); out.write(" http://www.apache.org/licenses/LICENSE-2.0\n"); out.write("\n"); out.write("Unless required by applicable law or agreed to in writing, software\n"); out.write("distributed under the License is distributed on an \"AS IS\" BASIS,\n"); out.write("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"); out.write("See the License for the specific language governing permissions and\n"); out.write("limitations under the License.\n"); out.write("-->\n"); out.write("\n"); out.write("\n"); out.write("<!--\n"); out.write("Copyright 2012 The Infinit.e Open Source Project\n"); out.write("\n"); out.write("Licensed under the Apache License, Version 2.0 (the \"License\");\n"); out.write("you may not use this file except in compliance with the License.\n"); out.write("You may obtain a copy of the License at\n"); out.write("\n"); out.write(" http://www.apache.org/licenses/LICENSE-2.0\n"); out.write("\n"); out.write("Unless required by applicable law or agreed to in writing, software\n"); out.write("distributed under the License is distributed on an \"AS IS\" BASIS,\n"); out.write("WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"); out.write("See the License for the specific language governing permissions and\n"); out.write("limitations under the License.\n"); out.write("-->\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write("\n"); out.write('\n'); out.write('\n'); out.write('\n'); // !---------- Read AppConstants.js to get the API_ROOT value ----------! if (API_ROOT == null) { URL baseUrl = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), ""); ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("javascript"); String appConstantFile = null; InputStream in = null; // Use file from local deployment always try { in = new FileInputStream(application.getRealPath("/") + "AppConstants.js"); appConstantFile = IOUtils.toString(in); } catch (Exception e) { // System.out.println("Exception: " + e.getMessage()); } // Eval the file as JavaScript through or JS engine and call getEndPointUrl try { engine.eval(appConstantFile); engine.eval("output = getEndPointUrl();"); API_ROOT = (String) engine.get("output"); } catch (Exception e) { // System.out.println("Exception: " + e.getMessage()); } if (null == API_ROOT) { // Default to localhost API_ROOT = "http://localhost:8080/api/"; } if (API_ROOT.contains("localhost")) { localCookie = true; } else { localCookie = false; } } boolean isLoggedIn = false; messageToDisplay = ""; // Page request is a post back from the login form if (request.getParameter("username") != null && request.getParameter("password") != null) { String username = request.getParameter("username"); String password = request.getParameter("password"); isLoggedIn = getLogin(username, password, request, response); // Temp fix, refresh the page to retrieve the new cookie that was set out.println("<meta http-equiv=\"refresh\" content=\"0\">"); } // Make sure user is already logged in and retrieve their user id else { isLoggedIn = isLoggedIn(request, response); } out.write("\n"); out.write("\n"); out.write("\t\n"); out.write('\n'); out.write('\n'); out.write('\n'); messageToDisplay = ""; // if (isLoggedIn) { // Determine which action is being called for by the user String action = ""; if (request.getParameter("action") != null) action = request.getParameter("action").toLowerCase(); if (request.getParameter("dispatchAction") != null) action = request.getParameter("dispatchAction").toLowerCase(); try { if (action.equals("logout")) { logOut(request, response); out.println("<meta http-equiv=\"refresh\" content=\"0;url=index.jsp\">"); } } catch (Exception e) { // System.out.println(e.getMessage()); } } out.write("\n"); out.write("\n"); out.write( "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"); out.write("<html>\n"); out.write("<head>\n"); out.write("\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\n"); out.write("\t<link rel=\"stylesheet\" type=\"text/css\" href=\"inc/manager.css\" />\n"); out.write("\t<title>Infinit.e.Manager - Home</title>\n"); out.write("</head>\n"); out.write("<body>\n"); out.write("\n"); out.write("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" >\n"); out.write("<tr valign=\"middle\">\n"); out.write("\t<td width=\"100%\" background=\"image/infinite_logo_bg.png\">\n"); out.write("\t\t<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" >\n"); out.write("\t\t\t<tr valign=\"bottom\">\n"); out.write( "\t\t\t\t<td width=\"200\"><a href=\"index.jsp\"><img src=\"image/infinite_logo.png\" border=\"0\"></a></td>\n"); out.write("\t\t\t\t<td>\n"); out.write( "\t\t\t\t\t<a href=\"people.jsp\" class=\"headerLink\" title=\"Add/Edit Users\">People</a> \n"); out.write( "\t\t\t\t\t<a href=\"communities.jsp\" class=\"headerLink\" title=\"Add/Edit Communities\">Communities</a> \n"); out.write( "\t\t\t\t\t<a href=\"sources.jsp\" class=\"headerLink\" title=\"Add/Edit Sources\">Sources</a> \n"); out.write( "\t\t\t\t\t<!-- <a href=\"widgets.jsp\" class=\"headerLink\" title=\"Add/Edit Widgets\">Widgets</a> -->\n"); out.write( "\t\t\t\t\t<!-- <a href=\"hadoop.jsp\" class=\"headerLink\" title=\"Add/Edit Hadoop Jars\">Hadoop</a> -->\n"); out.write( "\t\t\t\t\t<!-- <a href=\"shares.jsp\" class=\"headerLink\" title=\"Add/Edit Shares\">Shares</a> -->\n"); out.write( "\t\t\t\t\t<a href=\"index.jsp\" class=\"headerLink\" title=\"Home\">Home</a> \n"); out.write( "\t\t\t\t\t<a href=\"?action=logout\" class=\"headerLink\" title=\"Logout\">Logout</a>\n"); out.write("\t\t\t\t</td>\n"); out.write( "\t\t\t\t<td align=\"right\" width=\"120\" background=\"image/ikanow_logo_smaller_bg.png\"></td>\n"); out.write("\t\t\t</tr>\n"); out.write("\t\t</table>\n"); out.write("\t</td>\n"); out.write("</tr>\n"); out.write("<tr>\n"); out.write("\t<td bgcolor=\"#ffffff\">\n"); out.write('\n'); out.write('\n'); if (!isLoggedIn) { out.write('\n'); out.write(' '); out.write(' '); out.write("<!-- Begin login_form.jsp -->\n"); out.write("\n"); out.write("<br />\n"); out.write("<br />\n"); out.write("<br />\n"); out.write("<br />\n"); out.write("<center>\n"); out.write("<form method=\"post\" name=\"login_form\">\n"); out.write( "<table class=\"standardTable\" cellpadding=\"5\" cellspacing=\"1\" width=\"35%\" >\n"); out.write("\t<tr>\n"); out.write("\t\t<td colspan=\"2\" align=\"center\">\n"); out.write("\t\t\t<font color=\"white\"><b>Login to Infinit.e.Manager</b></font>\n"); out.write("\t\t</td>\n"); out.write("\t</tr>\n"); out.write("\t<tr>\n"); out.write("\t\t<td bgcolor=\"white\" width=\"40%\">User Name:</td>\n"); out.write( "\t\t<td bgcolor=\"white\" width=\"60%\"><input type=\"text\" name=\"username\" size=\"40\"></td>\n"); out.write("\t</tr>\n"); out.write("\t<tr>\n"); out.write("\t\t<td bgcolor=\"white\" width=\"40%\">Password:</td>\n"); out.write( "\t\t<td bgcolor=\"white\" width=\"60%\"><input type=\"password\" name=\"password\" size=\"40\"></td>\n"); out.write("\t</tr>\n"); out.write("\t<tr>\n"); out.write("\t\t<td colspan=\"2\" align=\"right\"><input type=\"submit\"></td>\n"); out.write("\t</tr>\n"); out.write("</table>\n"); out.write("</form>\n"); out.write("</center>\n"); out.write("<br />\n"); out.write("<br />\n"); out.write("<br />\n"); out.write("<br />\n"); out.write("<!-- End login_form.jsp -->"); out.write('\n'); } else { out.write("\n"); out.write( "\t<table class=\"standardTable\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\" >\n"); out.write("\t<tr>\n"); out.write("\t\t<td width=\"100%\" bgcolor=\"#ffffff\">\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t\n"); out.write("\t\t\t<center>\n"); out.write( "\t\t\t<table class=\"standardTable\" cellpadding=\"5\" cellspacing=\"1\" width=\"50%\">\n"); out.write("\t\t\t\t<tr>\n"); out.write("\t\t\t\t\t<td> </td>\n"); out.write("\t\t\t\t</tr>\n"); out.write("\t\t\t\t<tr>\n"); out.write("\t\t\t\t\t<td bgcolor=\"white\">\n"); out.write("\t\t\t\t\t\t<ul>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"people.jsp\" title=\"Add/Edit Users\">People</a></b> - Add/Edit Users</li>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"communities.jsp\" title=\"Add/Edit Users\">Communities</a></b> - Add/Edit Communities and Membership</li>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"sources.jsp\" title=\"Add/Edit Users\">Sources</a></b> - Add/Edit Sources\n"); out.write( "\t\t\t\t\t\t\t\t<ul><li><b><a href=\"sourcemonitor.jsp\" title=\"Monitor Sources\" target=\"_blank\">Source Monitoring</a></b> (new tab)</li></ul>\n"); out.write("\t\t\t\t\t\t\t</li>\n"); out.write("\t\t\t\t\t\t</ul>\n"); out.write("\t\t\t\t\t\t<ul>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"fileUploader.jsp\" title=\"Add/Edit Users\" target=\"_blank\">File Uploader</a></b> - Add/Edit Files or JSON (new tab)</li>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"widgetUploader.jsp\" title=\"Add/Edit Users\" target=\"_blank\">Widget Uploader</a></b> - Add/Edit Widgets (new tab)</li>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"pluginManager.jsp\" title=\"Add/Edit Users\" target=\"_blank\">Plugin Manager</a></b> - Add/Edit Hadoop Plugins (new tab)</li>\t\t\t\t\t\t\n"); out.write("\t\t\t\t\t\t</ul>\n"); out.write("\t\t\t\t\t\t<ul>\n"); out.write( "\t\t\t\t\t\t\t<li><b><a href=\"chrome.html\" title=\"Install Chrome Source Extension\" target=\"_blank\">Infinit.e Chrome Extension</a></b> - Create Sources from Chrome</li>\n"); out.write("\t\t\t\t\t\t</ul>\n"); out.write("\t\t\t\t\t</td>\n"); out.write("\t\t\t\t</tr>\n"); out.write("\t\t\t</table>\n"); out.write("\t\t\t</center>\n"); out.write("\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t<br />\n"); out.write("\t\t\t<br />\n"); out.write("\t\t</td>\n"); out.write("\t<tr>\n"); out.write("\t</table>\n"); } out.write('\n'); out.write('\n'); out.write("\t\n"); out.write("\t</td>\n"); out.write("<tr>\n"); out.write("<tr>\n"); out.write("\t<td align=\"right\" bgcolor=\"#000000\">\n"); out.write("\t\t \n"); out.write( "\t\t<!-- <a href=\"http://www.ikanow.com\" title=\"www.ikanow.com\"><img src=\"image/ikanow_logo_small.png\" border=\"0\"></a> -->\n"); out.write("\t</td>\n"); out.write("</tr>\n"); out.write("</table>\n"); out.write("\n"); out.write("\n"); out.write("</body>\n"); out.write("</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) { } if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } }
public String getRealPath(String arg0) { return servletContext.getRealPath(arg0); }
private File generateJarDiff( ResourceCatalog catalog, DownloadRequest dreq, JnlpResource res, boolean doJarDiffWorkAround) { boolean del_old = false; boolean del_new = false; // Lookup up file for request version DownloadRequest fromDreq = dreq.getFromDownloadRequest(); try { JnlpResource fromRes = catalog.lookupResource(fromDreq); /* Get file locations */ String newFilePath = _servletContext.getRealPath(res.getPath()); String oldFilePath = _servletContext.getRealPath(fromRes.getPath()); // fix for 4720897 if (newFilePath == null) { newFilePath = getRealPath(res.getPath()); if (newFilePath != null) del_new = true; } if (oldFilePath == null) { oldFilePath = getRealPath(fromRes.getPath()); if (oldFilePath != null) del_old = true; } if (newFilePath == null || oldFilePath == null) { return null; } // Create temp. file to store JarDiff file in File tempDir = (File) _servletContext.getAttribute("javax.servlet.context.tempdir"); // fix for 4653036: JarDiffHandler() should use javax.servlet.context.tempdir to store the // jardiff File outputFile = File.createTempFile("jnlp", ".jardiff", tempDir); _log.addDebug( "Generating Jardiff between " + oldFilePath + " and " + newFilePath + " Store in " + outputFile); // Generate JarDiff OutputStream os = new FileOutputStream(outputFile); JarDiff.createPatch(oldFilePath, newFilePath, os, !doJarDiffWorkAround); os.close(); try { // Check that Jardiff is smaller, or return null if (outputFile.length() >= (new File(newFilePath).length())) { _log.addDebug("JarDiff discarded - since it is bigger"); return null; } // Check that Jardiff is smaller than the packed version of // the new file, if the file exists at all File newFilePacked = new File(newFilePath + ".pack.gz"); if (newFilePacked.exists()) { _log.addDebug("generated jardiff size: " + outputFile.length()); _log.addDebug("packed requesting file size: " + newFilePacked.length()); if (outputFile.length() >= newFilePacked.length()) { _log.addDebug("JarDiff discarded - packed version of requesting file is smaller"); return null; } } _log.addDebug("JarDiff generation succeeded"); return outputFile; } finally { // delete the temporarily downloaded file if (del_new) { new File(newFilePath).delete(); } if (del_old) { new File(oldFilePath).delete(); } } } catch (IOException ioe) { _log.addDebug("Failed to genereate jardiff", ioe); return null; } catch (ErrorResponseException ere) { _log.addDebug("Failed to genereate jardiff", ere); return null; } }