Example usage for java.util EnumSet of

List of usage examples for java.util EnumSet of

Introduction

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

Prototype

public static <E extends Enum<E>> EnumSet<E> of(E e) 

Source Link

Document

Creates an enum set initially containing the specified element.

Usage

From source file:org.ulyssis.ipp.processor.Processor.java

public Processor(final ProcessorOptions options) {
    Database.setDatabaseURI(options.getDatabaseUri());
    try (Connection connection = Database.createConnection(EnumSet.of(READ_WRITE))) {
        if (options.shouldClearDb()) {
            Database.clearDb(connection);
        }/* w  ww. j  a  va2  s .  co  m*/
        Database.initDb(connection);
        connection.commit();
    } catch (SQLException e) {
        LOG.fatal("Error initializing database!", e);
    }
    URI uri = options.getRedisUri();
    this.eventQueue = new LinkedBlockingQueue<>();
    this.eventCallbacks = new ConcurrentHashMap<>();
    this.onStartedCallbacks = new CopyOnWriteArrayList<>();
    this.readerListeners = new ArrayList<>();
    this.threads = new ArrayList<>();
    // TODO: Move status reporting and processing of commands to ZeroMQ?
    // Also: post some stuff to a log in the db?
    this.statusReporter = new StatusReporter(uri, Config.getCurrentConfig().getStatusChannel());
    this.commandProcessor = new CommandProcessor(uri, Config.getCurrentConfig().getControlChannel(),
            statusReporter);
    initCommandProcessor();
    snapshot = new Snapshot(Instant.EPOCH);
    if (!restoreFromDb()) {
        registerInitialTags();
    }
}

From source file:com.norconex.jefmon.server.JEFMonServer.java

private WebAppContext buildWebappContext() {

    WebAppContext webappContext = new WebAppContext();
    webappContext.setResourceBase("/");

    // Add Wicket filter
    WicketFilter filter = new WicketFilter(app);
    FilterHolder filterHolder = new FilterHolder(filter);
    filterHolder.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, JEFMON_MAPPING);
    webappContext.addFilter(filterHolder, JEFMON_MAPPING, EnumSet.of(DispatcherType.REQUEST));

    // Add custom error message
    webappContext.setErrorHandler(new ErrorHandler() {
        protected void writeErrorPageBody(HttpServletRequest request, Writer writer, int code, String message,
                boolean showStacks) throws IOException {
            String uri = request.getRequestURI();
            writeErrorPageMessage(request, writer, code, message, uri);
            if (showStacks)
                writeErrorPageStacks(request, writer);
            writer.write("<hr><i><small>" + "Norconex JEF Monitor</small></i><hr/>\n");
        }//from  w w  w .  j  a v a  2 s . co m
    });

    return webappContext;
}

From source file:ch.cyberduck.cli.SingleTransferItemFinderTest.java

@Test
public void testUploadDirectory() throws Exception {
    final CommandLineParser parser = new PosixParser();
    final CommandLine input = parser.parse(TerminalOptionsBuilder.options(), new String[] { "--upload",
            "ftps://test.cyberduck.ch/remote/", System.getProperty("java.io.tmpdir") });

    final Set<TransferItem> found = new SingleTransferItemFinder().find(input, TerminalAction.upload,
            new Path("/remote/", EnumSet.of(Path.Type.directory)));
    assertFalse(found.isEmpty());/*from  ww  w . j a v a  2s . c  om*/
    final Iterator<TransferItem> iter = found.iterator();
    final Local temp = LocalFactory.get(System.getProperty("java.io.tmpdir"));
    assertTrue(temp.getType().contains(Path.Type.directory));
    assertEquals(new TransferItem(new Path("/remote", EnumSet.of(Path.Type.directory)), temp), iter.next());
}

From source file:com.zxy.commons.hystrix.web.HystrixInitializer.java

/**
 * {@inheritDoc}/*from   ww  w .j a  v  a  2s.com*/
 */
public void onStartup(ServletContext container) throws ServletException {
    //        WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(container);
    Properties properties = load();
    String enabled = properties.getProperty(HystrixProperties.HYSTRIX_ENABLED);
    String streamEnabled = properties.getProperty(HystrixProperties.HYSTRIX_STREAM_ENABLED);
    if ((StringUtils.isBlank(enabled) || "true".equalsIgnoreCase(enabled))
            && (StringUtils.isBlank(streamEnabled) || "true".equalsIgnoreCase(streamEnabled))) {

        // AnnotationConfigWebApplicationContext ctx = new
        // AnnotationConfigWebApplicationContext();
        // ctx.register(AppConfig.class);
        // ctx.setServletContext(container);

        // ServletRegistration.Dynamic servlet =
        // container.addServlet("dispatcher", new DispatcherServlet(ctx));
        // WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(container);
        // servlet.setLoadOnStartup(1);
        // servlet.addMapping("/");

        FilterRegistration.Dynamic hystrixRequestContextServletFilter = container
                .addFilter("HystrixRequestContextServletFilter", new HystrixRequestContextServletFilter());
        hystrixRequestContextServletFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true,
                "/*");

        FilterRegistration.Dynamic hystrixRequestLogViaResponseHeaderServletFilter = container.addFilter(
                "HystrixRequestLogViaResponseHeaderServletFilter",
                new HystrixRequestLogViaResponseHeaderServletFilter());
        hystrixRequestLogViaResponseHeaderServletFilter
                .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");

        ServletRegistration.Dynamic hystrixMetricsStreamServlet = container
                .addServlet("HystrixMetricsStreamServlet", new HystrixMetricsStreamServlet());
        hystrixMetricsStreamServlet.addMapping("/hystrix.stream");

        // ServletRegistration.Dynamic proxyStreamServlet =
        // container.addServlet("ProxyStreamServlet", new
        // ProxyStreamServlet());
        // proxyStreamServlet.addMapping("/proxy.stream");
    }
}

From source file:net.solarnetwork.node.dao.jdbc.test.JdbcSettingsDaoTests.java

@Test
public void insertVolatile() {
    replay(eventAdminMock);//from  w w  w. j av a  2s .  com

    Setting s = new Setting();
    s.setKey(TEST_KEY);
    s.setType(TEST_TYPE);
    s.setValue(TEST_VALUE);
    s.setFlags(EnumSet.of(SettingFlag.Volatile));

    settingDao.storeSetting(s);

    verify(eventAdminMock);
}

From source file:ch.cyberduck.core.spectra.SpectraMultipleDeleteFeatureTest.java

@Test
public void testDeletePlaceholder() throws Exception {
    final Host host = new Host(new SpectraProtocol() {
        @Override//from w  w  w.j ava  2s.c om
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"),
            Integer.valueOf(System.getProperties().getProperty("spectra.port")),
            new Credentials(System.getProperties().getProperty("spectra.user"),
                    System.getProperties().getProperty("spectra.key")));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("cyberduck", EnumSet.of(Path.Type.volume));
    final Path test = new S3DirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(
            new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), null,
            new TransferStatus());
    assertTrue(new S3FindFeature(session).find(test));
    assertTrue(new DefaultFindFeature(session).find(test));
    new S3MultipleDeleteFeature(session).delete(Arrays.asList(test, test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    assertFalse(new S3FindFeature(session).find(test));
    session.close();
}

From source file:ch.cyberduck.core.cryptomator.DAVDirectoryFeatureTest.java

@Test
public void testMakeDirectoryLongFilenameEncrypted() throws Exception {
    final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("webdav.user"),
                    System.getProperties().getProperty("webdav.password")));
    host.setDefaultPath("/dav/basic");
    final DAVSession session = new DAVSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new RandomStringGenerator.Builder().build().generate(130),
            EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(/*from  w  w  w.j  a  va  2s .  co  m*/
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    new CryptoDirectoryFeature<String>(session, new DAVDirectoryFeature(session), new DAVWriteFeature(session),
            cryptomator).mkdir(test, null, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new DAVDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.ftp.FTPStatListServiceTest.java

@Test
public void testParse8006() throws Exception {
    final List<String> lines = Arrays.asList("212-Status of /cgi-bin:",
            " drwxr-xr-x   3 1564466  15000           4 Jan 19 19:56 .",
            " drwxr-x---  13 1564466  15000          44 Jun 13 18:36 ..",
            " drwxr-xr-x   2 1564466  15000           2 May 25  2009 tmp", " End of status",
            "212 -rw-r--r--   1 1564466  15000        9859 Jan 19 19:56 adoptees.php");
    final FTPFileEntryParser parser = new UnixFTPEntryParser();
    final List<String> list = new FTPStatListService(null, parser).parse(212,
            lines.toArray(new String[lines.size()]));
    assertEquals(6, list.size());/*from   w  w  w .j av a  2s .  c  om*/
    final Path parent = new Path("/cgi-bin", EnumSet.of(Path.Type.directory));
    final AttributedList<Path> parsed = new FTPListResponseReader(parser, true).read(parent, list,
            new DisabledListProgressListener());
    assertEquals(2, parsed.size());
    assertTrue(parsed.contains(new Path(parent, "tmp", EnumSet.of(Path.Type.directory))));
    assertTrue(parsed.contains(new Path(parent, "adoptees.php", EnumSet.of(Path.Type.file))));
}

From source file:ch.cyberduck.core.openstack.SwiftObjectListService.java

@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener)
        throws BackgroundException {
    try {//www.  j  av a 2s .c om
        final AttributedList<Path> children = new AttributedList<Path>();
        final int limit = PreferencesFactory.get().getInteger("openstack.list.object.limit");
        String marker = null;
        List<StorageObject> list;
        do {
            final Path container = containerService.getContainer(directory);
            list = session.getClient().listObjectsStartingWith(regionService.lookup(container),
                    container.getName(),
                    containerService.isContainer(directory) ? StringUtils.EMPTY
                            : containerService.getKey(directory) + Path.DELIMITER,
                    null, limit, marker, Path.DELIMITER);
            for (StorageObject object : list) {
                final PathAttributes attributes = new PathAttributes();
                attributes.setOwner(container.attributes().getOwner());
                attributes.setRegion(container.attributes().getRegion());
                if (StringUtils.isNotBlank(object.getMd5sum())) {
                    // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of
                    // the concatenated string of ETags for each of the segments in the manifest.
                    attributes.setChecksum(Checksum.parse(object.getMd5sum()));
                }
                attributes.setSize(object.getSize());
                final String lastModified = object.getLastModified();
                if (lastModified != null) {
                    try {
                        attributes.setModificationDate(dateParser.parse(lastModified).getTime());
                    } catch (InvalidDateException e) {
                        log.warn(String.format("%s is not ISO 8601 format %s", lastModified, e.getMessage()));
                    }
                }
                final EnumSet<AbstractPath.Type> types = "application/directory".equals(object.getMimeType())
                        ? EnumSet.of(Path.Type.directory)
                        : EnumSet.of(Path.Type.file);
                if (StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) {
                    if (children.contains(new Path(directory, PathNormalizer.name(object.getName()),
                            EnumSet.of(Path.Type.directory), attributes))) {
                        // There is already a real placeholder file with application/directory MIME type. Only
                        // add virtual directory if the placeholder object is missing
                        continue;
                    }
                }
                children.add(new Path(directory, PathNormalizer.name(object.getName()), types, attributes));
                marker = object.getName();
            }
            listener.chunk(directory, children);
        } while (list.size() == limit);
        return children;
    } catch (GenericException e) {
        throw new SwiftExceptionMappingService().map("Listing directory {0} failed", e, directory);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map(e, directory);
    }
}

From source file:info.gehrels.voting.web.SpringConfig.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    CharacterEncodingFilter filter = new CharacterEncodingFilter();
    filter.setEncoding("UTF-8");
    servletContext.addFilter("characterEncodingFilter", filter).addMappingForUrlPatterns(EnumSet.of(REQUEST),
            false, "/*");
}