Example usage for java.util Collections EMPTY_SET

List of usage examples for java.util Collections EMPTY_SET

Introduction

In this page you can find the example usage for java.util Collections EMPTY_SET.

Prototype

Set EMPTY_SET

To view the source code for java.util Collections EMPTY_SET.

Click Source Link

Document

The empty set (immutable).

Usage

From source file:org.cloudfoundry.identity.uaa.login.util.LocalUaaRestTemplate.java

@Override
protected OAuth2AccessToken acquireAccessToken(OAuth2ClientContext oauth2Context)
        throws UserRedirectRequiredException {
    ClientDetails client = clientDetailsService.loadClientByClientId(getClientId());
    Set<String> scopes = new HashSet<>();
    for (GrantedAuthority authority : client.getAuthorities()) {
        scopes.add(authority.getAuthority());
    }// w  w w.  ja v a2  s .  c o m
    Set<String> resourceIds = new HashSet<>();
    resourceIds.add(Origin.UAA);
    Set<String> responseTypes = new HashSet<>();
    responseTypes.add("token");
    Map<String, String> requestParameters = new HashMap<>();
    requestParameters.put(OAuth2Utils.CLIENT_ID, "login");
    requestParameters.put(OAuth2Utils.GRANT_TYPE, "client_credentials");
    OAuth2Request request = new OAuth2Request(requestParameters, "login",
            (Collection<? extends GrantedAuthority>) Collections.EMPTY_SET, true, scopes, resourceIds, null,
            responseTypes, Collections.EMPTY_MAP);
    OAuth2Authentication authentication = new OAuth2Authentication(request, null);
    OAuth2AccessToken result = tokenServices.createAccessToken(authentication);
    oauth2Context.setAccessToken(result);
    return result;
}

From source file:pt.ist.maidSyncher.domain.activeCollab.ACTask.java

private Collection<String> processMainAssignee(pt.ist.maidSyncher.api.activeCollab.ACTask acTask) {

    ACUser acUser = ACUser.findById(acTask.getAssigneeId());
    ACUser oldMainAssignee = getMainAssignee();
    setMainAssignee(acUser);//from w  w  w .  ja  v a  2 s  . c  om
    return !ObjectUtils.equals(acUser, oldMainAssignee)
            ? Collections.singleton(getPropertyDescriptorNameAndCheckItExists(acTask, "assigneeId"))
            : Collections.EMPTY_SET;
}

From source file:uk.gov.gchq.gaffer.data.elementdefinition.ElementDefinitions.java

@JsonIgnore
public Set<String> getEdgeGroups() {
    return null != edges ? edges.keySet() : Collections.EMPTY_SET;
}

From source file:com.adobe.ags.curly.test.ErrorBehaviorTest.java

@Test
public void testGlobalIgnore() throws IOException, ParseException {
    ApplicationState.getInstance().errorBehaviorProperty().set(ErrorBehavior.IGNORE);
    List<Action> actions = Arrays.asList(failureAction(), failureAction(), failureAction());
    ActionGroupRunner runner = new ActionGroupRunner("Global Ignore Test", ignore -> client, actions,
            Collections.EMPTY_MAP, Collections.EMPTY_SET);
    runner.run();/*from www .  jav a2  s  .  c  om*/
    assertResults(runner.getResult(), false, true);
}

From source file:com.vaushell.superpipes.nodes.shaarli.N_Shaarli_Post.java

@SuppressWarnings("unchecked")
@Override/* ww  w.  j a va 2s.  c om*/
protected void loop() throws Exception {
    // Receive
    setMessage(getLastMessageOrWait());

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("[" + getNodeID() + "] receive message : " + Message.formatSimple(getMessage()));
    }

    if (!getMessage().contains(Message.KeyIndex.URI) || !getMessage().contains(Message.KeyIndex.TITLE)
            || !getMessage().contains(Message.KeyIndex.TAGS)) {
        throw new IllegalArgumentException("message doesn't have an uri, a title or a set of tags");
    }

    // Send to Shaarli
    // Log in
    if (!client.login(getProperties().getConfigString("login"), getProperties().getConfigString("password"))) {
        throw new IllegalArgumentException("Login error");
    }

    final URI uri = (URI) getMessage().getProperty(Message.KeyIndex.URI);
    final Tags tags = (Tags) getMessage().getProperty(Message.KeyIndex.TAGS);

    final String ID = new A_Retry<String>() {

        @Override
        protected String executeContent() throws IOException {
            final String title = (String) getMessage().getProperty(Message.KeyIndex.TITLE);

            final String ID = client.createLink(uri == null ? null : uri.toString(), title,
                    (String) getMessage().getProperty(Message.KeyIndex.DESCRIPTION),
                    tags == null ? Collections.EMPTY_SET : tags.getAll(), false);

            if (ID == null || ID.isEmpty()) {
                throw new IOException("Cannot post link with title=" + title);
            } else {
                return ID;
            }
        }

    }.setRetry(getProperties().getConfigInteger("retry", 10))
            .setWaitTime(getProperties().getConfigDuration("wait-time", new Duration(5000L)))
            .setWaitTimeMultiplier(getProperties().getConfigDouble("wait-time-multiplier", 2.0))
            .setJitterRange(getProperties().getConfigInteger("jitter-range", 500))
            .setMaxDuration(getProperties().getConfigDuration("max-duration", new Duration(0L))).execute();

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("[" + getNodeID() + "] receive ID : " + ID);
    }

    getMessage().setProperty("id-shaarli", ID);

    sendMessage();
}

From source file:org.eclipse.dataset.metadata.Metadata.java

@SuppressWarnings("unchecked")
@Override//w w  w  . jav  a 2 s .  co m
public Collection<String> getMetaNames() throws Exception {
    return metadata == null ? (Collection<String>) Collections.EMPTY_SET
            : Collections.unmodifiableCollection(metadata.keySet());
}

From source file:de.hybris.platform.maintenance.CleanupCronJobIntegrationTest.java

@Before
public void setup() {
    final ItemObjectResolver modelResolver = Registry.getApplicationContext().getBean("modelResolver",
            ItemObjectResolver.class);

    //the performable with all the needed services
    gmjp = new GenericMaintenanceJobPerformable();
    gmjp.setModelService(modelService);/*from   w  ww. j av  a 2s. c  om*/
    gmjp.setFlexibleSearchService(flexibleSearchService);
    gmjp.setSessionService(sessionService);
    gmjp.setModelResolver(modelResolver);

    //the testsubject with the default values
    cuCJmi = new CleanupCronJobStrategy();
    cuCJmi.setModelService(modelService);
    cuCJmi.setTypeService(typeService);
    cuCJmi.setResult(Collections.singleton(CronJobResult.SUCCESS));
    cuCJmi.setStatus(Collections.singleton(CronJobStatus.FINISHED));
    cuCJmi.setExcludedCronJobCodes(Collections.EMPTY_SET);

    gmjp.setMaintenanceCleanupStrategy(cuCJmi);
    assertEquals("MaintenanceCleanupJob", gmjp.getType());

    final MaintenanceCleanupJobModel slayerJob = modelService.create(MaintenanceCleanupJobModel.class);
    slayerJob.setCode("cleanupCronJobsPerformable");
    slayerJob.setSpringId("cleanupCronJobsPerformable");

    modelService.save(slayerJob);
}

From source file:org.wso2.carbon.identity.application.authz.xacml.pip.AuthenticationContextAttributePIP.java

@Override
public Set<String> getAttributeValues(URI attributeType, URI attributeId, URI category, String issuer,
        EvaluationCtx evaluationCtx) throws Exception {

    EvaluationResult context;// w  w w  . ja  va2 s.com
    String contextId = null;

    if (StringUtils.isBlank(attributeId.toString())) {
        log.debug("Empty attribute URI received..");
        return Collections.EMPTY_SET;
    }
    context = evaluationCtx.getAttribute(new URI(StringAttribute.identifier),
            new URI(XACMLAppAuthzConstants.AUTH_CTX_ID), issuer, new URI(XACMLAppAuthzConstants.AUTH_CATEGORY));
    if (context != null && context.getAttributeValue() != null && context.getAttributeValue().isBag()) {
        BagAttribute bagAttribute = (BagAttribute) context.getAttributeValue();
        if (bagAttribute.size() > 0) {
            contextId = ((AttributeValue) bagAttribute.iterator().next()).encode();
            if (log.isDebugEnabled()) {
                log.debug(String.format("Finding attributes for the context %1$s", contextId));
            }
        }
    }

    if (contextId != null) {
        AuthenticationContext authCtx = FrameworkUtils.getAuthenticationContextFromCache(contextId);
        if (authCtx != null) {
            Set<String> values = new HashSet<>();
            switch ((category.toString())) {
            case XACMLAppAuthzConstants.AUTH_CONTEXT_PROPERTY_CATEGORY:
                values = getAuthenticationContextProperty(authCtx, attributeType, attributeId, category, issuer,
                        evaluationCtx);
                break;
            case XACMLAppAuthzConstants.AUTH_CONTEXT_REQ_PARAM_CATEGORY:
                values = getAuthenticationRequestParameter(authCtx, attributeType, attributeId, category,
                        issuer, evaluationCtx);
                break;
            case XACMLAppAuthzConstants.AUTH_CONTEXT_REQ_HEADER_CATEGORY:
                values = getAuthenticationRequestHeader(authCtx, attributeType, attributeId, category, issuer,
                        evaluationCtx);
                break;
            default:
            }

            if (!values.isEmpty()) {
                if (log.isDebugEnabled()) {
                    String valuesString = StringUtils.join(values, ",");
                    log.debug("Returning " + attributeId + " value as " + valuesString);
                }
                return values;
            }

            switch (attributeId.toString()) {
            case XACMLAppAuthzConstants.INBOUND_PROTOCOL_ATTRIBUTE:
                values.add(authCtx.getRequestType());
                break;
            case XACMLAppAuthzConstants.CLIENT_IP_ATTRIBUTE:
                Object ipObj = authCtx.getParameter(IdentityConstants.USER_IP);
                if (ipObj != null) {
                    values.add(ipObj.toString());
                }
                break;
            default:
            }
            if (log.isDebugEnabled()) {
                String valuesString = StringUtils.join(values, ",");
                log.debug("Returning " + attributeId + " value as " + valuesString);
            }
            return values;
        }
    }
    return Collections.emptySet();
}

From source file:uk.gov.gchq.gaffer.data.elementdefinition.ElementDefinitions.java

@JsonIgnore
public Set<String> getEntityGroups() {
    return null != entities ? entities.keySet() : Collections.EMPTY_SET;
}

From source file:org.archive.nutchwax.urlfilter.WaybackURLFilter.java

/**
 * Utility function to read a list of exclusion records from a file
 * specified in the configuration./*from w w w.  ja  va2s.  c o m*/
 */
public static Set<String> getExclusions(Configuration conf) {
    String exclusionsPath = conf.get("nutchwax.urlfilter.wayback.exclusions");

    if (exclusionsPath == null || exclusionsPath.trim().length() == 0) {
        LOG.warn("No exclusions file set for property: \"nutchwax.urlfilter.wayback.exclusions\"");

        return Collections.EMPTY_SET;
    }

    LOG.warn("Using exclusions: " + exclusionsPath);

    Set<String> exclusions = new HashSet<String>();

    BufferedReader reader = null;
    try {
        Path p = new Path(exclusionsPath.trim());

        FileSystem fs = FileSystem.get(conf);

        if (fs.exists(p)) {
            InputStream is = p.getFileSystem(conf).open(p);

            reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));

            String line;
            while ((line = reader.readLine()) != null) {
                String fields[] = line.split("\\s+");

                if (fields.length < 3) {
                    LOG.warn("Malformed exclusion, not enough fields (" + fields.length + "): " + line);
                    continue;
                }

                // We only want the first three fields.  Chop-off anything extra.
                if (fields.length >= 3) {
                    line = fields[0] + fields[1] + fields[2];
                }

                exclusions.add(line);
            }
        } else {
            LOG.warn("Exclusions doesn't exist: " + exclusionsPath);
        }
    } catch (IOException e) {
        // Umm, what to do?
        throw new RuntimeException(e);
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException e) {
            // Ignore it.
        }
    }

    return exclusions;
}