List of usage examples for java.util EnumSet of
public static <E extends Enum<E>> EnumSet<E> of(E e)
From source file:ch.cyberduck.core.dropbox.DropboxListService.java
protected Path parse(final Path directory, final Metadata metadata) { final EnumSet<AbstractPath.Type> type; if (metadata instanceof FileMetadata) { type = EnumSet.of(Path.Type.file); } else if (metadata instanceof FolderMetadata) { type = EnumSet.of(Path.Type.directory); } else {//from w w w. j a va2 s. c o m log.warn(String.format("Skip file %s", metadata)); return null; } return new Path(directory, PathNormalizer.name(metadata.getName()), type, attributes.convert(metadata)); }
From source file:ch.cyberduck.core.cryptomator.SingleTransferWorkerTest.java
@Test public void testUpload() 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 dir1 = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); final Local localDirectory1 = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random()); localDirectory1.mkdir();/*from www . ja v a 2 s. c o m*/ final byte[] content = RandomUtils.nextBytes(62768); final Path file1 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Local localFile1 = new Local(localDirectory1, file1.getName()); final OutputStream out1 = localFile1.getOutputStream(false); IOUtils.write(content, out1); out1.close(); final Path file2 = new Path(dir1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Local localFile2 = new Local(localDirectory1, file2.getName()); final OutputStream out2 = localFile2.getOutputStream(false); IOUtils.write(content, out2); out2.close(); final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()); cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new PasswordCallback() { @Override public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { return new VaultCredentials("test"); } })); PreferencesFactory.get().setProperty("factory.vault.class", CryptoVault.class.getName()); final Transfer t = new UploadTransfer(new Host(new TestProtocol()), Collections.singletonList(new TransferItem(dir1, localDirectory1)), new NullFilter<>()); assertTrue(new SingleTransferWorker(session, session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() { @Override public TransferAction prompt(final TransferItem file) { return TransferAction.overwrite; } }, new DisabledTransferErrorCallback(), new DisabledProgressListener(), new DisabledStreamListener(), new DisabledLoginCallback(), new DisabledPasswordCallback()) { }.run(session, session)); assertTrue(new CryptoFindFeature(session, new DAVFindFeature(session), cryptomator).find(dir1)); assertEquals(content.length, new CryptoAttributesFeature(session, new DAVAttributesFinderFeature(session), cryptomator) .find(file1).getSize()); { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length); final InputStream in = new CryptoReadFeature(session, new DAVReadFeature(session), cryptomator) .read(file1, new TransferStatus().length(content.length), new DisabledConnectionCallback()); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer); assertArrayEquals(content, buffer.toByteArray()); } assertEquals(content.length, new CryptoAttributesFeature(session, new DAVAttributesFinderFeature(session), cryptomator) .find(file2).getSize()); { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length); final InputStream in = new CryptoReadFeature(session, new DAVReadFeature(session), cryptomator) .read(file1, new TransferStatus().length(content.length), new DisabledConnectionCallback()); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(in, buffer); assertArrayEquals(content, buffer.toByteArray()); } new CryptoDeleteFeature(session, new DAVDeleteFeature(session), cryptomator).delete( Arrays.asList(file1, file2, dir1, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); localFile1.delete(); localFile2.delete(); localDirectory1.delete(); }
From source file:io.lavagna.service.ProjectService.java
@Transactional(readOnly = false) public Project create(String name, String shortName, String description) { queries.createProject(trimToNull(name), trimToNull(shortName.toUpperCase(Locale.ENGLISH)), trimToNull(description));/*from ww w. j a va2 s .c o m*/ Project project = queries.findLastCreatedProject(); // Add default labels to the Project cardLabelRepository.addSystemLabels(project.getId()); // create default column definitions createDefaultColumnDefinitions(project.getId()); // Role anonymousRole = new Role("ANONYMOUS"); permissionService.createFullRoleInProjectId(anonymousRole, project.getId(), false, true, true); permissionService.updatePermissionsToRole(anonymousRole, EnumSet.of(Permission.READ)); // return project; }
From source file:ch.cyberduck.core.cryptomator.OneDriveDirectoryFeatureTest.java
@Test public void testMakeDirectoryLongFilenameEncrypted() throws Exception { final Path home = new OneDriveHomeFinderFeature(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 2 s . co m*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoDirectoryFeature<Void>(session, new OneDriveDirectoryFeature(session), new OneDriveWriteFeature(session), cryptomator).mkdir(test, null, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new OneDriveDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:ch.cyberduck.core.cryptomator.SFTPMoveFeatureTest.java
@Test public void testMoveSameFolderCryptomator() throws Exception { final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("sftp.user"), System.getProperties().getProperty("sftp.password"))); final SFTPSession session = new SFTPSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path home = new SFTPHomeDirectoryService(session).find(); final Path vault = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); final Path source = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final Path target = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()); cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(/* ww w . j a va2s. co m*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoTouchFeature<Void>(session, new DefaultTouchFeature<Void>(new DefaultUploadFeature<Void>(new SFTPWriteFeature(session))), new SFTPWriteFeature(session), cryptomator).touch(source, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source)); new CryptoMoveFeature(session, new SFTPMoveFeature(session), new SFTPDeleteFeature(session), cryptomator) .move(source, target, new TransferStatus(), new Delete.Callback() { @Override public void delete(final Path file) { // } }, new DisabledConnectionCallback()); assertFalse(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source)); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(target)); new CryptoDeleteFeature(session, new SFTPDeleteFeature(session), cryptomator) .delete(Arrays.asList(target, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.onedrive.OneDriveReadFeatureTest.java
@Test public void testReadRange() throws Exception { final Path drive = new OneDriveHomeFinderFeature(session).find(); final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new OneDriveTouchFeature(session).touch(test, new TransferStatus()); final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random()); final byte[] content = RandomUtils.nextBytes(1000); final OutputStream out = local.getOutputStream(false); assertNotNull(out);//from w w w . j a va 2 s .c o m IOUtils.write(content, out); out.close(); new DefaultUploadFeature<Void>(new OneDriveWriteFeature(session)).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), new TransferStatus().length(content.length), new DisabledConnectionCallback()); final TransferStatus status = new TransferStatus(); status.setLength(content.length); status.setAppend(true); status.setOffset(100L); final OneDriveReadFeature read = new OneDriveReadFeature(session); assertTrue(read.offset(test)); final InputStream in = read.read(test, status.length(content.length - 100), new DisabledConnectionCallback()); assertNotNull(in); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100); new StreamCopier(status, status).transfer(in, buffer); final byte[] reference = new byte[content.length - 100]; System.arraycopy(content, 100, reference, 0, content.length - 100); assertArrayEquals(reference, buffer.toByteArray()); in.close(); new OneDriveDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:ch.cyberduck.core.cryptomator.DriveTouchFeatureTest.java
@Test public void testTouchLongFilenameEncryptedDefaultFeature() throws Exception { final Path home = new DriveHomeFinderService(session).find(); final CryptoVault cryptomator = new CryptoVault( new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new DisabledPasswordStore()); final Path vault = cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(/*from w ww. j av a2 s .c o m*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); final Path test = new CryptoTouchFeature<Void>(session, new DriveTouchFeature(session), new DriveWriteFeature(session), cryptomator) .touch(new Path(vault, new RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.file)), new TransferStatus()); Assert.assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new DriveDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:ch.cyberduck.core.irods.IRODSUploadFeatureTest.java
@Test @Ignore/*from www.jav a 2 s .c o m*/ public void testAppend() throws Exception { final ProtocolFactory factory = new ProtocolFactory( new HashSet<>(Collections.singleton(new IRODSProtocol()))); final Profile profile = new ProfilePlistReader(factory) .read(new Local("../profiles/iRODS (iPlant Collaborative).cyberduckprofile")); final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials(System.getProperties().getProperty("irods.key"), System.getProperties().getProperty("irods.secret"))); final IRODSSession session = new IRODSSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final int length = 32770; final byte[] content = RandomUtils.nextBytes(length); final OutputStream out = local.getOutputStream(false); IOUtils.write(content, out); out.close(); final Checksum checksumPart1; final Checksum checksumPart2; final Path test = new Path(new IRODSHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); { final TransferStatus status = new TransferStatus().length(content.length / 2); checksumPart1 = new IRODSUploadFeature(session).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(content.length / 2, status.getOffset()); } { final TransferStatus status = new TransferStatus().length(content.length / 2).skip(content.length / 2) .append(true); checksumPart2 = new IRODSUploadFeature(session).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback()); assertEquals(content.length / 2, status.getOffset()); } assertNotEquals(checksumPart1, checksumPart2); final byte[] buffer = new byte[content.length]; final InputStream in = new IRODSReadFeature(session).read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); assertArrayEquals(content, buffer); new IRODSDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); local.delete(); session.close(); }
From source file:ch.cyberduck.ui.cocoa.FileController.java
@Override protected boolean validateInput() { if (StringUtils.contains(inputField.stringValue(), Path.DELIMITER)) { return false; }/*from www. j a va 2 s . c o m*/ if (StringUtils.isNotBlank(inputField.stringValue())) { if (cache.get(this.getWorkdir()) .contains(new Path(this.getWorkdir(), inputField.stringValue(), EnumSet.of(Path.Type.file)))) { return false; } if (cache.get(this.getWorkdir()).contains( new Path(this.getWorkdir(), inputField.stringValue(), EnumSet.of(Path.Type.directory)))) { return false; } return true; } return false; }
From source file:SheetResourcesIT.java
public void testCopySheet() throws SmartsheetException, IOException { Folder folder = createFolder();/*ww w. jav a2 s.c o m*/ //ContainerDestination destination = new ContainerDestination.AddContainerDestinationBuilder().setDestinationType(DestinationType.HOME).setDestinationId(null).setNewName("New Copied sheet").build(); ContainerDestination destination = new ContainerDestination.AddContainerDestinationBuilder() .setDestinationType(DestinationType.FOLDER).setDestinationId(folder.getId()) .setNewName("New Copied sheet").build(); Sheet sheet = smartsheet.sheetResources().copySheet(newSheetHome.getId(), destination, EnumSet.of(SheetCopyInclusion.ALL)); assertEquals(sheet.getName(), "New Copied sheet"); deleteFolder(folder.getId()); }