use of org.dataportabilityproject.types.transfer.auth.TokenAuthData in project data-transfer-project by google.
the class MicrosoftCalendarImportTest method setUp.
@Before
public void setUp() {
client = new OkHttpClient.Builder().build();
mapper = new ObjectMapper();
transformerService = new TransformerServiceImpl();
token = new TokenAuthData("token456");
server = new MockWebServer();
jobStore = new MockJobStore();
}
use of org.dataportabilityproject.types.transfer.auth.TokenAuthData in project data-transfer-project by google.
the class MicrosoftContactsImporter method importItem.
@Override
public ImportResult importItem(UUID jobId, TokenAuthData authData, ContactsModelWrapper wrapper) {
JCardReader reader = new JCardReader(wrapper.getVCards());
try {
List<VCard> cards = reader.readAll();
List<String> problems = new ArrayList<>();
int[] id = new int[] { 1 };
List<Map<String, Object>> requests = cards.stream().map(card -> {
TransformResult<LinkedHashMap> result = transformerService.transform(LinkedHashMap.class, card);
problems.addAll(result.getProblems());
LinkedHashMap contact = result.getTransformed();
Map<String, Object> request = createRequest(id[0], CONTACTS_URL, contact);
id[0]++;
return request;
}).collect(toList());
if (!problems.isEmpty()) {
// TODO log problems
}
return batchRequest(authData, requests, baseUrl, client, objectMapper).getResult();
} catch (IOException e) {
// TODO log
e.printStackTrace();
return new ImportResult(ImportResult.ResultType.ERROR, "Error deserializing contacts: " + e.getMessage());
}
}
Aggregations