/**
   * Parse the key/value pairs out of a conglomerate cookie.
   *
   * <p>The returned map will not contain empty values (zero length strings: they are discarded).
   *
   * @param cookieName the name of the cookie
   * @param currentRequest current request
   * @return the non-null map of key/value pairs
   */
  public static Map<String, String> parseConglomerateCookie(
      String cookieName, HttpServletRequest currentRequest) {
    Map<String, String> result = new LinkedHashMap<String, String>();

    final String cookieValue = CookieUtils.getCookieValue(cookieName, currentRequest);
    if (StringUtils.isNotBlank(cookieValue)) {
      final String[] values = cookieValue.split("[|]");
      for (String rawKeyValuePair : values) {
        if (StringUtils.isNotBlank(rawKeyValuePair)) {
          String keyValuePair = JiraUrlCodec.decode(rawKeyValuePair, "UTF-8");
          if (StringUtils.isNotBlank(keyValuePair)) {
            Matcher m = CONGLOMERATE_KEYPAIR_PATTERN.matcher(keyValuePair);
            if (m.matches()) {
              final String key = m.group(1);
              final String value = m.group(2);
              result.put(key, value);
            }
          }
        }
      }
    }

    return result;
  }