@POST
  @Produces(APPLICATION_JSON)
  public Response post(
      @Context HttpServletRequest request,
      @QueryParam("repositoryId") Integer repositoryId,
      @QueryParam("pullRequestId") Long pullRequestId,
      @QueryParam("formIdentifier") final String formIdentifier)
      throws Exception {
    if (userManager.getRemoteUser(request) == null) {
      return status(UNAUTHORIZED).build();
    }

    final PrnfsSettings settings = getSettings();
    for (PrnfsNotification prnfsNotification : settings.getNotifications()) {
      PrnfsPullRequestAction pullRequestAction = PrnfsPullRequestAction.valueOf(BUTTON_TRIGGER);
      final PullRequest pullRequest = pullRequestService.getById(repositoryId, pullRequestId);
      Map<PrnfsVariable, Supplier<String>> variables = getVariables(settings, formIdentifier);
      PrnfsRenderer renderer =
          getRenderer(pullRequest, prnfsNotification, pullRequestAction, variables, request);
      if (prnfsPullRequestEventListener.notificationTriggeredByAction(
          prnfsNotification, pullRequestAction, renderer)) {
        prnfsPullRequestEventListener.notify(
            prnfsNotification, pullRequestAction, pullRequest, variables, renderer);
      }
    }
    return status(OK).build();
  }
 @GET
 @Produces(APPLICATION_JSON)
 public Response get(
     @Context HttpServletRequest request,
     @QueryParam("repositoryId") Integer repositoryId,
     @QueryParam("pullRequestId") Long pullRequestId)
     throws Exception {
   if (userManager.getRemoteUser(request) == null) {
     return status(UNAUTHORIZED).build();
   }
   List<PrnfsButton> buttons = newArrayList();
   final PrnfsSettings settings = getSettings();
   for (PrnfsButton candidate : settings.getButtons()) {
     UserKey userKey = userManager.getRemoteUserKey();
     PrnfsPullRequestAction pullRequestAction = PrnfsPullRequestAction.valueOf(BUTTON_TRIGGER);
     final PullRequest pullRequest = pullRequestService.getById(repositoryId, pullRequestId);
     Map<PrnfsVariable, Supplier<String>> variables =
         getVariables(settings, candidate.getFormIdentifier());
     if (allowedUseButton(
             candidate, userManager.isAdmin(userKey), userManager.isSystemAdmin(userKey))
         && triggeredByAction(settings, pullRequestAction, pullRequest, variables, request)) {
       buttons.add(candidate);
     }
   }
   return ok(gson.toJson(buttons), APPLICATION_JSON).build();
 }
 private boolean triggeredByAction(
     PrnfsSettings settings,
     PrnfsPullRequestAction pullRequestAction,
     PullRequest pullRequest,
     Map<PrnfsVariable, Supplier<String>> variables,
     HttpServletRequest request) {
   for (PrnfsNotification prnfsNotification : settings.getNotifications()) {
     PrnfsRenderer renderer =
         getRenderer(pullRequest, prnfsNotification, pullRequestAction, variables, request);
     if (prnfsPullRequestEventListener.notificationTriggeredByAction(
         prnfsNotification, pullRequestAction, renderer)) {
       return TRUE;
     }
   }
   return FALSE;
 }