Google App Engine RPC Service - google-app-engine

I've created an application using Google Web Toolkit and Google App Engine that saves objects based on user selections into a RPC Service Implementation.
It was my understanding that everytime GWT "creates" this service, the data is reinstantiated with the default values. Unfortunately it seems like when a user on one computer saves a change to the data, another user on another computer is seeing the data change on their end. Im not using a datastore or anything so why is this happening?
EDIT: After some research I am seeing that I need to use sessions to handle the delivery of the objects. However, in my RemoteServiceServlet I am calling this.getThreadLocalRequest and it's returning null. Why does this.getThreadLocalRequest() return null??
UPDATE: Answering my own questions here : ) You cannot getThreadLocalRequest() in the constructor of your Servlet. duh.

The problem was that I was calling getThreadLocalRequest() in the constructor of my servlet. Good thing to be aware of - the local request doesnt happen until the servlet is loaded.

Related

GAE Cloud Endpoints custom API public api key issues

I've exposed a few APIs using go-endpoints. The APIs work fine, but what I'd like to do is restrict usage of the APIs to only a few referers. Since I'm not passing any authentication information, I do not need OAuth (actually, I really do not want to use OAuth as I expect anonymous users to utilize a front-end that uses this API... I just want that front-end and perhaps another one to use my API).
Apparently the way to do this is to make a Public API Key using the Google Developers Console (Project --> APIs and auth --> Credentials --> Create new Key).
I've changed my JavaScript to use this key, by passing it as a param: https://my-app-id.appspot.com/_ah/api/myService/v1/doSomething?key=key_from_developer_console
However, when I make the call, I get a 403 back with this error:
"Access Not Configured. The API () is not enabled for your project. Please use the Google Developers Console to update your configuration."
Well, initially I set the referer to my-app-id.appspot.com/*, which is only place I want my API to be used from. So I figured I'd remove it just to see, but I get the same issue.
There are some old posts here about having to enable Contacts API and Google + API. I tried that, and it didn't work either.
So what gives? There is virtually no documentation from Google on this Public API Key feature. This is really driving me up a wall...
I had this exact same problem yesterday. I decided to generate my own key and added in my own logic to check for the 'key' param from the request. I just added the self-generated key to my env_variables and it works. However, if you try to redeploy after taking this approach, you may still see the access configuration issues..at least I have still.

appengine.google.com & objectify - working ok locally but not on gae?

I am developing a backend using Android Studio and Java.
I use objectify to manipulate entities in Google's Datastore.
The question is the following: everything works ok locally. I can call any of the endpoint and add, update and delete entities. However, anything to do with the same entities do not seem to work on GAE... Is there anything specific required for this to work?
Logs are fairly limited also but it appears all endpoints register properly.
The only thing meaningful out of the GAE and logs section is for return calls being set to 200 but nothing more....
Thoughts? Thanks.
I was looking at the google public issue tracker and saw your code posted there (I am also editing your answer to add said code). I can't help but notice that in your "test.html", you load the function from "localhost:8080". This will obviously break your code whenever you're using it on a client's machine, because it will try to load the function from HIS localhost, which won't have your function in it.
When you're running your code on your production server, you would need to use something like "your-end-point.your-application.appspot.com" to get your function.
Also, I think that you can ONLY pass around either JSON or "JavaBeans" object. And it seems the "Test" you are passing isn't a JavaBeans (it has a constructor with at least a parameter).
The fact it never loads the function properly could also explain why your Logs don't show.

What is a proper way to initialize data store for static data in Google App Engine?

I have a model called "Category" in my app in GAE.
This model simply contains a name and it's parent category, and this won't be changed frequently after the website go online.
I'd like to know what is a better way to put these model instances in the beginning?
I now only know to execute (category.put()) in a webapp.RequestHandler by issuing a http request. But I suspect there is a proper way to do this.
Thanks!
You can use the remote API to connect to your datastore in a shell and add data as required.
Or, if it's a huge amount, you could think about using the bulk loader - but I suspect that the remote API will be more suitable.

Any way to get the pending_ms value for the current (or a specific) request from App Engine?

I'd like to know, in a particular request, what the pending_ms value is (assuming it exists for the given request).
I know that the App Engine logs include this value, but I'm hoping to find it elsewhere for use in gae_mini_profiler.
I've searched around the App Engine source, but no luck -- this is being added elsewhere in the GAE pipeline.
There's not currently any way to access this programmatically, either from within the request or outside it. Please do file a feature request for it, though.

Calling Function on a different client SIlverlight

I have one very weird question.
There are 2 Silverlight Client
1. Admin
2. User
Now, I want a scenario wherein the Admin Silverlight can initiate a function call on the User Silverlight.
Pretty much a newbie with SL so wonder if that would be possible.
I'd appreciate any help.
Thanks
I suppose the applications are not in the same browser / machine, and when you describe the usage pattern as admin and user, I take that there are probably more users than admins.
You might want to take a look at duplex bindings for WCF services - this is a web service binding that allows pushing notifications to clients from the server. When all clients establish such a channel, you can implement hub-and-spoke communication between clients.
This blog post gives a good receipt for getting started:
http://silverlightforbusiness.net/2009/06/23/pushing-data-from-the-server-to-silverlight-3-using-a-duplex-wcf-service/
If they are both in the same frame/browser, you could call JavaScript in the first using the HtmlPage API, which could interact with the second.
So:
Silverlight control -> injects JS into HtmlPage -> JS interacts with Silverlight control 2 (assuming this is possible, please correct me if wrong) -> Silverlight control responds.
If they are in separate windows or running "out of browser", I would expect it wouldn't work.
If the 2 instances are seperated (i.e., the admin is on one machine and the user is on another) there's no direct way to do it. However, you can rig it up with a publisher/subscriber style system.
Assumption: You have some sort of shared data store between the two, maybe a database or something.
Idea: You have the admin client write a request to this shared data store; an entry in a table, or a new file in a network share, or something. You have the user client app regularly scan this table/share for new entries, say every .5 seconds or so. When it sees the entry, it executes the requested operation, storing any return values back to the shared store. When the admin sees the return value, he knows the operation has been successfully executed.
There are a couple of options that I can think of.
You could implement some sort of remote procedure call via web services whereby one Silverlight app posts a request to call the method, and the other Silverlight regularly checks for method call requests.
If hosted on the same HTML page in a browser, you could use javascript to allow the two controls to interact.
However, direct communication between two Silverlight instances isn't supported, and while the suggestions may help to achieve something close to what you want, they don't provide a complete solution that will work in all scenarios.

Resources