Tuesday, October 11, 2011

Google Apps Integration and App Engine's namespaces

I have integrated our GAE app with Google Apps Marketplace. I set the namespace strategy to GOOGLE_APPS_DOMAIN so that each Google Apps domain will have it's own isolated dataset.

When I enter the app from the app's login page by entering Google App's email id and password, everything works fine. Namespace is being set to the domain name. However, when I enter the app from Google Apps universal navigation link, Namespace is being set to blank instead of the domain name. After a quick troubleshooting session, I found that NamespaceManager.getGoogleAppsNamespace(). method is not returning the domain name when the app is accessed from the universal navigation bar.

After some delving into App Engine's API source code, I came up with a workaround that I can use until I find the root cause of why the original approach didn't work.


case GOOGLE_APPS_DOMAIN: {

/*
* Original code. Commented out because getGoogleAppsNamespace
* not returning the apps domain name. Unable to find out the
* reason
*/

// NamespaceManager.set(NamespaceManager.getGoogleAppsNamespace());



if (NamespaceManager.getGoogleAppsNamespace().equals("")) {

Object userOrganizationObject;
String userOrganization;

userOrganizationObject = com.google.apphosting.api.ApiProxy
.getCurrentEnvironment()
.getAttributes()
.get("com.google.appengine.api.users.UserService.user_organization");

if (userOrganizationObject == null) {
userOrganization = "";
} else {
userOrganization = userOrganizationObject.toString();
}

NamespaceManager.set(userOrganization);

} else {

NamespaceManager.set(NamespaceManager
.getGoogleAppsNamespace());
}

break;
}


No comments:

Post a Comment