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

@ -54,7 +54,7 @@ CREATE TABLE IF NOT EXISTS `orng_app_registry` (
`appid` int(11) NOT NULL, `appid` int(11) NOT NULL,
`personId` varchar(255) NOT NULL, `personId` varchar(255) NOT NULL,
`createdDT` datetime NOT NULL, `createdDT` datetime NOT NULL,
PRIMARY KEY (`appid`) PRIMARY KEY (`appid`, `personId` )
) ENGINE=MyISAM DEFAULT CHARSET=latin1; ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- -------------------------------------------------------- -- --------------------------------------------------------

View file

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

View file

@ -72,8 +72,10 @@ gadgets.pubsubrouter.init(function(id) {
else if (channel == 'added' && my.gadgets[moduleId].view == 'home') { else if (channel == 'added' && my.gadgets[moduleId].view == 'home') {
if (message == 'Y') { if (message == 'Y') {
_gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'SHOW', 'profile_edit_view']); _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'SHOW', 'profile_edit_view']);
// find out whose page we are on, if any
var userId = gadgets.util.getUrlParameters()['uri'] || document.URL.replace('/display/', '/individual/');
osapi.activities.create( osapi.activities.create(
{ 'userId': gadgets.util.getUrlParameters()['Person'], { 'userId': userId,
'appId': my.gadgets[moduleId].appId, 'appId': my.gadgets[moduleId].appId,
'activity': {'postedTime': new Date().getTime(), 'title': 'added a gadget', 'body': 'added the ' + my.gadgets[moduleId].name + ' gadget to their profile' } 'activity': {'postedTime': new Date().getTime(), 'title': 'added a gadget', 'body': 'added the ' + my.gadgets[moduleId].name + ' gadget to their profile' }
}).execute(function(response){}); }).execute(function(response){});
@ -389,8 +391,10 @@ OrngGadget.prototype.handleToggle = function() {
_gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN_IN_EDIT', 'profile_edit_view']); _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN_IN_EDIT', 'profile_edit_view']);
} }
else { else {
// find out whose page we are on, if any
var userId = gadgets.util.getUrlParameters()['uri'] || document.URL.replace('/display/', '/individual/');
osapi.activities.create( osapi.activities.create(
{ 'userId': gadgets.util.getUrlParameters()['Person'], { 'userId': userId,
'appId': my.gadgets[this.id].appId, 'appId': my.gadgets[this.id].appId,
'activity': {'postedTime': new Date().getTime(), 'title': 'gadget viewed', 'body': my.gadgets[this.id].name + ' gadget was viewed' } 'activity': {'postedTime': new Date().getTime(), 'title': 'gadget viewed', 'body': my.gadgets[this.id].name + ' gadget was viewed' }
}).execute(function(response){}); }).execute(function(response){});