2010-07-21

Testing vCard Operations

vCard data is an essential component of groupware / collaboration operations;  from sending an electric business card as a e-mail attachment, to synchronizing your mobile device or desktop PIM - vCard is everywhere.  But a vCard is a complicated structure and there is an enormous variation in the details (and quality) of the various implementations.  Some applications will keep fields they don't recognize while others will discard them.  Some applications will drop attributes of fields and/or add their own - and of course expect whatever the server is to keep track of them.  This means that being able to debug exactly what happens to a vCard is a critical system administration task.  To facilitate this OpenGroupware Coils provides two command line utilities:
  • coils-get-vcard
  • coils-parse-vcard
Both are quite straight-forward.  coils-get-vcard simply produces the vCard for a specified Contact;  this is the same vCard that will be sent to any client requesting that Contact as a vCard via HTTP.
$ coils-get-vcard --objectid=10100
BEGIN:VCARD
VERSION:3.0
UID:coils://Contact/10100
ADR;X-COILS-ADDRESS-TYPE=location;TYPE=other:;Bang the dums Incorporated;9999 Mo
 nroe Ave NW;Grand Rapids;MI;49505;USA
ADR;X-COILS-ADDRESS-TYPE=mailing;TYPE=work,pref:;Bang the dums Incorporated;9999
  Monroe Ave NW;Grand Rapids;MI;49505;USA
....
The coils-parse-vcard performs the opposite action - it accepts a vCard file and produces the Omphalos representation of the attributes derived from the vCard.  This reveals how OpenGroupware Coils will respond to a vCard that is PUT from a client.

$ coils-parse-vcard --file=10100-2.vcf
{'_ADDRESSES': [{'city': u'Grand Rapids',
                 'country': u'USA',
                 'name1': u'Bang The Drums Incorporated',
                 'postalCode': u'49599',
                 'state': u'MI',
                 'street': u'9999 Monroe Ave NW',
                 'type': u'location'},
                {'city': u'Grand Rapids',
...

Optionally the --update option to coils-parse-vcard will cause the utility [using an administrative context] to create or update the related Contact in the OpenGroupware Coils instance.  So coils-parse-vcard can double both as a debugging tool and a data import tool.

No comments:

Post a Comment