Last active
March 7, 2016 14:09
-
-
Save rominirani/9004217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApiMethod(name = "insertQuote", scopes = {Constants.EMAIL_SCOPE}, | |
clientIds = {Constants.WEB_CLIENT_ID, | |
Constants.ANDROID_CLIENT_ID, | |
com.google.api.server.spi.Constant.API_EXPLORER_CLIENT_ID}, | |
audiences = {Constants.ANDROID_AUDIENCE}) | |
public Quote insertQuote(Quote quote, User user) throws UnauthorizedException { | |
if (user == null) throw new UnauthorizedException("User is Not Valid"); | |
PersistenceManager mgr = getPersistenceManager(); | |
try { | |
if (quote.getId() != null) { | |
if (containsQuote(quote)) { | |
throw new EntityExistsException("Object already exists"); | |
} | |
} | |
mgr.makePersistent(quote); | |
} finally { | |
mgr.close(); | |
} | |
return quote; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exception handling from google has been updated to OAuthRequestException as mentioned here sir .
Although your technique is much more friendly .
https://cloud.google.com/appengine/docs/java/endpoints/auth
Thanks for the amazing write up its been really helpful.