private void prepareJqlParams(
      final ShareService.ValidateShareSearchRequestResult result,
      final Map<String, Object> params) {
    final String jql = getJql(result);

    UrlBuilder jqlUrlBuilder = new UrlBuilder(false);
    jqlUrlBuilder.addParameter("reset", true);
    jqlUrlBuilder.addParameter(JQL_QUERY_PARAMETER, jql);
    params.put("jqlSearchLinkUrlParams", jqlUrlBuilder.asUrlString());

    if (result.getSearchRequest() != null) {
      putSearchRequestParams(params, result.getSearchRequest());
    }
  }
  private Map<String, Object> prepareParams(
      final ShareService.ValidateShareSearchRequestResult result) {
    Map<String, Object> params = Maps.newHashMap();
    params.put("remoteUser", result.getUser());

    prepareJqlParams(result, params);

    String message = result.getShareBean().getMessage();
    if (StringUtils.isNotBlank(message)) {
      params.put("comment", message);
      params.put(
          "htmlComment",
          TextUtils.htmlEncode(
              message)); // required by templates/email/html/includes/fields/comment.vm
    }

    return params;
  }
 private String getJql(final ShareService.ValidateShareSearchRequestResult result) {
   return Option.option(result.getSearchRequest())
       .fold(
           new Supplier<String>() {
             @Override
             public String get() {
               return result.getShareBean().getJql();
             }
           },
           new Function<SearchRequest, String>() {
             @Override
             public String apply(final SearchRequest request) {
               return request.getQuery().getQueryString();
             }
           });
 }
 private void publishShareEvent(final ShareService.ValidateShareSearchRequestResult result) {
   final AbstractShareEvent event =
       getProperEvent(result.getSearchRequest(), result.getShareBean(), result.getUser());
   eventPublisher.publish(event);
 }