private void sendError(HttpServletRequest request, HttpServletResponse response, Throwable e) throws IOException { log.error("Error processing request: " + request.getRequestURI() + "?" + request.getQueryString(), e); Configuration configuration = AppBeans.get(Configuration.class); boolean isProductionMode = configuration.getConfig(RestConfig.class).getProductionMode(); String msg; if (isProductionMode) { msg = "Internal server error"; } else { Throwable t = ExceptionUtils.getRootCause(e); msg = t != null ? ExceptionUtils.getStackTrace(t) : ExceptionUtils.getStackTrace(e); } response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); }
@PostConstruct private int init() { converters.add(jsonConverter); converters.add(xmlConverter); converters.add(xmlConverter2); RestConfig restConfig = configuration.getConfig(RestConfig.class); restApiVersion = restConfig.getRestApiVersion(); return restApiVersion; }
@Override public String process(Set<Entity> entities) throws Exception { MyJSONObject.Array result = new MyJSONObject.Array(); for (Entity entity : entities) { MyJSONObject entityJson = encodeInstance(entity, new HashSet<Entity>(), getMetaClass(entity), null); if (restConfig.getRestApiVersion() == 1) { //return map for old version of rest api MyJSONObject valueJson = encodeInstance(entity, new HashSet<Entity>(), getMetaClass(entity), null); MyJSONObject.Array mapping = new MyJSONObject.Array(); mapping.add(entityJson); mapping.add(valueJson); result.add(mapping); } else { result.add(entityJson); } } return result.toString(); }