List of usage examples for java.util List removeAll
boolean removeAll(Collection<?> c);
From source file:com.ah.ui.actions.admin.UsersAction.java
public void initSSIDProfiles() throws Exception { List<CheckItem> availableList = getBoCheckItems("ssidName", SsidProfile.class, null); Collection<CheckItem> removeList = new Vector<CheckItem>(); for (CheckItem obj : availableList) { for (SsidProfile ssidProfile : getDataSource().getSsidProfiles()) { if (ssidProfile.getId().longValue() == obj.getId()) { removeList.add(obj);// ww w .j ava2 s. com } } } availableList.removeAll(removeList); ssidProfileOptions = new OptionsTransfer(MgrUtil.getUserMessage("admin.user.avaliable.ssidProfile"), MgrUtil.getUserMessage("admin.user.selected.ssidProfile"), availableList, getDataSource().getSsidProfiles(), "id", "value", "ssidProfiles", 8, "200px", "8", true); }
From source file:org.cloudfoundry.client.lib.CloudFoundryClient.java
public void updateApplicationUris(String appName, List<String> uris) throws CloudFoundryException { CloudApplication app = getApplication(appName); List<String> newUris = new ArrayList<String>(uris); newUris.removeAll(app.getUris());/*w w w .j av a 2 s . c om*/ List<String> removeUris = app.getUris(); removeUris.removeAll(uris); removeUris(removeUris, app.getMeta().getGuid()); addUris(newUris, app.getMeta().getGuid()); }
From source file:com.redhat.rhn.frontend.xmlrpc.kickstart.profile.ProfileHandler.java
/** * Returns a list for each kickstart profile of activation keys that are present * in that profile but not the other.//from www . ja va 2 s . c om * * @param loggedInUser The current user * @param kickstartLabel1 identifies a profile to be compared; * cannot be <code>null</code> * @param kickstartLabel2 identifies a profile to be compared; * cannot be <code>null</code> * * @return map of kickstart label to a list of keys in that profile but not in * the other; if no keys match the criteria the list will be empty * * @xmlrpc.doc Returns a list for each kickstart profile; each list will contain * activation keys not present on the other profile. * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("string", "kickstartLabel1") * @xmlrpc.param #param("string", "kickstartLabel2") * @xmlrpc.returntype * #struct("Comparison Info") * #prop_desc("array", "kickstartLabel1", "Actual label of the first kickstart * profile is the key into the struct") * #array() * $ActivationKeySerializer * #array_end() * #prop_desc("array", "kickstartLabel2", "Actual label of the second kickstart * profile is the key into the struct") * #array() * $ActivationKeySerializer * #array_end() * #struct_end() */ public Map<String, List<ActivationKey>> compareActivationKeys(User loggedInUser, String kickstartLabel1, String kickstartLabel2) { if (kickstartLabel1 == null) { throw new IllegalArgumentException("kickstartLabel1 cannot be null"); } if (kickstartLabel2 == null) { throw new IllegalArgumentException("kickstartLabel2 cannot be null"); } // Leverage exisitng handler for key loading KeysHandler keysHandler = new KeysHandler(); List<ActivationKey> keyList1 = keysHandler.getActivationKeys(loggedInUser, kickstartLabel1); List<ActivationKey> keyList2 = keysHandler.getActivationKeys(loggedInUser, kickstartLabel2); // Set operations to determine deltas List<ActivationKey> onlyInKickstart1 = new ArrayList<ActivationKey>(keyList1); onlyInKickstart1.removeAll(keyList2); List<ActivationKey> onlyInKickstart2 = new ArrayList<ActivationKey>(keyList2); onlyInKickstart2.removeAll(keyList1); // Package up for return Map<String, List<ActivationKey>> results = new HashMap<String, List<ActivationKey>>(2); results.put(kickstartLabel1, onlyInKickstart1); results.put(kickstartLabel2, onlyInKickstart2); return results; }
From source file:com.microsoft.tfs.client.common.server.cache.buildstatus.BuildStatusManager.java
/** * You must set refreshInProgress to true before calling this method, to * block other refreshes from running./*www. j a v a2 s . c om*/ */ private void refreshInternal() { synchronized (refreshLock) { Check.isTrue(refreshInProgress, "refreshInProgress"); //$NON-NLS-1$ } try { /* If we're not connected, defer. */ if (!ConnectionHelper.isConnected(connection)) { return; } /* * If the current server does not support queued builds at all (TFS * 2005, V1 service), do no work here. */ if (connection.getBuildServer().getBuildServerVersion().isV1()) { return; } /* A list of build changes to notify listeners for */ final List<IQueuedBuild> watchAddedList = new ArrayList<IQueuedBuild>(); final List<IQueuedBuild> watchRemovedList = new ArrayList<IQueuedBuild>(); final List<IQueuedBuild> statusChangedList = new ArrayList<IQueuedBuild>(); /* The list of watched build IDs to query from the server */ final List<Integer> queryIdList = new ArrayList<Integer>(); BuildStatusCache statusCache; /* Add in the in-memory list of watched builds */ synchronized (watchedBuildLock) { /* * Compose a list of build ids that have been removed from the * on-disk cache. (Ie, they are currently in memory, but are not * in the on-disk cache, meaning that another process has * removed this from the watch list.) Create the list by taking * all watched builds in-memory and removing those on disk. The * remainder is builds that were removed externally. */ final List<Integer> externallyRemovedList = new ArrayList<Integer>(); externallyRemovedList.addAll(watchedBuilds.keySet()); /* * Synchronize with the list of data on-disk (another process * may have modified this list.) Assume the build status cache * is the canonical list of watched build IDs. (It will always * include any modifications made in this client, or in any * other client.) */ statusCache = BuildStatusCache.load(connection); queryIdList.addAll(statusCache.getBuilds()); /* * Remove any items in our in-memory list that did not exist on * disk. */ externallyRemovedList.removeAll(queryIdList); for (final Iterator<Integer> i = externallyRemovedList.iterator(); i.hasNext();) { final Integer removedId = i.next(); log.debug(MessageFormat.format( "Queued build id {0} no longer watched, removed by an external process", //$NON-NLS-1$ ("" + removedId))); //$NON-NLS-1$ watchRemovedList.add(watchedBuilds.remove(removedId)); } } if (log.isDebugEnabled()) { if (queryIdList.size() == 0) { log.debug("No watched builds to query"); //$NON-NLS-1$ } else { final StringBuffer buildIdDebugList = new StringBuffer(); for (int i = 0; i < queryIdList.size(); i++) { buildIdDebugList.append(((i > 0) ? ", " : "") + queryIdList.get(i)); //$NON-NLS-1$ //$NON-NLS-2$ } log.debug("Querying build status for queued build ids: " + buildIdDebugList.toString()); //$NON-NLS-1$ } } if (queryIdList.size() > 0) { /* Query the server */ final int[] queryIds = new int[queryIdList.size()]; for (int i = 0; i < queryIdList.size(); i++) { queryIds[i] = queryIdList.get(i).intValue(); } /* * Query with definitions so that we can get the definition name * for the QueuedBuildsTableControl */ final IQueuedBuild[] queuedBuilds = connection.getBuildServer().getQueuedBuild(queryIds, QueryOptions.DEFINITIONS); final List<IQueuedBuild> savedQueuedBuilds = new ArrayList<IQueuedBuild>(); /* * Store new queued build data, see if the data has changed * since the last refresh */ synchronized (watchedBuildLock) { for (int i = 0; i < queuedBuilds.length; i++) { /* * The server no longer has this build detail. This * could be because the retention policy removed it or * it was removed manually. */ if (queuedBuilds[i].getID() == 0 || queuedBuilds[i].getBuild() == null && queuedBuilds[i].getStatus() == null) { log.debug(MessageFormat.format( "Watched build id {0} is no longer on the server, will no longer be watched", //$NON-NLS-1$ queryIds[i])); final IQueuedBuild existingQueuedBuildData = watchedBuilds.remove(queryIds[i]); if (existingQueuedBuildData != null) { watchRemovedList.add(existingQueuedBuildData); } continue; } savedQueuedBuilds.add(queuedBuilds[i]); final IQueuedBuild existingQueuedBuildData = watchedBuilds.get(queuedBuilds[i].getID()); /* * We do not have existing data, this was added by * another process */ if (existingQueuedBuildData == null) { watchAddedList.add(queuedBuilds[i]); watchedBuilds.put(queuedBuilds[i].getID(), queuedBuilds[i]); } /* * If the build status has changed, notify listeners and * update the cache with the newest data. */ else if (buildStatusChanged(existingQueuedBuildData, queuedBuilds[i])) { statusChangedList.add(queuedBuilds[i]); watchedBuilds.put(queuedBuilds[i].getID(), queuedBuilds[i]); } } } /* * Load the checkin details build information node for any newly * added or status changed builds who have completed building. */ final List<IQueuedBuild> loadInformationList = new ArrayList<IQueuedBuild>(); loadInformationList.addAll(watchAddedList); loadInformationList.addAll(statusChangedList); for (final IQueuedBuild queuedBuild : loadInformationList) { if (queuedBuild.getBuild() == null || queuedBuild.getBuild().getStatus() == null) { continue; } final IBuildDetail buildDetail = queuedBuild.getBuild(); final BuildStatus buildStatus = buildDetail.getStatus(); if ((buildStatus.contains(BuildStatus.PARTIALLY_SUCCEEDED) || buildStatus.contains(BuildStatus.SUCCEEDED)) && (buildDetail.getInformation() == null || buildDetail.getInformation() .getNodesByType(InformationTypes.CHECK_IN_OUTCOME).length == 0)) { buildDetail.refresh(new String[] { InformationTypes.CHECK_IN_OUTCOME }, QueryOptions.ALL); } } /* Persist changes to disk */ statusCache.setBuilds(savedQueuedBuilds.toArray(new IQueuedBuild[savedQueuedBuilds.size()])); statusCache.save(connection); } /* Notify listeners of new / removed watched builds */ if (statusChangedList.size() > 0 || watchAddedList.size() > 0 || watchRemovedList.size() > 0) { ((BuildStatusManagerListener) listeners.getListener()).onUpdateStarted(); for (final IQueuedBuild removedBuild : watchRemovedList) { ((BuildStatusManagerListener) listeners.getListener()).onWatchedBuildRemoved(removedBuild); } for (final IQueuedBuild addedBuild : watchAddedList) { ((BuildStatusManagerListener) listeners.getListener()).onWatchedBuildAdded(addedBuild); } for (final IQueuedBuild changedBuild : statusChangedList) { ((BuildStatusManagerListener) listeners.getListener()).onBuildStatusChanged(changedBuild); } ((BuildStatusManagerListener) listeners.getListener()).onUpdateFinished(); } } finally { synchronized (refreshLock) { refreshInProgress = false; refreshLastTime = System.currentTimeMillis(); } } }
From source file:com.redhat.rhn.frontend.xmlrpc.kickstart.profile.ProfileHandler.java
/** * Returns a list for each kickstart profile of properties that are different between * the profiles. Each property that is not equal between the two profiles will be * present in both lists with the current values for its respective profile. * * @param loggedInUser The current user// w ww .j a v a 2 s . c o m * cannot be <code>null</code> * @param kickstartLabel1 identifies a profile to be compared; * cannot be <code>null</code> * @param kickstartLabel2 identifies a profile to be compared; * cannot be <code>null</code> * * @return map of kickstart label to a list of properties and their values whose * values are different for each profile * * @xmlrpc.doc Returns a list for each kickstart profile; each list will contain the * properties that differ between the profiles and their values for that * specific profile . * @xmlrpc.param #param("string", "sessionKey") * @xmlrpc.param #param("string", "kickstartLabel1") * @xmlrpc.param #param("string", "kickstartLabel2") * @xmlrpc.returntype * #struct("Comparison Info") * #prop_desc("array", "kickstartLabel1", "Actual label of the first kickstart * profile is the key into the struct") * #array() * $KickstartOptionValueSerializer * #array_end() * #prop_desc("array", "kickstartLabel2", "Actual label of the second kickstart * profile is the key into the struct") * #array() * $KickstartOptionValueSerializer * #array_end() * #struct_end() */ public Map<String, List<KickstartOptionValue>> compareAdvancedOptions(User loggedInUser, String kickstartLabel1, String kickstartLabel2) { // Validate parameters if (kickstartLabel1 == null) { throw new IllegalArgumentException("kickstartLabel1 cannot be null"); } if (kickstartLabel2 == null) { throw new IllegalArgumentException("kickstartLabel2 cannot be null"); } // Load the profiles KickstartData profile1 = KickstartFactory.lookupKickstartDataByLabelAndOrgId(kickstartLabel1, loggedInUser.getOrg().getId()); KickstartData profile2 = KickstartFactory.lookupKickstartDataByLabelAndOrgId(kickstartLabel2, loggedInUser.getOrg().getId()); // Load the options KickstartOptionsCommand profile1OptionsCommand = new KickstartOptionsCommand(profile1.getId(), loggedInUser); KickstartOptionsCommand profile2OptionsCommand = new KickstartOptionsCommand(profile2.getId(), loggedInUser); // Set operations to determine which values are different. The equals method // of KickstartOptionValue will take the name and value into account, so // only cases where this tuple is present in both will be removed. List<KickstartOptionValue> onlyInProfile1 = profile1OptionsCommand.getDisplayOptions(); onlyInProfile1.removeAll(profile2OptionsCommand.getDisplayOptions()); List<KickstartOptionValue> onlyInProfile2 = profile2OptionsCommand.getDisplayOptions(); onlyInProfile2.removeAll(profile1OptionsCommand.getDisplayOptions()); // Package for transport Map<String, List<KickstartOptionValue>> results = new HashMap<String, List<KickstartOptionValue>>(2); results.put(kickstartLabel1, onlyInProfile1); results.put(kickstartLabel2, onlyInProfile2); return results; }
From source file:gov.nih.nci.caarray.test.api.external.v1_0.java.SearchServiceTest.java
@Test public void testSearchForFiles_Limit() throws InvalidInputException { logForSilverCompatibility(TEST_NAME, "testSearchForFiles_Limit"); FileSearchCriteria fsc = new FileSearchCriteria(); SearchResult<File> sr = service.searchForFiles(fsc, null); assertTrue(sr.isFullResult());/*w ww. j a v a 2 s . com*/ int all = sr.getResults().size(); int chunk = all / 2 + 2; // somewhere near past the middle // first batch LimitOffset off = new LimitOffset(chunk, 0); sr = service.searchForFiles(fsc, off); assertEquals(off.getOffset(), sr.getFirstResultOffset()); all -= sr.getResults().size(); List<String> ids = getIds(sr.getResults()); assertEquals(chunk, ids.size()); // second batch off.setOffset(sr.getResults().size()); sr = service.searchForFiles(fsc, off); all -= sr.getResults().size(); assertEquals(0, all); // check we didnt get the same ones in the second chunk ids.removeAll(getIds(sr.getResults())); assertEquals(chunk, ids.size()); }
From source file:gov.nih.nci.caarray.test.api.external.v1_0.java.SearchServiceTest.java
@Test public void testsearchForBiomaterials_Limit() throws InvalidInputException { logForSilverCompatibility(TEST_NAME, "testsearchForBiomaterials_Limit"); BiomaterialSearchCriteria bisc = new BiomaterialSearchCriteria(); SearchResult<Biomaterial> sr = service.searchForBiomaterials(bisc, null); assertTrue(sr.isFullResult());// www . j av a2s . co m int all = sr.getResults().size(); int chunk = all / 2 + 10; // somewhere near past the middle // first batch LimitOffset off = new LimitOffset(chunk, 0); sr = service.searchForBiomaterials(bisc, off); assertEquals(off.getOffset(), sr.getFirstResultOffset()); all -= sr.getResults().size(); List<String> ids = getIds(sr.getResults()); assertEquals(chunk, ids.size()); // second batch off.setOffset(sr.getResults().size()); sr = service.searchForBiomaterials(bisc, off); all -= sr.getResults().size(); assertEquals(0, all); // check we didnt get the same ones in the second chunk ids.removeAll(getIds(sr.getResults())); assertEquals(chunk, ids.size()); }
From source file:com.enonic.vertical.userservices.UserHandlerController.java
protected void handlerJoinGroup(HttpServletRequest request, HttpServletResponse response, HttpSession session, ExtendedMap formItems) throws VerticalUserServicesException, RemoteException { UserEntity user = securityService.getLoggedInPortalUserAsEntity(); UserEntity executor = securityService.getRunAsUser(); if (user == null) { String message = "User must be logged in."; VerticalUserServicesLogger.warn(this.getClass(), 0, message, null); redirectToErrorPage(request, response, formItems, ERR_USER_NOT_LOGGED_IN, null); return;/*from w w w.ja va 2s . co m*/ } String[] requiredParameters = new String[] { "key" }; List<String> missingParameters = findMissingRequiredParameters(requiredParameters, formItems, true); if (!missingParameters.isEmpty()) { String message = createMissingParametersMessage("Join group", missingParameters); VerticalUserServicesLogger.warn(this.getClass(), 0, message, null); redirectToErrorPage(request, response, formItems, ERR_PARAMETERS_MISSING, null); return; } List<GroupKey> groupKeysToAdd = getSubmittedGroupKeys(formItems, "key"); List<GroupKey> existingKeysForUser = getExistingDirectMembershipsForUser(user); groupKeysToAdd.removeAll(existingKeysForUser); if (groupKeysToAdd.size() >= 1) { GroupSpecification userGroupForLoggedInUser = new GroupSpecification(); userGroupForLoggedInUser.setKey(user.getUserGroupKey()); AddMembershipsCommand addMembershipCommand = new AddMembershipsCommand(userGroupForLoggedInUser, executor.getKey()); addMembershipCommand.setUpdateOpenGroupsOnly(true); addMembershipCommand.setRespondWithException(true); for (GroupKey groupKeyToAdd : groupKeysToAdd) { addMembershipCommand.addGroupsToAddTo(groupKeyToAdd); } try { userStoreService.addMembershipsToGroup(addMembershipCommand); updateUserInSession(session); } catch (UserStoreAccessException e) { String message = "Not allowed to add user to group: %t"; VerticalUserServicesLogger.warn(this.getClass(), 0, message, e); redirectToErrorPage(request, response, formItems, ERR_JOIN_GROUP_NOT_ALLOWED, null); return; } catch (RuntimeException e) { String message = "Failed to add user to group: %t"; VerticalUserServicesLogger.warn(this.getClass(), 0, message, e); redirectToErrorPage(request, response, formItems, ERR_JOIN_GROUP_FAILED, null); return; } } redirectToPage(request, response, formItems); }
From source file:net.sourceforge.atunes.kernel.modules.repository.RepositoryHandler.java
/** * Gets the unplayed audio files./* w ww .j a va2s .c om*/ * * @return the unplayed audio files */ public List<AudioFile> getUnplayedAudioFiles() { if (repository != null) { List<AudioFile> unplayedAudioFiles = repository.getAudioFilesList(); unplayedAudioFiles.removeAll(repository.getStats().getAudioFilesRanking().getNFirstElements(-1)); return unplayedAudioFiles; } return new ArrayList<AudioFile>(); }