Documentation for the Google Cloud MBS states that access to stored Entities can be controlled via prefixing the KindName of that entity with strings "[public]" or "[private]" (or nothing).
https://cloud.google.com/developers/articles/mobile-backend-starter-api-reference#acfce
However attempting insertion of CloudEntities into the Datastore using KindNames that start with [public] or [private] causes an exception/error, specifically that the KindName is invalid.
This is the case both for the Backend running in Open and in Secured mode (using Google login credentials to derive the _owner field)
e.g. here I use KindName "[public]TestDB" which fails, whereas "TestDB" would not throw any exception.
04-22 19:57:54.132: E/AndroidRuntime(4690): Process: com.example.package, PID: 4690
04-22 19:57:54.132: E/AndroidRuntime(4690): java.lang.IllegalArgumentException: Illegal kind name: [public]TestDB
04-22 19:57:54.132: E/AndroidRuntime(4690): at com.google.cloud.backend.core.CloudEntity.(CloudEntity.java:86)
04-22 19:57:54.132: E/AndroidRuntime(4690): at com.example.package.CloudUtil.convertUpdatesToCEList(CloudUtil.java:252)
04-22 19:57:54.132: E/AndroidRuntime(4690): at com.example.package.CloudUtil.checkSync(CloudUtil.java:199)
The relevant section of code editted/compressed for brevity is:
CloudBackendMessaging cbm=_cloudfrag.getCloudBackend();
List<CloudEntity> entries=new ArrayList<CloudEntity>();
while (...) {
CloudEntity ce=new CloudEntity(_CLOUD_DB_KIND);
ce.put("fieldname", devID);
entries.add(ce);
}
_countActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
cbm.updateAll(entries, handler);
}
});
Where handler is the callback and _cloudfrag is the CloudBackendFragment from the sample code.
I get the same effect using both inserts and updates, for single or multiple i.e. lists of entities at a time.
I can only think I'm misunderstanding the documentation - but it seems fairly explicit that KindNames can begin with [public] [private] etc?
Judging by the bug reports on github from others experiencing the same issue, this is a bug in Google's MBS library.
Unfortunately the response to this has been silence for months until tonight the devs posted a single commit updating the readme file to indicate this library is no longer supported and is not an official google product (despite it being pushed as a starter kit with every cloud project started from the console!).
https://github.com/GoogleCloudPlatform/solutions-mobile-backend-starter-android-client/pull/16
Looking at the source I think this access modifier feature was never actually implemented despite documentation to the contrary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With