@Override public void deleteMessages(final JSONObject deleteIds, AsyncCallback<String> callback) { String address = deProperties.getMuleServiceBaseUrl() + "notifications/delete"; // $NON-NLS-1$ ServiceCallWrapper wrapper = new ServiceCallWrapper(POST, address, deleteIds.toString()); deServiceFacade.getServiceData(wrapper, callback); }
@Override public void getRecentMessages(AsyncCallback<NotificationList> callback) { String address = deProperties.getMuleServiceBaseUrl() + "notifications/last-ten-messages"; // $NON-NLS-1$ ServiceCallWrapper wrapper = new ServiceCallWrapper(GET, address); deServiceFacade.getServiceData( wrapper, new NotificationCallbackConverter(callback, notesFactory)); }
@Override public void markAllNotificationsSeen(AsyncCallback<Void> callback) { String address = deProperties.getMuleServiceBaseUrl() + "notifications/mark-all-seen"; // $NON-NLS-1$ ServiceCallWrapper wrapper = new ServiceCallWrapper(POST, address, userInfo.getUsername()); deServiceFacade.getServiceData(wrapper, new StringToVoidCallbackConverter(callback)); }
@Override public void getMessageCounts(final AsyncCallback<Counts> callback) { final String addr = deProperties.getMuleServiceBaseUrl() + "notifications/count-messages?seen=false"; //$NON-NLS-1$ final ServiceCallWrapper wrapper = new ServiceCallWrapper(Type.GET, addr); final AsyncCallback<String> convCB = new CountsCB(callback, notesFactory); deServiceFacade.getServiceData(wrapper, convCB); }
@Override public void markAsSeen(final List<HasId> seenIds, AsyncCallback<String> callback) { String address = deProperties.getMuleServiceBaseUrl() + "notifications/seen"; // $NON-NLS-1$ Splittable payload = StringQuoter.createSplittable(); diskResourceUtil.createStringIdListSplittable(seenIds).assign(payload, "uuids"); ServiceCallWrapper wrapper = new ServiceCallWrapper(POST, address, payload.getPayload()); deServiceFacade.getServiceData(wrapper, callback); }
@Override public void deleteAll(NotificationCategory category, AsyncCallback<String> callback) { String address = deProperties.getMuleServiceBaseUrl() + "notifications/delete-all"; // $NON-NLS-1$ if (NotificationCategory.ALL != category) { address += "?filter=" + URL.encodeQueryString(category.toString().toLowerCase()); } ServiceCallWrapper wrapper = new ServiceCallWrapper(DELETE, address); deServiceFacade.getServiceData(wrapper, callback); }
@Override public <C extends NotificationCallback> void getNotifications( int limit, int offset, String filter, String sortDir, C callback) { String address = deProperties.getMuleServiceBaseUrl(); StringBuilder builder = new StringBuilder("notifications/messages?limit=" + limit + "&offset=" + offset); if (filter != null && !filter.isEmpty()) { builder.append("&filter=").append(URL.encodeQueryString(filter)); } if (sortDir != null && !sortDir.isEmpty() && !sortDir.equalsIgnoreCase("NONE")) { builder.append("&sortDir=").append(URL.encodeQueryString(sortDir)); } address = address + builder.toString(); ServiceCallWrapper wrapper = new ServiceCallWrapper(GET, address); deServiceFacade.getServiceData(wrapper, callback); }