// Stores dsocial contact
// Returns:
//   dsocialContact : the contact, modified to include items like Id and LastModified/Created
//   err : error or nil
func (p *InMemoryDataStore) StoreDsocialContact(dsocialUserId, dsocialContactId string, contact *dm.Contact) (dsocialContact *dm.Contact, err os.Error) {
	if dsocialContactId == "" {
		dsocialContactId = p.GenerateId(dsocialUserId, "contact")
		fmt.Printf("[DS]: Generated Id for storing dsocial contact: %v\n", dsocialContactId)
		contact.Id = dsocialContactId
	} else {
		fmt.Printf("[DS]: Using existing contact id: %v\n", dsocialContactId)
	}
	bc.AddIdsForDsocialContact(contact, p, dsocialUserId)
	//k := strings.Join([]string{dsocialUserId, dsocialContactId}, "/")
	c := new(dm.Contact)
	*c = *contact
	p.store(dsocialUserId, _INMEMORY_CONTACT_COLLECTION_NAME, dsocialContactId, c)
	dsocialContact = contact
	return
}
// Stores dsocial contact
// Returns:
//   dsocialContact : the contact, modified to include items like Id and LastModified/Created
//   err : error or nil
func (p *InMemoryDataStore) StoreDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId string, contact *dm.Contact) (dsocialContact *dm.Contact, err os.Error) {
	//k := strings.Join([]string{dsocialUserId, externalServiceId, externalUserId, externalContactId}, "/")
	k := strings.Join([]string{externalServiceId, externalUserId, externalContactId}, "|")
	if externalServiceId == "" || externalUserId == "" || externalContactId == "" {
		panic(fmt.Sprintf("One of the following three strings are empty: externalServiceId: %s, externalUserId: %s, externalContactId: %s\n", externalServiceId, externalUserId, externalContactId))
	} else if strings.Contains(externalServiceId, "|") || strings.Contains(externalUserId, "|") || strings.Contains(externalContactId, "|") {
		panic(fmt.Sprintf("One of the following three strings contain pipe character: externalServiceId: %s, externalUserId: %s, externalContactId: %s\n", externalServiceId, externalUserId, externalContactId))
	}
	extid := dsocialUserId + "/" + k
	bc.AddIdsForDsocialContact(contact, p, dsocialUserId)
	c := new(dm.Contact)
	*c = *contact
	c.Id = extid
	p.store(dsocialUserId, _INMEMORY_CONTACT_FOR_EXTERNAL_CONTACT_COLLECTION_NAME, extid, c)
	dsocialContact = contact
	return
}