@GET @Path("/all") @AnonymousAllowed public Response getLinks(@QueryParam("gadgetId") Long gadgetId) { final ApplicationUser applicationUser = authenticationContext.getUser(); final User user = applicationUser.getDirectoryUser(); if (this.justStarted) { Map<String, String> userPrefs = portletConfigurationManager.getByPortletId(gadgetId).getUserPrefs(); // TODO: pass in the name of used UserPref as ajax parameter String allLinks = userPrefs.get("allLinks"); if (customlinks.isEmpty() && allLinks != null && allLinks != "") userPrefProcess(allLinks); this.justStarted = false; } if (customlinks.isEmpty()) { CacheControl cc = new CacheControl(); cc.setNoCache(true); return Response.ok(new Warning()).cacheControl(cc).build(); } CacheControl cc = new CacheControl(); cc.setNoCache(true); return Response.ok(customlinks).cacheControl(cc).build(); }
/** * Converts the given field values object into a set of values. * * @param fieldValues field values * @return a set of field values */ Set<User> convertToUserSet(Object fieldValues) { if (fieldValues == null) { return Collections.emptySet(); } if (fieldValues instanceof Collection) // http://jira.atlassian.com/browse/JRA-13523 { Collection<ApplicationUser> applicationUsers = (Collection<ApplicationUser>) fieldValues; Set<User> users = new HashSet<User>(applicationUsers.size()); for (ApplicationUser applicationUser : applicationUsers) { users.add(applicationUser.getDirectoryUser()); } return users; } else { ApplicationUser applicationUser = (ApplicationUser) fieldValues; return Collections.singleton(applicationUser.getDirectoryUser()); } }
private AdhocNotificationService.ValidateNotificationResult expectNotificationToRecipient( final NotificationRecipient recipient) { final NotificationBuilder notificationBuilder = Mockito.mock(NotificationBuilder.class); when(notificationBuilderFactory.createNotificationBuilder( eq(shareBean.getMessage()), eq(recipient), any(Set.class))) .thenReturn(notificationBuilder); final AdhocNotificationService.ValidateNotificationResult validationResult = new MockAdhocNotificationService() .getSampleValidationResult(user.getDirectoryUser(), issue, notificationBuilder); when(notificationService.validateNotification( notificationBuilder, user.getDirectoryUser(), issue, CONTINUE_ON_NO_RECIPIENTS)) .thenReturn(validationResult); return validationResult; }
@Before public void setUp() { shareIssueService = new ShareIssueService( eventPublisher, notificationService, notificationBuilderFactory, notificationRecipientUtil); when(user.getDirectoryUser()).thenReturn(directoryUser); }