List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:com.intuit.tank.filter.UpgradeFilters.java
public synchronized void upgrade() { if (!filtersUpgraded) { try {/*from w w w . j a v a 2 s . c o m*/ ScriptFilterDao filterDao = new ScriptFilterDao(); ScriptFilterActionDao actionDao = new ScriptFilterActionDao(); List<ScriptFilter> all = filterDao.findAll(); Set<Integer> toDelete = new HashSet<Integer>(); for (ScriptFilterAction act : actionDao.findAll()) { toDelete.add(act.getId()); } for (ScriptFilter filter : all) { for (ScriptFilterAction action : filter.getActions()) { toDelete.remove(action.getId()); String value = action.getValue(); String original = value; if (value.startsWith("@") && value.lastIndexOf('@') == 0) { value = "#{" + value.substring(1) + "}"; } else if (value.startsWith(FUNCTION_STRING_CONCAT_FULL)) { value = value.substring(FUNCTION_STRING_CONCAT_FULL.length()); } else if (value.startsWith(FUNCTION_STRING_CONCAT)) { value = processConcat(value); } else if (value.startsWith(FUNCTION_STRING_GET_CSV)) { value = processFunction("ioFunctions.getCSVData", value); } else if (value.indexOf('@') != -1) { value = replaceVariables(value); } if (!original.equals(value)) { action.setValue(value); actionDao.saveOrUpdate(action); } } } for (Integer id : toDelete) { actionDao.delete(id); } // filterDao.persistCollection(toModify); filtersUpgraded = true; } catch (Exception e) { LOG.error("Error upgrading filters: " + e, e); } } }
From source file:hudson.security.GlobalMatrixAuthorizationStrategy.java
/** * Returns all SIDs configured in this matrix, minus "anonymous" * * @return/*from ww w. ja va2 s . c o m*/ * Always non-null. */ public List<String> getAllSIDs() { Set<String> r = new HashSet<String>(); for (Set<String> set : grantedPermissions.values()) r.addAll(set); r.remove("anonymous"); String[] data = r.toArray(new String[r.size()]); Arrays.sort(data); return Arrays.asList(data); }
From source file:com.antsdb.saltedfish.nosql.Validator.java
private void validateReplay(Set<Long> positions) throws Exception { if (!this.doesValidateReplay) { return;//from ww w . ja v a 2s. c o m } Gobbler gobbler = this.humpback.getGobbler(); gobbler.replay(SpaceManager.HEADER_SIZE, true, new ReplayHandler() { @Override public void put(Gobbler.PutEntry entry) { positions.remove(entry.getSpacePointer()); } @Override public void index(IndexEntry entry) { positions.remove(entry.getSpacePointer()); } @Override public void delete(DeleteEntry entry) { long sp = entry.getSpacePointer(); positions.remove(sp); } }); if (positions.size() > 0) { for (Long i : positions) { this.errors++; println("error: log position %08x is not found in replay", i); } } }
From source file:net.sbbi.upnp.DiscoveryAdvertisement.java
/** * Unregisters an event category sent by UPNP devices * @param notificationEvent the event type, either DiscoveryAdvertisement.EVENT_SSDP_ALIVE * or DiscoveryAdvertisement.EVENT_SSDP_BYE_BYE * @param nt the type of device advertisement, upnp:rootdevice will unregister all advertisement in relation with nt upnp:rootdevice * a null value specify that all nt type are unregistered * @param eventHandler the events handler that needs to be unregistred. *//* www . j a v a 2 s .com*/ public void unRegisterEvent(int notificationEvent, String nt, DiscoveryEventHandler eventHandler) { synchronized (REGISTRATION_PROCESS) { if (nt == null) nt = NT_ALL_EVENTS; if (notificationEvent == EVENT_SSDP_ALIVE) { Set handlers = (Set) aliveRegistered.get(nt); if (handlers != null) { handlers.remove(eventHandler); if (handlers.size() == 0) { aliveRegistered.remove(nt); } } } else if (notificationEvent == EVENT_SSDP_BYE_BYE) { Set handlers = (Set) byeByeRegistered.get(nt); if (handlers != null) { handlers.remove(eventHandler); if (handlers.size() == 0) { byeByeRegistered.remove(nt); } } } else { throw new IllegalArgumentException("Unknown notificationEvent type"); } if (aliveRegistered.size() == 0 && byeByeRegistered.size() == 0) { stopDevicesListenerThread(); } } }
From source file:com.hp.autonomy.frontend.find.hod.search.FindHodDocumentService.java
@Override protected Documents<HodSearchResult> queryTextIndex(final SearchRequest<ResourceIdentifier> searchRequest, final boolean fetchPromotions) throws HodErrorException { try {/* www .ja v a 2 s .c om*/ return super.queryTextIndex(searchRequest, fetchPromotions); } catch (final HodErrorException e) { if (e.getErrorCode() == HodErrorCode.INDEX_NAME_INVALID) { final Boolean publicIndexesEnabled = findConfigService.getConfig().getIod() .getPublicIndexesEnabled(); final HodDatabasesRequest databasesRequest = new HodDatabasesRequest.Builder() .setPublicIndexesEnabled(publicIndexesEnabled).build(); final Cache cache = cacheManager.getCache(CacheNames.DATABASES); if (cache != null) { cache.clear(); } final Set<Database> updatedDatabases = databasesService.getDatabases(databasesRequest); final QueryRestrictions<ResourceIdentifier> queryRestrictions = searchRequest .getQueryRestrictions(); final Set<ResourceIdentifier> badIndexes = new HashSet<>(queryRestrictions.getDatabases()); for (final Database database : updatedDatabases) { final ResourceIdentifier resourceIdentifier = new ResourceIdentifier(database.getDomain(), database.getName()); badIndexes.remove(resourceIdentifier); } final List<ResourceIdentifier> goodIndexes = new ArrayList<>(queryRestrictions.getDatabases()); goodIndexes.removeAll(badIndexes); searchRequest.setQueryRestrictions(new HodQueryRestrictions.Builder() .setQueryText(queryRestrictions.getQueryText()) .setFieldText(queryRestrictions.getFieldText()).setDatabases(goodIndexes) .setMinDate(queryRestrictions.getMinDate()).setMaxDate(queryRestrictions.getMaxDate()) .setMinScore(queryRestrictions.getMinScore()) .setStateMatchId(queryRestrictions.getStateMatchId()) .setStateDontMatchId(queryRestrictions.getStateDontMatchId()).build()); final Documents<HodSearchResult> resultDocuments = super.queryTextIndex(searchRequest, fetchPromotions); final Warnings warnings = new Warnings(badIndexes); return new Documents<>(resultDocuments.getDocuments(), resultDocuments.getTotalResults(), resultDocuments.getExpandedQuery(), resultDocuments.getSuggestion(), resultDocuments.getAutoCorrection(), warnings); } else { throw e; } } }
From source file:nz.co.senanque.perspectiveslibrary.BundleListenerImpl.java
private BundleVersion removeFromMap(BundleVersion bundleVersion) { Set<BundleVersion> bundles = m_map.get(bundleVersion.getName()); if (bundles == null) { // No bundles of this name yet to create new name return null; } else {/* ww w . ja va 2 s . co m*/ // we do have a bundle of this name so add this version // it is a Set so if it is already there nothing happens. bundles.remove(bundleVersion); } return getLatestVersion(bundleVersion.getName()); }
From source file:org.apache.taverna.gis.GisActivityFactoryTest.java
@Test public void testGetInputPorts() { Set<String> expectedInputs = new HashSet<String>(); expectedInputs.add("firstInput"); Set<ActivityInputPort> inputPorts = activityFactory.getInputPorts(configuration); assertEquals("Unexpected inputs", expectedInputs.size(), inputPorts.size()); for (ActivityInputPort inputPort : inputPorts) { assertTrue("Wrong input : " + inputPort.getName(), expectedInputs.remove(inputPort.getName())); }/*w w w . ja v a2s . com*/ ObjectNode specialConfiguration = JsonNodeFactory.instance.objectNode(); specialConfiguration.put("exampleString", "specialCase"); specialConfiguration.put("exampleUri", "http://localhost:8080/myEndPoint"); assertEquals("Unexpected inputs", 2, activityFactory.getInputPorts(specialConfiguration).size()); }
From source file:com.haulmont.cuba.core.sys.listener.EntityListenerManager.java
/** * Unregister an entity listener./* w ww.ja va2 s. c o m*/ * * @param entityClass entity * @param listenerClass listener class */ public void removeListener(Class<? extends Entity> entityClass, Class<?> listenerClass) { lock.writeLock().lock(); try { Set<String> set = dynamicListeners.get(entityClass); if (set != null) { set.remove(listenerClass.getName()); } cache.clear(); } finally { lock.writeLock().unlock(); } }
From source file:com.haulmont.cuba.core.sys.listener.EntityListenerManager.java
/** * Unregister an entity listener./*from w ww . jav a2 s . c om*/ * * @param entityClass entity * @param listenerBeanName listener bean name */ public void removeListener(Class<? extends Entity> entityClass, String listenerBeanName) { lock.writeLock().lock(); try { Set<String> set = dynamicListeners.get(entityClass); if (set != null) { set.remove(listenerBeanName); } cache.clear(); } finally { lock.writeLock().unlock(); } }
From source file:org.trpr.platform.servicefw.impl.spring.web.HomeController.java
private Set<String> findUniqueUrls(Collection<String> inputs) { Set<String> result = new HashSet<String>(inputs); for (String url : inputs) { String extended = url + ".*"; if (inputs.contains(extended)) { result.remove(extended); }//from ww w. j a va2 s. c om extended = url + "/"; if (inputs.contains(extended)) { result.remove(extended); } } return result; }