List of usage examples for java.util Collections EMPTY_SET
Set EMPTY_SET
To view the source code for java.util Collections EMPTY_SET.
Click Source Link
From source file:org.forgerock.openam.examples.PwnedAuth.java
/** * Gets the user's AMIdentity from LDAP. * * @return The AMIdentity for the user./* w w w .j a v a 2s . c o m*/ */ public AMIdentity getIdentity() { AMIdentity amIdentity = null; AMIdentityRepository amIdRepo = getAMIdentityRepository(getRequestOrg()); IdSearchControl idsc = new IdSearchControl(); idsc.setAllReturnAttributes(true); Set<AMIdentity> results = Collections.EMPTY_SET; try { idsc.setMaxResults(0); IdSearchResults searchResults = amIdRepo.searchIdentities(IdType.USER, userName, idsc); if (searchResults != null) { results = searchResults.getSearchResults(); } if (results.isEmpty()) { debug.error("PwnedAuth.getIdentity() : User " + userName + " is not found"); } else if (results.size() > 1) { debug.error("PwnedAuth.getIdentity() : More than one user found for the userName " + userName); } else { amIdentity = results.iterator().next(); } } catch (IdRepoException e) { debug.error("PwnedAuth.getIdentity() : Error searching Identities with username : " + userName, e); } catch (SSOException e) { debug.error("PwnedAuth.getIdentity() : Module exception : ", e); } return amIdentity; }
From source file:org.apache.jackrabbit.core.security.principal.DefaultPrincipalProvider.java
/** * Recursively collect all Group-principals the specified principal is * member of.//from w w w. ja v a 2 s. c o m * * @param princ * @return all Group principals the specified <code>princ</code> is member of * including inherited membership. */ private Set collectGroupMembership(Principal princ, Set membership) { String princName = princ.getName(); if (!hasPrincipal(princName)) { return Collections.EMPTY_SET; } try { Authorizable auth = userManager.getAuthorizable(princ); if (auth != null) { Iterator itr = auth.memberOf(); while (itr.hasNext()) { Group group = (Group) itr.next(); membership.add(group.getPrincipal()); } } else { log.debug("Cannot find authorizable for principal " + princ.getName()); } } catch (RepositoryException e) { log.warn("Failed to determine membership for " + princName, e.getMessage()); } return membership; }
From source file:pl.datamatica.traccar.api.providers.UserProvider.java
private void removeUserResources(User user) throws Exception { DeviceGroupProvider deviceGroupProvider = new DeviceGroupProvider(em, user); GeoFenceProvider geoProvider = new GeoFenceProvider(em); geoProvider.setRequestUser(user);// ww w .ja v a 2 s.c om //users user.setManagedUsers(Collections.EMPTY_SET); em.persist(user); Query query = em.createQuery("SELECT u FROM User u WHERE u.managedBy = :manager"); query.setParameter("manager", user); for (User us : (List<User>) query.getResultList()) { us.setManagedBy(requestUser); logger.info("{} became manager of {}", requestUser.getLogin(), us.getLogin()); } // devices user.setDevices(Collections.EMPTY_SET); em.persist(user); query = em.createQuery("SELECT d FROM Device d WHERE d.owner = :owner"); query.setParameter("owner", user); for (Device dev : (List<Device>) query.getResultList()) { dev.setOwner(requestUser); logger.info("{} became owner of {}(id={})", requestUser.getLogin(), dev.getName(), dev.getId()); } em.flush(); // tracks RouteProvider rp = new RouteProvider(em, user); query = em.createQuery("SELECT r FROM Route r wHERE r.owner = :owner"); query.setParameter("owner", user); for (Route r : (List<Route>) query.getResultList()) rp.forceDeleteRoute(r); // geofences query = em.createQuery("SELECT g FROM GeoFence g WHERE :user in elements(g.users)"); query.setParameter("user", user); List<GeoFence> gfs = query.getResultList(); for (GeoFence geo : gfs) { if (geo.getOwner() == user) { geo.setUsers(new HashSet<>()); geo.setOwner(null); em.flush(); em.remove(geo); } else { Set<User> us = geo.getUsers(); us.remove(user); geo.setUsers(us); } } em.flush(); // groups for (Group gr : user.getGroups()) { Set<User> us = gr.getUsers(); if (us == null) continue; if (us.size() == 1) { deviceGroupProvider.hardRemoveGroup(gr); } else { us.remove(user); gr.setUsers(us); } } // RulesAcceptances query = em.createQuery("DELETE FROM RulesAcceptance a WHERE a.id.user = :user"); query.setParameter("user", user); query.executeUpdate(); //BleDevices query = em.createQuery("DELETE FROM BleDevice bd where bd.owner = :user"); query.setParameter("user", user); query.executeUpdate(); //UserEvent query = em.createQuery("DELETE FROM UserEvent ue where ue.user = :user"); query.setParameter("user", user); query.executeUpdate(); }
From source file:com.netease.backend.collector.rss.common.util.UrlValidator.java
/** * Customizable constructor. Validation behavior is modifed by passing in options. * @param schemes the set of valid schemes * @param authorityValidator Regular expression validator used to validate the authority part * @param options Validation options. Set using the public constants of this class. * To set multiple options, simply add them together: * <p><code>ALLOW_2_SLASHES + NO_FRAGMENTS</code></p> * enables both of those options.//from ww w. ja v a 2 s.co m */ public UrlValidator(String[] schemes, RegexValidator authorityValidator, long options) { this.options = options; if (isOn(ALLOW_ALL_SCHEMES)) { this.allowedSchemes = Collections.EMPTY_SET; } else { if (schemes == null) { schemes = DEFAULT_SCHEMES; } this.allowedSchemes = new HashSet(); this.allowedSchemes.addAll(Arrays.asList(schemes)); } this.authorityValidator = authorityValidator; }
From source file:net.sourceforge.fenixedu.domain.credits.util.AnnualTeachingCreditsByPeriodBean.java
public Set<TeacherServiceLog> getLogs() { final TeacherService teacherService = getTeacherService(); return teacherService == null ? Collections.EMPTY_SET : teacherService.getSortedLogs(); }
From source file:org.opens.tgol.controller.SignUpControllerTest.java
private void setUpMockEmailSender() { mockEmailSender = createMock(EmailSender.class); Set<String> toUserList = new HashSet<String>(); toUserList.add("to@user.com"); mockEmailSender.sendEmail("from@user.com", toUserList, Collections.EMPTY_SET, StringUtils.EMPTY, "subject", "content"); expectLastCall();/*from w w w.java2 s .c o m*/ replay(mockEmailSender); instance.setEmailSender(mockEmailSender); }
From source file:org.asqatasun.webapp.controller.SignUpControllerTest.java
private void setUpMockEmailSender() { mockEmailSender = createMock(EmailSender.class); Set<String> toUserList = new HashSet(); toUserList.add("to@user.com"); mockEmailSender.sendEmail("from@user.com", toUserList, Collections.EMPTY_SET, StringUtils.EMPTY, "subject", "content"); expectLastCall();//from w ww .j av a2 s . com replay(mockEmailSender); instance.setEmailSender(mockEmailSender); }
From source file:com.phoenixst.plexus.AbstractGraph.java
/** * This implementation delegates to {@link #edges() edges()}, * except for when the specified <code>edgePredicate</code> is * either {@link FalsePredicate#INSTANCE} or an instance of * {@link EqualPredicate}. These two cases are optimized. *///w w w. j a v a 2s . co m public Collection edges(Predicate edgePredicate) { if (edgePredicate == null || edgePredicate == TruePredicate.INSTANCE) { return edges(); } else if (edgePredicate == FalsePredicate.INSTANCE) { return Collections.EMPTY_SET; } else if (edgePredicate instanceof EqualPredicate) { Graph.Edge testEdge = (Graph.Edge) ((EqualPredicate) edgePredicate).getTestObject(); if (!containsEdge(testEdge)) { return Collections.EMPTY_SET; } return new SingletonEdgeCollection(this, testEdge); } else { return new FilteredCollection(edges(), edgePredicate); } }
From source file:fr.inria.atlanmod.instantiator.neoEMF.GenericMetamodelConfig.java
@SuppressWarnings("unchecked") private Set<EClass> eSubtypesClosure(Map<EClass, Set<EClass>> eSubtypesMap, EClass eType) { Set<EClass> result = new LinkedHashSet<EClass>(); if (!eSubtypesMap.containsKey(eType)) { return Collections.EMPTY_SET; } else {// ww w. j av a2 s. com result.addAll(eSubtypesMap.get(eType)); for (EClass eSubType : eSubtypesMap.get(eType)) { if (!eSubType.equals(eType)) result.addAll(eSubtypesClosure(eSubtypesMap, eSubType)); } } return result; }
From source file:com.redhat.rhn.manager.monitoring.ModifyFilterCommand.java
private Set getCriteria() { Set result = filter.getCriteria(); return (result == null) ? Collections.EMPTY_SET : result; }