@Override public boolean isSupported(final Path file, final Type type) { return file.isFile(); }
public SimplePathPredicate(final Path file) { this.file = file; this.type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory; this.path = file.getAbsolute(); }
@Override protected int compareFirst(final Path p1, final Path p2) { if((p1.isDirectory() && p2.isDirectory()) || p1.isFile() && p2.isFile()) { if(ascending) { return impl.compare(descriptor.getKind(p1), descriptor.getKind(p2)); } return -impl.compare(descriptor.getKind(p1), descriptor.getKind(p2)); } if(p1.isFile()) { return ascending ? 1 : -1; } return ascending ? -1 : 1; } }
public CaseInsensitivePathPredicate(final Path file) { this.type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory; this.path = StringUtils.lowerCase(file.getAbsolute()); }
@Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { if(file.isFile() || file.isPlaceholder()) { try { return new S3AttributesFinderFeature(session).find(file).getMetadata(); } catch(NotfoundException e) { if(file.isPlaceholder()) { // No placeholder file may exist but we just have a common prefix return Collections.emptyMap(); } throw e; } } return Collections.emptyMap(); }
@Override public void visit(final AttributedList<Path> list, final int index, final Path p) { if(p.isFile()) { if(p.attributes().isDuplicate()) { if(p.attributes().getRevision() == 1) { final Map<String, String> custom = new HashMap<>(p.attributes().getCustom()); custom.put(SpectraVersioningFeature.KEY_REVERTABLE, Boolean.TRUE.toString()); p.attributes().setCustom(custom); } } } } });
/** * @param selected File * @return True if the selected path is editable (not a directory and no known binary file) */ public boolean isEditable(final Path selected) { if(this.isMounted()) { if(pool.getHost().getCredentials().isAnonymousLogin()) { return false; } return selected.isFile(); } return false; }
@Override public String getKind(final Path file) { if(file.isFile()) { return this.getKind(file.getName()); } if(file.isDirectory()) { return LocaleFactory.localizedString("Folder"); } return LocaleFactory.localizedString("Unknown"); }
private void updateQuickLookSelection(final List<Path> selected) { final List<TransferItem> downloads = new ArrayList<TransferItem>(); for(Path file : selected) { if(!file.isFile()) { continue; } downloads.add(new TransferItem(file, TemporaryFileServiceFactory.get().create(pool.getHost().getUuid(), file))); } if(downloads.size() > 0) { final Transfer download = new DownloadTransfer(pool.getHost(), downloads); final TransferOptions options = new TransferOptions(); this.background(new QuicklookTransferBackgroundAction(this, quicklook, pool, download, options, downloads)); } }
public DefaultPathPredicate(final Path file) { final Path.Type type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory; String qualifier = StringUtils.EMPTY; if(StringUtils.isNotBlank(file.attributes().getRegion())) { if(new PathContainerService().isContainer(file)) { qualifier += file.attributes().getRegion(); } } if(file.isFile()) { if(StringUtils.isNotBlank(file.attributes().getVersionId())) { qualifier += file.attributes().getVersionId(); } } final String path = file.getAbsolute(); reference = "[" + type + "]" + "-" + qualifier + path; }
/** * This creates an URL that uses Cookie-based Authentication. The ACLs for the given Google user account * has to be setup first. * <p> * Google Storage lets you provide browser-based authenticated downloads to users who do not have * Google Storage accounts. To do this, you apply Google account-based ACLs to the object and then * you provide users with a URL that is scoped to the object. */ @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DefaultUrlProvider(session.getHost()).toUrl(file); if(file.isFile()) { // Authenticated browser download using cookie-based Google account authentication in conjunction with ACL list.add(new DescriptiveUrl(URI.create(String.format("https://storage.cloud.google.com%s", URIEncoder.encode(file.getAbsolute()))), DescriptiveUrl.Type.authenticated, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Authenticated")))); } return list; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } } return list; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { if(file.isVolume()) { return DescriptiveUrlBag.empty(); } final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { final String download = String.format("%s/file/%s/%s", session.getClient().getDownloadUrl(), URIEncoder.encode(containerService.getContainer(file).getName()), URIEncoder.encode(containerService.getKey(file))); list.add(new DescriptiveUrl(URI.create(download), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), Scheme.https.name().toUpperCase(Locale.ROOT)))); } return list; } }
/** * @param file File or bucket * @return Encryption algorithm used for file or null if not encrypted. For buckets, return setting in preferences if any. */ @Override public Algorithm getEncryption(final Path file) throws BackgroundException { if(file.isFile() || file.isPlaceholder()) { try { return new S3AttributesFinderFeature(session).find(file).getEncryption(); } catch(NotfoundException e) { if(file.isPlaceholder()) { // No placeholder file may exist but we just have a common prefix return Algorithm.NONE; } throw e; } } return Algorithm.NONE; }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(file.isFile()) { try { Files.createFile(session.toPath(file)); } catch(FileAlreadyExistsException e) { // } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create file {0}", e, file); } } return new Path(file.getParent(), file.getName(), file.getType(), new LocalAttributesFinderFeature(session).find(file)); }
@Override public PathAttributes find(final Path file) throws BackgroundException { final PathAttributes attributes = new PathAttributes(delegate.withCache(new CryptoPathCache(cache)).find(vault.encrypt(session, file))); if(file.isFile()) { attributes.setSize(vault.toCleartextSize(attributes.getSize())); } return attributes; }
@Action public void insideButtonClicked(final ID sender) { final Path selected = this.getSelectedPath(); //first row selected if(null == selected) { return; } if(selected.isDirectory()) { this.setWorkdir(selected); } else if(selected.isFile() || this.getSelectionCount() > 1) { if(preferences.getBoolean("browser.doubleclick.edit")) { this.editButtonClicked(null); } else { this.downloadButtonClicked(null); } } }
@Override public TransferStatus prepare(final Path file, final Local local, final TransferStatus parent, final ProgressListener progress) throws BackgroundException { final TransferStatus status = super.prepare(file, local, parent, progress); if(file.isFile()) { if(parent.isExists()) { final Write.Append append = upload.append(file, status.getLength(), cache); if(append.append && append.size < local.attributes().getSize()) { // Append to existing file status.setAppend(true); status.setLength(status.getLength() - append.size); status.setOffset(append.size); // Disable use of temporary target when resuming upload status.rename((Path) null); } } } return status; } }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); if(file.isFile()) { list.add(this.createSignedUrl(file, 60 * 60)); // Default signed URL expiring in 24 hours. list.add(this.createSignedUrl(file, PreferencesFactory.get().getInteger("s3.url.expire.seconds"))); // Week list.add(this.createSignedUrl(file, 7 * 24 * 60 * 60)); // Month list.add(this.createSignedUrl(file, 7 * 24 * 60 * 60 * 4)); } return list; }