// SetData sets data by pathes
SetData sets data by pathes
// SetData sets data by pathes
func (adapter *usersAdapter) SetData(data map[string]interface{}) (err error) {
	for path, value := range data {
		if path == adapter.config.VISPath {
			users, ok := value.([]interface{})
			if !ok {
				return fmt.Errorf("wrong value type for path %s", path)
			}
			adapter.users = []string{}
			for _, user := range users {
				userStr, ok := user.(string)
				if !ok {
					return fmt.Errorf("wrong element type for path %s", path)
				}
				adapter.users = append(adapter.users, userStr)
			}
			log.WithField("users", adapter.users).Debug("Set Users")
			if adapter.subscribed {
				adapter.subscribeChannel <- map[string]interface{}{path: users}
			}
			if err = adapter.writeUsers(); err != nil {
				return err
			}
		} else {
			return fmt.Errorf("path %s doesn't exits", path)
		}
	}
	return nil
}
func ( adapter * usersAdapter ) SetData ( data map [ string ] interface { } ) ( err error ) { for path , value := range data { if path == adapter . config . VISPath { users , ok := value . ( [ ] interface { } ) if ! ok { return fmt . Errorf ( " " , path ) } adapter . users = [ ] string { } for _ , user := range users { userStr , ok := user . ( string ) if ! ok { return fmt . Errorf ( " " , path ) } adapter . users = append ( adapter . users , userStr ) } log . WithField ( " " , adapter . users ) . Debug ( " " ) if adapter . subscribed { adapter . subscribeChannel <- map [ string ] interface { } { path : users } } if err = adapter . writeUsers ( ) ; err != nil { return err } } else { return fmt . Errorf ( " " , path ) } } return nil }
SetData sets data by pathes
SetData sets data by pathes