// Stores dsocial group // Returns: // dsocialGroup : the group, modified to include items like Id and LastModified/Created // err : error or nil func (p *InMemoryDataStore) StoreDsocialGroup(dsocialUserId, dsocialGroupId string, group *dm.Group) (dsocialGroup *dm.Group, err os.Error) { if dsocialGroupId == "" { dsocialGroupId = p.GenerateId(dsocialUserId, "group") fmt.Printf("[DS]: Generated Id for storing dsocial group: %v\n", dsocialGroupId) group.Id = dsocialGroupId } else { fmt.Printf("[DS]: Using existing group id: %v\n", dsocialGroupId) } //k := strings.Join([]string{dsocialUserId, dsocialGroupId}, "/") g := new(dm.Group) *g = *group p.store(dsocialUserId, _INMEMORY_GROUP_COLLECTION_NAME, dsocialGroupId, g) dsocialGroup = group return }
func AddIdsForDsocialGroup(g *dm.Group, ds DataStoreService, dsocialUserId string) (err os.Error) { if g == nil { return } if g.UserId == "" { g.UserId = dsocialUserId } if g.Acl.OwnerId == "" { g.Acl.OwnerId = dsocialUserId } if g.Id == "" { g.Id = ds.GenerateId(dsocialUserId, "group") } return }
// Stores dsocial group // Returns: // dsocialGroup : the group, modified to include items like Id and LastModified/Created // err : error or nil func (p *InMemoryDataStore) StoreDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId string, group *dm.Group) (dsocialGroup *dm.Group, err os.Error) { //k := strings.Join([]string{dsocialUserId, externalServiceId, externalUserId, externalGroupId}, "/") k := strings.Join([]string{externalServiceId, externalUserId, externalGroupId}, "|") if externalServiceId == "" || externalUserId == "" || externalGroupId == "" { panic(fmt.Sprintf("One of the following three strings are empty: externalServiceId: %s, externalUserId: %s, externalGroupId: %s\n", externalServiceId, externalUserId, externalGroupId)) } else if strings.Contains(externalServiceId, "|") || strings.Contains(externalUserId, "|") || strings.Contains(externalGroupId, "|") { panic(fmt.Sprintf("One of the following three strings contain pipe character: externalServiceId: %s, externalUserId: %s, externalGroupId: %s\n", externalServiceId, externalUserId, externalGroupId)) } extid := dsocialUserId + "/" + k bc.AddIdsForDsocialGroup(group, p, dsocialUserId) g := new(dm.Group) *g = *group g.Id = extid fmt.Printf("[DS]: Storing %s with id %v for %s\n", _INMEMORY_GROUP_FOR_EXTERNAL_GROUP_COLLECTION_NAME, extid, g.Name) p.store(dsocialUserId, _INMEMORY_GROUP_FOR_EXTERNAL_GROUP_COLLECTION_NAME, extid, g) dsocialGroup = group return }