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

@SafeVarargs
public static <E extends Enum<E>> EnumSet<E> of(E first, E... rest) 

Source Link

Document

Creates an enum set initially containing the specified elements.

Usage

From source file:ch.cyberduck.core.b2.B2ObjectListServiceTest.java

@Test
public void testListChunking() throws Exception {
    final B2Session session = new B2Session(new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
            new Credentials(System.getProperties().getProperty("b2.user"),
                    System.getProperties().getProperty("b2.key"))));
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path bucket = new B2DirectoryFeature(session)
            .mkdir(new Path(String.format("test-%s", UUID.randomUUID().toString()),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path file1 = new B2TouchFeature(session).touch(
            new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final Path file2 = new B2TouchFeature(session).touch(
            new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final AttributedList<Path> list = new B2ObjectListService(session, new B2FileidProvider(session), 1)
            .list(bucket, new DisabledListProgressListener());
    assertTrue(list.contains(file1));/*  ww w .  ja v  a 2  s  .  c o  m*/
    assertTrue(list.contains(file2));

    new B2DeleteFeature(session).delete(Arrays.asList(bucket, file1, file2), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

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

@Test
public void testTouchLongFilenameEncryptedDefaultFeature() throws Exception {
    final Host host = new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com",
            new Credentials(System.getProperties().getProperty("rackspace.key"),
                    System.getProperties().getProperty("rackspace.secret")));
    final SwiftSession session = new SwiftSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory));
    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.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(//ww w .java 2  s .c o m
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final SwiftRegionService regionService = new SwiftRegionService(session);
    new CryptoTouchFeature<StorageObject>(session,
            new DefaultTouchFeature<StorageObject>(
                    new SwiftSmallObjectUploadFeature(new SwiftWriteFeature(session, regionService))),
            new SwiftWriteFeature(session, regionService), cryptomator).touch(test, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new SwiftDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.sds.SDSDelegatingMoveFeatureTest.java

@Test
public void testMoveDifferentDataRoom() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.enableMetrics();/*  w  w w  .j a v  a2 s.  c o  m*/
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room1 = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path room2 = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path test = new Path(room1, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    new SDSTouchFeature(session).touch(test, new TransferStatus());
    final Path target = new Path(room2, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    new SDSDelegatingMoveFeature(session, new SDSMoveFeature(session)).move(test, target, new TransferStatus(),
            new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertFalse(new SDSFindFeature(session).find(test));
    assertTrue(new SDSFindFeature(session).find(target));
    assertEquals(0, session.getMetrics().get(Copy.class));
    new SDSDeleteFeature(session).delete(Arrays.asList(room1, room2), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

From source file:ch.cyberduck.core.sds.SDSDelegatingCopyFeatureTest.java

@Test
public void testCopyFileWithRename() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path room = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path test = new SDSTouchFeature(session).touch(
            new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)),
            new TransferStatus());
    final Path copy = new Path(
            new SDSDirectoryFeature(session).mkdir(new Path(room,
                    new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null,
                    new TransferStatus()),
            new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final SDSCopyFeature feature = new SDSCopyFeature(session);
    assertFalse(feature.isSupported(test, copy));
    new SDSDelegatingCopyFeature(session, feature).copy(test, copy, new TransferStatus(),
            new DisabledConnectionCallback());
    assertTrue(new SDSFindFeature(session).find(test));
    assertTrue(new SDSFindFeature(session).find(copy));
    new SDSDeleteFeature(session).delete(Collections.singletonList(room), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();/*w ww. ja  v  a2s  .c  o m*/
}

From source file:ch.cyberduck.core.sds.SDSMoveFeatureTest.java

@Test
public void testMoveDifferentDataRoom() throws Exception {
    final Host host = new Host(new SDSProtocol(), "duck.ssp-europe.eu", new Credentials(
            System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key")));
    final SDSSession session = new SDSSession(host, new DisabledX509TrustManager(),
            new DefaultX509KeyManager());
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback(),
            PathCache.empty());/*from   ww  w.j a  va 2s.  c o m*/
    final Path room1 = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path room2 = new SDSDirectoryFeature(session)
            .mkdir(new Path(new AlphanumericRandomStringService().random(),
                    EnumSet.of(Path.Type.directory, Path.Type.volume)), null, new TransferStatus());
    final Path test = new Path(room1, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    new SDSTouchFeature(session).touch(test, new TransferStatus());
    final Path target = new Path(room2, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    new SDSMoveFeature(session).move(test, target, new TransferStatus(), new Delete.DisabledCallback(),
            new DisabledConnectionCallback());
    assertFalse(new SDSFindFeature(session).find(test));
    assertTrue(new SDSFindFeature(session).find(target));
    new SDSDeleteFeature(session).delete(Arrays.asList(room1, room2), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
    session.close();
}

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

@Test
public void testWriteZeroLength() throws Exception {
    final Host host = new Host(new SwiftProtocol(), "identity.api.rackspacecloud.com",
            new Credentials(System.getProperties().getProperty("rackspace.key"),
                    System.getProperties().getProperty("rackspace.secret")));
    final SwiftSession session = new SwiftSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final SwiftRegionService regionService = new SwiftRegionService(session);
    final SwiftLargeUploadWriteFeature feature = new SwiftLargeUploadWriteFeature(session, regionService,
            new SwiftSegmentService(session, ".segments-test/"));
    final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final byte[] content = RandomUtils.nextBytes(0);
    final TransferStatus status = new TransferStatus();
    status.setLength(-1L);/*from  w  w  w. j  a v a2s .com*/
    final Path file = new Path(container, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final HttpResponseOutputStream<List<StorageObject>> out = feature.write(file, status,
            new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    assertEquals(content.length, IOUtils.copyLarge(in, out));
    in.close();
    out.close();
    assertNotNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new SwiftReadFeature(session, regionService).read(file,
            new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new SwiftDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
}

From source file:ch.cyberduck.core.cloudfront.WebsiteCloudFrontDistributionConfiguration.java

@Override
public Distribution read(final Path container, final Distribution.Method method, final LoginCallback prompt)
        throws BackgroundException {
    if (method.equals(Distribution.WEBSITE)) {
        try {//w  ww. j  ava2s .c  om
            final WebsiteConfig configuration = session.getClient().getWebsiteConfig(container.getName());
            final Distribution distribution = new Distribution(this.getOrigin(container, method), method,
                    configuration.isWebsiteConfigActive());
            distribution.setStatus(LocaleFactory.localizedString("Deployed", "S3"));
            // http://example-bucket.s3-website-us-east-1.amazonaws.com/
            distribution.setUrl(URI
                    .create(String.format("%s://%s", method.getScheme(), this.getWebsiteHostname(container))));
            distribution.setIndexDocument(configuration.getIndexDocumentSuffix());
            distribution.setContainers(new S3BucketListService(session).list(
                    new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)),
                    new DisabledListProgressListener()).toList());
            return distribution;
        } catch (ServiceException e) {
            // Not found. Website configuration not enabled.
            final Distribution distribution = new Distribution(this.getOrigin(container, method), method,
                    false);
            distribution.setStatus(e.getErrorMessage());
            distribution.setUrl(URI
                    .create(String.format("%s://%s", method.getScheme(), this.getWebsiteHostname(container))));
            return distribution;
        }
    } else {
        return super.read(container, method, prompt);
    }
}

From source file:ch.cyberduck.core.googlestorage.GoogleStorageWebsiteDistributionConfiguration.java

@Override
public Distribution read(final Path file, final Distribution.Method method, final LoginCallback prompt)
        throws BackgroundException {
    final Path container = containerService.getContainer(file);
    final URI origin = URI
            .create(String.format("%s://%s.%s", method.getScheme(), container.getName(), this.getHostname()));
    try {//from ww  w . j a  v  a  2  s  .  c  o  m
        final WebsiteConfig configuration = session.getClient().getWebsiteConfigImpl(container.getName());
        final Distribution distribution = new Distribution(origin, method,
                configuration.isWebsiteConfigActive());
        distribution.setUrl(URI.create(
                String.format("%s://%s.%s", method.getScheme(), container.getName(), this.getHostname())));
        distribution.setStatus(LocaleFactory.localizedString("Deployed", "S3"));
        distribution.setIndexDocument(configuration.getIndexDocumentSuffix());
        final DistributionLogging logging = this.getFeature(DistributionLogging.class, method);
        if (logging != null) {
            final LoggingConfiguration c = new GoogleStorageLoggingFeature(session).getConfiguration(container);
            distribution.setLogging(c.isEnabled());
            distribution.setLoggingContainer(c.getLoggingTarget());
            distribution.setContainers(new S3BucketListService(session).list(
                    new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)),
                    new DisabledListProgressListener()).toList());
        }
        return distribution;
    } catch (ServiceException e) {
        // Not found. Website configuration is disabled.
        final Distribution distribution = new Distribution(origin, method, false);
        distribution.setStatus(e.getErrorMessage());
        distribution.setUrl(URI.create(
                String.format("%s://%s.%s", method.getScheme(), container.getName(), this.getHostname())));
        return distribution;
    }
}

From source file:ch.cyberduck.core.b2.B2ObjectListService.java

protected Marker parse(final Path directory, final AttributedList<Path> objects,
        final B2ListFilesResponse response, final Map<String, Integer> revisions) throws BackgroundException {
    for (B2FileInfoResponse info : response.getFiles()) {
        if (StringUtils.equals(PathNormalizer.name(info.getFileName()), B2PathContainerService.PLACEHOLDER)) {
            continue;
        }//w w w .  j av  a  2s  . co m
        if (StringUtils.isBlank(info.getFileId())) {
            // Common prefix
            final Path placeholder = new Path(directory, PathNormalizer.name(info.getFileName()),
                    EnumSet.of(Path.Type.directory, Path.Type.placeholder));
            objects.add(placeholder);
            continue;
        }
        final PathAttributes attributes = this.parse(info);
        final Integer revision;
        if (revisions.keySet().contains(info.getFileName())) {
            // Later version already found
            attributes.setDuplicate(true);
            revision = revisions.get(info.getFileName()) + 1;
        } else {
            revision = 1;
        }
        revisions.put(info.getFileName(), revision);
        attributes.setRevision(revision);
        objects.add(new Path(directory, PathNormalizer.name(info.getFileName()),
                info.getAction() == Action.start ? EnumSet.of(Path.Type.file, Path.Type.upload)
                        : EnumSet.of(Path.Type.file),
                attributes));
    }
    if (null == response.getNextFileName()) {
        return new Marker(response.getNextFileName(), response.getNextFileId());
    }
    return new Marker(response.getNextFileName(), response.getNextFileId());
}

From source file:com.novartis.pcs.ontology.rest.servlet.SubtermsServlet.java

private void serialize(String referenceId, boolean pending, HttpServletResponse response) {
    try {//  ww w.  ja v a 2s .  co  m
        EnumSet<Status> statusSet = pending ? EnumSet.of(Status.PENDING, Status.APPROVED)
                : EnumSet.of(Status.APPROVED);
        Collection<Term> terms = termDAO.loadSubTermsByReferenceId(referenceId, statusSet);
        List<TermDTO> dtos = new ArrayList<TermDTO>(terms.size());
        for (Term term : terms) {
            if (statusSet.contains(term.getStatus())) {
                dtos.add(new TermDTO(term));
            }
        }
        if (!dtos.isEmpty()) {
            response.setStatus(HttpServletResponse.SC_OK);
            response.setHeader("Access-Control-Allow-Origin", "*");
            response.setContentType(MEDIA_TYPE_JSON + ";charset=utf-8");
            response.setHeader("Cache-Control", "public, max-age=0");

            // As per jackson javadocs - Encoding will be UTF-8
            mapper.writeValue(response.getOutputStream(), dtos);
        } else {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            response.setContentLength(0);
        }
    } catch (Exception e) {
        log("Failed to serialize synonyms to JSON", e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.setContentLength(0);
    }
}