@Test public void testFind() throws Exception { final Path test = new Path(DriveHomeFinderService.MYDRIVE_FOLDER, UUID.randomUUID().toString() + ".txt", EnumSet.of(Path.Type.file)); final DriveFileidProvider fileid = new DriveFileidProvider(session).withCache(cache); new DriveTouchFeature(session, fileid).touch(test, new TransferStatus()); final DriveAttributesFinderFeature f = new DriveAttributesFinderFeature(session, fileid); final PathAttributes attributes = f.find(test); assertEquals(0L, attributes.getSize()); assertNotNull(attributes.getVersionId()); new DriveDeleteFeature(session, fileid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
@Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(new PathContainerService().isContainer(file)) { return PathAttributes.EMPTY; } final Path query; if(file.getType().contains(Path.Type.placeholder)) { query = new Path(file.getParent(), FilenameUtils.removeExtension(file.getName()), file.getType(), file.attributes()); } else { query = file; } final AttributedList<Path> list = new FileidDriveListService(session, fileid, query).list(file.getParent(), new DisabledListProgressListener()); final Path found = list.find(new DriveFileidProvider.IgnoreTrashedPathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); }
DriveAttributesFinderFeature implements AttributesFinder { @Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(new PathContainerService().isContainer(file)) { return PathAttributes.EMPTY; } final Path query; if(file.getType().contains(Path.Type.placeholder)) { query = new Path(file.getParent(), FilenameUtils.removeExtension(file.getName()), file.getType(), file.attributes()); } else { query = file; } final AttributedList<Path> list = new FileidDriveListService(session, fileid, query).list(file.getParent(), new DisabledListProgressListener()); final Path found = list.find(new DriveFileidProvider.IgnoreTrashedPathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); } }
DriveAttributesFinderFeature implements AttributesFinder { @Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(new PathContainerService().isContainer(file)) { return PathAttributes.EMPTY; } final Path query; if(file.getType().contains(Path.Type.placeholder)) { query = new Path(file.getParent(), FilenameUtils.removeExtension(file.getName()), file.getType(), file.attributes()); } else { query = file; } final AttributedList<Path> list = new FileidDriveListService(session, fileid, query).list(file.getParent(), new DisabledListProgressListener()); final Path found = list.find(new DriveFileidProvider.IgnoreTrashedPathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); } DriveAttributesFinderFeature(final DriveSession session, final DriveFileidProvider fileid); }
DriveAttributesFinderFeature implements AttributesFinder { @Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(new PathContainerService().isContainer(file)) { return PathAttributes.EMPTY; } final Path query; if(file.getType().contains(Path.Type.placeholder)) { query = new Path(file.getParent(), FilenameUtils.removeExtension(file.getName()), file.getType(), file.attributes()); } else { query = file; } final AttributedList<Path> list = new FileidDriveListService(session, fileid, query).list(file.getParent(), new DisabledListProgressListener()); final Path found = list.find(new DriveFileidProvider.IgnoreTrashedPathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); } DriveAttributesFinderFeature(final DriveSession session, final DriveFileidProvider fileid); @Override PathAttributes find(final Path file); @Override AttributesFinder withCache(final Cache<Path> cache); }
DriveAttributesFinderFeature implements AttributesFinder { @Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(new PathContainerService().isContainer(file)) { return PathAttributes.EMPTY; } final Path query; if(file.getType().contains(Path.Type.placeholder)) { query = new Path(file.getParent(), FilenameUtils.removeExtension(file.getName()), file.getType(), file.attributes()); } else { query = file; } final AttributedList<Path> list = new FileidDriveListService(session, fileid, query).list(file.getParent(), new DisabledListProgressListener()); final Path found = list.find(new DriveFileidProvider.IgnoreTrashedPathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); } DriveAttributesFinderFeature(final DriveSession session, final DriveFileidProvider fileid); @Override PathAttributes find(final Path file); @Override AttributesFinder withCache(final Cache<Path> cache);  }