@Test public void toUrl() throws Exception { final Path file = new Path(new OneDriveHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new GraphTouchFeature(session).touch(file, new TransferStatus().withMime("x-application/cyberduck")); assertNotEquals(DescriptiveUrl.EMPTY, new OneDriveSharingLinkUrlProvider(session).toDownloadUrl(file, null, new DisabledPasswordCallback())); new GraphDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback) throws BackgroundException { try { final OneDriveItem item = session.toItem(file); if(null == item) { throw new NotfoundException(file.getAbsolute()); } if(log.isDebugEnabled()) { log.debug(String.format("Create shared link for %s", file)); } return new DescriptiveUrl(URI.create(item.createSharedLink(OneDriveSharingLink.Type.VIEW).getLink().getWebUrl()), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
OneDriveSharingLinkUrlProvider implements PromptUrlProvider { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback) throws BackgroundException { try { final OneDriveItem item = session.toItem(file); if(null == item) { throw new NotfoundException(file.getAbsolute()); } if(log.isDebugEnabled()) { log.debug(String.format("Create shared link for %s", file)); } return new DescriptiveUrl(URI.create(item.createSharedLink(OneDriveSharingLink.Type.VIEW).getLink().getWebUrl()), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
OneDriveSharingLinkUrlProvider implements PromptUrlProvider { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback) throws BackgroundException { try { final OneDriveItem item = session.toItem(file); if(null == item) { throw new NotfoundException(file.getAbsolute()); } if(log.isDebugEnabled()) { log.debug(String.format("Create shared link for %s", file)); } return new DescriptiveUrl(URI.create(item.createSharedLink(OneDriveSharingLink.Type.VIEW).getLink().getWebUrl()), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } OneDriveSharingLinkUrlProvider(final OneDriveSession session); }
OneDriveSharingLinkUrlProvider implements PromptUrlProvider { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback) throws BackgroundException { try { final OneDriveItem item = session.toItem(file); if(null == item) { throw new NotfoundException(file.getAbsolute()); } if(log.isDebugEnabled()) { log.debug(String.format("Create shared link for %s", file)); } return new DescriptiveUrl(URI.create(item.createSharedLink(OneDriveSharingLink.Type.VIEW).getLink().getWebUrl()), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } OneDriveSharingLinkUrlProvider(final OneDriveSession session); @Override boolean isSupported(final Path file, final Type type); @Override DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback); @Override DescriptiveUrl toUploadUrl(final Path file, final Object o, final PasswordCallback callback); }
OneDriveSharingLinkUrlProvider implements PromptUrlProvider { @Override public DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback) throws BackgroundException { try { final OneDriveItem item = session.toItem(file); if(null == item) { throw new NotfoundException(file.getAbsolute()); } if(log.isDebugEnabled()) { log.debug(String.format("Create shared link for %s", file)); } return new DescriptiveUrl(URI.create(item.createSharedLink(OneDriveSharingLink.Type.VIEW).getLink().getWebUrl()), DescriptiveUrl.Type.signed, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Pre-Signed", "S3"))); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } OneDriveSharingLinkUrlProvider(final OneDriveSession session); @Override boolean isSupported(final Path file, final Type type); @Override DescriptiveUrl toDownloadUrl(final Path file, final Object o, final PasswordCallback callback); @Override DescriptiveUrl toUploadUrl(final Path file, final Object o, final PasswordCallback callback);  }