@Test public void testToUrl() throws Exception { final DropboxTemporaryUrlProvider provider = new DropboxTemporaryUrlProvider(session); final Path file = new Path(new DropboxHomeFinderFeature(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new DropboxTouchFeature(session).touch(file, new TransferStatus()); assertNotNull(provider.toDownloadUrl(file, null, new DisabledPasswordCallback()).getUrl()); new DropboxDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException { try { if(log.isDebugEnabled()) { log.debug(String.format("Create temporary link for %s", file)); } final String link = new DbxUserFilesRequests(session.getClient(file)).getTemporaryLink(containerService.getKey(file)).getLink(); final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiry.add(Calendar.HOUR, 4); return new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())) ); } catch(DbxException e) { throw new DropboxExceptionMappingService().map(e); } }
DropboxTemporaryUrlProvider implements PromptUrlProvider<Void, Void> { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException { try { if(log.isDebugEnabled()) { log.debug(String.format("Create temporary link for %s", file)); } final String link = new DbxUserFilesRequests(session.getClient(file)).getTemporaryLink(containerService.getKey(file)).getLink(); final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiry.add(Calendar.HOUR, 4); return new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())) ); } catch(DbxException e) { throw new DropboxExceptionMappingService().map(e); } } }
DropboxTemporaryUrlProvider implements PromptUrlProvider<Void, Void> { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException { try { if(log.isDebugEnabled()) { log.debug(String.format("Create temporary link for %s", file)); } final String link = new DbxUserFilesRequests(session.getClient(file)).getTemporaryLink(containerService.getKey(file)).getLink(); final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiry.add(Calendar.HOUR, 4); return new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())) ); } catch(DbxException e) { throw new DropboxExceptionMappingService().map(e); } } DropboxTemporaryUrlProvider(final DropboxSession session); }
DropboxTemporaryUrlProvider implements PromptUrlProvider<Void, Void> { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException { try { if(log.isDebugEnabled()) { log.debug(String.format("Create temporary link for %s", file)); } final String link = new DbxUserFilesRequests(session.getClient(file)).getTemporaryLink(containerService.getKey(file)).getLink(); final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiry.add(Calendar.HOUR, 4); return new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())) ); } catch(DbxException e) { throw new DropboxExceptionMappingService().map(e); } } DropboxTemporaryUrlProvider(final DropboxSession session); @Override DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback); @Override DescriptiveUrl toUploadUrl(final Path file, final Void options, final PasswordCallback callback); @Override boolean isSupported(final Path file, final Type type); }
DropboxTemporaryUrlProvider implements PromptUrlProvider<Void, Void> { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback) throws BackgroundException { try { if(log.isDebugEnabled()) { log.debug(String.format("Create temporary link for %s", file)); } final String link = new DbxUserFilesRequests(session.getClient(file)).getTemporaryLink(containerService.getKey(file)).getLink(); final Calendar expiry = Calendar.getInstance(TimeZone.getTimeZone("UTC")); expiry.add(Calendar.HOUR, 4); return new DescriptiveUrl(URI.create(link), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Temporary", "S3")) + " (" + MessageFormat.format(LocaleFactory.localizedString("Expires {0}", "S3") + ")", UserDateFormatterFactory.get().getMediumFormat(expiry.getTimeInMillis())) ); } catch(DbxException e) { throw new DropboxExceptionMappingService().map(e); } } DropboxTemporaryUrlProvider(final DropboxSession session); @Override DescriptiveUrl toDownloadUrl(final Path file, final Void options, final PasswordCallback callback); @Override DescriptiveUrl toUploadUrl(final Path file, final Void options, final PasswordCallback callback); @Override boolean isSupported(final Path file, final Type type);  }