Example usage for java.util Set remove

List of usage examples for java.util Set remove

Introduction

In this page you can find the example usage for java.util Set remove.

Prototype

boolean remove(Object o);

Source Link

Document

Removes the specified element from this set if it is present (optional operation).

Usage

From source file:eu.trentorise.smartcampus.permissionprovider.model.ClientDetailsEntity.java

@Override
public Set<String> getScope() {
    if (scope != null) {
        Set<String> set = Utils.delimitedStringToSet(scope, ",");
        set.remove("");
        return set;
    }//  w ww.j a  v  a2 s.  co m
    return Collections.emptySet();
}

From source file:net.kenblair.scheduler.service.Scheduler.java

/**
 * Executes the scheduler./*from   w  w w . j  a  va  2  s .  co  m*/
 * <p/>
 * Should be run on a regular basis such as every 30 seconds.
 */
public void run() {
    final Set<String> jobsToCancel = new HashSet<>(jobs.keySet());
    for (final ScheduledJob job : repository.findEnabledJobs()) {
        try {
            jobsToCancel.remove(job.getId());

            final String id = job.getId();

            if (jobs.containsKey(id)) {
                if (!jobs.get(id).sameAs(job)) {
                    jobs.remove(id).cancel();
                } else {
                    continue;
                }
            }

            final Job theJob = new Job(getBean(job), job);
            jobs.put(id, theJob);
            theJob.schedule();
        } catch (final Throwable t) {
            logger.error("Exception while processing scheduled jobs", t);
        }
    }

    for (final String id : jobsToCancel) {
        jobs.remove(id).cancel();
    }
}

From source file:org.carewebframework.security.spring.AbstractAuthenticationProvider.java

/**
 * Authentication Provider. Produces a trusted <code>UsernamePasswordAuthenticationToken</code>
 * if//from  w ww .j a  va2  s. co  m
 * 
 * @param authentication The authentication context.
 * @return authentication Authentication object if authentication succeeded. Null if not.
 */
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    CWFAuthenticationDetails details = (CWFAuthenticationDetails) authentication.getDetails();
    String username = (String) authentication.getPrincipal();
    String password = (String) authentication.getCredentials();
    String domain = null;

    if (log.isDebugEnabled()) {
        log.debug("User: " + username);
        log.debug("Details, RA: " + details == null ? "null" : details.getRemoteAddress());
    }

    if (username != null) {
        String pcs[] = username.split("\\\\", 2);
        domain = pcs[0];
        username = pcs.length > 1 ? pcs[1] : null;
    }

    ISecurityDomain securityDomain = domain == null ? null
            : SecurityUtil.getSecurityService().getSecurityDomain(domain);

    if (username == null || password == null || securityDomain == null) {
        throw new BadCredentialsException("Missing security credentials.");
    }

    IUser user = authenticate(username, password, securityDomain, details);
    details.setDetail("user", user);
    List<GrantedAuthority> userAuthorities = new ArrayList<GrantedAuthority>();
    List<String> list = getAuthorities(user);
    Set<String> authorities = list == null ? new HashSet<String>() : new HashSet<String>(list);

    for (String grantedAuthority : grantedAuthorities) {
        if (grantedAuthority.startsWith("-")) {
            authorities.remove(grantedAuthority.substring(1));
        } else {
            authorities.add(grantedAuthority);
        }
    }

    for (String authority : authorities) {
        if (!authority.isEmpty()) {
            userAuthorities.add(new SimpleGrantedAuthority(authority));
        }
    }

    User principal = new User(username, password, true, true, true, true, userAuthorities);

    authentication = new UsernamePasswordAuthenticationToken(principal, principal.getPassword(),
            principal.getAuthorities());
    ((UsernamePasswordAuthenticationToken) authentication).setDetails(details);
    return authentication;
}

From source file:org.nbheaven.sqe.codedefects.history.controlcenter.panels.SQEHistoryPanel.java

private void removeSelectedProvider(QualityProvider provider) {
    Set<String> l = new HashSet<String>(Arrays.asList(getSelectedProviders()));
    l.remove(provider.getId());
    setSelectedProviders(l.toArray(new String[l.size()]));
}

From source file:de.hybris.platform.b2bacceleratorservices.company.impl.DefaultB2BCommerceUserService.java

@Override
public B2BPermissionModel removePermissionFromCustomer(final String user, final String permission) {
    final B2BCustomerModel customer = this.getCustomerForUid(user);
    final Set<B2BPermissionModel> permissionModels = new HashSet<B2BPermissionModel>(customer.getPermissions());
    final B2BPermissionModel permissionModel = getPermissionForCode(permission);
    permissionModels.remove(permissionModel);
    customer.setPermissions(permissionModels);
    this.getModelService().save(customer);
    return permissionModel;
}

From source file:com.shigengyu.hyperion.core.WorkflowStateSet.java

public WorkflowStateSet remove(Iterable<WorkflowState> workflowStates) {
    Set<WorkflowState> states = Sets.newHashSet(this.workflowStates);
    for (WorkflowState workflowState : Lists.newArrayList(workflowStates)) {
        states.remove(workflowState);
    }/*from   www . j a v  a  2s . com*/
    return new WorkflowStateSet(states);
}

From source file:eu.trentorise.smartcampus.permissionprovider.model.ClientDetailsEntity.java

@Override
public Set<String> getResourceIds() {
    if (resourceIds != null) {
        Set<String> set = Utils.delimitedStringToSet(resourceIds, ",");
        set.remove("");
        return set;
    }//w  w  w .  j a  v  a  2s.com
    return Collections.emptySet();
}

From source file:com.manydesigns.portofino.servlets.PortofinoListener.java

protected void discoverModules(ModuleRegistry moduleRegistry, ClassLoader classLoader) {
    ResolverUtil<Module> resolver = new ResolverUtil<Module>();
    resolver.setExtensions(".class", ".groovy");
    resolver.setClassLoader(classLoader);
    resolver.findImplementations(Module.class, Module.class.getPackage().getName());
    Set<Class<? extends Module>> classes = resolver.getClasses();
    classes.remove(Module.class);
    for (Class<? extends Module> moduleClass : classes) {
        try {/*from  ww w. j a  va 2s.co m*/
            logger.debug("Adding discovered module " + moduleClass);
            Module module = moduleClass.newInstance();
            moduleRegistry.getModules().add(module);
        } catch (Throwable e) {
            logger.error("Could not register module " + moduleClass, e);
        }
    }
}

From source file:service.TagService.java

public void delete(Long tagId, boolean deleteLinks) {
    if (tagId != null) {
        Tag tag = tagDao.find(tagId);//www.j a va  2s .co  m
        if (tag != null) {
            if (deleteLinks) {
                for (Client client : tag.getClients()) {
                    Set<Tag> cltags = client.getTags();
                    cltags.remove(tag);
                    client.setTags(cltags);
                    if (validate(client)) {
                        clientDao.update(client);
                        addError(client.getNameCompany());
                    }
                }
                tagDao.delete(tag);
            } else {
                tag.setDeleteDate(new Date());
            }
        } else {
            addError("? ?  ?");
        }
    } else {
        addError(" ?  ");
    }
}

From source file:com.bia.ccm.services.impl.AccountStatusNotificationServiceImpl.java

@Override
@Transactional(propagation = Propagation.REQUIRED)
public void savePreferences(PreferenceDto preferenceDto, long organization) {
    // add new and delete old --> Emails
    List<EmailPreference> emailPreferences = this.emailPreferenceDao.findByOrganization(organization);
    Set<String> emails = preferenceDto.getEmails();
    for (EmailPreference emailPreference : emailPreferences) {
        if (!emails.contains(emailPreference.getEmail())) {
            this.emailPreferenceDao.delete(emailPreference);
        } else {/*from ww  w  . ja  v a2 s .c  o m*/
            emails.remove(emailPreference.getEmail());
        }
    }
    for (String email : emails) {
        EmailPreference emailPreference = new EmailPreference(email, organization);
        this.emailPreferenceDao.persist(emailPreference);
    }

    // Timings
    List<EmailTimePreference> emailTimePreferences = this.emailTimePreferenceDao
            .findByOrganization(organization);
    Set<Short> timings = preferenceDto.getTimings();
    for (EmailTimePreference emailTimePreference : emailTimePreferences) {
        if (!timings.contains(emailTimePreference.getReportTime())) {
            this.emailTimePreferenceDao.delete(emailTimePreference);
        } else {
            timings.remove(emailTimePreference.getReportTime());
        }
    }
    for (Short timing : preferenceDto.getTimings()) {
        EmailTimePreference emailTimePreference = new EmailTimePreference(timing, organization);
        this.emailTimePreferenceDao.persist(emailTimePreference);
    }
}