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.jbpm.kie.services.impl.RuntimeDataServiceImpl.java
protected List<String> getDeploymentsForUser() { String identityName = null;//from ww w .j a v a 2s.c om List<String> roles = null; try { identityName = identityProvider.getName(); roles = identityProvider.getRoles(); } catch (Exception e) { // in case there is no way to collect either name of roles of the requesting used return empty list return new ArrayList<String>(); } List<String> usersDeploymentIds = userDeploymentIdsCache.get(identityName); if (usersDeploymentIds != null) { return usersDeploymentIds; } usersDeploymentIds = new ArrayList<String>(); userDeploymentIdsCache.put(identityName, usersDeploymentIds); boolean isSecured = false; for (Map.Entry<String, List<String>> entry : deploymentsRoles.entrySet()) { if (entry.getValue().isEmpty() || CollectionUtils.containsAny(roles, entry.getValue())) { usersDeploymentIds.add(entry.getKey()); } if (entry.getValue() != null && !entry.getValue().isEmpty()) { isSecured = true; } } if (isSecured && usersDeploymentIds.isEmpty()) { usersDeploymentIds.add("deployments-are-secured"); } return usersDeploymentIds; }
From source file:org.jbpm.kie.services.impl.security.DeploymentRolesManager.java
public List<String> getDeploymentsForUser(IdentityProvider identityProvider) { String identityName = null;/*ww w .jav a 2 s. com*/ List<String> roles = null; try { identityName = identityProvider.getName(); roles = identityProvider.getRoles(); } catch (Exception e) { // in case there is no way to collect either name of roles of the requesting used return empty list return new ArrayList<String>(); } List<String> usersDeploymentIds = userDeploymentIdsCache.get(identityName); if (usersDeploymentIds != null) { return usersDeploymentIds; } usersDeploymentIds = new ArrayList<String>(); userDeploymentIdsCache.put(identityName, usersDeploymentIds); boolean isSecured = false; for (Map.Entry<String, List<String>> entry : deploymentsRoles.entrySet()) { if (entry.getValue().isEmpty() || CollectionUtils.containsAny(roles, entry.getValue())) { usersDeploymentIds.add(entry.getKey()); } if (entry.getValue() != null && !entry.getValue().isEmpty()) { isSecured = true; } } if (isSecured && usersDeploymentIds.isEmpty()) { usersDeploymentIds.add("deployments-are-secured"); } return usersDeploymentIds; }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
public void selectFromList(String locator, List<String> items) { List<String> values = getSelectedListValues(locator); boolean containsValues = CollectionUtils.containsAny(values, items); if (containsValues) { selectFromListByValue(locator, items); return;/*from w w w. j a v a 2 s . com*/ } List<String> texts = getSelectedListLabels(locator); boolean containsText = CollectionUtils.containsAny(texts, items); if (containsText) { selectFromListByLabel(locator, items); } }
From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java
public void unselectFromList(String locator, List<String> items) { List<String> values = getSelectedListValues(locator); boolean containsValues = CollectionUtils.containsAny(values, items); if (containsValues) { unselectFromListByValue(locator, items); return;/*from w w w . j a v a2 s .c o m*/ } List<String> texts = getSelectedListLabels(locator); boolean containsText = CollectionUtils.containsAny(texts, items); if (containsText) { unselectFromListByLabel(locator, items); } }
From source file:org.kutkaitis.timetable2.timetable.MonteCarlo.java
private boolean isStudentInOneLectureAtTheTime(Teacher teacher, List<Group> teachersGroups, Group group, int lectureNumber, LinkedHashMap<String, LinkedHashMap> dayTimeTable) { boolean mandatoryConditionsMet = true; if (group != null) { // System.out.println("Grupe idejimui: " + group.getGroupName()); List<Student> groupStudents = group.getStudents(); Collection<LinkedHashMap> teachersTimeTables = dayTimeTable.values(); // System.out.println("teachersTimeTables before if: " + teachersTimeTables); for (LinkedHashMap<String, String> teachersTimeTable : teachersTimeTables) { // System.out.println("Iskviete fore"); if (teachersTimeTable.isEmpty()) { mandatoryConditionsMet = true; continue; }//from w w w . ja v a2 s . c o m // System.out.println("teachersTimeTable: " + teachersTimeTable); String groupNameToSplit = teachersTimeTable.get(String.valueOf(lectureNumber)); if (groupNameToSplit == null) { mandatoryConditionsMet = true; continue; } String[] splittedGroupNames = groupNameToSplit.split(":"); String groupName = splittedGroupNames[1].trim(); // System.out.println("Group name: " + groupName); Group groupToCheck = studentsMockDataFiller.getGroups().get(groupName); // System.out.println("groupToCheck: " + groupToCheck); boolean contains = true; if (StringUtils.equals(groupName, "-----")) { contains = false; } if (groupToCheck != null) { // System.out.println("Group to check: " + groupToCheck.getGroupName()); contains = CollectionUtils.containsAny(groupStudents, groupToCheck.getStudents()); // System.out.println("Contains: " + contains); } if (contains == false) { mandatoryConditionsMet = true; } else { mandatoryConditionsMet = false; return mandatoryConditionsMet; } } } else { mandatoryConditionsMet = false; } return mandatoryConditionsMet; }
From source file:org.lockss.poller.v3.V3Poller.java
boolean isGroupMatch(PeerIdentityStatus status) { List groups = status.getGroups(); // if we haven't recorded a group, allow it if (groups == null || groups.isEmpty()) { return true; }/*w w w .j a v a 2 s. c o m*/ if (CollectionUtils.containsAny(groups, ConfigManager.getPlatformGroupList())) { return true; } if (TimeBase.msSince(status.getLastGroupTime()) > pollManager.getWrongGroupRetryTime()) { // Don't want to keep trying him status.setLastGroupTime(TimeBase.nowMs()); return true; } return false; }
From source file:org.lockss.poller.v3.V3PollFactory.java
/** * Construct a new V3 Voter to participate in a poll. * /*w w w . j ava 2s .c om*/ * @param daemon The LOCKSS Daemon * @param msg The Poll message that invited this peer. * @param pollspec The Poll Spec for this poll. * @param orig The caller of the poll * @param duration Unused * @return An active V3 Voter or null if decide not to participate. * @throws V3Serializer.PollSerializerException */ private V3Voter makeV3Voter(LockssDaemon daemon, LcapMessage msg, PollSpec pollspec, PeerIdentity orig, long duration) throws V3Serializer.PollSerializerException { log.debug2("Creating V3Voter for " + orig + "'s poll: " + pollspec); IdentityManager idMgr = daemon.getIdentityManager(); V3LcapMessage m = (V3LcapMessage) msg; CachedUrlSet cus = pollspec.getCachedUrlSet(); // Do we have the AU? if (cus == null) { log.debug2("Ignoring poll request from " + orig + " don't have AU: " + pollspec.getAuId()); PollNak reason = daemon.areAusStarted() ? PollNak.NAK_NO_AU : PollNak.NAK_NOT_READY; sendNak(daemon, reason, pollspec.getAuId(), (V3LcapMessage) msg); return null; } ArchivalUnit au = cus.getArchivalUnit(); String auPollVer = AuUtil.getPollVersion(au); if (!pollspec.getPluginVersion().equals(auPollVer)) { log.debug("Ignoring poll request from " + orig + " for " + au.getName() + ", plugin version mismatch; have: " + auPollVer + ", need: " + pollspec.getPluginVersion()); sendNak(daemon, PollNak.NAK_PLUGIN_VERSION_MISMATCH, pollspec.getAuId(), (V3LcapMessage) msg, auPollVer); return null; } // Remove any record that this peer doesn't have the AU deleteFromNoAuPeers(au, orig); // Ignore messages from ourself. if (orig == idMgr.getLocalPeerIdentity(Poll.V3_PROTOCOL)) { log.warning("Got request from myself, ignoring."); return null; } if (!CurrentConfig.getBooleanParam(PARAM_ENABLE_V3_VOTER, DEFAULT_ENABLE_V3_VOTER)) { log.debug("V3 Voter not enabled, so not participating in poll " + m.getKey()); sendNak(daemon, PollNak.NAK_DISABLED, pollspec.getAuId(), m); return null; } // check polling group List ourGroups = ConfigManager.getPlatformGroupList(); if (m.getGroupList() == null || !CollectionUtils.containsAny(ourGroups, m.getGroupList())) { sendNak(daemon, PollNak.NAK_GROUP_MISMATCH, pollspec.getAuId(), m); return null; } AuState aus = AuUtil.getAuState(au); // Decline poll if AU is known not to have substance. (Might drop out // later if we discover, while hashing, that AU has no substance.) switch (aus.getSubstanceState()) { case No: log.debug("Declining poll request from " + orig + ", AU has no substantial content: " + au.getName()); sendNak(daemon, PollNak.NAK_NO_SUBSTANCE, pollspec.getAuId(), m); return null; default: } // Never vote if not crawled, even if pub down XXX Voting should be // allowed if either crawled or recovered. Substance test isn't // enough. Should vote only after *complete* crawl or recovery (which // might be determined by poll agreement), but might have substance // after incomplete crawl. if (!aus.hasCrawled()) { log.debug("AU not crawled, not voting: " + pollspec.getAuId()); sendNak(daemon, PollNak.NAK_NOT_CRAWLED, pollspec.getAuId(), m); return null; } // Check to see if we're running too many polls already. if (daemon.getPollManager().tooManyV3Voters()) { log.info("Not starting new V3 Voter for poll on AU " + au.getAuId() + "."); sendNak(daemon, PollNak.NAK_TOO_MANY_VOTERS, pollspec.getAuId(), m); return null; } // Make a probabilistic choice based on the number of willing repairers // we have for this AU if (!ProbabilisticChoice.choose(acceptProb(orig, au))) { log.info("Not participating in poll; AU is safe: " + au.getName()); sendNak(daemon, PollNak.NAK_HAVE_SUFFICIENT_REPAIRERS, pollspec.getAuId(), m); return null; } // Update the status of the peer that called this poll. PeerIdentityStatus status = idMgr.getPeerIdentityStatus(orig); if (status != null) { status.calledPoll(); } log.debug("Creating V3Voter to participate in poll " + m.getKey()); V3Voter voter = new V3Voter(daemon, m); return voter; }
From source file:org.lockss.protocol.IdentityManagerStatus.java
private boolean isGroupMatch(PeerIdentityStatus status, List myGroups) { Collection hisGroups = status.getGroups(); return hisGroups == null || hisGroups.isEmpty() || CollectionUtils.containsAny(myGroups, hisGroups); }
From source file:org.lockss.servlet.ServletUtil.java
static boolean shouldDisplayGroups(List groups) { List dontGroups = CurrentConfig.getList(PARAM_DONT_DISPLAY_GROUPS, DEFAULT_DONT_DISPLAY_GROUPS); return groups != null && !CollectionUtils.containsAny(groups, dontGroups); }
From source file:org.lockss.ws.status.PeerWsSource.java
@Override public Boolean getPlatformGroupMatch() { if (!platformGroupMatchPopulated) { List<String> peerGroups = getGroups(); boolean match = peerGroups == null || peerGroups.isEmpty() || CollectionUtils.containsAny(platformGroups, peerGroups); setPlatformGroupMatch(Boolean.valueOf(match)); platformGroupMatchPopulated = true; }/* www .j a va 2 s .c o m*/ return super.getPlatformGroupMatch(); }