/** * Utility helper for implementing getInterestedUsers() that gets everyone in the group identified * by the group id in data1. * * @param block * @return */ protected final Set<User> getUsersWhoCareAboutData1Group(Block block) { Group group; try { group = EJBUtil.lookupGuid(em, Group.class, block.getData1AsGuid()); } catch (NotFoundException e) { throw new RuntimeException("invalid group in data1 of " + block, e); } Set<User> groupMembers = groupSystem.getUserMembers(SystemViewpoint.getInstance(), group); return groupMembers; }
protected final Set<User> getUsersWhoCareAboutData1UserAndExternalAccount( Block block, ExternalAccountType accountType) { User user = getData1User(block); if (externalAccountSystem.getExternalAccountExistsLovedAndEnabled( SystemViewpoint.getInstance(), user, accountType)) { return getUsersWhoCareAboutData1User(block, user); } else { return Collections.emptySet(); } }
private Set<Group> getGroupsData1UserIsIn(Block block, User user) { switch (block.getInclusion()) { case IN_ALL_STACKS: case ONLY_WHEN_VIEWED_BY_OTHERS: return groupSystem.findRawGroups(SystemViewpoint.getInstance(), user); case ONLY_WHEN_VIEWING_SELF: return Collections.emptySet(); // no default, hides bugs } throw new RuntimeException("invalid inclusion " + block); }
@Override protected Post loadObject(Guid guid) { try { PostingBoard board = EJBUtil.defaultLookup(PostingBoard.class); Post post = board.loadRawPost(SystemViewpoint.getInstance(), guid); // Filter group notifications from search results if (board.postIsGroupNotification(post)) return null; return post; } catch (NotFoundException e) { throw new RuntimeException(e); } }
private FacebookAccount lookupFacebookAccount(String key) { try { FacebookAccount facebookAccount = facebookSystem.lookupFacebookAccount(SystemViewpoint.getInstance(), key); return facebookAccount; } catch (ParseException e) { throw new RuntimeException("Could not parse the key " + key + " as a user guid", e); } catch (NotFoundException e) { throw new RuntimeException( "Could not find the user or facebook account for the user with guid " + key, e); } }
private Set<User> getUsersWhoCareAboutData1User(Block block, User user) { Set<User> peopleWhoCare = null; switch (block.getInclusion()) { case IN_ALL_STACKS: case ONLY_WHEN_VIEWED_BY_OTHERS: peopleWhoCare = identitySpider.getUsersWhoHaveUserAsContact(SystemViewpoint.getInstance(), user); // we also show each block to its "owner" when it is IN_ALL_STACKS; // we include the "owner" for the ONLY_WHEN_VIEWED_BY_OTHERS block, so // that the block is displayed in the owner's mugshot when it is viewed // by another person peopleWhoCare.add(user); return peopleWhoCare; case ONLY_WHEN_VIEWING_SELF: peopleWhoCare = Collections.singleton(user); return peopleWhoCare; // no default, it hides bugs } throw new RuntimeException("invalid inclusion " + block); }