@Test public void testMkdir() throws Exception { final DriveFileidProvider fileid = new DriveFileidProvider(session).withCache(cache).withCache(cache); final Path test = new DriveDirectoryFeature(session, fileid).mkdir( new Path(DriveHomeFinderService.MYDRIVE_FOLDER, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); assertNotNull(test.attributes().getVersionId()); assertTrue(new DefaultFindFeature(session).find(test)); new DriveDeleteFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); test.attributes().setVersionId(null); assertFalse(new DriveFindFeature(session, fileid).find(test)); assertFalse(new DefaultFindFeature(session).find(test)); assertTrue(new DefaultAttributesFinderFeature(session).find(test).isDuplicate()); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(folder.getParent())) { final TeamDrive execute = session.getClient().teamdrives().create( new UUIDRandomStringService().random(), new TeamDrive().setName(folder.getName()) ).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new PathAttributes(folder.attributes()).withVersionId(execute.getId())); } else { final Drive.Files.Create insert = session.getClient().files().create(new File() .setName(folder.getName()) .setMimeType("application/vnd.google-apps.folder") .setParents(Collections.singletonList(fileid.getFileid(folder.getParent(), new DisabledListProgressListener())))); final File execute = insert .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new DriveAttributesFinderFeature(session, fileid).toAttributes(execute)); } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot create folder {0}", e, folder); } }
DriveDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(folder.getParent())) { final TeamDrive execute = session.getClient().teamdrives().create( new UUIDRandomStringService().random(), new TeamDrive().setName(folder.getName()) ).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new PathAttributes(folder.attributes()).withVersionId(execute.getId())); } else { final Drive.Files.Create insert = session.getClient().files().create(new File() .setName(folder.getName()) .setMimeType("application/vnd.google-apps.folder") .setParents(Collections.singletonList(fileid.getFileid(folder.getParent(), new DisabledListProgressListener())))); final File execute = insert .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new DriveAttributesFinderFeature(session, fileid).toAttributes(execute)); } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot create folder {0}", e, folder); } } }
DriveDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(folder.getParent())) { final TeamDrive execute = session.getClient().teamdrives().create( new UUIDRandomStringService().random(), new TeamDrive().setName(folder.getName()) ).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new PathAttributes(folder.attributes()).withVersionId(execute.getId())); } else { final Drive.Files.Create insert = session.getClient().files().create(new File() .setName(folder.getName()) .setMimeType("application/vnd.google-apps.folder") .setParents(Collections.singletonList(fileid.getFileid(folder.getParent(), new DisabledListProgressListener())))); final File execute = insert .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new DriveAttributesFinderFeature(session, fileid).toAttributes(execute)); } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot create folder {0}", e, folder); } } DriveDirectoryFeature(final DriveSession session, final DriveFileidProvider fileid); }
DriveDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(folder.getParent())) { final TeamDrive execute = session.getClient().teamdrives().create( new UUIDRandomStringService().random(), new TeamDrive().setName(folder.getName()) ).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new PathAttributes(folder.attributes()).withVersionId(execute.getId())); } else { final Drive.Files.Create insert = session.getClient().files().create(new File() .setName(folder.getName()) .setMimeType("application/vnd.google-apps.folder") .setParents(Collections.singletonList(fileid.getFileid(folder.getParent(), new DisabledListProgressListener())))); final File execute = insert .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new DriveAttributesFinderFeature(session, fileid).toAttributes(execute)); } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot create folder {0}", e, folder); } } DriveDirectoryFeature(final DriveSession session, final DriveFileidProvider fileid); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override DriveDirectoryFeature withWriter(final Write<VersionId> writer); @Override boolean isSupported(final Path workdir, final String name); }
DriveDirectoryFeature implements Directory<VersionId> { @Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(DriveHomeFinderService.TEAM_DRIVES_NAME.equals(folder.getParent())) { final TeamDrive execute = session.getClient().teamdrives().create( new UUIDRandomStringService().random(), new TeamDrive().setName(folder.getName()) ).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new PathAttributes(folder.attributes()).withVersionId(execute.getId())); } else { final Drive.Files.Create insert = session.getClient().files().create(new File() .setName(folder.getName()) .setMimeType("application/vnd.google-apps.folder") .setParents(Collections.singletonList(fileid.getFileid(folder.getParent(), new DisabledListProgressListener())))); final File execute = insert .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new DriveAttributesFinderFeature(session, fileid).toAttributes(execute)); } } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot create folder {0}", e, folder); } } DriveDirectoryFeature(final DriveSession session, final DriveFileidProvider fileid); @Override Path mkdir(final Path folder, final String region, final TransferStatus status); @Override DriveDirectoryFeature withWriter(final Write<VersionId> writer); @Override boolean isSupported(final Path workdir, final String name);  }