use of ezvcard.io.json.JCardWriter in project data-transfer-project by google.
the class GoogleContactsExporter method makeVCardString.
@VisibleForTesting
static String makeVCardString(List<VCard> vCardList) throws IOException {
StringWriter stringWriter = new StringWriter();
JCardWriter jCardWriter = new JCardWriter(stringWriter);
for (VCard vCardProperties : vCardList) {
// needs to be loop so error can be thrown
jCardWriter.write(vCardProperties);
}
jCardWriter.flush();
return stringWriter.toString();
}
use of ezvcard.io.json.JCardWriter in project data-transfer-project by google.
the class LocalImportTestRunner method createCards.
private static String createCards() throws IOException {
StringWriter stringWriter = new StringWriter();
JCardWriter writer = new JCardWriter(stringWriter);
VCard card1 = new VCard();
StructuredName structuredName1 = new StructuredName();
structuredName1.setGiven("Test Given Data1");
structuredName1.setFamily("Test Surname Data1");
card1.setStructuredName(structuredName1);
VCard card2 = new VCard();
StructuredName structuredName2 = new StructuredName();
structuredName2.setGiven("Test Given Data2");
structuredName2.setFamily("Test Surname Data2");
card2.setStructuredName(structuredName2);
writer.write(card1);
writer.write(card2);
writer.close();
return stringWriter.toString();
}
use of ezvcard.io.json.JCardWriter in project data-transfer-project by google.
the class MicrosoftContactsExporter method transform.
private ContactsModelWrapper transform(List<Map<String, Object>> rawContacts) {
StringWriter stringWriter = new StringWriter();
try (JCardWriter writer = new JCardWriter(stringWriter)) {
for (Map<String, Object> rawContact : rawContacts) {
TransformResult<VCard> result = transformerService.transform(VCard.class, rawContact);
if (result.hasProblems()) {
// FIXME log problem
continue;
}
writer.write(result.getTransformed());
}
} catch (IOException e) {
// TODO log
e.printStackTrace();
return new ContactsModelWrapper("");
}
return new ContactsModelWrapper(stringWriter.toString());
}
Aggregations