test_class.declarator: H2_STATEMENT_WAS_CANCELED = 57014
test_class.modifier: private static final
test_class.original_string: private static final int H2_STATEMENT_WAS_CANCELED = 57014;
test_class.type: int
test_class.var_name: H2_STATEMENT_WAS_CANCELED
test_class.declarator: HTTP_SERVER_HANDLER =
              new CommonHandler(false, mock(LayoutService.class), new HashMap<Pattern, HttpService>(),
                      mock(HttpSessionManager.class), new ArrayList<Object>(), mock(Clock.class))
test_class.modifier: private static final
test_class.original_string: private static final CommonHandler HTTP_SERVER_HANDLER =
              new CommonHandler(false, mock(LayoutService.class), new HashMap<Pattern, HttpService>(),
                      mock(HttpSessionManager.class), new ArrayList<Object>(), mock(Clock.class));
test_class.type: CommonHandler
test_class.var_name: HTTP_SERVER_HANDLER
test_class.file: ui/src/test/java/org/glowroot/ui/CommonHandlerTest.java
test_class.identifier: CommonHandlerTest
test_case.body: @Test
      public void shouldCreateNonTimeoutSqlExceptionResponse() throws Exception {
          // given
          Exception e = new SQLException("Another message", "", H2_STATEMENT_WAS_CANCELED + 1);
          // when
          CommonResponse httpResponse = HTTP_SERVER_HANDLER.newHttpResponseFromException(
                  mock(CommonRequest.class), mock(Authentication.class), e);
          // then
          String content = (String) httpResponse.getContent();
          ObjectNode node = (ObjectNode) new ObjectMapper().readTree(content);
          assertThat(node.get("message").asText())
                  .isEqualTo("java.sql.SQLException: Another message");
          assertThat(node.get("stackTrace")).isNotNull();
          assertThat(httpResponse.getStatus()).isEqualTo(HttpResponseStatus.INTERNAL_SERVER_ERROR);
      }
test_case.class_method_signature: CommonHandlerTest.shouldCreateNonTimeoutSqlExceptionResponse()
test_case.full_signature: @Test public void shouldCreateNonTimeoutSqlExceptionResponse()
test_case.identifier: shouldCreateNonTimeoutSqlExceptionResponse
test_case.invocations: newHttpResponseFromException mock mock getContent readTree isEqualTo assertThat asText get isNotNull assertThat get isEqualTo assertThat getStatus
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldCreateNonTimeoutSqlExceptionResponse()
focal_class.declarator: logger = LoggerFactory.getLogger(CommonHandler.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(CommonHandler.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: auditLogger = LoggerFactory.getLogger("audit")
focal_class.modifier: private static final
focal_class.original_string: private static final Logger auditLogger = LoggerFactory.getLogger("audit");
focal_class.type: Logger
focal_class.var_name: auditLogger
focal_class.declarator: mapper = ObjectMappers.create()
focal_class.modifier: private static final
focal_class.original_string: private static final ObjectMapper mapper = ObjectMappers.create();
focal_class.type: ObjectMapper
focal_class.var_name: mapper
focal_class.declarator: TEN_YEARS = DAYS.toMillis(3650)
focal_class.modifier: private static final
focal_class.original_string: private static final long TEN_YEARS = DAYS.toMillis(3650);
focal_class.type: long
focal_class.var_name: TEN_YEARS
focal_class.declarator: ONE_DAY = DAYS.toMillis(1)
focal_class.modifier: private static final
focal_class.original_string: private static final long ONE_DAY = DAYS.toMillis(1);
focal_class.type: long
focal_class.var_name: ONE_DAY
focal_class.declarator: FIVE_MINUTES = MINUTES.toMillis(5)
focal_class.modifier: private static final
focal_class.original_string: private static final long FIVE_MINUTES = MINUTES.toMillis(5);
focal_class.type: long
focal_class.var_name: FIVE_MINUTES
focal_class.declarator: RESOURCE_BASE = "org/glowroot/ui/app-dist"
focal_class.modifier: private static final
focal_class.original_string: private static final String RESOURCE_BASE = "org/glowroot/ui/app-dist";
focal_class.type: String
focal_class.var_name: RESOURCE_BASE
focal_class.declarator: RESOURCE_BASE_URL_PREFIX
focal_class.modifier: private static final @Nullable
focal_class.original_string: private static final @Nullable String RESOURCE_BASE_URL_PREFIX;
focal_class.type: String
focal_class.var_name: RESOURCE_BASE_URL_PREFIX
focal_class.declarator: mediaTypes =
              ImmutableMap.<String, MediaType>builder()
                      .put("html", MediaType.HTML_UTF_8)
                      .put("js", MediaType.TEXT_JAVASCRIPT_UTF_8)
                      .put("css", MediaType.CSS_UTF_8)
                      .put("ico", MediaType.create("image", "x-icon"))
                      .put("woff", MediaType.WOFF)
                      .put("woff2", MediaType.create("application", "font-woff2"))
                      .put("swf", MediaType.create("application", "vnd.adobe.flash-movie"))
                      .put("map", MediaType.JSON_UTF_8)
                      .build()
focal_class.modifier: private static final
focal_class.original_string: private static final ImmutableMap<String, MediaType> mediaTypes =
              ImmutableMap.<String, MediaType>builder()
                      .put("html", MediaType.HTML_UTF_8)
                      .put("js", MediaType.TEXT_JAVASCRIPT_UTF_8)
                      .put("css", MediaType.CSS_UTF_8)
                      .put("ico", MediaType.create("image", "x-icon"))
                      .put("woff", MediaType.WOFF)
                      .put("woff2", MediaType.create("application", "font-woff2"))
                      .put("swf", MediaType.create("application", "vnd.adobe.flash-movie"))
                      .put("map", MediaType.JSON_UTF_8)
                      .build();
focal_class.type: ImmutableMap<String, MediaType>
focal_class.var_name: mediaTypes
focal_class.declarator: H2_STATEMENT_WAS_CANCELED = 57014
focal_class.modifier: private static final
focal_class.original_string: private static final int H2_STATEMENT_WAS_CANCELED = 57014;
focal_class.type: int
focal_class.var_name: H2_STATEMENT_WAS_CANCELED
focal_class.declarator: central
focal_class.modifier: private final
focal_class.original_string: private final boolean central;
focal_class.type: boolean
focal_class.var_name: central
focal_class.declarator: layoutService
focal_class.modifier: private final
focal_class.original_string: private final LayoutService layoutService;
focal_class.type: LayoutService
focal_class.var_name: layoutService
focal_class.declarator: httpServices
focal_class.modifier: private final
focal_class.original_string: private final ImmutableMap<Pattern, HttpService> httpServices;
focal_class.type: ImmutableMap<Pattern, HttpService>
focal_class.var_name: httpServices
focal_class.declarator: jsonServiceMappings
focal_class.modifier: private final
focal_class.original_string: private final ImmutableList<JsonServiceMapping> jsonServiceMappings;
focal_class.type: ImmutableList<JsonServiceMapping>
focal_class.var_name: jsonServiceMappings
focal_class.declarator: httpSessionManager
focal_class.modifier: private final
focal_class.original_string: private final HttpSessionManager httpSessionManager;
focal_class.type: HttpSessionManager
focal_class.var_name: httpSessionManager
focal_class.declarator: clock
focal_class.modifier: private final
focal_class.original_string: private final Clock clock;
focal_class.type: Clock
focal_class.var_name: clock
focal_class.file: ui/src/main/java/org/glowroot/ui/CommonHandler.java
focal_class.identifier: CommonHandler
focal_class.class_method_signature: CommonHandler.CommonHandler(boolean central, LayoutService layoutService,
              Map<Pattern, HttpService> httpServices, HttpSessionManager httpSessionManager,
              List<Object> jsonServices, Clock clock)
focal_class.full_signature:   CommonHandler(boolean central, LayoutService layoutService,
              Map<Pattern, HttpService> httpServices, HttpSessionManager httpSessionManager,
              List<Object> jsonServices, Clock clock)
focal_class.identifier: CommonHandler
focal_class.parameters: (boolean central, LayoutService layoutService,
              Map<Pattern, HttpService> httpServices, HttpSessionManager httpSessionManager,
              List<Object> jsonServices, Clock clock)
focal_class.signature:  CommonHandler(boolean central, LayoutService layoutService,
              Map<Pattern, HttpService> httpServices, HttpSessionManager httpSessionManager,
              List<Object> jsonServices, Clock clock)
focal_class.class_method_signature: CommonHandler.handle(CommonRequest request)
focal_class.full_signature: public CommonResponse handle(CommonRequest request)
focal_class.identifier: handle
focal_class.modifiers: public
focal_class.parameters: (CommonRequest request)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handle(CommonRequest request)
focal_class.class_method_signature: CommonHandler.handleIfLoginOrLogoutRequest(CommonRequest request)
focal_class.full_signature: private @Nullable CommonResponse handleIfLoginOrLogoutRequest(CommonRequest request)
focal_class.identifier: handleIfLoginOrLogoutRequest
focal_class.modifiers: private @Nullable
focal_class.parameters: (CommonRequest request)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handleIfLoginOrLogoutRequest(CommonRequest request)
focal_class.class_method_signature: CommonHandler.handleRequest(CommonRequest request, Authentication authentication)
focal_class.full_signature: private CommonResponse handleRequest(CommonRequest request, Authentication authentication)
focal_class.identifier: handleRequest
focal_class.modifiers: private
focal_class.parameters: (CommonRequest request, Authentication authentication)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handleRequest(CommonRequest request, Authentication authentication)
focal_class.class_method_signature: CommonHandler.getHttpService(String path)
focal_class.full_signature: private @Nullable HttpService getHttpService(String path)
focal_class.identifier: getHttpService
focal_class.modifiers: private @Nullable
focal_class.parameters: (String path)
focal_class.return: HttpService
focal_class.signature: HttpService getHttpService(String path)
focal_class.class_method_signature: CommonHandler.handleHttpService(CommonRequest request, HttpService httpService,
              Authentication authentication)
focal_class.full_signature: private CommonResponse handleHttpService(CommonRequest request, HttpService httpService,
              Authentication authentication)
focal_class.identifier: handleHttpService
focal_class.modifiers: private
focal_class.parameters: (CommonRequest request, HttpService httpService,
              Authentication authentication)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handleHttpService(CommonRequest request, HttpService httpService,
              Authentication authentication)
focal_class.class_method_signature: CommonHandler.getJsonServiceMapping(CommonRequest request,
              String path)
focal_class.full_signature: private @Nullable JsonServiceMapping getJsonServiceMapping(CommonRequest request,
              String path)
focal_class.identifier: getJsonServiceMapping
focal_class.modifiers: private @Nullable
focal_class.parameters: (CommonRequest request,
              String path)
focal_class.return: JsonServiceMapping
focal_class.signature: JsonServiceMapping getJsonServiceMapping(CommonRequest request,
              String path)
focal_class.class_method_signature: CommonHandler.handleJsonServiceMappings(CommonRequest request,
              JsonServiceMapping jsonServiceMapping, Authentication authentication)
focal_class.full_signature: private CommonResponse handleJsonServiceMappings(CommonRequest request,
              JsonServiceMapping jsonServiceMapping, Authentication authentication)
focal_class.identifier: handleJsonServiceMappings
focal_class.modifiers: private
focal_class.parameters: (CommonRequest request,
              JsonServiceMapping jsonServiceMapping, Authentication authentication)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handleJsonServiceMappings(CommonRequest request,
              JsonServiceMapping jsonServiceMapping, Authentication authentication)
focal_class.class_method_signature: CommonHandler.newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception)
focal_class.full_signature:  CommonResponse newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception)
focal_class.identifier: newHttpResponseFromException
focal_class.parameters: (CommonRequest request,
              Authentication authentication, Exception exception)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception)
focal_class.class_method_signature: CommonHandler.handleNotAuthorized(CommonRequest request,
              Authentication authentication)
focal_class.full_signature: private CommonResponse handleNotAuthorized(CommonRequest request,
              Authentication authentication)
focal_class.identifier: handleNotAuthorized
focal_class.modifiers: private
focal_class.parameters: (CommonRequest request,
              Authentication authentication)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handleNotAuthorized(CommonRequest request,
              Authentication authentication)
focal_class.class_method_signature: CommonHandler.handleStaticResource(String path, CommonRequest request)
focal_class.full_signature: private CommonResponse handleStaticResource(String path, CommonRequest request)
focal_class.identifier: handleStaticResource
focal_class.modifiers: private
focal_class.parameters: (String path, CommonRequest request)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse handleStaticResource(String path, CommonRequest request)
focal_class.class_method_signature: CommonHandler.getExpiresForPath(String path)
focal_class.full_signature: private @Nullable Date getExpiresForPath(String path)
focal_class.identifier: getExpiresForPath
focal_class.modifiers: private @Nullable
focal_class.parameters: (String path)
focal_class.return: Date
focal_class.signature: Date getExpiresForPath(String path)
focal_class.class_method_signature: CommonHandler.getAgentRollupIdFromRequest(CommonRequest request)
focal_class.full_signature: private static @Nullable String getAgentRollupIdFromRequest(CommonRequest request)
focal_class.identifier: getAgentRollupIdFromRequest
focal_class.modifiers: private static @Nullable
focal_class.parameters: (CommonRequest request)
focal_class.return: String
focal_class.signature: String getAgentRollupIdFromRequest(CommonRequest request)
focal_class.class_method_signature: CommonHandler.buildJsonResponse(@Nullable Object responseObject)
focal_class.full_signature: private static CommonResponse buildJsonResponse(@Nullable Object responseObject)
focal_class.identifier: buildJsonResponse
focal_class.modifiers: private static
focal_class.parameters: (@Nullable Object responseObject)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse buildJsonResponse(@Nullable Object responseObject)
focal_class.class_method_signature: CommonHandler.build(HttpMethod httpMethod, String path,
              String permission, Object jsonService, Method method)
focal_class.full_signature: private static JsonServiceMapping build(HttpMethod httpMethod, String path,
              String permission, Object jsonService, Method method)
focal_class.identifier: build
focal_class.modifiers: private static
focal_class.parameters: (HttpMethod httpMethod, String path,
              String permission, Object jsonService, Method method)
focal_class.return: JsonServiceMapping
focal_class.signature: JsonServiceMapping build(HttpMethod httpMethod, String path,
              String permission, Object jsonService, Method method)
focal_class.class_method_signature: CommonHandler.getSecureUrlForPath(String path)
focal_class.full_signature: private static @Nullable URL getSecureUrlForPath(String path)
focal_class.identifier: getSecureUrlForPath
focal_class.modifiers: private static @Nullable
focal_class.parameters: (String path)
focal_class.return: URL
focal_class.signature: URL getSecureUrlForPath(String path)
focal_class.class_method_signature: CommonHandler.getUrlForPath(String path)
focal_class.full_signature: private static @Nullable URL getUrlForPath(String path)
focal_class.identifier: getUrlForPath
focal_class.modifiers: private static @Nullable
focal_class.parameters: (String path)
focal_class.return: URL
focal_class.signature: URL getUrlForPath(String path)
focal_class.class_method_signature: CommonHandler.newHttpResponseWithMessage(HttpResponseStatus status,
              @Nullable String message)
focal_class.full_signature: private static CommonResponse newHttpResponseWithMessage(HttpResponseStatus status,
              @Nullable String message)
focal_class.identifier: newHttpResponseWithMessage
focal_class.modifiers: private static
focal_class.parameters: (HttpResponseStatus status,
              @Nullable String message)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse newHttpResponseWithMessage(HttpResponseStatus status,
              @Nullable String message)
focal_class.class_method_signature: CommonHandler.newHttpResponseWithStackTrace(Exception e,
              HttpResponseStatus status, @Nullable String simplifiedMessage)
focal_class.full_signature: static CommonResponse newHttpResponseWithStackTrace(Exception e,
              HttpResponseStatus status, @Nullable String simplifiedMessage)
focal_class.identifier: newHttpResponseWithStackTrace
focal_class.modifiers: static
focal_class.parameters: (Exception e,
              HttpResponseStatus status, @Nullable String simplifiedMessage)
focal_class.return: CommonResponse
focal_class.signature: CommonResponse newHttpResponseWithStackTrace(Exception e,
              HttpResponseStatus status, @Nullable String simplifiedMessage)
focal_class.class_method_signature: CommonHandler.getHttpResponseWithStackTrace(Exception e,
              @Nullable String simplifiedMessage)
focal_class.full_signature: private static String getHttpResponseWithStackTrace(Exception e,
              @Nullable String simplifiedMessage)
focal_class.identifier: getHttpResponseWithStackTrace
focal_class.modifiers: private static
focal_class.parameters: (Exception e,
              @Nullable String simplifiedMessage)
focal_class.return: String
focal_class.signature: String getHttpResponseWithStackTrace(Exception e,
              @Nullable String simplifiedMessage)
focal_class.class_method_signature: CommonHandler.callMethod(JsonServiceMapping jsonServiceMapping,
              List<Class<?>> parameterTypes, List<Object> parameters,
              Map<String, List<String>> queryParameters, Authentication authentication,
              CommonRequest request)
focal_class.full_signature: private static @Nullable Object callMethod(JsonServiceMapping jsonServiceMapping,
              List<Class<?>> parameterTypes, List<Object> parameters,
              Map<String, List<String>> queryParameters, Authentication authentication,
              CommonRequest request)
focal_class.identifier: callMethod
focal_class.modifiers: private static @Nullable
focal_class.parameters: (JsonServiceMapping jsonServiceMapping,
              List<Class<?>> parameterTypes, List<Object> parameters,
              Map<String, List<String>> queryParameters, Authentication authentication,
              CommonRequest request)
focal_class.return: Object
focal_class.signature: Object callMethod(JsonServiceMapping jsonServiceMapping,
              List<Class<?>> parameterTypes, List<Object> parameters,
              Map<String, List<String>> queryParameters, Authentication authentication,
              CommonRequest request)
focal_class.class_method_signature: CommonHandler.isAutoRefresh(@Nullable List<String> autoRefreshParams)
focal_class.full_signature: private static boolean isAutoRefresh(@Nullable List<String> autoRefreshParams)
focal_class.identifier: isAutoRefresh
focal_class.modifiers: private static
focal_class.parameters: (@Nullable List<String> autoRefreshParams)
focal_class.return: boolean
focal_class.signature: boolean isAutoRefresh(@Nullable List<String> autoRefreshParams)
focal_method.body: CommonResponse newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception) throws Exception {
          Exception e = exception;
          if (e instanceof InvocationTargetException) {
              Throwable cause = e.getCause();
              if (cause instanceof Exception) {
                  e = (Exception) cause;
              }
          }
          if (e instanceof JsonServiceException) {
              // this is an "expected" exception, no need to log
              JsonServiceException jsonServiceException = (JsonServiceException) e;
              if (jsonServiceException.getStatus() == FORBIDDEN) {
                  return handleNotAuthorized(request, authentication);
              } else {
                  return newHttpResponseWithMessage(jsonServiceException.getStatus(),
                          jsonServiceException.getMessage());
              }
          }
          logger.error(e.getMessage(), e);
          if (e instanceof SQLException
                  && ((SQLException) e).getErrorCode() == H2_STATEMENT_WAS_CANCELED) {
              return newHttpResponseWithMessage(REQUEST_TIMEOUT,
                      "Query timed out (timeout is configurable under Configuration > Advanced)");
          }
          return newHttpResponseWithStackTrace(e, INTERNAL_SERVER_ERROR, null);
      }
focal_method.class_method_signature: CommonHandler.newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception)
focal_method.full_signature:  CommonResponse newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception)
focal_method.identifier: newHttpResponseFromException
focal_method.invocations: getCause getStatus handleNotAuthorized newHttpResponseWithMessage getStatus getMessage error getMessage getErrorCode newHttpResponseWithMessage newHttpResponseWithStackTrace
focal_method.parameters: (CommonRequest request,
              Authentication authentication, Exception exception)
focal_method.return: CommonResponse
focal_method.signature: CommonResponse newHttpResponseFromException(CommonRequest request,
              Authentication authentication, Exception exception)