diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AdminPanel.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AdminPanel.java index 5032457d89e..1cbe50e62ef 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AdminPanel.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AdminPanel.java @@ -17,10 +17,7 @@ public class AdminPanel { public void getJson( - SurveyJSONWrapper r, - HttpServletRequest request, - HttpServletResponse response, - SurveyMain sm) + SurveyJSONWrapper r, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException { /* * Assume caller has already confirmed UserRegistry.userIsAdmin @@ -43,7 +40,7 @@ public void getJson( } else if (action.equals("settings_set")) { setSettings(r, request); } else if (action.equals("create_login")) { - createAndLogin(r, request, response, sm); + createAndLogin(r, request, response); } else { r.put("err", "Unknown action: " + action); } @@ -99,10 +96,10 @@ private void unlinkUser(SurveyJSONWrapper r, HttpServletRequest request) throws private void showThreads(SurveyJSONWrapper r) throws JSONException { JSONObject threads = new JSONObject(); ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); - long deadlockedThreads[] = threadBean.findDeadlockedThreads(); + long[] deadlockedThreads = threadBean.findDeadlockedThreads(); if (deadlockedThreads != null) { JSONArray dead = new JSONArray(); - ThreadInfo deadThreadInfo[] = threadBean.getThreadInfo(deadlockedThreads, true, true); + ThreadInfo[] deadThreadInfo = threadBean.getThreadInfo(deadlockedThreads, true, true); for (ThreadInfo deadThread : deadThreadInfo) { dead.put( new JSONObject() @@ -132,9 +129,9 @@ private void showExceptions(SurveyJSONWrapper r, HttpServletRequest request) JSONObject exceptions = new JSONObject(); ChunkyReader cr = SurveyLog.getChunkyReader(); exceptions.put("lastTime", cr.getLastTime()); - ChunkyReader.Entry e = null; + ChunkyReader.Entry e; if (request.getParameter("before") != null) { - Long before = Long.parseLong(request.getParameter("before")); + long before = Long.parseLong(request.getParameter("before")); e = cr.getEntryBelow(before); } else { e = cr.getLastEntry(); @@ -178,17 +175,11 @@ private void setSettings(SurveyJSONWrapper r, HttpServletRequest request) throws * @param r * @param request * @param response - * @param sm - *

Earlier version was in createAndLogin.jsp - * @throws JSONException */ private void createAndLogin( - SurveyJSONWrapper r, - HttpServletRequest request, - HttpServletResponse response, - SurveyMain sm) + SurveyJSONWrapper r, HttpServletRequest request, HttpServletResponse response) throws JSONException { - if (SurveyMain.isSetup == false) { + if (!SurveyMain.isSetup) { r.put("isSetup", false); return; } @@ -197,7 +188,7 @@ private void createAndLogin( WebContext.clearCookie(request, response, SurveyMain.QUERY_PASSWORD); WebContext.clearCookie(request, response, SurveyMain.COOKIE_SAVELOGIN); - String orgs[] = UserRegistry.getOrgList(); + String[] orgs = UserRegistry.getOrgList(); String myorg = orgs[(int) Math.rint(Math.random() * (orgs.length - 1))]; JSONObject levels = new JSONObject(); for (final VoteResolver.Level l : VoteResolver.Level.values()) { // like 999 @@ -216,7 +207,7 @@ private void createAndLogin( r.put("defaultLevel", UserRegistry.TC); } - static final String allNames[] = { + static final String[] allNames = { // http://en.wikipedia.org/wiki/List_of_most_popular_given_names (Greenland) "Ivaana", "Pipaluk", "Nivi", "Paninnguaq", "Ivalu", "Naasunnguaq", "Julie", "Ane", "Isabella", "Kimmernaq", @@ -226,15 +217,13 @@ private void createAndLogin( private String randomName() { // generate random name - StringBuilder genname = new StringBuilder(); - genname.append(choose(allNames)); - genname.append(' '); - genname.append((char) ('A' + new Random().nextInt(26))); - genname.append('.'); - genname.append(' '); - genname.append( - choose( + return choose(allNames) + + ' ' + + (char) ('A' + new Random().nextInt(26)) + + '.' + + ' ' + + choose( "Vetter", "Linguist", "User", @@ -244,8 +233,7 @@ private String randomName() { "Person", "Account", "Login", - "CLDR")); - return genname.toString(); + "CLDR"); } private String choose(String... option) { diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DefaultDataSubmissionResultHandler.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DefaultDataSubmissionResultHandler.java index a21b486c1e6..38fb97a6a18 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DefaultDataSubmissionResultHandler.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DefaultDataSubmissionResultHandler.java @@ -139,7 +139,7 @@ public void handleError(DataRow p, CheckStatus status, String choice_v) { ctx.print("" + p.getDisplayName() + ": "); ctx.print("   Value: " + choice_v + " "); String cls = SurveyMain.shortClassName(status.getCause()); - ctx.printHelpLink("/" + cls, "" + cls, true); + ctx.printHelpLink("/" + cls, "" + cls); if (status.getType().equals(CheckStatus.errorType)) { ctx.print(ctx.iconHtml("stop", cls)); } else { diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java index 69851d72590..8a5f145dd18 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java @@ -439,7 +439,7 @@ private void processRequest( mySession.userDidAction(); SurveyJSONWrapper r = newJSONStatus(request, sm); r.put("what", what); - new AdminPanel().getJson(r, request, response, sm); + new AdminPanel().getJson(r, request, response); send(r, out); } else { sendError( diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java index f401b6133cc..9b694f20f05 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java @@ -72,13 +72,10 @@ import org.unicode.cldr.util.CldrUtility; import org.unicode.cldr.util.CoverageInfo; import org.unicode.cldr.util.Factory; -import org.unicode.cldr.util.Factory.DirectoryType; -import org.unicode.cldr.util.Factory.SourceTreeType; import org.unicode.cldr.util.LDMLUtilities; import org.unicode.cldr.util.LocaleNormalizer; import org.unicode.cldr.util.LocaleSet; import org.unicode.cldr.util.Organization; -import org.unicode.cldr.util.Pair; import org.unicode.cldr.util.PathHeader; import org.unicode.cldr.util.PathHeader.PageId; import org.unicode.cldr.util.PathHeader.SurveyToolStatus; @@ -118,6 +115,7 @@ public class SurveyMain extends HttpServlet implements CLDRProgressIndicator, Ex private static final UnicodeSet supportedNameSet = new UnicodeSet("[a-zA-Z]").freeze(); static final int TWELVE_WEEKS = 3600 * 24 * 7 * 12; + // WARNING: this is used by generalinfo.jsp public static final String DEFAULT_CONTENT_LINK = "default content locale"; @@ -145,30 +143,14 @@ public enum Phase { * TC/Admin may make changes, but the SurveyTool is locked to any lower levels. */ VETTING_CLOSED("Vetting Closed", CheckCLDR.Phase.FINAL_TESTING), - /** - * DEPRECATED: use VETTING_CLOSED - * - * @see #VETTING_CLOSED - * @deprecated - */ - @Deprecated - CLOSED("Closed", CheckCLDR.Phase.FINAL_TESTING), - /** - * DEPRECATED: Not to be used in the SurveyTool. - * - * @see #VETTING_CLOSED - * @deprecated - */ - @Deprecated - FINAL_TESTING("Final Testing", CheckCLDR.Phase.FINAL_TESTING), + /** The SurveyTool is not open for any changes. */ READONLY("Read-Only", CheckCLDR.Phase.FINAL_TESTING), + /** - * Do not use. - * - * @deprecated + * Survey Tool is in Beta mode. Votes, announcements, etc., will be stored in special + * database tables with the "_beta" suffix, and will be used only for testing. */ - @Deprecated BETA("Beta", CheckCLDR.Phase.SUBMISSION); private final String what; @@ -211,19 +193,11 @@ public String urlStub() { return url; } + // WARNING: this is used by menu_top.jsp public String urlQuery() { return SurveyMain.QUERY_SECTION + "=" + url; } - /** - * @param base - * @param locale - * @return Called from menu_top.jsp only - */ - public String urlFull(String base, String locale) { - return base + "?_=" + locale + "&" + urlQuery(); - } - public String display() { return display; } @@ -270,8 +244,6 @@ public static boolean isUnofficial() { private static final String URL_HOST = "http://www.unicode.org/"; public static final String URL_CLDR = URL_HOST + "cldr/"; - public static final String BUG_URL_BASE = CLDRURLS.CLDR_NEWTICKET_URL; - // caution: GENERAL_HELP_URL and GENERAL_HELP_NAME may be used by jsp public static final String GENERAL_HELP_URL = CLDRURLS.GENERAL_HELP_URL; public static final String GENERAL_HELP_NAME = "Instructions"; @@ -470,7 +442,7 @@ public SurveyMain() { /** output MIME header, build context, and run code.. */ @Override public void doPost(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { + throws IOException { doGet(request, response); } @@ -482,8 +454,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) public static String fileBaseASeed; @Override - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { if (respondToBogusRequest(request, response)) { return; } @@ -1476,7 +1447,7 @@ public String getProgress() { /** * Get the current source revision, as HTML * - * @return Called from jsp files as well as locally + *

WARNING: this is accessed by index.jsp and st_footer.jsp */ public static String getCurrev() { return getCurrev(true); @@ -1709,7 +1680,7 @@ private void doUDump(WebContext ctx) { * @param ctx * @param pref which preference * @param what description of preference - *

Called from debug_jsp.jspf as well as locally + *

Called from debug_jsp.jspf */ public boolean showTogglePref(WebContext ctx, String pref, String what) { boolean val = ctx.prefBool(pref); @@ -2127,7 +2098,7 @@ private void doLocale(WebContext ctx, String which, String whyBad) { if (ctx.getLocale() != null) { locale = ctx.getLocale().toString(); } - if ((locale == null) || (locale.length() <= 0)) { + if ((locale == null) || (locale.length() == 0)) { ctx.redirect(ctx.vurl()); return; } else { @@ -2144,7 +2115,7 @@ private void doLocale(WebContext ctx, String which, String whyBad) { * @param menu the ID of the current item * @param title the Title of this menu * @param key the URL field to use (such as 'x') - *

Called by doList and WebContext.showCoverageLevel, and from jsp + *

WARNING: accessed by usermenu.jsp */ public static void printMenu( WebContext ctx, String which, String menu, String title, String key) { @@ -2234,8 +2205,6 @@ void notifyUser(WebContext ctx, String theirEmail, String pass) { MailSender.getInstance().queue(fromId, u.id, subject, body); } - public static final String CHECKCLDR = "CheckCLDR_"; // key for CheckCLDR objects by locale - /** * @param ctx * @param which @@ -2509,7 +2478,7 @@ public boolean isClosed() { return (use == 0); } - public UserLocaleStuff(CLDRLocale locale) { + public UserLocaleStuff() { synchronized (allUserLocaleStuffs) { allUserLocaleStuffs.add(this); } @@ -2520,12 +2489,11 @@ public UserLocaleStuff(CLDRLocale locale) { * Return the UserLocaleStuff for the current context. Any user of this should be within session * sync and must be balanced with calls to close(); * - * @param locale * @see UserLocaleStuff#close() * @see WebContext#getUserFile() */ - public UserLocaleStuff getUserFile(CLDRLocale locale) { - UserLocaleStuff uf = new UserLocaleStuff(locale); // always open a new + public UserLocaleStuff getUserFile() { + UserLocaleStuff uf = new UserLocaleStuff(); // always open a new uf.open(); // incr count. return uf; } @@ -2641,8 +2609,7 @@ private synchronized void checkAllLocales() { d, "//ldml/layout/orientation/characterOrder"); if (directionalityItem != null) { direction = LDMLUtilities.getNodeValue(directionalityItem); - if (direction != null && direction.length() > 0) { - } else { + if (direction == null || direction.length() == 0) { direction = null; } } @@ -3111,81 +3078,6 @@ public synchronized File getVetdir() { return _vetdir; } - public File makeDataDir(String kind) throws IOException { - File vetdir = getVetdir(); - if (vetdir == null) { - throw new InternalError("vetdir is null."); - } - File dataDir = new File(vetdir, kind); - if (!dataDir.exists()) { - if (!dataDir.mkdirs()) { - throw new IOException("Couldn't create " + dataDir.getAbsolutePath()); - } - } - return dataDir; - } - - private File makeDataDir(String kind, CLDRLocale loc) throws IOException { - File dataDir = makeDataDir(kind); // get the parent dir. - - // rest of this function is just to determine which subdir (common or - // seed) - - Factory f = getDiskFactory(); - File sourceDir = f.getSourceDirectoryForLocale(loc.getBaseName()); - - SourceTreeType sourceType = Factory.getSourceTreeType(sourceDir); - DirectoryType dirType = Factory.getDirectoryType(sourceDir); - File subDir = new File(dataDir, sourceType.name()); - if (!subDir.exists()) { - if (!subDir.mkdirs()) { - throw new IOException("Couldn't create " + subDir.getAbsolutePath()); - } - } - File subSubDir = new File(subDir, dirType.name()); - if (!subSubDir.exists()) { - if (!subSubDir.mkdirs()) { - throw new IOException("Couldn't create " + subSubDir.getAbsolutePath()); - } - } - return subSubDir; - } - - /** - * @param kind - * @param loc - * @return - * @throws IOException - *

Called from output-status.jsp - */ - public File getDataDir(String kind, CLDRLocale loc) throws IOException { - return getDataFile(kind, loc).getParentFile(); - } - - private final Map, File> dirToFile = new HashMap<>(); - - /** - * Just get the File. Don't write it. - * - * @param kind - * @param loc - * @return - * @throws IOException - */ - public synchronized File getDataFile(String kind, CLDRLocale loc) throws IOException { - Pair k = new Pair<>(kind, loc); - File f = dirToFile.get(k); - if (f == null) { - f = makeDataFile(kind, loc); - dirToFile.put(k, f); - } - return f; - } - - private File makeDataFile(String kind, CLDRLocale loc) throws IOException { - return new File(makeDataDir(kind, loc), loc + ".xml"); - } - private OutputFileManager outputFileManager = null; public synchronized OutputFileManager getOutputFileManager() { @@ -3264,12 +3156,6 @@ private static File[] getInFiles(File baseDir) { return baseDir.listFiles(myFilter); } - protected static CLDRLocale getLocaleOf(String localeName) { - int dot = localeName.indexOf('.'); - String theLocale = localeName.substring(0, dot); - return CLDRLocale.getInstance(theLocale); - } - private static Set localeListSet = null; private static Set roLocales = null; @@ -3381,16 +3267,6 @@ protected static void busted(String what, Throwable t) { } } - /** - * mark as busted, with no special logging. This is called by the SurveyLog to make sure an out - * of memory marks things as down. - * - * @param t - */ - public static void markBusted(Throwable t) { - markBusted(t.toString(), t, StackTracker.stackToString(t.getStackTrace(), 0)); - } - /** * log that the survey tool is down. * @@ -3659,18 +3535,10 @@ public static String localhost() { // ============= Following have to do with phases - public static boolean isPhaseVetting() { - return phase() == Phase.VETTING; - } - public static boolean isPhaseVettingClosed() { return phase() == Phase.VETTING_CLOSED; } - public static boolean isPhaseClosed() { - return (phase() == Phase.CLOSED) || (phase() == Phase.VETTING_CLOSED); - } - public static boolean isPhaseReadonly() { return phase() == Phase.READONLY; } @@ -3679,10 +3547,6 @@ public static boolean isPhaseBeta() { return phase() == Phase.BETA; } - public static boolean isPhaseFinalTesting() { - return phase() == Phase.FINAL_TESTING; - } - public static Phase phase() { return currentPhase; } @@ -3714,12 +3578,12 @@ public static Date getVotesAfterDate() { } @Override - public void readExternal(ObjectInput arg0) throws IOException, ClassNotFoundException { + public void readExternal(ObjectInput arg0) { STFactory.unimp(); // do not call } @Override - public void writeExternal(ObjectOutput arg0) throws IOException { + public void writeExternal(ObjectOutput arg0) { STFactory.unimp(); // do not call } @@ -3746,29 +3610,29 @@ public JSONObject statusJSON(HttpServletRequest request) throws JSONException { * fields without care. See CLDR-15040 */ private class StatusForFrontEnd implements JSONString { - private String contextPath; - private int dbopen = DBUtils.db_number_open; - private int dbused = DBUtils.db_number_used; - private int observers = CookieSession.getObserverCount(); - private String isBusted = SurveyMain.isBusted; - private boolean isPhaseBeta = isPhaseBeta(); - private boolean isSetup = SurveyMain.isSetup; - private boolean isUnofficial = SurveyMain.isUnofficial(); - private String newVersion = SurveyMain.newVersion; + private final boolean isPhaseBeta = isPhaseBeta(); + private final String contextPath; + private final int dbopen = DBUtils.db_number_open; + private final int dbused = DBUtils.db_number_used; + private final int observers = CookieSession.getObserverCount(); + private final String isBusted = SurveyMain.isBusted; + private final boolean isSetup = SurveyMain.isSetup; + private final boolean isUnofficial = SurveyMain.isUnofficial(); + private final String newVersion = SurveyMain.newVersion; private String organizationName = null; - private int pages = SurveyMain.pages; + private final int pages = SurveyMain.pages; private Object permissions = null; - private Phase phase = phase(); + private final Phase phase = phase(); private String sessionId = null; - private String specialHeader = getSpecialHeaderText(); - private long surveyRunningStamp = SurveyMain.surveyRunningStamp.current(); - private double sysload = osmxbean.getSystemLoadAverage(); - private ElapsedTimer uptime = SurveyMain.uptime; + private final String specialHeader = getSpecialHeaderText(); + private final long surveyRunningStamp = SurveyMain.surveyRunningStamp.current(); + private final double sysload = osmxbean.getSystemLoadAverage(); + private final ElapsedTimer uptime = SurveyMain.uptime; private User user = null; - private int users = CookieSession.getUserCount(); + private final int users = CookieSession.getUserCount(); private String sessionMessage = null; - private Runtime r = Runtime.getRuntime(); + private final Runtime r = Runtime.getRuntime(); double memtotal = r.totalMemory() / 1024000.0; double memfree = r.freeMemory() / 1024000.0; diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java index 3a79f2ad6e3..00e747f0e42 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java @@ -99,9 +99,6 @@ private synchronized void notify(User u) { /** Anonymous user - special for imported old losing votes */ public static final int ANONYMOUS = VoteResolver.Level.anonymous.getSTLevel(); - /** min level */ - public static final int NO_LEVEL = -1; - /** special "IP" value referring to a user being added */ public static final String FOR_ADDING = "(for adding)"; @@ -278,6 +275,7 @@ public String toHtml(User forUser) { } } + // WARNING: this is accessed by admin-usersWithOldVotes.jsp public String toHtml() { return "WARNING: this is accessed by st_footer.jsp */ public Map getParameterMap() { return request.getParameterMap(); @@ -117,10 +116,8 @@ public WebContext(HttpServletRequest irq, HttpServletResponse irs) throws IOExce * * @param irq * @param irs - * @throws IOException */ - protected void setRequestResponse(HttpServletRequest irq, HttpServletResponse irs) - throws IOException { + protected void setRequestResponse(HttpServletRequest irq, HttpServletResponse irs) { request = irq; response = irs; // register us - only if another webcontext is not already registered. @@ -156,10 +153,10 @@ protected void setStream(Writer w) { * @param response * @param out * @return the new WebContext, which was cloned from the one posted to the Request - * @throws IOException + *

WARNING: this is accessed by stcontext.jspf */ public static JspWebContext fromRequest( - ServletRequest request, ServletResponse response, Writer out) throws IOException { + ServletRequest request, ServletResponse response, Writer out) { WebContext ctx = (WebContext) request.getAttribute(CLDR_WEBCONTEXT); if (ctx == null) { throw new InternalError( @@ -205,16 +202,6 @@ boolean fieldBool(String x, boolean def) { } } - /** - * get a field's value as an integer, or -1 if not found - * - * @param x field name - * @return the field's value as an integer, or -1 if it was not found - */ - public final int fieldInt(String x) { - return fieldInt(x, -1); - } - /** * get a field's value, or the default * @@ -329,7 +316,7 @@ String pref(String x, String def) { if (ret != null) { session.prefPut(x, ret); } - if ((ret == null) || (ret.length() <= 0)) { + if ((ret == null) || (ret.length() == 0)) { ret = def; } return ret; @@ -349,16 +336,6 @@ public String atarget(String t) { } } - /** - * Get the target keyword and value for an 'a href' HTML tag on TARGET_ZOOMED - * - * @return the 'target=...' string - may be blank if the user has requested no popups - * @see #TARGET_ZOOMED - */ - public String atarget() { - return atarget(TARGET_ZOOMED); - } - /** * Add a parameter to the output URL * @@ -410,6 +387,7 @@ public void setQuery(String k, String v) { * * @param k * @param v + *

WARNING: this is accessed by debug_jsp.jspf and report.jspf */ public void setQuery(String k, int v) { setQuery(k, Integer.toString(v)); @@ -478,7 +456,7 @@ public String base() { } } - // caution: maybe used by *.jsp + // WARNING: this is accessed by st_top.jsp public String vurl(CLDRLocale loc) { return vurl(loc, null, null, null); } @@ -607,21 +585,6 @@ public String jspLink(String s) { : ((session != null) ? ("&s=" + session.id) : "")); } - /** - * Get a link (Text URL) to a JSP - * - * @param s resource to link to - * @return the URL suitable for Text - */ - public String jspUrl(String s) { - return context(s) - + "?a=" - + base() - + ((outQuery != null) - ? ("&" + outQuery) - : ((session != null) ? ("&s=" + session.id) : "")); - } - /** * return the IP of the remote user. If they are behind a proxy, return the actual original URL. * @@ -751,7 +714,7 @@ void print(Throwable t) { /** * Send the user to another URL. Won't work if there was already some output. * - * @param where + * @param where the URL for redirection, such as "/cldr-apps/v#//" * @see HttpServletResponse#sendRedirect(String) */ void redirect(String where) { @@ -764,11 +727,7 @@ void redirect(String where) { } } - /** - * Close the stream. Normally not called directly, except in outermost processor. - * - * @throws IOException - */ + /** Close the stream. Normally not called directly, except in outermost processor. */ void close() throws IOException { if (!dontCloseMe) { out.close(); @@ -840,27 +799,7 @@ public final String localeString() { return locale.toString(); } - /** Print the coverage level for a certain locale. */ - public void showCoverageLevel() { - String itsLevel = getEffectiveCoverageLevel(); - String recLevel = getRecommendedCoverageLevel(); - String def = getRequiredCoverageLevel(); - if (def.equals(COVLEV_RECOMMENDED)) { - print("Coverage Level: " + itsLevel + "
"); - } else { - print( - "Coverage Level: " - + def - + " (overriding " - + itsLevel - + ")
"); - } - print("Recommended level: " + recLevel + "
"); - print("

"); - } - + // WARNING: this is accessed by menu_top.jsp and possibleProblems.jsp public String getEffectiveCoverageLevel(CLDRLocale locale) { return getEffectiveCoverageLevel(locale.getBaseName()); } @@ -874,24 +813,6 @@ public String getEffectiveCoverageLevel(String locale) { return level; } - public String getRecommendedCoverageLevel() { - String myOrg = session.getUserOrg(); - if (!isCoverageOrganization(myOrg)) { - return COVLEV_DEFAULT_RECOMMENDED_STRING; - } else { - CLDRLocale loc = getLocale(); - if (loc != null) { - Level lev = StandardCodes.make().getLocaleCoverageLevel(myOrg, loc.toString()); - if (lev == Level.UNDETERMINED) { - lev = COVLEVEL_DEFAULT_RECOMMENDED; - } - return lev.toString(); - } else { - return COVLEVEL_DEFAULT_RECOMMENDED.toString(); - } - } - } - public static final String COVLEV_RECOMMENDED = "default"; public static final String[] PREF_COVLEV_LIST = { COVLEV_RECOMMENDED, @@ -920,21 +841,7 @@ public static boolean isCoverageOrganization(String org) { .contains(org.toLowerCase())); } - /** - * Append the WebContext Options map to the specified map - * - * @return the map - */ - public CheckCLDR.Options getOptionsMap() { - String def = getRequiredCoverageLevel(); - String org = getEffectiveCoverageLevel(); - - return new CheckCLDR.Options(getLocale(), SurveyMain.getTestPhase(), def, org); - } - - /** - * @return - */ + // WARNING: this is accessed by possibleProblems.jsp public String getEffectiveCoverageLevel() { return getEffectiveCoverageLevel(getLocale().toString()); } @@ -946,10 +853,11 @@ public String getRequiredCoverageLevel() { // Internal Utils public static final String CAN_MODIFY = "canModify"; - public static final String DATA_PAGE = "DataPage"; - public static final String ZOOMED_IN = "zoomedIn"; - public static final String DATA_ROW = "DataRow"; - public static final String BASE_EXAMPLE = "baseExample"; + public static final String DATA_PAGE = + "DataPage"; // WARNING: this is accessed by stcontext.jspf + public static final String ZOOMED_IN = + "zoomedIn"; // WARNING: this is accessed by stcontext.jspf + public static final String DATA_ROW = "DataRow"; // WARNING: this is accessed by stcontext.jspf /** * Print a link to help with a specified title @@ -958,36 +866,9 @@ public String getRequiredCoverageLevel() { * @param title the title of the help */ public void printHelpLink(String what, String title) { - printHelpLink(what, title, true); - } - - /** - * @param what - * @param title - * @param doEdit - * @deprecated editing is deprecated - */ - @Deprecated - public void printHelpLink(String what, String title, boolean doEdit) { - printHelpLink(what, title, doEdit, true); - } - - /** - * @deprecated editing is deprecated - * @param what - * @param title - * @param doEdit - * @param parens - */ - @Deprecated - private void printHelpLink(String what, String title, boolean doEdit, boolean parens) { - if (parens) { - print("("); - } + print("("); print("" + title + ""); - if (parens) { - println(")"); - } + println(")"); } /** @@ -1090,8 +971,6 @@ public void includeFragment(String filename) { * @param request * @param response * @param filename - * @throws ServletException - * @throws IOException , NullPointerException */ public static void includeFragment( HttpServletRequest request, HttpServletResponse response, String filename) @@ -1199,7 +1078,7 @@ public Boolean canModify() { public SurveyMain.UserLocaleStuff getUserFile() { SurveyMain.UserLocaleStuff uf = peekUserFile(); if (uf == null) { - uf = sm.getUserFile(getLocale()); + uf = sm.getUserFile(); put("UserFile", uf); } return uf; @@ -1254,7 +1133,7 @@ private User user() { * Get a certain cookie * * @param id - * @return + * @return WARNING: this is accessed by usermenu.jsp */ public Cookie getCookie(String id) { return getCookie(request, id); @@ -1296,23 +1175,11 @@ public static String getCookieValue(HttpServletRequest hreq, String id) { return null; } - /** - * Set a cookie - * - * @param id - * @param value - * @param expiry - */ - Cookie addCookie(String id, String value, int expiry) { - return addCookie(response, id, value, expiry); - } - - static Cookie addCookie(HttpServletResponse response, String id, String value, int expiry) { + static void addCookie(HttpServletResponse response, String id, String value, int expiry) { Cookie c = new Cookie(id, value); c.setMaxAge(expiry); c.setPath("/"); response.addCookie(c); - return c; } /** @@ -1390,6 +1257,7 @@ String urlForLocale(CLDRLocale locale) { return vurl(locale, null, null, null); } + // WARNING: this is accessed by generalinfo.jsp and st_top.jsp public String getLocaleDisplayName(String loc) { return getLocaleDisplayName(CLDRLocale.getInstance(loc)); } @@ -1465,8 +1333,7 @@ public void setSession() { User jwtInfo = CookieSession.sm.reg.getInfo(Integer.parseInt(jwtId)); if (jwtInfo != null) { user = jwtInfo; - logger.fine( - "Logged in " + jwtInfo.toString() + " #" + jwtId + " using JWT"); + logger.fine("Logged in " + jwtInfo + " #" + jwtId + " using JWT"); } } } @@ -1538,43 +1405,43 @@ public void setSession() { logger.fine("Session Now=" + session + ", user=" + user); - // guest? - if (UserRegistry.userIsTC(user)) { - // allow in administrator or TC. - } else if ((user != null) && (session == null)) { // user trying to log in- - if (CookieSession.tooManyUsers()) { - System.err.println( - "Refused login for " - + email - + " from " - + userIP() - + " - too many users ( " - + CookieSession.getUserCount() - + ")"); - setSessionMessage( - "We are swamped with about " - + CookieSession.getUserCount() - + " people using the SurveyTool right now! Please try back in a little while."); - return; - } - } else if (session == null || (session.user == null)) { // guest user - if (CookieSession.tooManyObservers()) { - if (session != null) { + // allow in administrator or TC. + if (!UserRegistry.userIsTC(user)) { + if ((user != null) && (session == null)) { // user trying to log in- + if (CookieSession.tooManyUsers()) { System.err.println( - "Logged-out observer " - + session.id + "Refused login for " + + email + " from " + userIP() + " - too many users ( " + CookieSession.getUserCount() + ")"); - session.remove(); // remove observers at this point - session = null; + setSessionMessage( + "We are swamped with about " + + CookieSession.getUserCount() + + " people using the SurveyTool right now! Please try back in a little while."); + return; + } + } else if (session == null || (session.user == null)) { // guest user + if (CookieSession.tooManyObservers()) { + if (session != null) { + System.err.println( + "Logged-out observer " + + session.id + + " from " + + userIP() + + " - too many users ( " + + CookieSession.getUserCount() + + ")"); + session.remove(); // remove observers at this point + session = null; + } + logout(); // clear session cookie + setSessionMessage( + "We have too many people browsing the CLDR Data on the Survey Tool. Please try again later when the load has gone down."); + return; } - logout(); // clear session cookie - setSessionMessage( - "We have too many people browsing the CLDR Data on the Survey Tool. Please try again later when the load has gone down."); - return; } }