private String addUris(DataSource dataSource, Collection<String> uris) throws IOException { String xml = toXml(dataSource, uris, type); log.info(format("Adding URIs:%n%s", xml)); String dataSourcesUrl = getDataSourcesUrl(); Post request = new Post(dataSourcesUrl, getCredentials()); request.addFile("file", xml.getBytes(StandardCharsets.UTF_8)); request.setAccept(APPLICATION_JSON); request.setSocketTimeout(SOCKET_TIMEOUT); String result = null; try { result = request.executeAsString(); log.info(format("Added URIs with result:%n%s", result)); addCount += uris.size(); } catch(Exception e) { log.severe(format("Cannot add URIs: %s", e)); } return result; }
private String updateUris(DatasourceType dataSourceType) throws IOException { String xml = toXml(dataSourceType); log.info(format("Updating URIs:%n%s", xml)); String dataSourcesUrl = getDataSourcesUrl(); Post request = new Post(dataSourcesUrl, getCredentials()); request.addFile("file", xml.getBytes(StandardCharsets.UTF_8)); request.setAccept(APPLICATION_JSON); request.setSocketTimeout(SOCKET_TIMEOUT); String result = null; try { result = request.executeAsString(); log.info(format("Updated URIs with result:%n%s", result)); updateCount += getDownloadableCount(dataSourceType); } catch(Exception e) { log.severe(format("Cannot update URIs: %s", e)); } return result; }