if(new SimplePathPredicate(directory).test(home)) { attributes.withVersionId(null);
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> children = new AttributedList<>(); String page = null; do { final TeamDriveList list = session.getClient().teamdrives().list() .setPageToken(page) .setPageSize(pagesize) .execute(); for(TeamDrive f : list.getTeamDrives()) { final Path child = new Path(directory, f.getName(), EnumSet.of(Path.Type.directory, Path.Type.volume), new PathAttributes().withVersionId(f.getId())); children.add(child); } listener.chunk(directory, children); page = list.getNextPageToken(); if(log.isDebugEnabled()) { log.debug(String.format("Continue with next page token %s", page)); } } while(page != null); return children; } catch(IOException e) { throw new DriveExceptionMappingService().map("Listing directory failed", e, directory); } }
if(marker.getItems().length == 1) { final BaseVersionOrDeleteMarker markerObject = marker.getItems()[0]; copy.attributes().withVersionId(markerObject.getVersionId()).setCustom(Collections.singletonMap(KEY_DELETE_MARKER, Boolean.TRUE.toString())); delete.delete(Collections.singletonList(source), connectionCallback, callback); copy = new S3ThresholdCopyFeature(session, accessControlListFeature).copy(source, renamed, status.length(source.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonList(new Path(source).withAttributes(new PathAttributes(source.attributes()).withVersionId(null))), connectionCallback, callback);
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { // Write header final Cryptor cryptor = vault.getCryptor(); final FileHeader header = cryptor.fileHeaderCryptor().create(); status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header)); status.setNonces(new RandomNonceGenerator()); final Path target = proxy.touch(vault.encrypt(session, file), status); final Path decrypt = vault.decrypt(session, target); decrypt.attributes().withVersionId(target.attributes().getVersionId()); return decrypt; }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { try { if(nodeid.isEncrypted(file)) { nodeid.setFileKey(status); } final StatusOutputStream<VersionId> out = writer.write(file, status, new DisabledConnectionCallback()); out.close(); return new Path(file.getParent(), file.getName(), file.getType(), new PathAttributes(file.attributes()).withVersionId(out.getStatus().id)); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create file {0}", e, file); } }
final Path renamed = new Path(destination, next.getName(), next.getType(), next.attributes().withVersionId(null)); files.put(next, renamed);
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final File copy = session.getClient().files().copy(fileid.getFileid(source, new DisabledListProgressListener()), new File() .setParents(Collections.singletonList(fileid.getFileid(target.getParent(), new DisabledListProgressListener()))) .setName(target.getName())) .setSupportsTeamDrives(PreferencesFactory.get().getBoolean("googledrive.teamdrive.enable")).execute(); return new Path(target.getParent(), target.getName(), target.getType(), new PathAttributes(target.attributes()).withVersionId(copy.getId())); } catch(IOException e) { throw new DriveExceptionMappingService().map("Cannot copy {0}", e, source); } }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { InputStream in; StatusOutputStream out; in = from.getFeature(Read.class).read(source, new TransferStatus(status), callback); Write write = to.getFeature(MultipartWrite.class); if(null == write) { // Fallback if multipart write is not available write = to.getFeature(Write.class); } out = write.write(target, status, callback); new StreamCopier(status, status).transfer(in, out); final Object reply = out.getStatus(); if(reply instanceof VersionId) { return new Path(target.getParent(), target.getName(), target.getType(), new PathAttributes(target.attributes()).withVersionId(((VersionId) reply).id)); } return target; }
@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 { // Identified by the special folder MIME type application/vnd.google-apps.folder 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); } }
new PathAttributes(renamed.attributes()).withVersionId(file.attributes().getVersionId()));