Merge from 1.5 branch: NIHVIVO-3954 Add OpenSocial bug fixes from Eric Meeks: make compound key in app_registry table, show sandbox login, ensure that randomly assigned Gadget ID is not negative, modify JS to find out whose page we are on.

This commit is contained in:
j2blake 2012-09-07 15:41:57 +00:00
parent 07b73bbc22
commit 0a72583712
3 changed files with 14 additions and 4 deletions

View file

@ -16,6 +16,8 @@ import java.util.List;
import java.util.Map;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.json.JSONObject;
@ -42,6 +44,8 @@ public class OpenSocialManager {
public static final String TAG_NAME = "openSocial";
private static final String DEFAULT_DRIVER = "com.mysql.jdbc.Driver";
private static final Log log = LogFactory.getLog(OpenSocialManager.class);
// for performance
private static Map<String, GadgetSpec> gadgetCache;
@ -445,6 +449,7 @@ public class OpenSocialManager {
.getAttribute(OPENSOCIAL_GADGETS);
String[] urls = openSocialGadgetURLS.split(System.getProperty("line.separator"));
for (String openSocialGadgetURL : urls) {
openSocialGadgetURL = openSocialGadgetURL.trim();
if (openSocialGadgetURL.length() == 0)
continue;
int appId = 0; // if URL matches one in the DB, use DB provided
@ -459,7 +464,8 @@ public class OpenSocialManager {
channels = allDBGadgets.get(gadgetFileName).getChannels();
unknownGadget = false;
} else {
appId = openSocialGadgetURL.hashCode();
log.warn("Could not find " + gadgetFileName + " in " + allDBGadgets.keySet());
appId = Math.abs(openSocialGadgetURL.hashCode());
}
// if they asked for a specific one, only let it in
if (requestAppId != null && Integer.parseInt(requestAppId) != appId) {