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 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(
@@ -188,6 +185,7 @@ public WebContext(WebContext other) {
throw new InternalError("Can't slice a URLWebContext - use clone()");
}
init(other);
+ throw new RuntimeException("Double-plus ungood WebContext!");
}
/**
@@ -205,16 +203,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 +317,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 +337,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 +388,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 +457,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 +586,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,12 +715,22 @@ 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) {
try {
- response.sendRedirect(where);
+ final boolean HARD_CODE_REDIRECT_PORT = true;
+ if (HARD_CODE_REDIRECT_PORT) {
+ String port = "8888"; // request.getServerPort()
+ String directUrl =
+ request.getScheme() + "://" + request.getServerName() + ":" + port + where;
+ System.out.println("Sending redirect to directUrl = " + directUrl);
+ response.sendRedirect(directUrl);
+ } else {
+ System.out.println("Sending redirect to where = " + where);
+ response.sendRedirect(where);
+ }
out.close();
close();
} catch (IOException ioe) {
@@ -764,11 +738,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 +810,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("