public Status asStatus(boolean verbose) { Response.Status response = Response.status(getStatus()); if (verbose) { StringBuilder buffer = new StringBuilder(); Formatting.renderStyleSheet(buffer); buffer.append("<div class=\"juzu\">"); buffer.append("<h1>Oups something went wrong</h1>"); // Use getCause as it can be overriden with subclasses Throwable c = getCause(); if (c != null) { Formatting.renderThrowable(null, buffer, c); } else { // Use getMessage as it can be overriden with subclasses String m = getHtmlMessage(); buffer.append(m); } buffer.append("</div>"); response = response.content(buffer).withMimeType("text/html"); } return response; }
public Status asStatus(boolean verbose) { Response.Status response = Response.status(getStatus()); if (verbose) { StringBuilder buffer = new StringBuilder(); Formatting.renderStyleSheet(buffer); buffer.append("<div class=\"juzu\">"); buffer.append("<h1>Oups something went wrong</h1>"); // Use getCause as it can be overriden with subclasses Throwable c = getCause(); if (c != null) { Formatting.renderThrowable(null, buffer, c); } else { // Use getMessage as it can be overriden with subclasses String m = getHtmlMessage(); buffer.append(m); } buffer.append("</div>"); response = response.content(buffer).withMimeType("text/html"); } return response; }
@Ajax @Resource public Response saveActivePlugin(String pluginId, String inputs) { JSON data = new JSON(); try { Map<String, String> datas = parserParams(inputs); for (String channelId : datas.keySet()) { pluginSettingService.saveActivePlugin(channelId, pluginId, Boolean.valueOf(datas.get(channelId))); } data.set("status", "ok"); data.set("result", datas); } catch (Exception e) { LOG.error("Failed to save settings", e); data.set("status", "false"); data.set("error", "Exception: " + e.getMessage()); } return Response.ok(data.toString()).withMimeType("application/json"); }
@Ajax @Resource public Response saveSender(String name, String email) { JSON data = new JSON(); data.set("name", name); data.set("email",email); if(name != null && name.length() > 0 && NotificationUtils.isValidEmailAddresses(email)) { settingService.set(org.exoplatform.commons.api.settings.data.Context.GLOBAL, Scope.GLOBAL, NotificationPluginUtils.NOTIFICATION_SENDER_NAME, SettingValue.create(name)); settingService.set(org.exoplatform.commons.api.settings.data.Context.GLOBAL, Scope.GLOBAL, NotificationPluginUtils.NOTIFICATION_SENDER_EMAIL, SettingValue.create(email)); data.set("status","OK"); } else { data.set("status","NOK"); } return Response.ok(data.toString()).withMimeType("application/json"); }
@Resource public Response.Content onlineFriends() { String userId = ConversationState.getCurrent().getIdentity().getUserId(); JSONArray json = getOnlineFriends(userId); return Response.ok(json.toString()).withMimeType("application/json; charset=UTF-8").withHeader("Cache-Control", "no-cache"); }