List of usage examples for org.apache.commons.collections CollectionUtils containsAny
public static boolean containsAny(final Collection coll1, final Collection coll2)
true
iff at least one element is in both collections. From source file:org.asqatasun.rules.accessiweb22.Aw22Rule08031.java
/** * Checks recursively whether an element has a parent with a lang attribute * * @param el/*from w w w . j a v a2s . com*/ * @return whether the element passed as argument has a parent with a lang * attribute */ private boolean isElementHasParentWithLang(Element el) { return CollectionUtils.containsAny(el.parents(), elementWithLang.get()); }
From source file:org.gradle.integtests.fixtures.DaemonGradleExecuter.java
private void configureDefaultLogging(List<String> args) { if (!allowExtraLogging) { return;//from w w w .ja v a2 s . com } List logOptions = asList("-i", "--info", "-d", "--debug", "-q", "--quite"); boolean alreadyConfigured = CollectionUtils.containsAny(args, logOptions); if (!alreadyConfigured) { args.add("-i"); } }
From source file:org.gridgain.grid.util.ipc.shmem.GridIpcSharedMemoryCrashDetectionSelfTest.java
/** * @throws Exception If failed./*from ww w . ja v a 2 s.c o m*/ */ public void testGgfsServerClientInteractionsUponClientKilling() throws Exception { U.setWorkDirectory(null, U.getGridGainHome()); // Run server endpoint. GridIpcSharedMemoryServerEndpoint srv = new GridIpcSharedMemoryServerEndpoint(); new GridTestResources().inject(srv); try { srv.start(); info("Check that server gets correct exception upon client's killing."); info("Shared memory IDs before starting client endpoint: " + GridIpcSharedMemoryUtils.sharedMemoryIds()); Collection<Integer> shmemIdsWithinInteractions = interactWithClient(srv, true); Collection<Integer> shmemIdsAfterInteractions = null; // Give server endpoint some time to make resource clean up. See GridIpcSharedMemoryServerEndpoint.GC_FREQ. for (int i = 0; i < 12; i++) { shmemIdsAfterInteractions = GridIpcSharedMemoryUtils.sharedMemoryIds(); info("Shared memory IDs created within interaction: " + shmemIdsWithinInteractions); info("Shared memory IDs after killing client endpoint: " + shmemIdsAfterInteractions); if (CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions)) U.sleep(1000); else break; } assertFalse( "List of shared memory IDs after killing client endpoint should not include IDs created " + "within server-client interactions.", CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions)); } finally { srv.close(); } }
From source file:org.gridgain.grid.util.ipc.shmem.GridIpcSharedMemoryCrashDetectionSelfTest.java
/** * @throws Exception If failed.//from w w w . j av a2 s . co m */ public void testGgfsClientServerInteractionsUponServerKilling() throws Exception { Collection<Integer> shmemIdsBeforeInteractions = GridIpcSharedMemoryUtils.sharedMemoryIds(); info("Shared memory IDs before starting server-client interactions: " + shmemIdsBeforeInteractions); Collection<Integer> shmemIdsWithinInteractions = interactWithServer(); Collection<Integer> shmemIdsAfterInteractions = GridIpcSharedMemoryUtils.sharedMemoryIds(); info("Shared memory IDs created within interaction: " + shmemIdsWithinInteractions); info("Shared memory IDs after server and client killing: " + shmemIdsAfterInteractions); if (!U.isLinux()) assertTrue( "List of shared memory IDs after server-client interactions should include IDs created within " + "client-server interactions.", shmemIdsAfterInteractions.containsAll(shmemIdsWithinInteractions)); else assertFalse( "List of shared memory IDs after server-client interactions should not include IDs created " + "(on Linux): within client-server interactions.", CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions)); ProcessStartResult srvStartRes = startSharedMemoryTestServer(); try { // Give server endpoint some time to make resource clean up. See GridIpcSharedMemoryServerEndpoint.GC_FREQ. for (int i = 0; i < 12; i++) { shmemIdsAfterInteractions = GridIpcSharedMemoryUtils.sharedMemoryIds(); info("Shared memory IDs after server restart: " + shmemIdsAfterInteractions); if (CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions)) U.sleep(1000); else break; } assertFalse( "List of shared memory IDs after server endpoint restart should not include IDs created: " + "within client-server interactions.", CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions)); } finally { srvStartRes.proc().kill(); srvStartRes.isKilledLatch().await(); } }
From source file:org.gridgain.grid.util.ipc.shmem.GridIpcSharedMemoryCrashDetectionSelfTest.java
/** * @throws Exception If failed./*from www . j av a2 s .c o m*/ */ public void testClientThrowsCorrectExceptionUponServerKilling() throws Exception { info("Shared memory IDs before starting server-client interactions: " + GridIpcSharedMemoryUtils.sharedMemoryIds()); Collection<Integer> shmemIdsWithinInteractions = checkClientThrowsCorrectExceptionUponServerKilling(); Collection<Integer> shmemIdsAfterInteractions = GridIpcSharedMemoryUtils.sharedMemoryIds(); info("Shared memory IDs created within interaction: " + shmemIdsWithinInteractions); info("Shared memory IDs after server killing and client graceful termination: " + shmemIdsAfterInteractions); assertFalse( "List of shared memory IDs after killing server endpoint should not include IDs created " + "within server-client interactions.", CollectionUtils.containsAny(shmemIdsAfterInteractions, shmemIdsWithinInteractions)); }
From source file:org.icgc.dcc.submission.shiro.DccWrappingRealm.java
private Set<String> buildProjectSpecificPermissions(String username, Collection<String> roles) { Set<String> permissions = Sets.newLinkedHashSet(); for (Project project : projectService.getProjects()) { if (Authorizations.hasAdminRole(roles) || project.hasUser(username) || CollectionUtils.containsAny(project.getGroups(), roles)) { permissions.add(AuthorizationPrivileges.projectViewPrivilege(project.getKey())); }//from w ww.j av a2 s . co m } return permissions; }
From source file:org.intalio.tempo.workflow.auth.BaseRestrictedEntity.java
public boolean isAvailableTo(UserRoles credentials) { String userId = credentials.getUserID(); for (String userOwner : getUserOwners()) if (userId.equals(userOwner)) return true; return CollectionUtils.containsAny(getRoleOwners(), credentials.getAssignedRoles()); }
From source file:org.jahia.ajax.gwt.helper.ContentDefinitionHelper.java
private void add(ExtendedNodeType type, List<String> baseTypes, Map<String, ExtendedNodeType> contentTypes, Collection<ExtendedNodeType> result, boolean excludeNonDroppable) { if (!excludedTypes.contains(type.getName()) && !type.isMixin() && !type.isAbstract() && (!excludeNonDroppable || CollectionUtils .containsAny(Arrays.asList(type.getDeclaredSupertypeNames()), contentTypes.keySet()))) { if (!baseTypes.isEmpty()) { for (String t : baseTypes) { if (type.isNodeType(t)) { result.add(type);//from www. j a va 2 s. co m return; } } } else { result.add(type); } } }
From source file:org.jajuk.services.dj.TransitionDigitalDJ.java
/** * Gets the transition.// w ww. j ava 2 s . c o m * * @param ambience * * @return transition mapping this FROM ambience or null if none maps it */ public Transition getTransition(Ambience ambience) { for (Transition transition : transitions) { if (CollectionUtils.containsAny(transition.getFrom().getGenres(), ambience.getGenres())) { return transition; } } return null; }
From source file:org.jasig.ssp.service.impl.EvaluatedSuccessIndicatorServiceImpl.java
private SuccessIndicatorEvaluation evaluateStringMatchingRule(@Nonnull List<String> normalizedMetric, @Nullable String rawRule, @Nonnull SuccessIndicatorEvaluation resultOnMatch, @Nonnull SuccessIndicator successIndicator, @Nonnull Person person) { List<String> normalizedRule = null; try {//from w ww .ja v a2s .co m normalizedRule = normalizeForStringEvaluation(rawRule, successIndicator); } catch (RuntimeException e) { // see rationale for debug level logging elsewhere in this class LOGGER.debug("Failed to evaluate metric [{}] for person [{}] for against " + "STRING rule [{}] for result [{}] using success indicator [{}]. String rule is likely malformed.", new Object[] { normalizedMetric, person.getId(), rawRule, resultOnMatch, successIndicatorLoggingId(successIndicator), e }); // rule itself is formatted badly or otherwise non-normalizable, so handle the same way we do for // scale evals and treat this as a 'no match' return null; } if (isEmptyNormalizedString(normalizedRule)) { return null; } return CollectionUtils.containsAny(normalizedMetric, normalizedRule) ? resultOnMatch : null; }