Пример #1
0
  private void injectTopic() throws Exception {
    //
    String topicName = topicBase + toType;
    Topic topic = getTopicByName(topicName);
    if (topic == null) {
      getLog()
          .info(
              "topic name is '"
                  + topicName
                  + "' is wrong. Please set it exactly. Aborting injection ...");
      return;
    }
    Forum forum = getForumByTopicName(topicName);
    Category cat = getCategoryByForumName(forum.getForumName());

    //
    String[] userNames = getUserNames();
    if (userNames == null | userNames.length <= 0) {
      getLog()
          .info(
              "Don't assign permission any user to '"
                  + topicName
                  + "' topic. Please set it exactly. Aborting injection ...");
      return;
    }

    //
    topic = forumService.getTopic(cat.getId(), forum.getId(), topic.getId(), null);
    topic.setCanPost(userNames);
    topic.setCanView(userNames);
    topic.setEmailNotification(userNames);
    forumService.saveTopic(cat.getId(), forum.getId(), topic, false, false, new MessageBuilder());
    getLog()
        .info(
            "Assign permission '"
                + Arrays.toString(userNames)
                + "' user(s) into '"
                + topicName
                + "' topic in '"
                + forum.getForumName()
                + "' forum.");
  }