|
41 | 41 | import java.net.URLDecoder;
|
42 | 42 | import java.net.URLEncoder;
|
43 | 43 | import java.nio.charset.StandardCharsets;
|
44 |
| -import java.sql.Date; |
45 | 44 | import java.text.DecimalFormat;
|
46 | 45 | import java.text.NumberFormat;
|
47 |
| -import java.text.SimpleDateFormat; |
48 |
| -import java.util.ArrayList; |
49 |
| -import java.util.Arrays; |
50 | 46 | import java.util.Collection;
|
51 | 47 | import java.util.HashMap;
|
52 | 48 | import java.util.LinkedList;
|
53 | 49 | import java.util.List;
|
54 | 50 | import java.util.Locale;
|
55 | 51 | import java.util.Map;
|
56 | 52 | import java.util.Map.Entry;
|
57 |
| -import java.util.SortedSet; |
58 | 53 | import java.util.TreeMap;
|
59 | 54 | import java.util.function.Function;
|
60 | 55 | import java.util.logging.Level;
|
|
63 | 58 | import java.util.regex.Pattern;
|
64 | 59 | import java.util.zip.GZIPInputStream;
|
65 | 60 | import javax.servlet.http.HttpServletRequest;
|
66 |
| -import org.json.simple.JSONArray; |
67 |
| -import org.json.simple.JSONObject; |
68 |
| -import org.opengrok.indexer.configuration.Group; |
69 |
| -import org.opengrok.indexer.configuration.Project; |
70 | 61 | import org.opengrok.indexer.configuration.RuntimeEnvironment;
|
71 | 62 | import org.opengrok.indexer.history.Annotation;
|
72 | 63 | import org.opengrok.indexer.history.HistoryException;
|
73 | 64 | import org.opengrok.indexer.history.HistoryGuru;
|
74 | 65 | import org.opengrok.indexer.logger.LoggerFactory;
|
75 |
| -import org.opengrok.indexer.web.messages.MessagesContainer.AcceptedMessage; |
76 | 66 |
|
77 | 67 | import static org.opengrok.indexer.index.Indexer.PATH_SEPARATOR;
|
78 | 68 |
|
@@ -1264,203 +1254,6 @@ public static void dumpXref(Writer out, Reader in, String contextPath)
|
1264 | 1254 | }
|
1265 | 1255 | }
|
1266 | 1256 |
|
1267 |
| - /** |
1268 |
| - * Print list of messages into output |
1269 |
| - * |
1270 |
| - * @param out output |
1271 |
| - * @param set set of messages |
1272 |
| - */ |
1273 |
| - public static void printMessages(Writer out, SortedSet<AcceptedMessage> set) { |
1274 |
| - printMessages(out, set, false); |
1275 |
| - } |
1276 |
| - |
1277 |
| - /** |
1278 |
| - * Print set of messages into output |
1279 |
| - * |
1280 |
| - * @param out output |
1281 |
| - * @param set set of messages |
1282 |
| - * @param limited if the container should be limited |
1283 |
| - */ |
1284 |
| - public static void printMessages(Writer out, SortedSet<AcceptedMessage> set, boolean limited) { |
1285 |
| - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); |
1286 |
| - if (!set.isEmpty()) { |
1287 |
| - try { |
1288 |
| - out.write("<ul class=\"message-group"); |
1289 |
| - if (limited) { |
1290 |
| - out.write(" limited"); |
1291 |
| - } |
1292 |
| - out.write("\">\n"); |
1293 |
| - for (AcceptedMessage m : set) { |
1294 |
| - out.write("<li class=\"message-group-item "); |
1295 |
| - out.write(Util.encode(m.getMessage().getCssClass())); |
1296 |
| - out.write("\" title=\"Expires on "); |
1297 |
| - out.write(Util.encode(df.format(Date.from(m.getExpirationTime())))); |
1298 |
| - out.write("\">"); |
1299 |
| - out.write(Util.encode(df.format(Date.from(m.getAcceptedTime())))); |
1300 |
| - out.write(": "); |
1301 |
| - out.write(m.getMessage().getText()); |
1302 |
| - out.write("</li>"); |
1303 |
| - } |
1304 |
| - out.write("</ul>"); |
1305 |
| - } catch (IOException ex) { |
1306 |
| - LOGGER.log(Level.WARNING, |
1307 |
| - "An error occurred for a group of messages", ex); |
1308 |
| - } |
1309 |
| - } |
1310 |
| - } |
1311 |
| - |
1312 |
| - /** |
1313 |
| - * Print set of messages into json array |
1314 |
| - * |
1315 |
| - * @param set set of messages |
1316 |
| - * @return json array containing the set of messages |
1317 |
| - */ |
1318 |
| - @SuppressWarnings("unchecked") |
1319 |
| - public static JSONArray messagesToJson(SortedSet<AcceptedMessage> set) { |
1320 |
| - JSONArray array = new JSONArray(); |
1321 |
| - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); |
1322 |
| - for (AcceptedMessage m : set) { |
1323 |
| - JSONObject message = new JSONObject(); |
1324 |
| - message.put("class", Util.encode(m.getMessage().getCssClass())); |
1325 |
| - message.put("expiration", Util.encode(df.format(Date.from(m.getExpirationTime())))); |
1326 |
| - message.put("created", Util.encode(df.format(Date.from(m.getAcceptedTime())))); |
1327 |
| - message.put("text", Util.encode(m.getMessage().getText())); |
1328 |
| - JSONArray tags = new JSONArray(); |
1329 |
| - for (String t : m.getMessage().getTags()) { |
1330 |
| - tags.add(Util.encode(t)); |
1331 |
| - } |
1332 |
| - message.put("tags", tags); |
1333 |
| - array.add(message); |
1334 |
| - } |
1335 |
| - return array; |
1336 |
| - } |
1337 |
| - |
1338 |
| - /** |
1339 |
| - * Print set of messages into json object for given tag. |
1340 |
| - * |
1341 |
| - * @param tag return messages in json format for the given tag |
1342 |
| - * @return json object with 'tag' and 'messages' attribute or null |
1343 |
| - */ |
1344 |
| - @SuppressWarnings("unchecked") |
1345 |
| - public static JSONObject messagesToJsonObject(String tag) { |
1346 |
| - SortedSet<AcceptedMessage> messages = RuntimeEnvironment.getInstance().getMessages(tag); |
1347 |
| - if (messages.isEmpty()) { |
1348 |
| - return null; |
1349 |
| - } |
1350 |
| - JSONObject toRet = new JSONObject(); |
1351 |
| - toRet.put("tag", tag); |
1352 |
| - toRet.put("messages", messagesToJson(messages)); |
1353 |
| - return toRet; |
1354 |
| - } |
1355 |
| - |
1356 |
| - /** |
1357 |
| - * Print messages for given tags into json array |
1358 |
| - * |
1359 |
| - * @param array the array where the result should be stored |
1360 |
| - * @param tags list of tags |
1361 |
| - * @return json array of the messages (the same as the parameter) |
1362 |
| - * @see #messagesToJsonObject(String) |
1363 |
| - */ |
1364 |
| - @SuppressWarnings("unchecked") |
1365 |
| - public static JSONArray messagesToJson(JSONArray array, String... tags) { |
1366 |
| - array = array == null ? new JSONArray() : array; |
1367 |
| - for (String tag : tags) { |
1368 |
| - JSONObject messages = messagesToJsonObject(tag); |
1369 |
| - if (messages == null || messages.isEmpty()) { |
1370 |
| - continue; |
1371 |
| - } |
1372 |
| - array.add(messages); |
1373 |
| - } |
1374 |
| - return array; |
1375 |
| - } |
1376 |
| - |
1377 |
| - /** |
1378 |
| - * Print messages for given tags into json array |
1379 |
| - * |
1380 |
| - * @param tags list of tags |
1381 |
| - * @return json array of the messages |
1382 |
| - * @see #messagesToJson(JSONArray, String...) |
1383 |
| - * @see #messagesToJsonObject(String) |
1384 |
| - */ |
1385 |
| - public static JSONArray messagesToJson(String... tags) { |
1386 |
| - return messagesToJson((JSONArray) null, tags); |
1387 |
| - } |
1388 |
| - |
1389 |
| - /** |
1390 |
| - * Print messages for given tags into json array |
1391 |
| - * |
1392 |
| - * @param tags list of tags |
1393 |
| - * @return json array of the messages |
1394 |
| - * @see #messagesToJson(String...) |
1395 |
| - * @see #messagesToJsonObject(String) |
1396 |
| - */ |
1397 |
| - public static JSONArray messagesToJson(List<String> tags) { |
1398 |
| - String[] array = new String[tags.size()]; |
1399 |
| - return messagesToJson(tags.toArray(array)); |
1400 |
| - } |
1401 |
| - |
1402 |
| - /** |
1403 |
| - * Print messages for given project into json array. These messages are |
1404 |
| - * tagged by project description or tagged by any of the project's group |
1405 |
| - * name. |
1406 |
| - * |
1407 |
| - * @param project the project |
1408 |
| - * @param additionalTags additional list of tags |
1409 |
| - * @return the json array |
1410 |
| - * @see #messagesToJson(String...) |
1411 |
| - */ |
1412 |
| - public static JSONArray messagesToJson(Project project, String... additionalTags) { |
1413 |
| - if (project == null) { |
1414 |
| - return new JSONArray(); |
1415 |
| - } |
1416 |
| - List<String> tags = new ArrayList<>(); |
1417 |
| - tags.addAll(Arrays.asList(additionalTags)); |
1418 |
| - tags.add(project.getName()); |
1419 |
| - project.getGroups().stream().forEach((Group t) -> { |
1420 |
| - tags.add(t.getName()); |
1421 |
| - }); |
1422 |
| - return messagesToJson(tags); |
1423 |
| - } |
1424 |
| - |
1425 |
| - /** |
1426 |
| - * Print messages for given project into json array. These messages are |
1427 |
| - * tagged by project description or tagged by any of the project's group |
1428 |
| - * name |
1429 |
| - * |
1430 |
| - * @param project the project |
1431 |
| - * @return the json array |
1432 |
| - * @see #messagesToJson(Project, String...) |
1433 |
| - */ |
1434 |
| - public static JSONArray messagesToJson(Project project) { |
1435 |
| - return messagesToJson(project, new String[0]); |
1436 |
| - } |
1437 |
| - |
1438 |
| - /** |
1439 |
| - * Print messages for given group into json array. |
1440 |
| - * |
1441 |
| - * @param group the group |
1442 |
| - * @param additionalTags additional list of tags |
1443 |
| - * @return the json array |
1444 |
| - * @see #messagesToJson(java.util.List) |
1445 |
| - */ |
1446 |
| - public static JSONArray messagesToJson(Group group, String... additionalTags) { |
1447 |
| - List<String> tags = new ArrayList<>(); |
1448 |
| - tags.add(group.getName()); |
1449 |
| - tags.addAll(Arrays.asList(additionalTags)); |
1450 |
| - return messagesToJson(tags); |
1451 |
| - } |
1452 |
| - |
1453 |
| - /** |
1454 |
| - * Print messages for given group into json array. |
1455 |
| - * |
1456 |
| - * @param group the group |
1457 |
| - * @return the json array |
1458 |
| - * @see #messagesToJson(Group, String...) |
1459 |
| - */ |
1460 |
| - public static JSONArray messagesToJson(Group group) { |
1461 |
| - return messagesToJson(group, new String[0]); |
1462 |
| - } |
1463 |
| - |
1464 | 1257 | /**
|
1465 | 1258 | * Print a row in an HTML table.
|
1466 | 1259 | *
|
|
0 commit comments