@Test public void testGetRepository() throws Exception { final Host host = new Host(new DAVSSLProtocol(), "svn.cyberduck.ch", new Credentials( PreferencesFactory.get().getProperty("connection.login.anon.name"), null )); final DAVSession session = new DAVSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); final Quota.Space quota = new DAVQuotaFeature(session).get(); assertNotNull(quota); assertEquals(Long.MAX_VALUE, quota.available, 0L); assertEquals(0L, quota.used, 0L); }
@Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE ); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, home); } catch(NumberFormatException e) { throw new DefaultExceptionMappingService().map(e); } }
DAVQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE ); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, home); } catch(NumberFormatException e) { throw new DefaultExceptionMappingService().map(e); } } }
DAVQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE ); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, home); } catch(NumberFormatException e) { throw new DefaultExceptionMappingService().map(e); } } DAVQuotaFeature(final DAVSession session); }
DAVQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE ); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, home); } catch(NumberFormatException e) { throw new DefaultExceptionMappingService().map(e); } } DAVQuotaFeature(final DAVSession session); @Override Space get(); }
DAVQuotaFeature implements Quota { @Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE ); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, home); } catch(NumberFormatException e) { throw new DefaultExceptionMappingService().map(e); } } DAVQuotaFeature(final DAVSession session); @Override Space get();  }