Ejemplo n.º 1
0
  private Topic createdTopic(String owner) {
    Topic topicNew = new Topic();

    topicNew.setOwner(owner);
    topicNew.setTopicName("TestTopic");
    topicNew.setCreatedDate(new Date());
    topicNew.setModifiedBy("root");
    topicNew.setModifiedDate(new Date());
    topicNew.setLastPostBy("root");
    topicNew.setLastPostDate(new Date());
    topicNew.setDescription("Topic description");
    topicNew.setPostCount(0);
    topicNew.setViewCount(0);
    topicNew.setIsNotifyWhenAddPost("");
    topicNew.setIsModeratePost(false);
    topicNew.setIsClosed(false);
    topicNew.setIsLock(false);
    topicNew.setIsWaiting(false);
    topicNew.setIsActive(true);
    topicNew.setIcon("classNameIcon");
    topicNew.setIsApproved(true);
    topicNew.setCanView(new String[] {});
    topicNew.setCanPost(new String[] {});
    return topicNew;
  }
Ejemplo n.º 2
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.");
  }
Ejemplo n.º 3
0
  @Override
  public void inject(HashMap<String, String> params) throws Exception {

    //
    int number = param(params, NUMBER);
    String topicPrefix = params.get(TOPIC_PREFIX);

    //
    int fromUser = param(params, FROM_USER);
    int toUser = param(params, TO_USER);
    String userPrefix = params.get(USER_PREFIX);

    //
    int toForum = param(params, TO_FORUM);
    String forumPrefix = params.get(FORUM_PREFIX);
    init(userPrefix, null, forumPrefix, topicPrefix, null, 0);

    String forumName = forumBase + toForum;
    Forum forum = getForumByName(forumName);
    if (forum == null) {
      getLog()
          .info(
              "forum name is '"
                  + forumName
                  + "' wrong. Please set it exactly. Aborting injection ...");
      return;
    }

    Category cat = getCategoryByForumName(forumName);

    //
    for (int i = fromUser; i <= toUser; ++i) {
      String owner = userBase + i;

      //
      for (int j = 0; j < number; ++j) {
        String topicName = topicName();

        Topic topicNew = new Topic();

        topicNew.setOwner(owner);
        topicNew.setTopicName(topicName);
        topicNew.setCreatedDate(new Date());
        topicNew.setModifiedBy(owner);
        topicNew.setModifiedDate(new Date());
        topicNew.setLastPostBy(owner);
        topicNew.setLastPostDate(new Date());
        topicNew.setDescription(lorem.getParagraphs());
        topicNew.setPostCount(0);
        topicNew.setViewCount(0);
        topicNew.setIsNotifyWhenAddPost("");
        topicNew.setIsModeratePost(false);
        topicNew.setIsClosed(false);
        topicNew.setIsLock(false);
        topicNew.setIsWaiting(false);
        topicNew.setIsActive(true);
        topicNew.setIcon("classNameIcon");
        topicNew.setIsApproved(true);
        topicNew.setCanView(new String[] {});
        topicNew.setCanPost(new String[] {});

        //
        forumService.saveTopic(
            cat.getId(), forum.getId(), topicNew, true, false, new MessageBuilder());
        ++topicNumber;
        //
        getLog().info("Topic '" + topicName + "' in forum '" + forumName + "' created by " + owner);
      }
    }
  }