@Test public void testShouldBeIncludedBlacklist() throws Exception { SearchChannel channel = mock(SearchChannel.class); mockCapabilities(channel, true); doReturn(true).when(channel).hasPermission(any(User.class)); doReturn("TestChannel").when(channel).getId(); PropertyUtil.addProperty("actionhandler.SearchOptions.blacklist", "TestChannel"); SearchOptionsHandler handler = getHandler(); assertFalse("Channel should not permitted for guest", handler.shouldBeIncluded(channel, getGuestUser())); assertFalse("Channel should be permitted for user", handler.shouldBeIncluded(channel, getLoggedInUser())); PropertyUtil.clearProperties(); handler = getHandler(); assertTrue("Channel should not permitted for guest", handler.shouldBeIncluded(channel, getGuestUser())); assertTrue("Channel should be permitted for user", handler.shouldBeIncluded(channel, getLoggedInUser())); }
protected boolean shouldBeIncluded(SearchableChannel channel, User user) { if(!channel.getCapabilities().canTextSearch()) { return false; } if(blacklist.contains(channel.getId())) { return false; } return channel.hasPermission(user); }
SearchOptionsHandler extends ActionHandler { protected boolean shouldBeIncluded(SearchableChannel channel, User user) { if(!channel.getCapabilities().canTextSearch()) { return false; } if(blacklist.contains(channel.getId())) { return false; } return channel.hasPermission(user); } }
SearchOptionsHandler extends ActionHandler { protected boolean shouldBeIncluded(SearchableChannel channel, User user) { if(!channel.getCapabilities().canTextSearch()) { return false; } if(blacklist.contains(channel.getId())) { return false; } return channel.hasPermission(user); }  }
SearchOptionsHandler extends ActionHandler { protected boolean shouldBeIncluded(SearchableChannel channel, User user) { if(!channel.getCapabilities().canTextSearch()) { return false; } if(blacklist.contains(channel.getId())) { return false; } return channel.hasPermission(user); }  void setSearchService(SearchService service); @Override void init(); void handleAction(final ActionParameters params); }
SearchOptionsHandler extends ActionHandler { protected boolean shouldBeIncluded(SearchableChannel channel, User user) { if(!channel.getCapabilities().canTextSearch()) { return false; } if(blacklist.contains(channel.getId())) { return false; } return channel.hasPermission(user); }  void setSearchService(SearchService service); @Override void init(); void handleAction(final ActionParameters params);  }