Example usage for java.util EnumSet allOf

List of usage examples for java.util EnumSet allOf

Introduction

In this page you can find the example usage for java.util EnumSet allOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType) 

Source Link

Document

Creates an enum set containing all of the elements in the specified element type.

Usage

From source file:com.google.code.linkedinapi.client.examples.JobsApiExample.java

/**
 * Process command line options and call the service. 
 *///from  w  w  w . j a  va  2s.  c  om
private static void processCommandLine(CommandLine line, Options options) {
    if (line.hasOption(HELP_OPTION)) {
        printHelp(options);
    } else if (line.hasOption(CONSUMER_KEY_OPTION) && line.hasOption(CONSUMER_SECRET_OPTION)
            && line.hasOption(ACCESS_TOKEN_OPTION) && line.hasOption(ACCESS_TOKEN_SECRET_OPTION)) {
        final String consumerKeyValue = line.getOptionValue(CONSUMER_KEY_OPTION);
        final String consumerSecretValue = line.getOptionValue(CONSUMER_SECRET_OPTION);
        final String accessTokenValue = line.getOptionValue(ACCESS_TOKEN_OPTION);
        final String tokenSecretValue = line.getOptionValue(ACCESS_TOKEN_SECRET_OPTION);

        final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(consumerKeyValue,
                consumerSecretValue);
        final JobsApiClient client = factory.createLinkedInApiClient(accessTokenValue, tokenSecretValue);
        JobBookmarks bookmarks = client.getJobBookmarks(EnumSet.allOf(JobField.class));
        for (JobBookmark bookmark : bookmarks.getJobBookmarkList()) {
            System.out.println(bookmark.getSavedTimestamp());
            printResult(bookmark.getJob());
        }

        if (line.hasOption(ID_OPTION)) {
            String idValue = line.getOptionValue(ID_OPTION);
            System.out.println("Fetching profile for job with id:" + idValue);
            Job job = client.getJobById(idValue, EnumSet.allOf(JobField.class));
            printResult(job);
        } else {
            System.out.println("Fetching suggested jobs for current user.");
            Jobs jobs = client.getJobSuggestions();
            for (Job job : jobs.getJobList()) {
                printResult(job);
            }
        }
    } else {
        printHelp(options);
    }
}

From source file:com.redhat.developers.msa.namaste.NamasteApplication.java

@Override
public void run(NamasteConfiguration configuration, Environment environment) throws Exception {
    // Register Namaste REST service
    environment.jersey().register(new NamasteResource());

    // Enable CORS filter
    FilterRegistration.Dynamic filter = environment.servlets().addFilter("CORSFilter", CrossOriginFilter.class);
    filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false,
            environment.getApplicationContext().getContextPath() + "*");

    // Register HystrixMetricsStreamServlet
    environment.getApplicationContext().addServlet(HystrixMetricsStreamServlet.class, "/hystrix.stream");

    // Register BraveServletFilter
    Brave brave = new Brave.Builder("namaste").spanCollector(HttpSpanCollector
            .create(System.getenv("ZIPKIN_SERVER_URL"), new EmptySpanCollectorMetricsHandler())).build();
    Filter braveFilter = new BraveServletFilter(brave.serverRequestInterceptor(),
            brave.serverResponseInterceptor(), new DefaultSpanNameProvider());
    Dynamic filterRegistration = environment.servlets().addFilter("BraveServletFilter", braveFilter);
    // Explicit mapping to avoid trace on readiness probe
    filterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/api/namaste",
            "/api/namaste-chaining");

    // Configure Swagger
    environment.jersey().register(new ApiListingResource());
    environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
    BeanConfig beanConfig = new BeanConfig();
    beanConfig.setVersion("1.0.0");
    beanConfig.setSchemes(new String[] { "http" });
    beanConfig.setTitle("Namaste microservices REST API");
    beanConfig.setDescription("Operations that can be invoked in the namaste microservices");
    beanConfig.setResourcePackage("com.redhat.developers.msa.namaste");
    beanConfig.setLicense("Apache 2.0");
    beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
    beanConfig.setContact("developer@redhat.com");
    beanConfig.setBasePath("/api");
    beanConfig.setPrettyPrint(true);/*ww w  . j ava2s .  c o  m*/
    beanConfig.setScan(true);
}

From source file:org.eel.kitchen.jsonschema.keyword.AbstractTypeKeywordValidator.java

/**
 * Add a simple type to {@link #typeSet}
 *
 * <p>There are two special cases:</p>
 * <ul>//from  www.j a  v  a 2s . com
 *     <li>if type is {@link #ANY}, all values are filled in;</li>
 *     <li>if type is {@code number}, it also covers {@code integer}.</li>
 * </ul>
 *
 * @param type the type as a string
 */
private void addSimpleType(final String type) {
    if (ANY.equals(type)) {
        typeSet.addAll(EnumSet.allOf(NodeType.class));
        return;
    }

    final NodeType tmp = NodeType.fromName(type);
    typeSet.add(tmp);
    if (tmp == NodeType.NUMBER)
        typeSet.add(NodeType.INTEGER);
}

From source file:com.rockagen.gnext.main.BootStrap.java

protected void addFilter(final ServletContext ctx) {

    AccessFilter af = (AccessFilter) rootContext.getBean("accessFilter");
    CharacterEncodingFilter cef = (CharacterEncodingFilter) rootContext.getBean("characterEncodingFilter");

    DelegatingFilterProxy dfp = new DelegatingFilterProxy("springSecurityFilterChain");

    EnumSet<DispatcherType> dts = EnumSet.allOf(DispatcherType.class);

    // Access log filter
    ctx.addFilter("accessFilter", af).addMappingForUrlPatterns(dts, true, "/*");
    // Error wrapper filter
    // Character encoding filter
    ctx.addFilter("characterEncodingFilter", cef).addMappingForUrlPatterns(dts, true, "/*");
    // Spring security filter
    ctx.addFilter("spring-security", dfp).addMappingForUrlPatterns(dts, true, "/*");

}

From source file:it.geosolutions.geonetwork.GeonetworkUpdateTest.java

@Test
public void testUpdateMetadata() throws Exception {
    if (!runIntegrationTest())
        return;//from  w  w  w .  j a  v a 2s. c  o m

    GNInsertConfiguration cfg = createDefaultInsertConfiguration();

    GNPrivConfiguration pcfg = new GNPrivConfiguration();

    pcfg.addPrivileges(GNPrivConfiguration.GROUP_GUEST, EnumSet.of(GNPriv.FEATURED));
    pcfg.addPrivileges(GNPrivConfiguration.GROUP_INTRANET, EnumSet.of(GNPriv.DYNAMIC, GNPriv.FEATURED));
    pcfg.addPrivileges(GNPrivConfiguration.GROUP_ALL, EnumSet.of(GNPriv.VIEW, GNPriv.DYNAMIC, GNPriv.FEATURED));
    pcfg.addPrivileges(2, EnumSet.allOf(GNPriv.class));

    File file = loadFile("metadata.xml");
    assertNotNull(file);

    GNClient client = createClientAndLogin();
    long id = client.insertMetadata(cfg, file);

    client.setPrivileges(id, pcfg);

    String version = GNMetadataGetVersion.get(client.getConnection(), gnServiceURL, id);
    LOGGER.info("Version is " + version);

    assertNotNull(version);
    assertEquals("2", version); // the md has just been created

    Element md = client.get(id);
    //        XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    //        outputter.output(md, System.out);

    final String UPDATED_TEXT = "Updated title";
    {
        Element chstr = getTitleElement(md);
        assertEquals("TEST GeoBatch Action: GeoNetwork", chstr.getText());
        chstr.setText(UPDATED_TEXT);
    }

    File tempFile = File.createTempFile("gnm_update", ".xml");
    FileUtils.forceDeleteOnExit(tempFile);
    XMLOutputter fileOutputter = new XMLOutputter(Format.getCompactFormat());
    FileUtils.writeStringToFile(tempFile, fileOutputter.outputString(md));

    GNMetadataUpdate.update(client.getConnection(), gnServiceURL, id, version, tempFile);

    {
        Element md2 = client.get(id);
        Element chstr = getTitleElement(md2);
        assertEquals(UPDATED_TEXT, chstr.getText());
    }

    String version3 = GNMetadataGetVersion.get(client.getConnection(), gnServiceURL, id);
    LOGGER.info("Version is " + version3);

    assertNotNull(version3);
    assertEquals("4", version3); // the md has been updated once

    // try bad version number
    try {
        GNMetadataUpdate.update(client.getConnection(), gnServiceURL, id, "9999", tempFile);
        fail("Bad version exception not trapped");
    } catch (GNServerException e) {
        LOGGER.info("Bad version number error trapped properly (" + e.getMessage() + ")");
    }

    //        client.deleteMetadata(id);
}

From source file:org.hyperledger.examples.dropwizard.BlockExplorerApp.java

@Override
public void run(BlockExplorerConfiguration configuration, Environment environment) throws Exception {
    BCSAPI api = hyperLedgerBundle.getBCSAPI();
    final FilterRegistration.Dynamic cors = environment.servlets().addFilter("CORS", CrossOriginFilter.class);

    // Configure CORS parameters
    cors.setInitParameter("allowedOrigins", "*");
    cors.setInitParameter("allowedHeaders", "*");
    cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD");

    // Add URL mapping
    cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
    environment.jersey().register(new ExplorerResource(api));
}

From source file:gov.nih.nci.caarray.plugins.illumina.AbstractCsvDesignHelper.java

boolean isHeaderLine(List<String> values) {
    if (values.size() < requiredColumns.size()) {
        return false;
    }/*  w  ww.ja va  2s  .  c  o m*/
    Collection<T> headers = new ArrayList<T>(values.size());
    try {
        for (String v : values) {
            T h = Enum.valueOf(headerEnumClass, v.toUpperCase(Locale.getDefault()));
            headers.add(h);
        }
    } catch (IllegalArgumentException e) {
        return false;
    }

    return EnumSet.allOf(headerEnumClass).containsAll(headers);
}

From source file:com.google.code.linkedinapi.client.examples.CompaniesApiExample.java

/**
 * Process command line options and call the service. 
 *//*from  www  . ja  v  a 2 s  . c  om*/
private static void processCommandLine(CommandLine line, Options options) {
    if (line.hasOption(HELP_OPTION)) {
        printHelp(options);
    } else if (line.hasOption(CONSUMER_KEY_OPTION) && line.hasOption(CONSUMER_SECRET_OPTION)
            && line.hasOption(ACCESS_TOKEN_OPTION) && line.hasOption(ACCESS_TOKEN_SECRET_OPTION)) {
        final String consumerKeyValue = line.getOptionValue(CONSUMER_KEY_OPTION);
        final String consumerSecretValue = line.getOptionValue(CONSUMER_SECRET_OPTION);
        final String accessTokenValue = line.getOptionValue(ACCESS_TOKEN_OPTION);
        final String tokenSecretValue = line.getOptionValue(ACCESS_TOKEN_SECRET_OPTION);

        final LinkedInApiClientFactory factory = LinkedInApiClientFactory.newInstance(consumerKeyValue,
                consumerSecretValue);
        final CompaniesApiClient client = factory.createCompaniesApiClient(accessTokenValue, tokenSecretValue);

        if (line.hasOption(ID_OPTION)) {
            String idValue = line.getOptionValue(ID_OPTION);
            System.out.println("Fetching profile for company with id:" + idValue);
            Company company = client.getCompanyById(idValue, EnumSet.allOf(CompanyField.class));
            printResult(company);
            Products companyProducts = client.getCompanyProducts(idValue, EnumSet.allOf(ProductField.class));
            for (Product product : companyProducts.getProductList()) {
                printResult(product);
            }
        } else {
            System.out.println("Fetching profile for company. LinkedIn");
            Company company = client.getCompanyByUniversalName("linkedin", EnumSet.allOf(CompanyField.class));
            printResult(company);
        }
    } else {
        printHelp(options);
    }
}

From source file:com.graphaware.server.web.GraphAwareJetty9WebServer.java

@Override
protected void startJetty() {
    HandlerList handlerList;/*from   w  w  w  .  j  a  v a2  s . c  o m*/
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath(getContextPath(config));
    context.addLifeCycleListener(new JettyStartingListener(context.getServletContext()));
    context.addFilter(new FilterHolder(txFilter), "/*", EnumSet.allOf(DispatcherType.class));

    //If http logging is turned on, the jetty handler is a RequestLogHandler with a different type hierarchy than
    //the HandlerList returned when http logging is off
    if (getJetty().getHandler().getClass().equals(RequestLogHandler.class)) {
        handlerList = (HandlerList) ((RequestLogHandler) getJetty().getHandler()).getHandler();
    } else {
        handlerList = (HandlerList) getJetty().getHandler();
    }
    handlerList.setHandlers(ArrayUtil.prependToArray(context, handlerList.getHandlers(), Handler.class));

    super.startJetty();
}

From source file:io.lavagna.web.config.ServiceConf.java

@Bean
public UserService getUserService() {
    UserService u = mock(UserService.class);
    User user = new User(0, "test", "test-user", null, null, true, true, new Date());
    UserWithPermission uwp = new UserWithPermission(user, EnumSet.allOf(Permission.class),
            Collections.<String, Set<Permission>>emptyMap(), Collections.<Integer, Set<Permission>>emptyMap());
    when(u.findUserWithPermission(0)).thenReturn(uwp);
    return u;// w w w.j a v  a 2s.co m
}