@Test public void testOperate() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); assertFalse(new SwiftAccountLoader(session).operate(new DisabledLoginCallback(), container).isEmpty()); }
@Override protected Map<Region, AccountInfo> operate(final PasswordCallback callback, final Path file) throws BackgroundException { try { final Map<Region, AccountInfo> accounts = new ConcurrentHashMap<>(); for(Region region : session.getClient().getRegions()) { final AccountInfo info = session.getClient().getAccountInfo(region); if(log.isInfoEnabled()) { log.info(String.format("Signing key is %s", info.getTempUrlKey())); } if(StringUtils.isBlank(info.getTempUrlKey())) { try { final String key = new AsciiRandomStringService().random(); if(log.isDebugEnabled()) { log.debug(String.format("Set acccount temp URL key to %s", key)); } session.getClient().updateAccountMetadata(region, Collections.singletonMap("X-Account-Meta-Temp-URL-Key", key)); info.setTempUrlKey(key); } catch(GenericException e) { log.warn(String.format("Ignore failure %s updating account metadata", e)); } } accounts.put(region, info); } return accounts; } catch(GenericException e) { throw new SwiftExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
SwiftAccountLoader extends OneTimeSchedulerFeature<Map<Region, AccountInfo>> { @Override protected Map<Region, AccountInfo> operate(final PasswordCallback callback, final Path file) throws BackgroundException { try { final Map<Region, AccountInfo> accounts = new ConcurrentHashMap<>(); for(Region region : session.getClient().getRegions()) { final AccountInfo info = session.getClient().getAccountInfo(region); if(log.isInfoEnabled()) { log.info(String.format("Signing key is %s", info.getTempUrlKey())); } if(StringUtils.isBlank(info.getTempUrlKey())) { try { final String key = new AsciiRandomStringService().random(); if(log.isDebugEnabled()) { log.debug(String.format("Set acccount temp URL key to %s", key)); } session.getClient().updateAccountMetadata(region, Collections.singletonMap("X-Account-Meta-Temp-URL-Key", key)); info.setTempUrlKey(key); } catch(GenericException e) { log.warn(String.format("Ignore failure %s updating account metadata", e)); } } accounts.put(region, info); } return accounts; } catch(GenericException e) { throw new SwiftExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
SwiftAccountLoader extends OneTimeSchedulerFeature<Map<Region, AccountInfo>> { @Override protected Map<Region, AccountInfo> operate(final PasswordCallback callback, final Path file) throws BackgroundException { try { final Map<Region, AccountInfo> accounts = new ConcurrentHashMap<>(); for(Region region : session.getClient().getRegions()) { final AccountInfo info = session.getClient().getAccountInfo(region); if(log.isInfoEnabled()) { log.info(String.format("Signing key is %s", info.getTempUrlKey())); } if(StringUtils.isBlank(info.getTempUrlKey())) { try { final String key = new AsciiRandomStringService().random(); if(log.isDebugEnabled()) { log.debug(String.format("Set acccount temp URL key to %s", key)); } session.getClient().updateAccountMetadata(region, Collections.singletonMap("X-Account-Meta-Temp-URL-Key", key)); info.setTempUrlKey(key); } catch(GenericException e) { log.warn(String.format("Ignore failure %s updating account metadata", e)); } } accounts.put(region, info); } return accounts; } catch(GenericException e) { throw new SwiftExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SwiftAccountLoader(final SwiftSession session); }
SwiftAccountLoader extends OneTimeSchedulerFeature<Map<Region, AccountInfo>> { @Override protected Map<Region, AccountInfo> operate(final PasswordCallback callback, final Path file) throws BackgroundException { try { final Map<Region, AccountInfo> accounts = new ConcurrentHashMap<>(); for(Region region : session.getClient().getRegions()) { final AccountInfo info = session.getClient().getAccountInfo(region); if(log.isInfoEnabled()) { log.info(String.format("Signing key is %s", info.getTempUrlKey())); } if(StringUtils.isBlank(info.getTempUrlKey())) { try { final String key = new AsciiRandomStringService().random(); if(log.isDebugEnabled()) { log.debug(String.format("Set acccount temp URL key to %s", key)); } session.getClient().updateAccountMetadata(region, Collections.singletonMap("X-Account-Meta-Temp-URL-Key", key)); info.setTempUrlKey(key); } catch(GenericException e) { log.warn(String.format("Ignore failure %s updating account metadata", e)); } } accounts.put(region, info); } return accounts; } catch(GenericException e) { throw new SwiftExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SwiftAccountLoader(final SwiftSession session);  }
SwiftAccountLoader extends OneTimeSchedulerFeature<Map<Region, AccountInfo>> { @Override protected Map<Region, AccountInfo> operate(final PasswordCallback callback, final Path file) throws BackgroundException { try { final Map<Region, AccountInfo> accounts = new ConcurrentHashMap<>(); for(Region region : session.getClient().getRegions()) { final AccountInfo info = session.getClient().getAccountInfo(region); if(log.isInfoEnabled()) { log.info(String.format("Signing key is %s", info.getTempUrlKey())); } if(StringUtils.isBlank(info.getTempUrlKey())) { try { final String key = new AsciiRandomStringService().random(); if(log.isDebugEnabled()) { log.debug(String.format("Set acccount temp URL key to %s", key)); } session.getClient().updateAccountMetadata(region, Collections.singletonMap("X-Account-Meta-Temp-URL-Key", key)); info.setTempUrlKey(key); } catch(GenericException e) { log.warn(String.format("Ignore failure %s updating account metadata", e)); } } accounts.put(region, info); } return accounts; } catch(GenericException e) { throw new SwiftExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } SwiftAccountLoader(final SwiftSession session);   }