@Ajax @Resource public Response.Content incDate(String nbClick) throws Exception { int clickNumber = Integer.parseInt(nbclick); clickNumber++; nbclick = new Integer(clickNumber).toString(); return calendarHome(); }
@Ajax @Resource public Response.Content decDate(String nbClick) throws Exception { int clickNumber = Integer.parseInt(nbclick); clickNumber--; nbclick = new Integer(clickNumber).toString(); return calendarHome(); }
@Ajax @Resource public Response.Content getSearchResult(String key) { Iterator itr = null; if (calendarNonDisplayedList != null) itr = calendarNonDisplayedList.iterator(); searchResult.clear(); while (itr.hasNext()) { org.exoplatform.calendar.service.Calendar c = (org.exoplatform.calendar.service.Calendar) itr.next(); if (c.getName().toLowerCase().contains(key.toLowerCase())) searchResult.add(c); } // String label = "Default Personal Calendar"; return search.with().set("searchResultList", searchResult).ok().withCharset(Tools.UTF_8); }
@Ajax @Resource public Response.Content addCalendar(String calendarId) throws Exception { StringBuilder cals = new StringBuilder(); int i = 0; nonDisplayedCalendarList = (String[]) ArrayUtils.removeElement(nonDisplayedCalendarList, calendarId); while (i < nonDisplayedCalendarList.length) { if (!nonDisplayedCalendarList[i].equals(calendarId)) cals.append(nonDisplayedCalendarList[i]).append(","); i++; } settingService_.remove(Context.USER, Scope.APPLICATION, CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS); settingService_.set(Context.USER, Scope.APPLICATION, CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS, SettingValue.create("NonDisplayedCalendar:" + cals.toString())); return setting(); }
@Ajax @Resource public Response.Content deleteCalendar(String calendarId) throws Exception { nonDisplayedCalendarList = (String[]) ArrayUtils.add(nonDisplayedCalendarList, calendarId); StringBuffer cal = new StringBuffer(); int i = 0; while (i < nonDisplayedCalendarList.length) { cal.append(nonDisplayedCalendarList[i]).append(","); i++; } settingService_.remove(Context.USER, Scope.APPLICATION, CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS); settingService_.set(Context.USER, Scope.APPLICATION, CalendarPortletUtils.HOME_PAGE_CALENDAR_SETTINGS, SettingValue.create("NonDisplayedCalendar:" + cal.toString())); return setting(); }
@Ajax @Resource public Response.Content delete() throws Exception { //set Delete String userId = null; SessionProvider sProvider = null; try { userId = RequestContext.getCurrentInstance().getRemoteUser(); sProvider = SessionProvider.createSystemProvider(); Node userPrivateNode = nodeHierarchyCreator_.getUserNode(sProvider, userId).getNode(GettingStartedUtils.JCR_APPLICATION_NODE); if (userPrivateNode.hasNode(GettingStartedUtils.JCR_GS_NODE)) { Node gettingStartedNode = userPrivateNode.getNode(GettingStartedUtils.JCR_GS_NODE); if (gettingStartedNode.hasProperty(GettingStartedUtils.JCR_DELETE_GADGET_PROPERTY_NAME)) { gettingStartedNode.setProperty(GettingStartedUtils.JCR_DELETE_GADGET_PROPERTY_NAME, true); gettingStartedNode.save(); } } } catch (Exception E) { LOG.error("GettingStarted Portlet : Can not delete Portlet from ApplicationRegistry", E.getLocalizedMessage(), E); } finally { if (sProvider != null) { sProvider.close(); } } return gettingStarted.ok(); }
@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"); }
/** * 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"); }
@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.Content setting() throws Exception { calendarDisplayedList.clear(); calendarNonDisplayedList.clear(); String username = RequestContext.getCurrentInstance().getRemoteUser(); String defaultCalendarLabel = "Default"; Iterator itr1 = getAllCal(username).iterator(); while (itr1.hasNext()) { org.exoplatform.calendar.service.Calendar c = (org.exoplatform.calendar.service.Calendar) itr1.next(); if(c.getGroups()==null) { if (c.getId().equals(Utils.getDefaultCalendarId(username)) && c.getName().equals(calendarService_.getDefaultCalendarName())) { c.setName(defaultCalendarLabel); } } if (CalendarPortletUtils.contains(nonDisplayedCalendarList, c.getId())) { calendarNonDisplayedList.add(c); } else { calendarDisplayedList.add(c); } } return setting.with().set("displayedCalendar", calendarDisplayedList). set("nonDisplayedCalendar", calendarNonDisplayedList).ok().withCharset(Tools.UTF_8); }
@Ajax @Resource public Response.Content calendarHome() throws Exception {
@Resource public Response.Content uploadFile(HttpContext httpContext, FileItem file, String browser) throws IOException { if (browser != null && browser.equals("html5")) {
@Resource public Response.Content save(String style, String isChangeLogo, HttpContext httpContext) { if (isAdmin()) {
@Ajax @Resource public Response getGsList(String reload) throws Exception { HashMap bundle = new HashMap();
@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"); }