/** * return the object data contains the url of logo and the bar navigation * * @param httpContext * @return Resource */ @Ajax @Resource public Response.Content getResource(HttpContext httpContext) { JSONObject json = new JSONObject(); String style = "Dark"; if (settingService.get(Context.GLOBAL, Scope.GLOBAL, BAR_NAVIGATION_STYLE_KEY) != null) { style = (String) settingService.get(Context.GLOBAL, Scope.GLOBAL, BAR_NAVIGATION_STYLE_KEY) .getValue(); } try { json.put("error", "0"); json.put("style", style); json.put("logoUrl", getLogoUrl(httpContext, true)); } catch (JSONException ex) { if (LOG.isErrorEnabled()) { LOG.error("Can not put json value", ex); } } return Response.ok(json.toString()).with(PropertyType.MIME_TYPE, "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"); }
@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"); }
return Response.ok(result.toString()).with(PropertyType.MIME_TYPE, "application/json");
return Response.ok();
Streamable streamable = writer.marshall(s, context.getHandler().getMethod(), ret); if (streamable != null) { return Response.ok().with(PropertyType.MIME_TYPE, s).body(streamable);
Streamable streamable = writer.marshall(s, context.getHandler().getMethod(), ret); if (streamable != null) { return Response.ok().with(PropertyType.MIME_TYPE, s).body(streamable);
@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"); }