Example #1
0
 public String getDirectoryName() {
   final ApplicationUser user = getApplicationUser();
   if (userManager.isUserExisting(user)) {
     return crowdDirectoryService.findDirectoryById(user.getDirectoryId()).getName();
   }
   return "???";
 }
 @SuppressWarnings("unused") // Used in bulkeditusergroups.jsp
 public Collection<ApplicationUser> getUsersToAssignToTheMultiSelect() {
   final Collection<ApplicationUser> users = new ArrayList<ApplicationUser>();
   for (String username : getUsersToAssign()) {
     users.add(userManager.getUserByName(username));
   }
   return users;
 }
 @Override
 public Comment create(
     Issue issue,
     String author,
     String updateAuthor,
     String body,
     String groupLevel,
     Long roleLevelId,
     Date created,
     Date updated,
     boolean dispatchEvent) {
   return create(
       issue,
       userManager.getUserByKeyEvenWhenUnknown(author),
       userManager.getUserByKeyEvenWhenUnknown(updateAuthor),
       body,
       groupLevel,
       roleLevelId,
       created,
       updated,
       dispatchEvent);
 }
  public ErrorCollection validateDetails(HandlerDetailsModel details) {
    final SimpleErrorCollection errorCollection = new SimpleErrorCollection();
    final I18nHelper i18nHelper = authenticationContext.getI18nHelper();

    if (details.isCreateusers()) {
      // Check that the default reporter is NOT configured
      // As if it is configured and creating users is set to true,
      // it is ambiguous whether to create a new user or use the default reporter
      final boolean extUserMgmt = !userManager.hasWritableDirectory();
      if (StringUtils.isNotBlank(details.getReporterusername())) {
        if (extUserMgmt) {
          errorCollection.addError(
              "createusers", i18nHelper.getText("jmp.editHandlerDetails.error.external.user"));
        } else {
          errorCollection.addError(
              "reporterusername",
              i18nHelper.getText("jmp.editHandlerDetails.create.users.is.enabled"));
        }
      } else if (extUserMgmt) {
        errorCollection.addError(
            "createusers", i18nHelper.getText("jmp.editHandlerDetails.cant.create.users"));
      }
    }

    if (StringUtils.isNotBlank(details.getReporterusername())
        && !userUtil.userExists(details.getReporterusername())) {
      errorCollection.addError(
          "reporterusername", i18nHelper.getText("admin.errors.users.user.does.not.exist"));
    }

    if (StringUtils.isNotBlank(details.getCatchemail())
        && !TextUtils.verifyEmail(TextUtils.noNull(details.getCatchemail()).trim())) {
      errorCollection.addError("catchemail", i18nHelper.getText("admin.errors.invalid.email"));
    }

    if ("forward".equals(details.getBulk()) && StringUtils.isBlank(details.getForwardEmail())) {
      errorCollection.addError(
          "bulk", i18nHelper.getText("jmp.editHandlerDetails.forwardEmail.is.not.set"));
    }

    if (StringUtils.isNotBlank(details.getForwardEmail())
        && !TextUtils.verifyEmail(TextUtils.noNull(details.getForwardEmail()).trim())) {
      errorCollection.addError("forwardEmail", i18nHelper.getText("admin.errors.invalid.email"));
    }
    return errorCollection;
  }
 @Override
 public Attachment createAttachmentCopySourceFile(
     final File file,
     final String filename,
     final String contentType,
     final String attachmentAuthor,
     final Issue issue,
     final Map<String, Object> attachmentProperties,
     final Date createdTime)
     throws AttachmentException {
   return createAttachment(
       file,
       filename,
       contentType,
       userManager.getUserByName(attachmentAuthor),
       issue,
       null,
       null,
       attachmentProperties,
       createdTime,
       true);
 }
  @Override
  public List<User> findUsersAllowEmptyQuery(
      final JiraServiceContext jiraServiceContext, final String query) {
    // is it allowed?  How did they get here anyway??
    if (!canPerformAjaxSearch(jiraServiceContext)) {
      return Collections.emptyList();
    }

    StopWatch stopWatch = new StopWatch();
    final String convertedQuery = (query == null) ? "" : query.toLowerCase().trim();
    if (log.isDebugEnabled()) log.debug("Running user-picker search: '" + convertedQuery + "'");
    List<User> returnUsers = new ArrayList<User>();
    final boolean canShowEmailAddresses = canShowEmailAddresses(jiraServiceContext);
    final Collection<User> allUsers = userManager.getUsers();
    if (log.isDebugEnabled())
      log.debug("Found all " + allUsers.size() + " users in " + stopWatch.getIntervalTime() + "ms");

    final Predicate<User> userMatcher =
        new UserMatcherPredicate(convertedQuery, canShowEmailAddresses);
    for (final User user : allUsers) {
      if (user.isActive() && userMatcher.apply(user)) {
        returnUsers.add(user);
      }
    }
    if (log.isDebugEnabled())
      log.debug(
          "Matched " + returnUsers.size() + " users in " + stopWatch.getIntervalTime() + "ms");
    Collections.sort(
        returnUsers, new UserBestNameComparator(jiraServiceContext.getI18nBean().getLocale()));
    if (log.isDebugEnabled()) {
      log.debug(
          "Sorted top " + returnUsers.size() + " users in " + stopWatch.getIntervalTime() + "ms");
      log.debug("User-picker search completed in " + stopWatch.getTotalTime() + "ms");
    }
    return returnUsers;
  }
 @Override
 public Comment create(Issue issue, String author, String body, boolean dispatchEvent) {
   return create(issue, userManager.getUserByKeyEvenWhenUnknown(author), body, dispatchEvent);
 }
Example #8
0
 public ApplicationUser getApplicationUser() {
   if (user == null) {
     user = userManager.getUserByName(getName());
   }
   return user;
 }
Example #9
0
 public boolean canUpdateUserPassword() {
   return isSelectedUserEditable() && userManager.canUpdateUserPassword(getUser());
 }
Example #10
0
 public boolean isSelectedUsersGroupsEditable() {
   return userManager.canUpdateGroupMembershipForUser(getUser());
 }
Example #11
0
 public boolean isSelectedUserEditable() {
   if (userManager.canUpdateUser(getApplicationUser())) {
     return isRemoteUserPermittedToEditSelectedUser();
   }
   return false;
 }