コード例 #1
0
  /**
   * Creates a new user account in bibsonomy.
   *
   * @param user the user to be created
   * @throws IllegalArgumentException if the user is null or the user has neither username nor
   *     password specified.
   */
  public CreateUserQuery(final User user) throws IllegalArgumentException {
    if (!present(user)) throw new IllegalArgumentException("no user specified");
    if (!present(user.getName())) throw new IllegalArgumentException("no username specified");
    if (!present(user.getPassword())) throw new IllegalArgumentException("no password specified");

    this.user = user;
  }
  @Override
  public View workOn(AjaxRecommenderCommand<R> command) {
    final RequestWrapperContext context = command.getContext();

    /*
     * only users which are logged in might post bookmarks -> send them to
     * login page
     */
    if (!context.isUserLoggedIn()) {
      command.setResponseString("");
      return Views.AJAX_XML;
    }

    final User loginUser = context.getLoginUser();

    // ------------------------------------------------------------------------
    // THIS IS AN ISSUE WE STILL HAVE TO DISCUSS:
    // During the ECML/PKDD recommender challenge, many recommender systems
    // couldn't deal with the high load, so we filter out those users, which
    // are flagged as spammer either by an admin, or by the framework for sure
    // TODO: we could probably also filter out those users, which are
    //       flagged as 'spammer unsure'
    // ------------------------------------------------------------------------
    final User dbUser = adminLogic.getUserDetails(loginUser.getName());

    /*
     * set the user of the post to the loginUser (the recommender might need
     * the user name)
     */
    command.getPost().setUser(loginUser);

    /*
     * initialize groups
     */
    GroupingCommandUtils.initGroups(command, command.getPost().getGroups());

    // set postID for recommender
    command.getPost().setContentId(command.getPostID());

    if ((dbUser.isSpammer())
        && ((dbUser.getPrediction() == null && dbUser.getAlgorithm() == null)
            || (dbUser.getPrediction().equals(1)
                || dbUser.getAlgorithm().equals(USERSPAMALGORITHM)))) {
      // the user is a spammer
      log.debug("Filtering out recommendation request from spammer");
      if (this.getSpamTagRecommender() != null) {
        SortedSet<RecommendedTag> result =
            this.getSpamTagRecommender().getRecommendedTags(command.getPost());
        this.processRecommendedTags(command, result);
      } else {
        command.setResponseString("");
      }
    } else {
      // the user doesn't seem to be a spammer
      /*
       * get the recommended tags for the post from the command
       */
      if (this.getTagRecommender() != null) {
        SortedSet<RecommendedTag> result =
            this.getTagRecommender().getRecommendedTags(command.getPost(), command.getPostID());
        this.processRecommendedTags(command, result);
      } else {
        command.setResponseString("");
      }
    }

    return Views.AJAX_XML;
  }