Example #1
0
  private String postComment(
      String projectId, String entityId, String text, String name, String email) {
    if (projectId == null) throw new RuntimeException("projectId == null");
    if (Str.isBlank(text)) throw new RuntimeException("Comment is empty.");
    Project project = projectDao.getById(projectId);
    AEntity entity = daoService.getById(entityId);
    Comment comment =
        commentDao.postComment(entity, "<nowiki>" + text + "</nowiki>", name, email, true);

    String message = "New comment posted";
    if (!Str.isBlank(name)) message += " by " + name;
    subscriptionService.notifySubscribers(entity, message, project, email);

    project.updateHomepage(entity, true);
    String reference = ((ReferenceSupport) entity).getReference();
    String label = ((LabelSupport) entity).getLabel();
    ProjectEvent event =
        projectEventDao.postEvent(
            project, comment.getAuthorName() + " commented on " + reference + " " + label, entity);
    if (Str.isEmail(email)) subscriptionService.subscribe(email, entity);
    transactionService.commit();

    webApplication.sendToConversationsByProject(project, event);

    return "<h2>Comment posted</h2><p>Thank you for your comment! It will be visible in a few minutes.</p><p>Back to <strong>"
        + KunagiUtl.createExternalRelativeHtmlAnchor(entity)
        + "</strong>.</p>";
  }
Example #2
0
  private String submitIssue(
      String projectId,
      String label,
      String text,
      String additionalInfo,
      String externalTrackerId,
      String name,
      String email,
      boolean wiki,
      boolean publish,
      String remoteHost) {
    if (projectId == null) throw new RuntimeException("projectId == null");
    if (Str.isBlank(label))
      throw new RuntimeException(
          "Subject is empty, but required. Please write a short title for your issue.");
    if (Str.isBlank(text))
      throw new RuntimeException(
          "Text is empty, but required. Please wirte a short description of your issue.");
    Project project = projectDao.getById(projectId);
    String textAsWiki = wiki ? text : "<nowiki>" + text + "</nowiki>";
    Issue issue =
        issueDao.postIssue(
            project, label, textAsWiki, additionalInfo, externalTrackerId, name, email, publish);
    if (publish) {
      project.updateHomepage(issue);
    }
    String issuer = issue.getIssuer();
    if (Str.isBlank(issuer)) issuer = "anonymous";
    ProjectEvent event =
        projectEventDao.postEvent(
            project, issuer + " submitted " + issue.getReferenceAndLabel(), issue);
    if (Str.isEmail(email)) subscriptionService.subscribe(email, issue);
    transactionService.commit();

    webApplication.sendToConversationsByProject(project, issue);
    webApplication.sendToConversationsByProject(project, event);

    String issueLink =
        publish
            ? KunagiUtl.createExternalRelativeHtmlAnchor(issue)
            : "<code>" + issue.getReference() + "</code>";
    return "<h2>Feedback submitted</h2><p>Thank you for your feedback!</p><p>Your issue is now known as "
        + issueLink
        + " and will be reviewed by our Product Owner.</p>";
  }
Example #3
0
  @Override
  public void onSelectProject(GwtConversation conversation, String projectId) {
    Project project = projectDao.getById(projectId);
    User user = conversation.getSession().getUser();
    if (!project.isVisibleFor(user))
      throw new PermissionDeniedException(
          "Project '" + project + "' is not visible for user '" + user + "'");

    project.setLastOpenedDateAndTime(DateAndTime.now());
    conversation.setProject(project);
    user.setCurrentProject(project);
    ProjectUserConfig config = project.getUserConfig(user);
    config.touch();

    conversation.sendToClient(project);
    conversation.sendToClient(project.getSprints());
    conversation.sendToClient(project.getSprintReports());
    conversation.sendToClient(project.getParticipants());
    for (Requirement requirement : project.getProductBacklogRequirements()) {
      conversation.sendToClient(requirement);
      conversation.sendToClient(requirement.getEstimationVotes());
    }
    for (Requirement requirement : project.getCurrentSprint().getRequirements()) {
      conversation.sendToClient(requirement);
      conversation.sendToClient(requirement.getTasksInSprint());
    }
    conversation.sendToClient(project.getQualitys());
    conversation.sendToClient(project.getUserConfigs());
    conversation.sendToClient(project.getWikipages());
    conversation.sendToClient(project.getImpediments());
    conversation.sendToClient(project.getRisks());
    conversation.sendToClient(project.getLatestProjectEvents(5));
    conversation.sendToClient(project.getCalendarEvents());
    conversation.sendToClient(project.getFiles());
    conversation.sendToClient(project.getOpenIssues());
    conversation.sendToClient(project.getReleases());
    conversation.sendToClient(project.getBlogEntrys());

    sendToClients(conversation, config);
  }
Example #4
0
 @Override
 public void onCreateExampleProject(GwtConversation conversation) {
   User user = conversation.getSession().getUser();
   Project project = projectDao.postExampleProject(user, user, user);
   conversation.sendToClient(project);
 }