use of net.fortuna.ical4j.vcard.VCard in project stanbol by apache.
the class VcardIndexingSource method main.
public static void main(String[] args) throws Exception {
VcardIndexingSource instance = new VcardIndexingSource();
instance.prefix = "http://test.org/";
VCardBuilder parser = new VCardBuilder(new InputStreamReader(new FileInputStream(new File(args[0])), "utf8"));
Map<EntityType, Map<String, Set<String>>> entityMap = new EnumMap<EntityType, Map<String, Set<String>>>(EntityType.class);
entityMap.put(EntityType.organization, new HashMap<String, Set<String>>());
entityMap.put(EntityType.person, new HashMap<String, Set<String>>());
for (VCard vcard : parser.buildAll()) {
instance.processVcard(vcard, OntologyMappings.schemaOrgMappings, entityMap);
}
}
use of net.fortuna.ical4j.vcard.VCard in project bw-calendar-engine by Bedework.
the class DumpEntity method dump.
/**
* Dump the entire entity into the given file.
*
* @param f - the file
* @throws CalFacadeException
*/
@NoWrap
public void dump(final File f) throws CalFacadeException {
Dump dCl = getClass().getAnnotation(Dump.class);
if (dCl.format() == DumpFormat.xml) {
Writer wtr = null;
try {
XmlEmit xml = new XmlEmit();
wtr = new FileWriter(f);
xml.startEmit(wtr);
dump(xml, DumpType.def, false);
xml.flush();
return;
} catch (CalFacadeException cfe) {
throw cfe;
} catch (Throwable t) {
throw new CalFacadeException(t);
} finally {
if (wtr != null) {
try {
wtr.close();
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
}
}
if (dCl.format() == DumpFormat.vCard) {
Writer wtr = null;
try {
VCard vc = new VCard();
dump(vc, DumpType.def);
String vcStr = vc.toString();
wtr = new FileWriter(f);
wtr.append(vcStr);
return;
} catch (CalFacadeException cfe) {
throw cfe;
} catch (Throwable t) {
throw new CalFacadeException(t);
} finally {
if (wtr != null) {
try {
wtr.close();
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
}
}
throw new CalFacadeException("Unsupported dump format " + dCl.format());
}
use of net.fortuna.ical4j.vcard.VCard in project bw-calendar-engine by Bedework.
the class AbstractDirImpl method find.
@Override
public List<BwPrincipalInfo> find(final String cua, final String cutype, final boolean expand, final Holder<Boolean> truncated) throws CalFacadeException {
final CardDavInfo cdi = getCardDavInfo(false);
if ((cdi == null) || (cdi.getHost() == null)) {
return null;
}
BasicHttpClient cdc = null;
try {
cdc = new BasicHttpClient(cdi.getHost(), cdi.getPort(), null, 15 * 1000);
final List<BwPrincipalInfo> pis = find(cdc, cdi, cua, cutype);
if (!expand) {
return pis;
}
for (final BwPrincipalInfo pi : pis) {
if (!Kind.GROUP.getValue().equalsIgnoreCase(pi.getKind())) {
continue;
}
final List<BwPrincipalInfo> memberPis = new ArrayList<>();
VCard card = pi.getCard();
List<Property> members = card.getProperties(Id.MEMBER);
if (members == null) {
continue;
}
for (final Property p : members) {
BwPrincipalInfo memberPi = fetch(cdc, cdi, p.getValue());
if (memberPi != null) {
memberPis.add(memberPi);
}
}
pi.setMembers(memberPis);
}
return pis;
} catch (final Throwable t) {
if (getLogger().isDebugEnabled()) {
error(t);
}
throw new CalFacadeException(t);
} finally {
if (cdc != null) {
try {
cdc.release();
} catch (final Throwable ignored) {
}
}
}
}
Aggregations