use of org.datatransferproject.transfer.solid.SolidUtilities in project data-transfer-project by google.
the class SolidContactsImport method importItem.
@Override
public ImportResult importItem(UUID jobId, IdempotentImportExecutor idempotentExecutor, CookiesAndUrlAuthData authData, ContactsModelWrapper data) throws Exception {
checkState(authData.getCookies().size() == 1, "Exactly 1 cookie expected: %s", authData.getCookies());
SolidUtilities solidUtilities = new SolidUtilities(authData.getCookies().get(0));
String url = authData.getUrl();
List<VCard> vcards = Ezvcard.parse(data.getVCards()).all();
createContent(idempotentExecutor, url, vcards, solidUtilities);
return ImportResult.OK;
}
use of org.datatransferproject.transfer.solid.SolidUtilities in project data-transfer-project by google.
the class SolidContactsExport method export.
@Override
public ExportResult<ContactsModelWrapper> export(UUID jobId, CookiesAndUrlAuthData authData, Optional<ExportInformation> exportInformation) throws Exception {
if (exportInformation.isPresent()) {
throw new IllegalStateException("Currently solid doesn't support paged exports");
}
checkState(authData.getCookies().size() == 1, "Exactly 1 cookie expected: %s", authData.getCookies());
SolidUtilities solidUtilities = new SolidUtilities(authData.getCookies().get(0));
String url = authData.getUrl();
List<List<VCard>> vCards = explore(url, solidUtilities);
// TODO: This flattens all the address books together, which isn't perfect.
List<VCard> allCards = new ArrayList<>();
vCards.forEach(allCards::addAll);
return new ExportResult<>(ResultType.END, new ContactsModelWrapper(Ezvcard.write(allCards).go()));
}
Aggregations