diff --git a/opensocial/shindig_orng_tables.sql b/opensocial/shindig_orng_tables.sql index fe6b3afd8..a94db1d67 100644 --- a/opensocial/shindig_orng_tables.sql +++ b/opensocial/shindig_orng_tables.sql @@ -54,7 +54,7 @@ CREATE TABLE IF NOT EXISTS `orng_app_registry` ( `appid` int(11) NOT NULL, `personId` varchar(255) NOT NULL, `createdDT` datetime NOT NULL, - PRIMARY KEY (`appid`) + PRIMARY KEY (`appid`, `personId` ) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -------------------------------------------------------- diff --git a/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java b/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java index f3f3fdded..c5447bf7c 100644 --- a/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java +++ b/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java @@ -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 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) { diff --git a/webapp/web/js/openSocial/orng.js b/webapp/web/js/openSocial/orng.js index 2e9166799..e85076fe0 100644 --- a/webapp/web/js/openSocial/orng.js +++ b/webapp/web/js/openSocial/orng.js @@ -72,8 +72,10 @@ gadgets.pubsubrouter.init(function(id) { else if (channel == 'added' && my.gadgets[moduleId].view == 'home') { if (message == 'Y') { _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( - { 'userId': gadgets.util.getUrlParameters()['Person'], + { 'userId': userId, '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' } }).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']); } else { + // find out whose page we are on, if any + var userId = gadgets.util.getUrlParameters()['uri'] || document.URL.replace('/display/', '/individual/'); osapi.activities.create( - { 'userId': gadgets.util.getUrlParameters()['Person'], + { 'userId': userId, 'appId': my.gadgets[this.id].appId, 'activity': {'postedTime': new Date().getTime(), 'title': 'gadget viewed', 'body': my.gadgets[this.id].name + ' gadget was viewed' } }).execute(function(response){});