APID has ability to handle multiple scopes.
diff --git a/apigee_sync.go b/apigee_sync.go index bbdc8b3..7091ad3 100644 --- a/apigee_sync.go +++ b/apigee_sync.go
@@ -232,7 +232,7 @@ /* Get the bearer token */ status := getBearerToken() if status == false { - return errors.New("Unable to get new token") + log.Fatal("Unable to get Bearer token or is Invalid") } snapshotUri, err := url.Parse(config.GetString(configSnapServerBaseURI)) if err != nil { @@ -250,7 +250,7 @@ v := url.Values{} for _, scope := range scopes { - v.Add("scopes", scope) + v.Add("scope", scope) } snapshotUri.RawQuery = v.Encode() uri := snapshotUri.String() @@ -275,7 +275,7 @@ /* * Check if there is some data already, if there is, - * Proceed, else exit the service (Scopes & snapshotInfo + * Proceed, else exit the service (apid_config & snapshotInfo * have to be present for changeserver to function) */ snapshotInfo = findSnapshotInfo(config.GetString(configScopeId)) @@ -293,10 +293,19 @@ var resp common.Snapshot err = json.NewDecoder(r.Body).Decode(&resp) if err != nil { - log.Fatalf("JSON Response Data not parsable: [%s] ", err) - return err - } + /* + *If the data set is empty, allow it to proceed, as changeserver + * will feed data. Since Bootstrapping has passed, it has the + * Bootstrap config id to function. + */ + if downloadBootSnapshot == false { + log.Fatal("JSON Response Data not parsable: ", err) + } else { + downloadSnapshot = true + return nil + } + } /* * The idea here is that you download snapshot for the scopes * associated with the apidconfig Id, and then download the
diff --git a/listener.go b/listener.go index 36be24d..cb6ae18 100644 --- a/listener.go +++ b/listener.go
@@ -67,8 +67,7 @@ for _, payload := range changes.Changes { switch payload.Table { - case "public.apid_config_scope": - case "edgex.apid_config_scope": + case "public.apid_config_scope", "edgex.apid_config_scope": switch payload.Operation { case 1: insertApidConfigScope(payload.NewRow, db)