コード例 #1
0
ファイル: ViewUser.java プロジェクト: moink635/mysource
 public String getDirectoryName() {
   final ApplicationUser user = getApplicationUser();
   if (userManager.isUserExisting(user)) {
     return crowdDirectoryService.findDirectoryById(user.getDirectoryId()).getName();
   }
   return "???";
 }
コード例 #2
0
  @GET
  @Path("/all")
  @AnonymousAllowed
  public Response getLinks(@QueryParam("gadgetId") Long gadgetId) {
    final ApplicationUser applicationUser = authenticationContext.getUser();
    final User user = applicationUser.getDirectoryUser();

    if (this.justStarted) {
      Map<String, String> userPrefs =
          portletConfigurationManager.getByPortletId(gadgetId).getUserPrefs();
      // TODO: pass in the name of used UserPref as ajax parameter
      String allLinks = userPrefs.get("allLinks");
      if (customlinks.isEmpty() && allLinks != null && allLinks != "") userPrefProcess(allLinks);

      this.justStarted = false;
    }

    if (customlinks.isEmpty()) {
      CacheControl cc = new CacheControl();
      cc.setNoCache(true);
      return Response.ok(new Warning()).cacheControl(cc).build();
    }
    CacheControl cc = new CacheControl();
    cc.setNoCache(true);
    return Response.ok(customlinks).cacheControl(cc).build();
  }
コード例 #3
0
 private void populateGenericValueFromComment(Comment updatedComment, GenericValue commentGV) {
   ApplicationUser updateAuthor = updatedComment.getUpdateAuthorApplicationUser();
   commentGV.setString("updateauthor", updateAuthor == null ? null : updateAuthor.getKey());
   commentGV.setString("body", updatedComment.getBody());
   commentGV.setString("level", updatedComment.getGroupLevel());
   commentGV.set("rolelevel", updatedComment.getRoleLevelId());
   commentGV.set(
       "updated", JiraDateUtils.copyOrCreateTimestampNullsafe(updatedComment.getUpdated()));
 }
コード例 #4
0
 @Override
 protected String getOwnerId(HttpServletRequest request) {
   String ownerId = super.getOwnerId(request);
   if (StringUtils.isBlank(ownerId)) {
     String username = StringUtils.trim(request.getParameter("username"));
     ApplicationUser user = getUserUtil().getUserByName(username);
     if (user != null) {
       ownerId = user.getKey();
     }
   }
   return ownerId;
 }
コード例 #5
0
ファイル: UserCF.java プロジェクト: moink635/mysource
 /**
  * Converts the given field values object into a set of values.
  *
  * @param fieldValues field values
  * @return a set of field values
  */
 Set<User> convertToUserSet(Object fieldValues) {
   if (fieldValues == null) {
     return Collections.emptySet();
   }
   if (fieldValues instanceof Collection) // http://jira.atlassian.com/browse/JRA-13523
   {
     Collection<ApplicationUser> applicationUsers = (Collection<ApplicationUser>) fieldValues;
     Set<User> users = new HashSet<User>(applicationUsers.size());
     for (ApplicationUser applicationUser : applicationUsers) {
       users.add(applicationUser.getDirectoryUser());
     }
     return users;
   } else {
     ApplicationUser applicationUser = (ApplicationUser) fieldValues;
     return Collections.singleton(applicationUser.getDirectoryUser());
   }
 }
コード例 #6
0
  private AdhocNotificationService.ValidateNotificationResult expectNotificationToRecipient(
      final NotificationRecipient recipient) {
    final NotificationBuilder notificationBuilder = Mockito.mock(NotificationBuilder.class);
    when(notificationBuilderFactory.createNotificationBuilder(
            eq(shareBean.getMessage()), eq(recipient), any(Set.class)))
        .thenReturn(notificationBuilder);

    final AdhocNotificationService.ValidateNotificationResult validationResult =
        new MockAdhocNotificationService()
            .getSampleValidationResult(user.getDirectoryUser(), issue, notificationBuilder);

    when(notificationService.validateNotification(
            notificationBuilder, user.getDirectoryUser(), issue, CONTINUE_ON_NO_RECIPIENTS))
        .thenReturn(validationResult);

    return validationResult;
  }
コード例 #7
0
  @Before
  public void setUp() {
    shareIssueService =
        new ShareIssueService(
            eventPublisher,
            notificationService,
            notificationBuilderFactory,
            notificationRecipientUtil);

    when(user.getDirectoryUser()).thenReturn(directoryUser);
  }
コード例 #8
0
  /** Note: this will not compare the time stamps of two events - only everything else. */
  @SuppressWarnings({"RedundantIfStatement"})
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final AbstractProjectEvent event = (AbstractProjectEvent) o;

    if (getParams() != null ? !getParams().equals(event.getParams()) : event.getParams() != null) {
      return false;
    }
    if (project != null ? !project.equals(event.project) : event.project != null) {
      return false;
    }
    if (user != null ? !user.equals(event.user) : event.user != null) {
      return false;
    }
    return true;
  }
コード例 #9
0
  public Comment create(
      Issue issue,
      ApplicationUser author,
      ApplicationUser updateAuthor,
      String body,
      String groupLevel,
      Long roleLevelId,
      Date created,
      Date updated,
      Map<String, JSONObject> commentProperties,
      boolean dispatchEvent,
      boolean modifyIssueUpdateDate) {

    if (textFieldCharacterLengthValidator.isTextTooLong(body)) {
      final long maximumNumberOfCharacters =
          textFieldCharacterLengthValidator.getMaximumNumberOfCharacters();
      String errorMessage =
          getText("field.error.text.toolong", String.valueOf(maximumNumberOfCharacters));
      throw new IllegalArgumentException(errorMessage);
    }

    // create new instance of comment
    CommentImpl comment =
        new CommentImpl(
            projectRoleManager,
            author,
            updateAuthor,
            body,
            groupLevel,
            roleLevelId,
            created,
            updated,
            issue);

    // create persistable generic value
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put("issue", issue.getId());
    fields.put("type", ActionConstants.TYPE_COMMENT);

    ApplicationUser commentAuthor = comment.getAuthorApplicationUser();
    ApplicationUser commentUpdateAuthor = comment.getUpdateAuthorApplicationUser();
    fields.put("author", commentAuthor == null ? null : commentAuthor.getKey());
    fields.put("updateauthor", commentUpdateAuthor == null ? null : commentUpdateAuthor.getKey());
    fields.put("body", comment.getBody());
    fields.put("level", comment.getGroupLevel());
    fields.put("rolelevel", comment.getRoleLevelId());
    fields.put("created", new Timestamp(comment.getCreated().getTime()));
    fields.put("updated", new Timestamp(comment.getUpdated().getTime()));

    GenericValue commentGV = EntityUtils.createValue(COMMENT_ENTITY, fields);
    // set the ID on comment object
    comment.setId(commentGV.getLong(COMMENT_ID));

    // Update the issue object if required
    if (modifyIssueUpdateDate) {
      // JRA-36334: Only modify the Issue updated date if it would move forward - we don't want it
      // to go back in time
      if (comment.getUpdated().getTime() > issue.getUpdated().getTime()) {
        IssueFactory issueFactory = ComponentAccessor.getComponentOfType(IssueFactory.class);
        MutableIssue mutableIssue = issueFactory.getIssue(issue.getGenericValue());
        // JRA-15723: Use the comments updated time for the updated time of the issue.  This allows
        // users to
        // import old comments without setting the updated time on the issue to now, but to the date
        // of the old comments.
        mutableIssue.setUpdated(new Timestamp(comment.getUpdated().getTime()));
        issue.store();
      }
    }

    if (commentProperties != null) {
      setProperties(author, comment, commentProperties);
    }

    // Dispatch an event if required
    if (dispatchEvent) {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("eventsource", IssueEventSource.ACTION);
      dispatchIssueCommentAddedEvent(comment, params);
    }
    return comment;
  }
コード例 #10
0
 public int hashCode() {
   int result = super.hashCode();
   result = 29 * result + (project != null ? project.hashCode() : 0);
   result = 29 * result + (user != null ? user.hashCode() : 0);
   return result;
 }