@Test public void testActivityDoesNotExist() { final Collection<ActivitySecurityDTO> asdCollection = new ArrayList<ActivitySecurityDTO>(); asdCollection.add(asd); context.checking(new Expectations() { { allowing(getVisibleGroupsForUserMapper).execute(userId); will(returnValue(new HashSet<Long>())); allowing(securityMapper).execute(with(any(List.class))); will(returnValue(asdCollection)); allowing(asd).getExists(); will(returnValue(false)); allowing(asd).getId(); will(returnValue(activityId)); } }); Assert.assertEquals(0, sut.trim(Arrays.asList(activityId), userId).size()); context.assertIsSatisfied(); }
public List<Long> trim(final List<Long> activityIds, final Long userPersonId) { log.debug("Trimming " + activityIds.size() + " activity ids for person#" + userPersonId); Set<Long> accessibleGroupIds = getVisibleGroupsForUserMapper.execute(userPersonId); final Collection<ActivitySecurityDTO> securityDTOs = securityMapper.execute(activityIds); final List<Long> visibleActivities = new LinkedList<Long>(); for (ActivitySecurityDTO actSec : securityDTOs) { if (actSec.getExists() && (actSec.isDestinationStreamPublic() || accessibleGroupIds.contains(actSec .getDestinationEntityId()))) { log.debug("Activity with ID permitted: " + actSec.getId()); visibleActivities.add(actSec.getId()); } else { log.debug("Activity with ID NOT permitted: " + actSec.getId()); } } final List<Long> orderedActivities = new LinkedList<Long>(); for (int i = 0; i < activityIds.size(); i++) { if (visibleActivities.contains(activityIds.get(i))) { orderedActivities.add(activityIds.get(i)); } } return orderedActivities; }
ActivitySecurityTrimmer implements ListTrimmer, ActivityQueryListTrimmerFactory { public List<Long> trim(final List<Long> activityIds, final Long userPersonId) { log.debug("Trimming " + activityIds.size() + " activity ids for person#" + userPersonId); Set<Long> accessibleGroupIds = getVisibleGroupsForUserMapper.execute(userPersonId); final Collection<ActivitySecurityDTO> securityDTOs = securityMapper.execute(activityIds); final List<Long> visibleActivities = new LinkedList<Long>(); for (ActivitySecurityDTO actSec : securityDTOs) { if (actSec.getExists() && (actSec.isDestinationStreamPublic() || accessibleGroupIds.contains(actSec .getDestinationEntityId()))) { log.debug("Activity with ID permitted: " + actSec.getId()); visibleActivities.add(actSec.getId()); } else { log.debug("Activity with ID NOT permitted: " + actSec.getId()); } } final List<Long> orderedActivities = new LinkedList<Long>(); for (int i = 0; i < activityIds.size(); i++) { if (visibleActivities.contains(activityIds.get(i))) { orderedActivities.add(activityIds.get(i)); } } return orderedActivities; } }
ActivitySecurityTrimmer implements ListTrimmer, ActivityQueryListTrimmerFactory { public List<Long> trim(final List<Long> activityIds, final Long userPersonId) { log.debug("Trimming " + activityIds.size() + " activity ids for person#" + userPersonId); Set<Long> accessibleGroupIds = getVisibleGroupsForUserMapper.execute(userPersonId); final Collection<ActivitySecurityDTO> securityDTOs = securityMapper.execute(activityIds); final List<Long> visibleActivities = new LinkedList<Long>(); for (ActivitySecurityDTO actSec : securityDTOs) { if (actSec.getExists() && (actSec.isDestinationStreamPublic() || accessibleGroupIds.contains(actSec .getDestinationEntityId()))) { log.debug("Activity with ID permitted: " + actSec.getId()); visibleActivities.add(actSec.getId()); } else { log.debug("Activity with ID NOT permitted: " + actSec.getId()); } } final List<Long> orderedActivities = new LinkedList<Long>(); for (int i = 0; i < activityIds.size(); i++) { if (visibleActivities.contains(activityIds.get(i))) { orderedActivities.add(activityIds.get(i)); } } return orderedActivities; } ActivitySecurityTrimmer(final DomainMapper<List<Long>, Collection<ActivitySecurityDTO>> inSecurityMapper,
            final GetPrivateCoordinatedAndFollowedGroupIdsForUser inGetVisibleGroupsForUserMapper); }
ActivitySecurityTrimmer implements ListTrimmer, ActivityQueryListTrimmerFactory { public List<Long> trim(final List<Long> activityIds, final Long userPersonId) { log.debug("Trimming " + activityIds.size() + " activity ids for person#" + userPersonId); Set<Long> accessibleGroupIds = getVisibleGroupsForUserMapper.execute(userPersonId); final Collection<ActivitySecurityDTO> securityDTOs = securityMapper.execute(activityIds); final List<Long> visibleActivities = new LinkedList<Long>(); for (ActivitySecurityDTO actSec : securityDTOs) { if (actSec.getExists() && (actSec.isDestinationStreamPublic() || accessibleGroupIds.contains(actSec .getDestinationEntityId()))) { log.debug("Activity with ID permitted: " + actSec.getId()); visibleActivities.add(actSec.getId()); } else { log.debug("Activity with ID NOT permitted: " + actSec.getId()); } } final List<Long> orderedActivities = new LinkedList<Long>(); for (int i = 0; i < activityIds.size(); i++) { if (visibleActivities.contains(activityIds.get(i))) { orderedActivities.add(activityIds.get(i)); } } return orderedActivities; } ActivitySecurityTrimmer(final DomainMapper<List<Long>, Collection<ActivitySecurityDTO>> inSecurityMapper,
            final GetPrivateCoordinatedAndFollowedGroupIdsForUser inGetVisibleGroupsForUserMapper); List<Long> trim(final List<Long> activityIds, final Long userPersonId); @Override ListTrimmer getTrimmer(final JSONObject inRequest, final Long inUserEntityId); }
ActivitySecurityTrimmer implements ListTrimmer, ActivityQueryListTrimmerFactory { public List<Long> trim(final List<Long> activityIds, final Long userPersonId) { log.debug("Trimming " + activityIds.size() + " activity ids for person#" + userPersonId); Set<Long> accessibleGroupIds = getVisibleGroupsForUserMapper.execute(userPersonId); final Collection<ActivitySecurityDTO> securityDTOs = securityMapper.execute(activityIds); final List<Long> visibleActivities = new LinkedList<Long>(); for (ActivitySecurityDTO actSec : securityDTOs) { if (actSec.getExists() && (actSec.isDestinationStreamPublic() || accessibleGroupIds.contains(actSec .getDestinationEntityId()))) { log.debug("Activity with ID permitted: " + actSec.getId()); visibleActivities.add(actSec.getId()); } else { log.debug("Activity with ID NOT permitted: " + actSec.getId()); } } final List<Long> orderedActivities = new LinkedList<Long>(); for (int i = 0; i < activityIds.size(); i++) { if (visibleActivities.contains(activityIds.get(i))) { orderedActivities.add(activityIds.get(i)); } } return orderedActivities; } ActivitySecurityTrimmer(final DomainMapper<List<Long>, Collection<ActivitySecurityDTO>> inSecurityMapper,
            final GetPrivateCoordinatedAndFollowedGroupIdsForUser inGetVisibleGroupsForUserMapper); List<Long> trim(final List<Long> activityIds, final Long userPersonId); @Override ListTrimmer getTrimmer(final JSONObject inRequest, final Long inUserEntityId);  }