use of org.opendatakit.briefcase.reused.http.RequestBuilder in project briefcase by opendatakit.
the class PullFromAggregate method getFormAttachments.
List<AggregateAttachment> getFormAttachments(FormStatus form, RunnerStatus runnerStatus, PullFromAggregateTracker tracker) {
if (runnerStatus.isCancelled()) {
tracker.trackCancellation("Get form attachments");
return emptyList();
}
if (!form.getManifestUrl().filter(RequestBuilder::isUri).isPresent())
return emptyList();
tracker.trackStartGettingFormManifest();
URL manifestUrl = form.getManifestUrl().map(RequestBuilder::url).get();
Request<List<AggregateAttachment>> request = get(manifestUrl).asXmlElement().withResponseMapper(PullFromAggregate::parseMediaFiles).build();
Response<List<AggregateAttachment>> response = http.execute(request);
if (!response.isSuccess()) {
tracker.trackErrorGettingFormManifest(response);
return Collections.emptyList();
}
List<AggregateAttachment> attachments = response.get();
List<AggregateAttachment> attachmentsToDownload = attachments.stream().filter(mediaFile -> mediaFile.needsUpdate(form.getFormMediaDir(briefcaseDir))).collect(toList());
tracker.trackEndGettingFormManifest();
tracker.trackIgnoredFormAttachments(attachmentsToDownload.size(), attachments.size());
return attachmentsToDownload;
}
Aggregations