List of usage examples for java.util EnumSet allOf
public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementType)
From source file:pl.edu.icm.cermine.evaluation.SegmentationEvaluator.java
public void setLabels(Collection<BxZoneLabel> labels) { ignoredLabels.addAll(EnumSet.allOf(BxZoneLabel.class)); ignoredLabels.removeAll(labels); }
From source file:com.techtrip.dynbl.context.config.WebAppinitializer.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { // Setup Context to Accept Annotated Classes on Input (including plain Spring {@code @Component} // Stereotypes in addition to JSR-330 Compliant Classes using {@code javax.inject} AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); //context.setConfigLocation(APP_CONFIG_LOCATION); context.setConfigLocation(APP_CONFIG_LOCATION); /* /* w ww. ja v a 2 s. com*/ * Add a Spring Security Filter using the JEE6 Filter Registration Filter Method from {@code FilterRegistration) that allows filters to be registered * and configured with the specified context */ /* FilterRegistration.Dynamic securityFilter = servletContext.addFilter(ProjectKeyValConsts.SECURITY_FILTER.getKey(), new DelegatingFilterProxy(ProjectKeyValConsts.SECURITY_FILTER.getValue())); securityFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ProjectConsts.BASE_URL_MAPPING_PATTERN.getValue()); // where the filter will be applied */ // Add a Character Encoding Filter that specifies an encoding for mapped requests FilterRegistration.Dynamic characterEncodingFilter = servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter()); characterEncodingFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, ROOT_CONTEXT); // where the filter will be applied characterEncodingFilter.setInitParameter("encoding", "UTF-8"); characterEncodingFilter.setInitParameter("forceEncoding", Boolean.TRUE.toString()); characterEncodingFilter.setAsyncSupported(true); servletContext.addListener(new ContextLoaderListener(context)); servletContext.setInitParameter("defaultHtmlEscape", Boolean.TRUE.toString()); DispatcherServlet servlet = new DispatcherServlet(); // no explicit configuration reference here: everything is configured in the root container for simplicity servlet.setContextConfigLocation(""); /* TMT From JEE 6 API Docs: * Registers the given servlet instance with this ServletContext under the given servletName. * The registered servlet may be further configured via the returned ServletRegistration object. */ ServletRegistration.Dynamic appServlet = servletContext.addServlet(APP_SERVLET, servlet); appServlet.setLoadOnStartup(1); appServlet.setAsyncSupported(true); Set<String> mappingConflicts = appServlet.addMapping("/"); if (!mappingConflicts.isEmpty()) { throw new IllegalStateException(String.format( "The servlet named '%s' cannot be mapped to '/' under Tomcat versions <= 7.0.14", APP_SERVLET)); } // TMT servletContext.addListener(new Log4jConfigListener()); System.out.println("Application inplemented on Spring Version: " + SpringVersion.getVersion()); }
From source file:it.geosolutions.geonetwork.GeonetworkUpdateWithInfoTest.java
@Test public void testUpdateMetadata() throws Exception { if (!runIntegrationTest()) return;//from w w w . jav a 2 s . c om 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); //=== using the custom service MetadataInfo info = null; // first try: the service is installed? try { info = GNMetadataGetInfo.get(client.getConnection(), gnServiceURL, id, false); LOGGER.info("Basic metadataInfo by id is " + info); assertNotNull(info); assertNull(info.getVersion()); assertEquals(id, info.getId()); } catch (GNServerException ex) { if (ex.getHttpCode() == 404) { LOGGER.error("metadata.info.get is not installed on GeoNetwork. Skipping test."); assumeTrue(false); } else throw ex; } info = GNMetadataGetInfo.get(client.getConnection(), gnServiceURL, info.getUuid(), false); LOGGER.info("Basic metadataInfo by UUID is " + info); assertNotNull(info); assertNull(info.getVersion()); assertEquals(id, info.getId()); info = GNMetadataGetInfo.get(client.getConnection(), gnServiceURL, id, true); LOGGER.info("MetadataInfo is " + info); assertNotNull(info); assertEquals(Integer.valueOf(2), info.getVersion()); // the md has just been created assertEquals(id, info.getId()); 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_info_update", ".xml"); FileUtils.forceDeleteOnExit(tempFile); XMLOutputter fileOutputter = new XMLOutputter(Format.getCompactFormat()); FileUtils.writeStringToFile(tempFile, fileOutputter.outputString(md)); GNMetadataUpdate.update(client.getConnection(), gnServiceURL, id, Integer.toString(info.getVersion()), tempFile); { Element md2 = client.get(id); Element chstr = getTitleElement(md2); assertEquals(UPDATED_TEXT, chstr.getText()); } info = GNMetadataGetInfo.get(client.getConnection(), gnServiceURL, id, true); // String version3 = GNMetadataGetVersion.get(client.getConnection(), gnServiceURL, id); LOGGER.info("New MetadataInfo is " + info); assertNotNull(info.getVersion()); assertEquals(Integer.valueOf(4), info.getVersion()); // 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.jamocha.logging.TypedFilter.java
public void unwatchAll() { EnumSet.allOf(MarkerType.class) .forEach(mt -> this.markerToInExClusionList.put(mt, Pair.of(Boolean.FALSE, new ArrayList<>()))); }
From source file:org.cruxframework.crux.tools.server.JettyDevServer.java
public void start() throws Exception { SelectChannelConnector connector = new SelectChannelConnector(); connector.setHost(bindAddress);//from w w w .j ava2s .co m connector.setPort(port); connector.setReuseAddress(false); connector.setSoLingerTime(0); Server server = new Server(); server.addConnector(connector); WebAppContext webContext = new WebAppContext(); webContext.setWar(appRootDir.getCanonicalPath()); webContext.setParentLoaderPriority(true); webContext.setContextPath("/"); webContext.setClassLoader(Thread.currentThread().getContextClassLoader()); webContext.getInitParams().put("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false"); server.setHandler(webContext); if (addDevelopmentComponents) { webContext.addFilter(DeclarativeUIFilter.class, "*.html", EnumSet.allOf(DispatcherType.class)); webContext.addServlet(ViewTester.class, "/viewTester/*"); if (!webContext.getInitParams().containsKey(DevModeInitializerListener.OUTPUT_CHARSET)) { webContext.setInitParameter(DevModeInitializerListener.OUTPUT_CHARSET, pageOutputCharset); } webContext.addEventListener(new InitializerListener()); webContext.addEventListener(new DevModeInitializerListener()); } try { server.start(); server.join(); } catch (Exception e) { logger.error("cannot start web server", e); throw new UnableToCompleteException(); } }
From source file:com.consol.citrus.simulator.WebAppInitializer.java
public void onStartup(ServletContext servletContext) throws ServletException { XmlWebApplicationContext appContext = new XmlWebApplicationContext(); appContext.setConfigLocation("/WEB-INF/citrus-servlet-context.xml"); ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("citrus", new MessageDispatcherServlet()); dispatcherServlet.setLoadOnStartup(1); dispatcherServlet.addMapping("/simulator"); dispatcherServlet.addMapping("/simulator/*"); dispatcherServlet.setInitParameter("contextConfigLocation", ""); ServletRegistration.Dynamic statusServlet = servletContext.addServlet("status", new SimulatorStatusServlet()); statusServlet.setLoadOnStartup(1000); statusServlet.addMapping("/status"); statusServlet.addMapping("/status/*"); ServletRegistration.Dynamic runServlet = servletContext.addServlet("run", new SimulatorRunServlet()); runServlet.setLoadOnStartup(1000);// ww w . j a va2 s .co m runServlet.addMapping("/run"); runServlet.addMapping("/run/*"); ServletRegistration.Dynamic resourceServlet = servletContext.addServlet("resource", new StaticResourceServlet()); resourceServlet.setLoadOnStartup(1000); resourceServlet.addMapping("/info"); resourceServlet.addMapping("/info/*"); servletContext.addListener(new ContextLoaderListener(appContext)); CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter(); encodingFilter.setEncoding(System.getProperty("file.encoding", "UTF-8")); encodingFilter.setForceEncoding(true); FilterRegistration.Dynamic filter = servletContext.addFilter("encoding-filter", encodingFilter); filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); }
From source file:org.drools.planner.examples.manners2009.domain.Manners2009.java
public Collection<? extends Object> getProblemFacts() { List<Object> facts = new ArrayList<Object>(); facts.addAll(EnumSet.allOf(JobType.class)); facts.addAll(jobList);/* w w w . j a v a 2 s .c o m*/ facts.addAll(guestList); facts.addAll(EnumSet.allOf(Hobby.class)); facts.addAll(hobbyPracticianList); facts.addAll(tableList); facts.addAll(seatList); // Do not add the planning entity's (seatDesignationList) because that will be done automatically return facts; }
From source file:eu.itesla_project.security.SecurityAnalysisTool.java
@Override public void run(CommandLine line) throws Exception { Path caseFile = Paths.get(line.getOptionValue("case-file")); Set<LimitViolationType> limitViolationTypes = line.hasOption("limit-types") ? Arrays.stream(line.getOptionValue("limit-types").split(",")).map(LimitViolationType::valueOf) .collect(Collectors.toSet()) : EnumSet.allOf(LimitViolationType.class); Path csvFile = null;//from www. j av a 2s .co m if (line.hasOption("output-csv")) { csvFile = Paths.get(line.getOptionValue("output-csv")); } System.out.println("Loading network '" + caseFile + "'"); // load network Network network = Importers.loadNetwork(caseFile); if (network == null) { throw new RuntimeException("Case '" + caseFile + "' not found"); } network.getStateManager().allowStateMultiThreadAccess(true); ComponentDefaultConfig defaultConfig = new ComponentDefaultConfig(); SecurityAnalysisFactory securityAnalysisFactory = defaultConfig .findFactoryImplClass(SecurityAnalysisFactory.class).newInstance(); SecurityAnalysis securityAnalysis = securityAnalysisFactory.create(network, LocalComputationManager.getDefault(), 0); ContingenciesProviderFactory contingenciesProviderFactory = defaultConfig .findFactoryImplClass(ContingenciesProviderFactory.class).newInstance(); ContingenciesProvider contingenciesProvider = contingenciesProviderFactory.create(); // run security analysis on all N-1 lines SecurityAnalysisResult result = securityAnalysis.runAsync(contingenciesProvider).join(); if (!result.getPreContingencyResult().isComputationOk()) { System.out.println("Pre-contingency state divergence"); } LimitViolationFilter limitViolationFilter = new LimitViolationFilter(limitViolationTypes); if (csvFile != null) { System.out.println("Writing results to '" + csvFile + "'"); CsvTableFormatterFactory csvTableFormatterFactory = new CsvTableFormatterFactory(); Security.printPreContingencyViolations(result, Files.newBufferedWriter(csvFile, StandardCharsets.UTF_8), csvTableFormatterFactory, limitViolationFilter); Security.printPostContingencyViolations(result, Files.newBufferedWriter(csvFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND), csvTableFormatterFactory, limitViolationFilter); } else { SystemOutStreamWriter soutWriter = new SystemOutStreamWriter(); AsciiTableFormatterFactory asciiTableFormatterFactory = new AsciiTableFormatterFactory(); Security.printPreContingencyViolations(result, soutWriter, asciiTableFormatterFactory, limitViolationFilter); Security.printPostContingencyViolations(result, soutWriter, asciiTableFormatterFactory, limitViolationFilter); } }
From source file:io.appform.nautilus.funnel.FunnelServerApp.java
private void configureCors(Environment environment) { FilterRegistration.Dynamic filter = environment.servlets().addFilter("CORS", CrossOriginFilter.class); filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); filter.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET,PUT,POST,DELETE,OPTIONS"); filter.setInitParameter(CrossOriginFilter.ALLOWED_ORIGINS_PARAM, "*"); filter.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*"); filter.setInitParameter("allowedHeaders", "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin"); filter.setInitParameter("allowCredentials", "true"); }
From source file:com.sandeep.prototypes.address.AddressApplication.java
@Override public void run(AddressConfiguration addressConfiguration, Environment environment) throws Exception { FilterRegistration.Dynamic cors = environment.servlets().addFilter("CORS", CrossOriginFilter.class); cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*"); cors.setInitParameter(CrossOriginFilter.ACCESS_CONTROL_ALLOW_ORIGIN_HEADER, "*"); cors.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "Content-Type,Authorization,X-Requested-With,Content-Length,Accept,Origin"); cors.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "POST,GET,DELETE,PUT,OPTIONS"); cors.setInitParameter("allowCredentials", "true"); environment.jersey().register(new ApiListingResourceJSON()); environment.jersey().register(new ApiDeclarationProvider()); environment.jersey().register(new ResourceListingProvider()); environment.jersey().register(new AddressResource()); environment.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL); BeanConfig config = new BeanConfig(); config.setTitle(addressConfiguration.getApplicationTitle()); config.setDescription(addressConfiguration.getApplicationDescription()); config.setTermsOfServiceUrl(addressConfiguration.getApplicationTosUrl()); config.setContact(addressConfiguration.getApplicationContact()); config.setLicense(addressConfiguration.getLicense()); config.setVersion(addressConfiguration.getVersion()); config.setBasePath(addressConfiguration.getDocsPath()); config.setResourcePackage("com.sandeep.prototypes.address.resources"); config.setScan(true);// www.ja v a 2s . c o m }