@Test public void testGetMetadataFile() 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 Map<String, String> metadata = new DAVMetadataFeature(session).getMetadata(new Path("/trunk/README.md", EnumSet.of(Path.Type.file))); assertFalse(metadata.isEmpty()); assertTrue(metadata.containsKey("repository-uuid")); assertEquals("9e2dff1d-8f06-0410-b5b1-4d70b6340adc", metadata.get("repository-uuid")); session.close(); }
@Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final List<DavResource> resources = session.getClient().list(new DAVPathEncoder().encode(file), 0); for(DavResource resource : resources) { return resource.getCustomProps(); } return Collections.emptyMap(); } catch(SardineException e) { try { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(InteroperabilityException | NotfoundException i) { log.warn(String.format("Failure to obtain attributes of %s. %s", file, i)); return Collections.emptyMap(); } } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } }
DAVMetadataFeature implements Headers { @Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final List<DavResource> resources = session.getClient().list(new DAVPathEncoder().encode(file), 0); for(DavResource resource : resources) { return resource.getCustomProps(); } return Collections.emptyMap(); } catch(SardineException e) { try { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(InteroperabilityException | NotfoundException i) { log.warn(String.format("Failure to obtain attributes of %s. %s", file, i)); return Collections.emptyMap(); } } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } }
DAVMetadataFeature implements Headers { @Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final List<DavResource> resources = session.getClient().list(new DAVPathEncoder().encode(file), 0); for(DavResource resource : resources) { return resource.getCustomProps(); } return Collections.emptyMap(); } catch(SardineException e) { try { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(InteroperabilityException | NotfoundException i) { log.warn(String.format("Failure to obtain attributes of %s. %s", file, i)); return Collections.emptyMap(); } } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } DAVMetadataFeature(final DAVSession session); }
DAVMetadataFeature implements Headers { @Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final List<DavResource> resources = session.getClient().list(new DAVPathEncoder().encode(file), 0); for(DavResource resource : resources) { return resource.getCustomProps(); } return Collections.emptyMap(); } catch(SardineException e) { try { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(InteroperabilityException | NotfoundException i) { log.warn(String.format("Failure to obtain attributes of %s. %s", file, i)); return Collections.emptyMap(); } } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } DAVMetadataFeature(final DAVSession session); @Override Map<String, String> getDefault(final Local local); @Override Map<String, String> getMetadata(final Path file); @Override void setMetadata(final Path file, final TransferStatus status); }
DAVMetadataFeature implements Headers { @Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { final List<DavResource> resources = session.getClient().list(new DAVPathEncoder().encode(file), 0); for(DavResource resource : resources) { return resource.getCustomProps(); } return Collections.emptyMap(); } catch(SardineException e) { try { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(InteroperabilityException | NotfoundException i) { log.warn(String.format("Failure to obtain attributes of %s. %s", file, i)); return Collections.emptyMap(); } } catch(IOException e) { throw new HttpExceptionMappingService().map(e, file); } } DAVMetadataFeature(final DAVSession session); @Override Map<String, String> getDefault(final Local local); @Override Map<String, String> getMetadata(final Path file); @Override void setMetadata(final Path file, final TransferStatus status);  }