@Test
 public void testGetForumTopicsTags() throws Exception {
   EntityList<Forum> forums = forumService.getPublicForums();
   Forum forum = (Forum) forums.get(0);
   EntityList<Tag> entries = forumService.getForumTopicsTags(forum.getForumUuid());
   assertNotNull(entries);
   for (Tag tag : entries) {
     assertValid(tag);
   }
 }
Пример #2
0
 @Test
 public void newTopic() {
   Forum test = new Forum("Test", "Yop");
   User guillaume = User.find("byName", "Guillaume").first();
   test.newTopic(guillaume, "Hello", "Yop ...");
   assertEquals(2L, (long) guillaume.getTopicsCount());
   assertEquals(1, test.topics.size());
   assertEquals(1, test.getTopicsCount());
   assertEquals(5, Topic.count());
 }
Пример #3
0
 @Test
 public void testCascadeDelete() {
   Forum help = Forum.find("byName", "Play help").first();
   assertEquals(4, Topic.count());
   assertEquals(7, Post.count());
   help.delete();
   assertEquals(1, Topic.count());
   assertEquals(1, Post.count());
   User guillaume = User.find("byName", "Guillaume").first();
   assertEquals(0L, (long) guillaume.getTopicsCount());
 }
Пример #4
0
 @SecureAdmin
 public static void create(Long forumId, @Required String subject, String content) {
   if (validation.hasErrors()) {
     validation.keep();
     params.flash();
     flash.error("Please correct these errors !");
     post(forumId);
   }
   Forum forum = Forum.findById(forumId);
   notFoundIfNull(forum);
   Topic newTopic = forum.newTopic(connectedUser(), subject, content);
   show(forumId, newTopic.id, null);
 }
Пример #5
0
  public void deleteMe(Forum f) {
    TopicBBSManager.getInstance().delTopic(this);
    f.rmTopicByID(getID());

    try (Connection con = L2DatabaseFactory.getInstance().getConnection()) {
      PreparedStatement statement =
          con.prepareStatement("DELETE FROM topic WHERE topic_id=? AND topic_forum_id=?");
      statement.setInt(1, getID());
      statement.setInt(2, f.getID());
      statement.execute();
      statement.close();
    } catch (Exception e) {
      _log.log(Level.WARNING, "Error while deleting topic: " + e.getMessage(), e);
    }
  }
Пример #6
0
 private Forum[] getSubForums(JSONArray array) {
   Forum[] subForums = new Forum[array.length()];
   for (int i = 0; i < array.length(); i++) {
     try {
       JSONObject e = array.getJSONObject(i);
       Forum forum = new Forum();
       forum.id = e.getInt("id");
       forum.name = e.getString("name");
       if (e.has("viewing")) forum.viewers = e.getInt("viewing");
       if (e.has("forums")) forum.forums = getSubForums(e.getJSONArray("forums"));
       subForums[i] = forum;
     } catch (JSONException e) {
       Log.e("JSONException", e.toString());
     }
   }
   return subForums;
 }
Пример #7
0
 private String executeApiQuery(String entity, String method, String content) {
   String result = null;
   switch (entity) {
     case "forum":
       result = forum.exec(method, content);
       break;
     case "post":
       result = post.exec(method, content);
       break;
     case "user":
       result = user.exec(method, content);
       break;
     case "thread":
       result = thread.exec(method, content);
       break;
     case "util":
       result = utils.exec(method, content);
       break;
   }
   if (result != null) return result;
   else return ERROR;
 }
Пример #8
0
 @SecureAdmin
 public static void post(Long forumId) {
   Forum forum = Forum.findById(forumId);
   notFoundIfNull(forum);
   render(forum);
 }