<%@page import="com.ibm.icu.util.ULocale"%> <%@page import="org.xml.sax.SAXParseException"%> <%@page import="org.unicode.cldr.util.CLDRFile.DraftStatus"%> <%@page import="org.unicode.cldr.util.*"%> <%@page import="org.unicode.cldr.web.*"%> <%@page import="org.unicode.cldr.util.CLDRFile"%> <%@page import="org.unicode.cldr.util.SimpleXMLSource"%> <%@page import="org.unicode.cldr.util.XMLSource"%> <%@page import="org.unicode.cldr.util.XMLUploader"%> <%@page import="java.io.*"%><%@page import="java.util.*,org.apache.commons.fileupload.*,org.apache.commons.fileupload.servlet.*,org.apache.commons.io.FileCleaningTracker,org.apache.commons.fileupload.util.*,org.apache.commons.fileupload.disk.*,java.io.File" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%! public static DiskFileItemFactory newDiskFileItemFactory( ServletContext context, File repository) { FileCleaningTracker fileCleaningTracker = org.apache.commons.fileupload.servlet.FileCleanerCleanup .getFileCleaningTracker(context); DiskFileItemFactory factory = new DiskFileItemFactory( /* DiskFileItemFactory.DEFAULT_SIZE_THRESHOLD */ 1024000, repository); factory.setFileCleaningTracker(fileCleaningTracker); return factory; } %> <% File tmpDir = new File(System.getProperty("java.io.tmpdir")); DiskFileItemFactory factory = newDiskFileItemFactory(pageContext.getServletContext(),tmpDir); ServletFileUpload upload = new ServletFileUpload(factory); boolean isBad = !ServletFileUpload.isMultipartContent(request); if (!request.getMethod().equals("POST") || isBad) { response.sendRedirect(request.getContextPath() + "/upload.jsp"); } CLDRFile cf = null; InputStream fis = null; List list = upload.parseRequest(request); Map fields = new HashMap(); for(FileItem item : list) { if(item.isFormField()) { fields.put(item.getFieldName(),item.getString()); } else { if(fis!=null) throw new InternalError("Error, already got one"); fis = item.getInputStream(); } } boolean isSubmit = fields.containsKey("submit"); boolean isBulk = fields.containsKey("bulk"); String email = fields.get("email"); String sid = fields.get("s"); CookieSession cs = CookieSession.retrieve(sid); if(cs==null || cs.user==null) { response.sendRedirect(request.getContextPath()+"/survey"); return; } cs.userDidAction(); // mark user as not idle if(email==null||email.trim().isEmpty()) { response.sendRedirect(request.getContextPath()+"/upload.jsp?s="+sid); return; } UserRegistry.User theirU = CookieSession.sm.reg.get(email.trim()); if (theirU == null || (!theirU.equals(cs.user) && !cs.user.isAdminFor(theirU))) { // if no/bad file was given, kick them back o the upload form response.sendRedirect(request.getContextPath() + "/upload.jsp?s=" + sid + "&email=" + email.trim() + "&emailbad=t"); return; } if (fis==null || fis.available()==0) { // if no/bad file was given, kick them back o the upload form response.sendRedirect(request.getContextPath() + "/upload.jsp?s=" + sid + "&email=" + email.trim() + "&filebad=t"); return; } String title = isSubmit ? "Submitted As You" : "Submitted As Your Org"; %> SurveyTool File Submission | <%=title%> Re-Upload File/Try Another | Return to the SurveyTool

SurveyTool File Check | <%=title%> | Submitted as: <%= theirU.name %>

Your file is being tested.
For help, see: Using Bulk Upload.
Verify that there are no errors, then click the NEXT button.
<% XMLUploader.writeBulkInfoHtml("check", out); %>
<% try { cf = SimpleFactory.makeFileLenient(SurveyMain.fileBase+"/upload.xml",fis,DraftStatus.unconfirmed); } catch(Throwable t) { SurveyLog.logException(t, "while "+email+"uploading bulk file "); out.println("

Failed to parse.

"); while(t!=null) { %>
<%= StackTracker.stackToString(t.getStackTrace(), 1) %>
<%= t %>
<% t = t.getCause(); if(t!=null) { out.println("caused by
"); } } out.println("
Please fix the problems before proceeding.
"); out.flush(); return; } CLDRLocale loc = CLDRLocale.getInstance(cf.getLocaleID()); cs.stuff.remove("SubmitLocale"); %>

Locale

<%=loc + "
Name: " + loc.getDisplayName(SurveyMain.TRANS_HINT_LOCALE)%>
<% UserRegistry.ModifyDenial md = UserRegistry.userCanModifyLocaleWhy(cs.user,loc); if(!cs.sm.getLocalesSet().contains(loc)) { %>

Error: Locale doesn't exist in the Survey Tool.

<% } else if(cs.sm.getReadOnlyLocales().contains(loc)) { %>

Error: <%= loc.getDisplayName() %> may not be modified: <%= SpecialLocales.getComment(loc) %>

<% } else if(md != null) { %>

Error: <%= cs.user.name %> (<%= cs.user.email %>) may not modify <%= loc.getDisplayName() %>: <%= md.getReason() %>

<% } else { cs.stuff.put("SubmitLocale",cf); %>
<%
	for(String x : cf) {
		out.println(x + " : " +  cf.getStringValue(x));
	}
%>
<% } %>