private void notify(SUser user, String message) {
    String authToken = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_AUTH_TOKEN));
    String url = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_URL));
    Boolean useSsl =
        user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_USE_SSL))
            .trim()
            .equalsIgnoreCase("y");
    String roomNumber =
        user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_ROOM_NUMBER));
    String proxyHost = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_PROXY_HOST));
    String proxyPort = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_PROXY_PORT));
    int realport = 0;
    if (proxyPort != null && proxyPort.length() > 0) {
      try {
        realport = Integer.parseInt(proxyPort);
      } catch (Exception e) {
      }
    }

    String proxyUser = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_PROXY_USER));
    String proxyPass = user.getPropertyValue(new NotificatorPropertyKey(TYPE, CAMPFIRE_PROXY_PASS));

    Campfire campfire =
        new Campfire(authToken, url, useSsl, proxyHost, realport, proxyUser, proxyPass);
    campfire.postMessage(roomNumber, message);
  }
  @Nullable
  protected ModelAndView doHandle(HttpServletRequest request, HttpServletResponse response)
      throws Exception {

    HashMap<String, Object> params = new HashMap<String, Object>();

    SUser myUser = SessionUser.getUser(request);
    SProject myProject = null;
    SlackNotificationProjectSettings projSettings = null;

    if (request.getMethod().equalsIgnoreCase("post")) {
      if ((request.getParameter("projectId") != null)
          && request.getParameter("projectId").startsWith("project")) {
        projSettings =
            (SlackNotificationProjectSettings)
                mySettings.getSettings(request.getParameter("projectId"), "slackNotifications");
        myProject =
            this.myServer.getProjectManager().findProjectById(request.getParameter("projectId"));

        if ((projSettings != null)
            && (myProject != null)
            && (myUser.isPermissionGrantedForProject(
                myProject.getProjectId(), Permission.EDIT_PROJECT))) {
          if ((request.getParameter("submitAction") != null)
              && (request.getParameter("submitAction").equals("removeSlackNotification"))
              && (request.getParameter("removedSlackNotificationId") != null)) {
            projSettings.deleteSlackNotification(
                request.getParameter("removedSlackNotificationId"), myProject.getProjectId());
            if (projSettings.updateSuccessful()) {
              myProject.persist();
              params.put("messages", "<errors />");
            } else {
              params.put(
                  "messages",
                  "<errors><error id=\"messageArea\">The slacknotifications was not found. Have the SlackNotifications been edited on disk or by another user?</error></errors>");
            }

          } else if ((request.getParameter("submitAction") != null)
              && (request.getParameter("submitAction").equals("updateSlackNotification"))) {
            if ((request.getParameter("channel") != null)
                && (request.getParameter("channel").length() > 0)) {

              if (request.getParameter("slackNotificationId") != null) {
                Boolean enabled = false;
                Boolean mentionChannelEnabled = false;
                Boolean mentionSlackUserEnabled = false;
                Boolean buildTypeAll = false;
                Boolean buildTypeSubProjects = false;
                SlackNotificationContentConfig content = new SlackNotificationContentConfig();
                Set<String> buildTypes = new HashSet<String>();
                if ((request.getParameter("slackNotificationsEnabled") != null)
                    && (request.getParameter("slackNotificationsEnabled").equalsIgnoreCase("on"))) {
                  enabled = true;
                }
                if ((request.getParameter("mentionChannelEnabled") != null)
                    && (request.getParameter("mentionChannelEnabled").equalsIgnoreCase("on"))) {

                  mentionChannelEnabled = true;
                }
                if ((request.getParameter("mentionSlackUserEnabled") != null)
                    && (request.getParameter("mentionSlackUserEnabled").equalsIgnoreCase("on"))) {
                  mentionSlackUserEnabled = true;
                }

                content.setEnabled(
                    (request.getParameter("customContentEnabled") != null)
                        && (request.getParameter("customContentEnabled").equalsIgnoreCase("on")));

                if (content.isEnabled()) {

                  if ((request.getParameter("maxCommitsToDisplay") != null)
                      && (request.getParameter("maxCommitsToDisplay").length() > 0)) {
                    content.setMaxCommitsToDisplay(
                        convertToInt(
                            request.getParameter("maxCommitsToDisplay"),
                            SlackNotificationContentConfig.DEFAULT_MAX_COMMITS));
                  }

                  content.setShowBuildAgent(
                      (request.getParameter("showBuildAgent") != null)
                          && (request.getParameter("showBuildAgent").equalsIgnoreCase("on")));

                  content.setShowCommits(
                      (request.getParameter("showCommits") != null)
                          && (request.getParameter("showCommits").equalsIgnoreCase("on")));

                  content.setShowCommitters(
                      (request.getParameter("showCommitters") != null)
                          && (request.getParameter("showCommitters").equalsIgnoreCase("on")));

                  content.setShowElapsedBuildTime(
                      (request.getParameter("showElapsedBuildTime") != null)
                          && (request.getParameter("showElapsedBuildTime").equalsIgnoreCase("on")));

                  content.setShowFailureReason(
                      (request.getParameter("showFailureReason") != null)
                          && (request.getParameter("showFailureReason").equalsIgnoreCase("on")));

                  if ((request.getParameter("botName") != null)
                      && (request.getParameter("botName").length() > 0)) {
                    content.setBotName(request.getParameter("botName"));
                  }

                  if ((request.getParameter("iconUrl") != null)
                      && (request.getParameter("iconUrl").length() > 0)) {
                    content.setIconUrl(request.getParameter("iconUrl"));
                  }
                }

                BuildState states = new BuildState();

                checkAndAddBuildState(
                    request, states, BuildStateEnum.BUILD_SUCCESSFUL, BUILD_SUCCESSFUL);
                checkAndAddBuildState(request, states, BuildStateEnum.BUILD_FAILED, BUILD_FAILED);
                checkAndAddBuildState(request, states, BuildStateEnum.BUILD_FIXED, BUILD_FIXED);
                checkAndAddBuildState(request, states, BuildStateEnum.BUILD_BROKEN, BUILD_BROKEN);
                checkAndAddBuildState(request, states, BuildStateEnum.BUILD_STARTED, BUILD_STARTED);
                checkAndAddBuildState(
                    request, states, BuildStateEnum.BUILD_INTERRUPTED, BUILD_INTERRUPTED);
                checkAndAddBuildState(
                    request, states, BuildStateEnum.BEFORE_BUILD_FINISHED, BEFORE_FINISHED);
                checkAndAddBuildStateIfEitherSet(
                    request, states, BuildStateEnum.BUILD_FINISHED, BUILD_SUCCESSFUL, BUILD_FAILED);
                checkAndAddBuildState(
                    request,
                    states,
                    BuildStateEnum.RESPONSIBILITY_CHANGED,
                    "ResponsibilityChanged");

                if ((request.getParameter("buildTypeSubProjects") != null)
                    && (request.getParameter("buildTypeSubProjects").equalsIgnoreCase("on"))) {
                  buildTypeSubProjects = true;
                }
                if ((request.getParameter("buildTypeAll") != null)
                    && (request.getParameter("buildTypeAll").equalsIgnoreCase("on"))) {
                  buildTypeAll = true;
                } else {
                  if (request.getParameterValues("buildTypeId") != null) {
                    String[] types = request.getParameterValues("buildTypeId");
                    for (String string : types) {
                      buildTypes.add(string);
                    }
                  }
                }

                if (request.getParameter("slackNotificationId").equals("new")) {
                  projSettings.addNewSlackNotification(
                      myProject.getProjectId(),
                      request.getParameter("channel"),
                      request.getParameter("team"),
                      enabled,
                      states,
                      buildTypeAll,
                      buildTypeSubProjects,
                      buildTypes,
                      mentionChannelEnabled,
                      mentionSlackUserEnabled);
                  if (projSettings.updateSuccessful()) {
                    myProject.persist();
                    params.put("messages", "<errors />");
                  } else {
                    params.put(
                        "message",
                        "<errors><error id=\"\">" + projSettings.getUpdateMessage() + "</error>");
                  }
                } else {
                  projSettings.updateSlackNotification(
                      myProject.getProjectId(),
                      request.getParameter("slackNotificationId"),
                      request.getParameter("channel"),
                      enabled,
                      states,
                      buildTypeAll,
                      buildTypeSubProjects,
                      buildTypes,
                      mentionChannelEnabled,
                      mentionSlackUserEnabled,
                      content);
                  if (projSettings.updateSuccessful()) {
                    myProject.persist();
                    params.put("messages", "<errors />");
                  } else {
                    params.put(
                        "message",
                        "<errors><error id=\"\">" + projSettings.getUpdateMessage() + "</error>");
                  }
                }
              } // TODO Need to handle slackNotificationId being null

            } else {
              if ((request.getParameter("channel") == null)
                  || (request.getParameter("channel").length() == 0)) {
                params.put(
                    "messages",
                    "<errors><error id=\"emptySlackNotificationChannel\">Please enter a channel.</error></errors>");
              }
            }
          }
        } else {
          params.put(
              "messages",
              "<errors><error id=\"messageArea\">You do not appear to have permission to edit SlackNotifications.</error></errors>");
        }
      }
    }

    if (request.getMethod().equalsIgnoreCase("get")
        && request.getParameter("projectId") != null
        && request.getParameter("projectId").startsWith("project")) {

      SlackNotificationProjectSettings projSettings1 =
          (SlackNotificationProjectSettings)
              mySettings.getSettings(request.getParameter("projectId"), "slackNotifications");
      SProject project =
          this.myServer.getProjectManager().findProjectById(request.getParameter("projectId"));

      String message = projSettings1.getSlackNotificationsAsString();

      params.put("haveProject", "true");
      params.put("messages", message);
      params.put("projectId", project.getProjectId());
      params.put("projectExternalId", TeamCityIdResolver.getExternalProjectId(project));
      params.put("projectName", project.getName());

      params.put("slackNotificationCount", projSettings1.getSlackNotificationsCount());
      if (projSettings1.getSlackNotificationsCount() == 0) {
        params.put("noSlackNotifications", "true");
        params.put("slackNotifications", "false");
      } else {
        params.put("noSlackNotifications", "false");
        params.put("slackNotifications", "true");
        params.put("slackNotificationList", projSettings.getSlackNotificationsAsList());
        params.put("slackNotificationsDisabled", !projSettings.isEnabled());
        params.put("slackNotificationsEnabledAsChecked", projSettings.isEnabledAsChecked());
        params.put(
            "projectSlackNotificationsAsJson",
            ProjectSlackNotificationsBeanJsonSerialiser.serialise(
                ProjectSlackNotificationsBean.build(projSettings, project, myMainSettings)));
      }
    } else {
      params.put("haveProject", "false");
    }

    return new ModelAndView(myPluginPath + "SlackNotification/ajaxEdit.jsp", params);
  }