Sfoglia il codice sorgente

fix #2839 Adjust API response to conditionally include exception messages based on configuration.

Shinsuke Sugaya 11 mesi fa
parent
commit
ec6385766e

+ 10 - 2
src/main/java/org/codelibs/fess/api/engine/SearchEngineApiManager.java

@@ -102,8 +102,16 @@ public class SearchEngineApiManager extends BaseApiManager {
                 throw new WebApiException(HttpServletResponse.SC_FORBIDDEN, "Invalid session.");
             });
         } catch (final WebApiException e) {
-            logger.debug("Failed to access to Web API.", e);
-            response.sendError(e.getStatusCode(), e.getMessage());
+            String message;
+            if (Constants.TRUE.equalsIgnoreCase(ComponentUtil.getFessConfig().getApiJsonResponseExceptionIncluded())) {
+                logger.warn("Failed to access to Web API.", e);
+                message = e.getMessage();
+            } else {
+                final String errorCode = UUID.randomUUID().toString();
+                message = "[" + errorCode + "] Failed to access to Web API.";
+                logger.warn(message, e);
+            }
+            response.sendError(e.getStatusCode(), message);
         }
     }