@Test public void getRemoteFilesListListsAllChangelistAndResourcelistFilesInAnObject() throws Exception { String capabilityList = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<urlset xmlns:rs=\"http: "xmlns=\"http: " <rs:md capability=\"capabilitylist\"/>\n" + " <rs:ln rel=\"up\" href=\"http: " <rs:ln rel=\"describedby\" href=\"" + baseUrl + "description.xml\" type=\"application/rdf+xml\"/>\n" + " <url>\n" + " <loc>" + baseUrl + "resourcelist.xml</loc>\n" + " <rs:md capability=\"resourcelist\"/>\n" + " </url>\n" + " <url>\n" + " <loc>" + baseUrl + "changelist.xml</loc>\n" + " <rs:md capability=\"changelist\"/>\n" + " </url>" + "</urlset>\n"; String resourceList = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<urlset xmlns:rs=\"http: "xmlns=\"http: " <rs:md capability=\"resourcelist\" at=\"2018-03-21T10:55:07.907Z\" " + "completed=\"2018-03-21T10:56:39.551Z\"/>\n" + " <rs:ln rel=\"up\" href=\"" + baseUrl + "capabilitylist.xml\"/>\n" + " <url>\n" + " <loc>" + baseUrl + "files/dataset.nq</loc>\n" + " <rs:md type=\"application/n-quads\"/>\n" + " </url>\n" + "</urlset>\n"; String changeList = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<urlset xmlns=\"http: " xmlns:rs=\"http: " <rs:md capability=\"changelist\"\n" + " from=\"2013-01-02T00:00:00Z\"\n" + " until=\"2013-01-03T00:00:00Z\"/>\n" + " <url>\n" + " <loc>" + baseUrl + "files/dataset.nq</loc>\n" + " <lastmod>2013-01-02T13:00:00Z</lastmod>\n" + " <rs:md change=\"updated\" datetime=\"2013-01-02T13:00:00Z\"/>\n" + " <rs:ln rel=\"http: " type=\"application/vnd.timbuctoo-rdf.nquads_unified_diff\" />" + " </url>\n" + " <url>\n" + " <loc>" + baseUrl + "files/dataset.nq</loc>\n" + " <lastmod>2013-01-02T13:00:00Z</lastmod>\n" + " <rs:md change=\"updated\" datetime=\"2013-01-02T13:00:00Z\"/>\n" + " <rs:ln rel=\"http: " type=\"application/vnd.timbuctoo-rdf.nquads_unified_diff\" />" + " </url>\n" + "</urlset>"; InputStream capabilityListStream = new ByteArrayInputStream(capabilityList.getBytes()); InputStream resourceListStream = new ByteArrayInputStream(resourceList.getBytes()); InputStream changeListStream = new ByteArrayInputStream(changeList.getBytes()); ResourceSyncFileLoader.RemoteFileRetriever remoteFileRetriever = mock( ResourceSyncFileLoader.RemoteFileRetriever.class ); given(remoteFileRetriever.getFile(baseUrl + "capabilitylist.xml", null)).willReturn(capabilityListStream); given(remoteFileRetriever.getFile(baseUrl + "resourcelist.xml", null)).willReturn(resourceListStream); given(remoteFileRetriever.getFile(baseUrl + "changelist.xml", null) ).willReturn(changeListStream); ResourceSyncFileLoader resourceSyncFileLoader = new ResourceSyncFileLoader(remoteFileRetriever); ResourceSyncFileLoader.RemoteFilesList remoteFilesList = resourceSyncFileLoader.getRemoteFilesList( baseUrl + "capabilitylist.xml", null); assertThat(remoteFilesList.getChangeList(), containsInAnyOrder( hasProperty("url", is(baseUrl + "files/changes1.nqud")), hasProperty("url", is(baseUrl + "files/changes2.nqud")) )); assertThat(remoteFilesList.getResourceList(), contains(allOf( hasProperty("url", is(baseUrl + "files/dataset.nq")), hasProperty("mimeType", is("application/n-quads")) ))); }
public RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString) throws IOException, CantRetrieveFileException { List<UrlItem> capabilityList = getRsFile(capabilityListUri, authString).getItemList(); List<RemoteFile> changes = new ArrayList<>(); List<RemoteFile> resources = new ArrayList<>(); for (UrlItem capabilityListItem : capabilityList) { if (capabilityListItem.getMetadata().getCapability().equals(Capability.CHANGELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); String changeListExtension = ".*.nqud"; for (UrlItem changeListItem : rsFile.getItemList()) { RsLn changeLink = changeListItem.getLink(); if (changeLink != null) { if ((changeLink.getType().isPresent() && changeLink.getType().get().equals(MIME_TYPE_FOR_EXTENSION.get("nqud"))) || changeLink.getHref().matches(changeListExtension)) { Metadata changeMd = new Metadata(); changeMd.setMimeType(changeLink.getType().get()); changeMd.setDateTime(changeListItem.getMetadata().getDateTime()); RemoteFile remoteFile = getRemoteFile(new Tuple<>(changeLink.getHref(), changeMd), authString); changes.add(remoteFile); } } } } else if (capabilityListItem.getMetadata().getCapability().equals(Capability.RESOURCELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); for (UrlItem resourceListItem : rsFile.getItemList()) { if (MIME_TYPE_FOR_EXTENSION.values().contains(resourceListItem.getMetadata().getMimeType()) || SupportedRdfResourceListExtensions.createFromFile(resourceListItem.getLoc()) != null) { resources.add(getRemoteFile(new Tuple<>(resourceListItem.getLoc(), resourceListItem.getMetadata()), authString)); } } } } return new RemoteFilesList(changes, resources); }
ResourceSyncFileLoader { public RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString) throws IOException, CantRetrieveFileException { List<UrlItem> capabilityList = getRsFile(capabilityListUri, authString).getItemList(); List<RemoteFile> changes = new ArrayList<>(); List<RemoteFile> resources = new ArrayList<>(); for (UrlItem capabilityListItem : capabilityList) { if (capabilityListItem.getMetadata().getCapability().equals(Capability.CHANGELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); String changeListExtension = ".*.nqud"; for (UrlItem changeListItem : rsFile.getItemList()) { RsLn changeLink = changeListItem.getLink(); if (changeLink != null) { if ((changeLink.getType().isPresent() && changeLink.getType().get().equals(MIME_TYPE_FOR_EXTENSION.get("nqud"))) || changeLink.getHref().matches(changeListExtension)) { Metadata changeMd = new Metadata(); changeMd.setMimeType(changeLink.getType().get()); changeMd.setDateTime(changeListItem.getMetadata().getDateTime()); RemoteFile remoteFile = getRemoteFile(new Tuple<>(changeLink.getHref(), changeMd), authString); changes.add(remoteFile); } } } } else if (capabilityListItem.getMetadata().getCapability().equals(Capability.RESOURCELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); for (UrlItem resourceListItem : rsFile.getItemList()) { if (MIME_TYPE_FOR_EXTENSION.values().contains(resourceListItem.getMetadata().getMimeType()) || SupportedRdfResourceListExtensions.createFromFile(resourceListItem.getLoc()) != null) { resources.add(getRemoteFile(new Tuple<>(resourceListItem.getLoc(), resourceListItem.getMetadata()), authString)); } } } } return new RemoteFilesList(changes, resources); } }
ResourceSyncFileLoader { public RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString) throws IOException, CantRetrieveFileException { List<UrlItem> capabilityList = getRsFile(capabilityListUri, authString).getItemList(); List<RemoteFile> changes = new ArrayList<>(); List<RemoteFile> resources = new ArrayList<>(); for (UrlItem capabilityListItem : capabilityList) { if (capabilityListItem.getMetadata().getCapability().equals(Capability.CHANGELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); String changeListExtension = ".*.nqud"; for (UrlItem changeListItem : rsFile.getItemList()) { RsLn changeLink = changeListItem.getLink(); if (changeLink != null) { if ((changeLink.getType().isPresent() && changeLink.getType().get().equals(MIME_TYPE_FOR_EXTENSION.get("nqud"))) || changeLink.getHref().matches(changeListExtension)) { Metadata changeMd = new Metadata(); changeMd.setMimeType(changeLink.getType().get()); changeMd.setDateTime(changeListItem.getMetadata().getDateTime()); RemoteFile remoteFile = getRemoteFile(new Tuple<>(changeLink.getHref(), changeMd), authString); changes.add(remoteFile); } } } } else if (capabilityListItem.getMetadata().getCapability().equals(Capability.RESOURCELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); for (UrlItem resourceListItem : rsFile.getItemList()) { if (MIME_TYPE_FOR_EXTENSION.values().contains(resourceListItem.getMetadata().getMimeType()) || SupportedRdfResourceListExtensions.createFromFile(resourceListItem.getLoc()) != null) { resources.add(getRemoteFile(new Tuple<>(resourceListItem.getLoc(), resourceListItem.getMetadata()), authString)); } } } } return new RemoteFilesList(changes, resources); } ResourceSyncFileLoader(CloseableHttpClient httpClient);  ResourceSyncFileLoader(RemoteFileRetriever remoteFileRetriever); }
ResourceSyncFileLoader { public RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString) throws IOException, CantRetrieveFileException { List<UrlItem> capabilityList = getRsFile(capabilityListUri, authString).getItemList(); List<RemoteFile> changes = new ArrayList<>(); List<RemoteFile> resources = new ArrayList<>(); for (UrlItem capabilityListItem : capabilityList) { if (capabilityListItem.getMetadata().getCapability().equals(Capability.CHANGELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); String changeListExtension = ".*.nqud"; for (UrlItem changeListItem : rsFile.getItemList()) { RsLn changeLink = changeListItem.getLink(); if (changeLink != null) { if ((changeLink.getType().isPresent() && changeLink.getType().get().equals(MIME_TYPE_FOR_EXTENSION.get("nqud"))) || changeLink.getHref().matches(changeListExtension)) { Metadata changeMd = new Metadata(); changeMd.setMimeType(changeLink.getType().get()); changeMd.setDateTime(changeListItem.getMetadata().getDateTime()); RemoteFile remoteFile = getRemoteFile(new Tuple<>(changeLink.getHref(), changeMd), authString); changes.add(remoteFile); } } } } else if (capabilityListItem.getMetadata().getCapability().equals(Capability.RESOURCELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); for (UrlItem resourceListItem : rsFile.getItemList()) { if (MIME_TYPE_FOR_EXTENSION.values().contains(resourceListItem.getMetadata().getMimeType()) || SupportedRdfResourceListExtensions.createFromFile(resourceListItem.getLoc()) != null) { resources.add(getRemoteFile(new Tuple<>(resourceListItem.getLoc(), resourceListItem.getMetadata()), authString)); } } } } return new RemoteFilesList(changes, resources); } ResourceSyncFileLoader(CloseableHttpClient httpClient);  ResourceSyncFileLoader(RemoteFileRetriever remoteFileRetriever); static InputStream maybeDecompress(InputStream input); RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString); }
ResourceSyncFileLoader { public RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString) throws IOException, CantRetrieveFileException { List<UrlItem> capabilityList = getRsFile(capabilityListUri, authString).getItemList(); List<RemoteFile> changes = new ArrayList<>(); List<RemoteFile> resources = new ArrayList<>(); for (UrlItem capabilityListItem : capabilityList) { if (capabilityListItem.getMetadata().getCapability().equals(Capability.CHANGELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); String changeListExtension = ".*.nqud"; for (UrlItem changeListItem : rsFile.getItemList()) { RsLn changeLink = changeListItem.getLink(); if (changeLink != null) { if ((changeLink.getType().isPresent() && changeLink.getType().get().equals(MIME_TYPE_FOR_EXTENSION.get("nqud"))) || changeLink.getHref().matches(changeListExtension)) { Metadata changeMd = new Metadata(); changeMd.setMimeType(changeLink.getType().get()); changeMd.setDateTime(changeListItem.getMetadata().getDateTime()); RemoteFile remoteFile = getRemoteFile(new Tuple<>(changeLink.getHref(), changeMd), authString); changes.add(remoteFile); } } } } else if (capabilityListItem.getMetadata().getCapability().equals(Capability.RESOURCELIST.getXmlValue())) { UrlSet rsFile = getRsFile(capabilityListItem.getLoc(), authString); for (UrlItem resourceListItem : rsFile.getItemList()) { if (MIME_TYPE_FOR_EXTENSION.values().contains(resourceListItem.getMetadata().getMimeType()) || SupportedRdfResourceListExtensions.createFromFile(resourceListItem.getLoc()) != null) { resources.add(getRemoteFile(new Tuple<>(resourceListItem.getLoc(), resourceListItem.getMetadata()), authString)); } } } } return new RemoteFilesList(changes, resources); } ResourceSyncFileLoader(CloseableHttpClient httpClient);  ResourceSyncFileLoader(RemoteFileRetriever remoteFileRetriever); static InputStream maybeDecompress(InputStream input); RemoteFilesList getRemoteFilesList(String capabilityListUri, String authString);  }