diff --git a/opensocial/build_orng.xml b/opensocial/build_orng.xml
index 477bd9245..de883712c 100644
--- a/opensocial/build_orng.xml
+++ b/opensocial/build_orng.xml
@@ -89,25 +89,13 @@ deploy - Configure the application and deploy directly into the Tomcat webapps
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
+
+
+
@@ -118,6 +106,9 @@ deploy - Configure the application and deploy directly into the Tomcat webapps
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -188,10 +140,9 @@ deploy - Configure the application and deploy directly into the Tomcat webapps
-
-
+
-
+
diff --git a/opensocial/shindig_example_gadgets.sql b/opensocial/shindig_example_gadgets.sql
index 55e838315..4ff6aac51 100644
--- a/opensocial/shindig_example_gadgets.sql
+++ b/opensocial/shindig_example_gadgets.sql
@@ -1,17 +1,19 @@
-
-- Add some gadgets to play with ------------------------
--
-INSERT INTO `shindig_apps` (`appid`, `name`, `url`, `PersonFilterID`, `enabled`, `channels`) VALUES
-(100, 'Google Search', 'http://dev-profiles.ucsf.edu/apps/GoogleSearch.xml', NULL, 1, NULL),
-(101, 'Featured Presentations', 'http://dev-profiles.ucsf.edu/apps/SlideShare.xml', NULL, 1, NULL),
-(102, 'Faculty Mentor', 'http://dev-profiles.ucsf.edu/apps/Mentor.xml', NULL, 1, NULL),
-(103, 'Websites', 'http://dev-profiles.ucsf.edu/apps/Links.xml', NULL, 1, NULL),
-(104, 'Profile List', 'http://dev-profiles.ucsf.edu/apps/ProfileListTool.xml', NULL, 1, 'JSONPersonIds'),
-(105, 'Publication Export', 'http://dev-profiles.ucsf.edu/apps/PubExportTool.xml', NULL, 1, 'JSONPubMedIds'),
-(106, 'RDF Test Gadget', 'http://dev-profiles.ucsf.edu/gadgets/RDFTest.xml', NULL, 1, NULL);
+DELETE FROM `orng_apps`;
-INSERT INTO `shindig_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `view`, `closed_width`, `open_width`, `start_closed`, `chromeId`, `display_order`) VALUES
+INSERT INTO `orng_apps` (`appid`, `name`, `url`, `PersonFilterID`, `enabled`, `channels`) VALUES
+(100, 'Google Search', 'http://dev-profiles.ucsf.edu/orng/GoogleSearch.xml', NULL, 1, NULL),
+(101, 'Featured Presentations', 'http://dev-profiles.ucsf.edu/orng/SlideShare.xml', NULL, 1, NULL),
+(102, 'Faculty Mentor', 'http://dev-profiles.ucsf.edu/orng/Mentor.xml', NULL, 1, NULL),
+(103, 'Websites', 'http://dev-profiles.ucsf.edu/orng/Links.xml', NULL, 1, NULL),
+(104, 'Profile List', 'http://dev-profiles.ucsf.edu/orng/ProfileListTool.xml', NULL, 1, 'JSONPersonIds'),
+(106, 'RDF Test Gadget', 'http://dev-profiles.ucsf.edu/orng/RDFTest.xml', NULL, 0, NULL);
+
+DELETE FROM `orng_app_views`;
+
+INSERT INTO `orng_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `view`, `closed_width`, `open_width`, `start_closed`, `chromeId`, `display_order`) VALUES
(100, NULL, NULL, 'search', NULL, 600, 600, 1, 'gadgets-search', NULL),
(101, NULL, 'R', 'individual', 'profile', 290, 600, 1, 'gadgets-view', 3),
(101, NULL, NULL, 'individual-EDIT-MODE', 'home', 700, 700, 1, 'gadgets-edit', NULL),
@@ -23,6 +25,4 @@ INSERT INTO `shindig_app_views` (`appid`, `viewer_req`, `owner_req`, `page`, `vi
(104, 'U', NULL, 'gadgetDetails', 'canvas', 700, 700, 0, 'gadgets-detail', NULL),
(104, 'U', NULL, 'SimilarPeople.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL),
(104, 'U', NULL, 'individual', 'small', 290, 290, 0, 'gadgets-view', NULL),
-(104, 'U', NULL, 'CoAuthors.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL),
-(105, 'U', NULL, 'individual', 'small', 290, 290, 0, 'gadgets-view', NULL),
-(105, 'U', NULL, 'gadgetDetails', 'canvas', 700, 700, 0, 'gadgets-detail', NULL);
+(104, 'U', NULL, 'CoAuthors.aspx', 'small', 160, 160, 0, 'gadgets-tools', NULL);
diff --git a/opensocial/shindig_orng_tables.sql b/opensocial/shindig_orng_tables.sql
index ed52ea340..fe6b3afd8 100644
--- a/opensocial/shindig_orng_tables.sql
+++ b/opensocial/shindig_orng_tables.sql
@@ -1,9 +1,9 @@
--
--- Table structure for table `shindig_activity`
+-- Table structure for table `orng_activity`
--
-CREATE TABLE IF NOT EXISTS `shindig_activity` (
+CREATE TABLE IF NOT EXISTS `orng_activity` (
`activityId` int(11) NOT NULL AUTO_INCREMENT,
`userId` varchar(255) default NULL,
`appId` int(11) default NULL,
@@ -15,10 +15,10 @@ CREATE TABLE IF NOT EXISTS `shindig_activity` (
-- --------------------------------------------------------
--
--- Table structure for table `shindig_appdata`
+-- Table structure for table `orng_appdata`
--
-CREATE TABLE IF NOT EXISTS `shindig_appdata` (
+CREATE TABLE IF NOT EXISTS `orng_appdata` (
`userId` varchar(255) NOT NULL,
`appId` int(11) NOT NULL,
`keyname` varchar(255) NOT NULL,
@@ -31,10 +31,10 @@ CREATE TABLE IF NOT EXISTS `shindig_appdata` (
-- --------------------------------------------------------
--
--- Table structure for table `shindig_apps`
+-- Table structure for table `orng_apps`
--
-CREATE TABLE IF NOT EXISTS `shindig_apps` (
+CREATE TABLE IF NOT EXISTS `orng_apps` (
`appid` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`url` varchar(255) NOT NULL,
@@ -47,10 +47,10 @@ CREATE TABLE IF NOT EXISTS `shindig_apps` (
-- --------------------------------------------------------
--
--- Table structure for table `shindig_app_registry`
+-- Table structure for table `orng_app_registry`
--
-CREATE TABLE IF NOT EXISTS `shindig_app_registry` (
+CREATE TABLE IF NOT EXISTS `orng_app_registry` (
`appid` int(11) NOT NULL,
`personId` varchar(255) NOT NULL,
`createdDT` datetime NOT NULL,
@@ -60,10 +60,10 @@ CREATE TABLE IF NOT EXISTS `shindig_app_registry` (
-- --------------------------------------------------------
--
--- Table structure for table `shindig_app_views`
+-- Table structure for table `orng_app_views`
--
-CREATE TABLE IF NOT EXISTS `shindig_app_views` (
+CREATE TABLE IF NOT EXISTS `orng_app_views` (
`appid` int(11) NOT NULL,
`viewer_req` char(1) default NULL,
`owner_req` char(1) default NULL,
@@ -79,10 +79,10 @@ CREATE TABLE IF NOT EXISTS `shindig_app_views` (
-- --------------------------------------------------------
--
--- Table structure for table `shindig_messages`
+-- Table structure for table `orng_messages`
--
-CREATE TABLE IF NOT EXISTS `shindig_messages` (
+CREATE TABLE IF NOT EXISTS `orng_messages` (
`msgId` varchar(255) NOT NULL,
`senderId` varchar(255) default NULL,
`recipientId` varchar(255) default NULL,
@@ -97,47 +97,47 @@ CREATE TABLE IF NOT EXISTS `shindig_messages` (
DELIMITER //
-CREATE PROCEDURE shindig_registerAppPerson (uid varchar(255), aid INT, v BOOL)
+CREATE PROCEDURE orng_registerAppPerson (uid varchar(255), aid INT, v BOOL)
BEGIN
IF (v)
THEN
- INSERT INTO shindig_app_registry (appId, personId, createdDT) values (aid, uid, now());
+ INSERT INTO orng_app_registry (appId, personId, createdDT) values (aid, uid, now());
ELSE
- DELETE FROM shindig_app_registry where appId = aid AND personId = uid;
+ DELETE FROM orng_app_registry where appId = aid AND personId = uid;
END IF;
END //
DELIMITER ;
DELIMITER //
-CREATE PROCEDURE shindig_upsertAppData(uid varchar(255), aid INT, kn varchar(255),v varchar(4000))
+CREATE PROCEDURE orng_upsertAppData(uid varchar(255), aid INT, kn varchar(255),v varchar(4000))
BEGIN
DECLARE cnt int;
- SELECT count(*) FROM shindig_appdata WHERE userId = uid AND appId = aid and keyname = kn INTO cnt;
+ SELECT count(*) FROM orng_appdata WHERE userId = uid AND appId = aid and keyname = kn INTO cnt;
IF (cnt > 0)
THEN
- UPDATE shindig_appdata set `value` = v, updatedDT = NOW() WHERE userId = uid AND appId = aid and keyname = kn;
+ UPDATE orng_appdata set `value` = v, updatedDT = NOW() WHERE userId = uid AND appId = aid and keyname = kn;
ELSE
- INSERT INTO shindig_appdata (userId, appId, keyname, `value`) values (uid, aid, kn, v);
+ INSERT INTO orng_appdata (userId, appId, keyname, `value`) values (uid, aid, kn, v);
END IF;
-- if keyname is VISIBLE, do more
IF (kn = 'VISIBLE' AND v = 'Y')
THEN
- CALL shindig_registerAppPerson(uid, aid, 1);
+ CALL orng_registerAppPerson(uid, aid, 1);
ELSEIF (kn = 'VISIBLE' )
THEN
- CALL shindig_registerAppPerson(uid, aid, 0);
+ CALL orng_registerAppPerson(uid, aid, 0);
END IF;
END //
DELIMITER ;
DELIMITER //
-CREATE PROCEDURE shindig_deleteAppData(uid varchar(255),aid INT, kn varchar(255))
+CREATE PROCEDURE orng_deleteAppData(uid varchar(255),aid INT, kn varchar(255))
BEGIN
- DELETE FROM shindig_appdata WHERE userId = uid AND appId = aid and keyname = kn;
+ DELETE FROM orng_appdata WHERE userId = uid AND appId = aid and keyname = kn;
-- if keyname is VISIBLE, do more
IF (kn = 'VISIBLE' )
THEN
- CALL shindig_registerAppPerson(uid, aid, 0);
+ CALL orng_registerAppPerson(uid, aid, 0);
END IF;
END //
DELIMITER ;
diff --git a/opensocial/shindig.orng.properties.template b/opensocial/shindigorng.properties.template
similarity index 92%
rename from opensocial/shindig.orng.properties.template
rename to opensocial/shindigorng.properties.template
index 7d8d40ca5..7acf82b62 100644
--- a/opensocial/shindig.orng.properties.template
+++ b/opensocial/shindigorng.properties.template
@@ -1,190 +1,191 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-##################################################################
-#
-# Note from UCSF. Compare this to the latest in shindig-common/conf/shindig.properties
-# whenever you download a new version of shindig
-#
-##################################################################
-
-# Location of feature manifests (comma separated)
-shindig.features.default=res://features/features.txt
-
-# Location of container configurations (comma separated)
-#shindig.containers.default=res://containers/default/container.js
-shindig.containers.default=res://orng-container.js
-
-# A file containing blacklisted gadgets.
-shindig.blacklist.file=
-
-### Inbound OAuth support
-# The URL base to use for full OAuth support (three-legged)
-shindig.oauth.base-url=/oauth/
-shindig.oauth.authorize-action=/WEB-INF/authorize.jsp
-
-### Outbound OAuth support
-shindig.signing.state-key=
-shindig.signing.key-name=
-shindig.signing.key-file=
-shindig.signing.global-callback-url=http://localhost:8080/shindigorng/gadgets/oauthcallback
-shindig.signing.enable-signed-callbacks=true
-
-# Set to true if you want to allow the use of 3-legged OAuth tokens when viewer != owner.
-# This setting is not recommeneded for pages that allow user-controlled javascript, since
-# that javascript could be used to make unauthorized requests on behalf of the viewer of the page
-shindig.signing.viewer-access-tokens-enabled=false
-
-# If enabled here, configuration values can be found in container configuration files.
-shindig.locked-domain.enabled=false
-
-# TODO: This needs to be moved to container configuration.
-# Note by Eric. This is set up to now exclude everything and include nothing
-shindig.content-rewrite.only-allow-excludes=false
-shindig.content-rewrite.include-urls=.*
-shindig.content-rewrite.exclude-urls=
-shindig.content-rewrite.include-tags=body,embed,img,input,link,script,style
-shindig.content-rewrite.expires=86400
-shindig.content-rewrite.proxy-url=/shindigorng/gadgets/proxy?container=default&url=
-shindig.content-rewrite.concat-url=/shindigorng/gadgets/concat?container=default&
-shindig.content-rewrite.enable-split-js-concat=false
-
-#
-# Default set of forced libs to allow for better caching
-#
-# NOTE: setting this causes the EndToEnd test to fail the opensocial-templates test
-shindig.gadget-rewrite.default-forced-libs=core:rpc
-shindig.gadget-rewrite.default-forced-libs=
-
-#
-# Allow supported JavaScript features required by a gadget to be externalized on demand
-shindig.gadget-rewrite.externalize-feature-libs=true
-
-# Configuration for image rewriter
-shindig.image-rewrite.max-inmem-bytes = 1048576
-shindig.image-rewrite.max-palette-size = 256
-shindig.image-rewrite.allow-jpeg-conversion = true
-shindig.image-rewrite.jpeg-compression = 0.75
-shindig.image-rewrite.min-threshold-bytes = 200
-
-# Configuration for the os:Flash tag
-shindig.flash.min-version = 9.0.115
-
-# Configuration for template rewriter
-shindig.template-rewrite.extension-tag-namespace=http://ns.opensocial.org/2009/extensions
-
-# These values provide default TTLs for HTTP responses that don't use caching headers.
-shindig.cache.http.defaultTtl=3600000
-shindig.cache.http.negativeCacheTtl=60000
-
-# A default refresh interval for XML files, since there is no natural way for developers to
-# specify this value, and most HTTP responses don't include good cache control headers.
-shindig.cache.xml.refreshInterval=300000
-
-# Add entries in the form shindig.cache.lru..capacity to specify capacities for different
-# caches when using the LruCacheProvider.
-# It is highly recommended that the EhCache implementation be used instead of the LRU cache.
-shindig.cache.lru.default.capacity=1000
-shindig.cache.lru.expressions.capacity=1000
-shindig.cache.lru.gadgetSpecs.capacity=1000
-shindig.cache.lru.messageBundles.capacity=1000
-shindig.cache.lru.httpResponses.capacity=10000
-
-# The location of the EhCache configuration file.
-shindig.cache.ehcache.config=res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
-
-# True to enable JMX integration with cache stats
-shindig.cache.ehcache.jmx.enabled=true
-
-# true to enable JMX stats.
-shindig.cache.ehcache.jmx.stats=true
-
-# true to skip expensive encoding detection.
-# if true, will only attempt to validate utf-8. Assumes all other encodings are ISO-8859-1.
-shindig.http.fast-encoding-detection=true
-
-# Configuration for the HttpFetcher
-# Connection timeout, in milliseconds, for requests.
-shindig.http.client.connection-timeout-ms=5000
-
-# Maximum size, in bytes, of the object we fetched, 0 == no limit
-shindig.http.client.max-object-size-bytes=0
-
-# Strict-mode parsing for proxy and concat URIs ensures that the authority/host and path
-# for the URIs match precisely what is found in the container config for it. This is
-# useful where statistics and traffic routing patterns, typically in large installations,
-# key on hostname (and occasionally path). Enforcing this does come at the cost that
-# mismatches break, which in turn mandates that URI generation always happen in consistent
-# fashion, ie. by the class itself or tightly controlled code.
-shindig.uri.proxy.use-strict-parsing=false
-shindig.uri.concat.use-strict-parsing=false
-
-# Host:port of the proxy to use while fetching urls. Leave blank if proxy is
-# not to be used.
-org.apache.shindig.gadgets.http.basicHttpFetcherProxy=
-
-org.apache.shindig.serviceExpirationDurationMinutes=60
-
-#
-# Older versions of shindig used 'data' in the json-rpc response format
-# The spec calls for using 'result' instead, however to avoid breakage we
-# allow you to set it back to the old way here
-#
-# valid values are
-# result - new form
-# data - old broken form
-# both - return both fields for full compatibility
-#
-shindig.json-rpc.result-field=result
-
-# Remap "Internal server error"s received from the basicHttpFetcherProxy server to
-# "Bad Gateway error"s, so that it is clear to the user that the proxy server is
-# the one that threw the exception.
-shindig.accelerate.remapInternalServerError=true
-shindig.proxy.remapInternalServerError=true
-
-shindig.signing.key-file=@TOKEN_KEY_FILE@
-shindig.signing.key-name=
-
-####################################################################################
-#
-# Open Research Networking Gadgets Items
-#
-#####################################################################################
-
-# orng.system must be set to Profiles or VIVO
-#orng.system = Profiles
-orng.system = VIVO
-
-# orng.dbDriver is likely com.microsoft.sqlserver.jdbc.SQLServerDriver for Profiles and com.mysql.jdbc.Driver for VIVO
-#orng.dbDriver = com.microsoft.sqlserver.jdbc.SQLServerDriver
-orng.dbDriver = @DATA_SOURCE_DRIVER@
-orng.dbURL = @DATA_SOURCE_URL@
-orng.dbUser = @DATA_SOURCE_USERNAME@
-orng.dbPassword = @DATA_SOURCE_PASSWORD@
-orng.tokenservice.port = 8777
-# orng.RDFConverter = elda | babel
-orng.RDFConverter = elda
-#orng.RDFConverter = babel
-
-# until Profiles has RDF
-orng.profilesXMLService = http://dev-profiles.ucsf.edu/api_100810/ProfileService.svc/ProfileSearch
-orng.profilesRDF = true;
-
-
-
-
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+##################################################################
+#
+# Note from UCSF. Compare this to the latest in shindig-common/conf/shindig.properties
+# whenever you download a new version of shindig
+#
+##################################################################
+
+# Location of feature manifests (comma separated)
+shindig.features.default=res://features/features.txt
+
+# Location of container configurations (comma separated)
+# In shindigorng this is set automatically to either res://vivo-container.js or res://profiles-container.js based on your orng.system value below!
+# Leave this commented out !!!!
+#shindig.containers.default=res://containers/default/container.js
+
+
+# A file containing blacklisted gadgets.
+shindig.blacklist.file=
+
+### Inbound OAuth support
+# The URL base to use for full OAuth support (three-legged)
+shindig.oauth.base-url=/oauth/
+shindig.oauth.authorize-action=/WEB-INF/authorize.jsp
+
+### Outbound OAuth support
+shindig.signing.state-key=
+shindig.signing.key-name=
+shindig.signing.key-file=
+shindig.signing.global-callback-url=http://localhost:8080/shindigorng/gadgets/oauthcallback
+shindig.signing.enable-signed-callbacks=true
+
+# Set to true if you want to allow the use of 3-legged OAuth tokens when viewer != owner.
+# This setting is not recommeneded for pages that allow user-controlled javascript, since
+# that javascript could be used to make unauthorized requests on behalf of the viewer of the page
+shindig.signing.viewer-access-tokens-enabled=false
+
+# If enabled here, configuration values can be found in container configuration files.
+shindig.locked-domain.enabled=false
+
+# TODO: This needs to be moved to container configuration.
+# Note by Eric. This is set up to now exclude everything and include nothing
+shindig.content-rewrite.only-allow-excludes=false
+shindig.content-rewrite.include-urls=.*
+shindig.content-rewrite.exclude-urls=
+shindig.content-rewrite.include-tags=body,embed,img,input,link,script,style
+shindig.content-rewrite.expires=86400
+shindig.content-rewrite.proxy-url=/shindigorng/gadgets/proxy?container=default&url=
+shindig.content-rewrite.concat-url=/shindigorng/gadgets/concat?container=default&
+shindig.content-rewrite.enable-split-js-concat=false
+
+#
+# Default set of forced libs to allow for better caching
+#
+# NOTE: setting this causes the EndToEnd test to fail the opensocial-templates test
+shindig.gadget-rewrite.default-forced-libs=core:rpc
+shindig.gadget-rewrite.default-forced-libs=
+
+#
+# Allow supported JavaScript features required by a gadget to be externalized on demand
+shindig.gadget-rewrite.externalize-feature-libs=true
+
+# Configuration for image rewriter
+shindig.image-rewrite.max-inmem-bytes = 1048576
+shindig.image-rewrite.max-palette-size = 256
+shindig.image-rewrite.allow-jpeg-conversion = true
+shindig.image-rewrite.jpeg-compression = 0.75
+shindig.image-rewrite.min-threshold-bytes = 200
+
+# Configuration for the os:Flash tag
+shindig.flash.min-version = 9.0.115
+
+# Configuration for template rewriter
+shindig.template-rewrite.extension-tag-namespace=http://ns.opensocial.org/2009/extensions
+
+# These values provide default TTLs for HTTP responses that don't use caching headers.
+shindig.cache.http.defaultTtl=3600000
+shindig.cache.http.negativeCacheTtl=60000
+
+# A default refresh interval for XML files, since there is no natural way for developers to
+# specify this value, and most HTTP responses don't include good cache control headers.
+shindig.cache.xml.refreshInterval=300000
+
+# Add entries in the form shindig.cache.lru..capacity to specify capacities for different
+# caches when using the LruCacheProvider.
+# It is highly recommended that the EhCache implementation be used instead of the LRU cache.
+shindig.cache.lru.default.capacity=1000
+shindig.cache.lru.expressions.capacity=1000
+shindig.cache.lru.gadgetSpecs.capacity=1000
+shindig.cache.lru.messageBundles.capacity=1000
+shindig.cache.lru.httpResponses.capacity=10000
+
+# The location of the EhCache configuration file.
+shindig.cache.ehcache.config=res://org/apache/shindig/common/cache/ehcache/ehcacheConfig.xml
+
+# True to enable JMX integration with cache stats
+shindig.cache.ehcache.jmx.enabled=true
+
+# true to enable JMX stats.
+shindig.cache.ehcache.jmx.stats=true
+
+# true to skip expensive encoding detection.
+# if true, will only attempt to validate utf-8. Assumes all other encodings are ISO-8859-1.
+shindig.http.fast-encoding-detection=true
+
+# Configuration for the HttpFetcher
+# Connection timeout, in milliseconds, for requests.
+shindig.http.client.connection-timeout-ms=5000
+
+# Maximum size, in bytes, of the object we fetched, 0 == no limit
+shindig.http.client.max-object-size-bytes=0
+
+# Strict-mode parsing for proxy and concat URIs ensures that the authority/host and path
+# for the URIs match precisely what is found in the container config for it. This is
+# useful where statistics and traffic routing patterns, typically in large installations,
+# key on hostname (and occasionally path). Enforcing this does come at the cost that
+# mismatches break, which in turn mandates that URI generation always happen in consistent
+# fashion, ie. by the class itself or tightly controlled code.
+shindig.uri.proxy.use-strict-parsing=false
+shindig.uri.concat.use-strict-parsing=false
+
+# Host:port of the proxy to use while fetching urls. Leave blank if proxy is
+# not to be used.
+org.apache.shindig.gadgets.http.basicHttpFetcherProxy=
+
+org.apache.shindig.serviceExpirationDurationMinutes=60
+
+#
+# Older versions of shindig used 'data' in the json-rpc response format
+# The spec calls for using 'result' instead, however to avoid breakage we
+# allow you to set it back to the old way here
+#
+# valid values are
+# result - new form
+# data - old broken form
+# both - return both fields for full compatibility
+#
+shindig.json-rpc.result-field=result
+
+# Remap "Internal server error"s received from the basicHttpFetcherProxy server to
+# "Bad Gateway error"s, so that it is clear to the user that the proxy server is
+# the one that threw the exception.
+shindig.accelerate.remapInternalServerError=true
+shindig.proxy.remapInternalServerError=true
+
+shindig.signing.key-file=@TOKEN_KEY_FILE@
+shindig.signing.key-name=mykey
+
+#####################################################################################
+#
+# Open Research Networking Gadgets Items
+#
+#####################################################################################
+
+# orng.RDFConverter should be elda. We also currently support babel but it is only being used for test and comparison purposes
+# and babel will be phased out
+orng.RDFConverter = elda
+orng.tokenservice.port = 8777
+orng.securityTokenKeyFile = @TOKEN_KEY_FILE@
+
+# orng.system must be set to Profiles or VIVO
+#orng.system = Profiles
+#orng.dbDriver = com.microsoft.sqlserver.jdbc.SQLServerDriver
+#orng.dbURL = jdbc:sqlserver://dev-sql-ctsi.ucsf.edu;instanceName=default;portNumber=1433;databaseName=profiles_100
+#orng.dbUser = App_Profiles10
+#orng.dbPassword = Password1234
+
+orng.system = VIVO
+orng.dbDriver = @DATA_SOURCE_DRIVER@
+orng.dbURL = @DATA_SOURCE_URL@
+orng.dbUser = @DATA_SOURCE_USERNAME@
+orng.dbPassword = @DATA_SOURCE_PASSWORD@
+
+
+
diff --git a/opensocial/shindigorng.war b/opensocial/shindigorng.war
index fa845ad02..7d2d1d99b 100644
Binary files a/opensocial/shindigorng.war and b/opensocial/shindigorng.war differ
diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java
index 5323223bd..d85ba6ada 100644
--- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java
+++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java
@@ -273,10 +273,15 @@ public class PagedSearchController extends FreemarkerHttpServlet {
// VIVO OpenSocial Extension by UCSF
try {
OpenSocialManager openSocialManager = new OpenSocialManager(vreq, "search");
- // put list of people found onto pubsub channel
- List ids = OpenSocialManager.getOpenSocialId(individuals);
- openSocialManager.setPubsubData(OpenSocialManager.JSON_PERSONID_CHANNEL,
- OpenSocialManager.buildJSONPersonIds(ids, "" + ids.size() + " people found"));
+ // put list of people found onto pubsub channel
+ // only turn this on for a people only search
+ if ("http://vivoweb.org/ontology#vitroClassGrouppeople".equals(vreq.getParameter(PARAM_CLASSGROUP))) {
+ List ids = OpenSocialManager.getOpenSocialId(individuals);
+ openSocialManager.setPubsubData(OpenSocialManager.JSON_PERSONID_CHANNEL,
+ OpenSocialManager.buildJSONPersonIds(ids, "" + ids.size() + " people found"));
+ }
+ // TODO put this in a better place to guarantee that it gets called at the proper time!
+ openSocialManager.removePubsubGadgetsWithoutData();
body.put("openSocial", openSocialManager);
if (openSocialManager.isVisible()) {
body.put("bodyOnload", "my.init();");
@@ -285,7 +290,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
log.error("IOException in doTemplate()", e);
} catch (SQLException e) {
log.error("SQLException in doTemplate()", e);
- }
+ }
String template = templateTable.get(format).get(Result.PAGED);
diff --git a/webapp/src/edu/ucsf/vitro/opensocial/GadgetController.java b/webapp/src/edu/ucsf/vitro/opensocial/GadgetController.java
index 89d6cea00..5947802c0 100644
--- a/webapp/src/edu/ucsf/vitro/opensocial/GadgetController.java
+++ b/webapp/src/edu/ucsf/vitro/opensocial/GadgetController.java
@@ -23,7 +23,11 @@ public class GadgetController extends FreemarkerHttpServlet {
@Override
protected ResponseValues processRequest(VitroRequest vreq) {
- if (vreq.getServletPath().endsWith("/sandbox")) {
+ if ("/clearcache".equalsIgnoreCase(vreq.getPathInfo())) {
+ OpenSocialManager.clearCache();
+ return new RedirectResponseValues("/");
+ }
+ else if ("/sandbox".equalsIgnoreCase(vreq.getPathInfo())) {
boolean sandbox = "True".equalsIgnoreCase(ConfigurationProperties.getBean(vreq.getSession()
.getServletContext()).getProperty("OpenSocial.sandbox"));
if (!sandbox) {
@@ -81,7 +85,7 @@ public class GadgetController extends FreemarkerHttpServlet {
try {
OpenSocialManager openSocialManager = new OpenSocialManager(vreq, "gadgetSandbox");
String gadgetURLS = "";
- for (PreparedGadget gadget : openSocialManager.getVisibleGadgets())
+ for (GadgetSpec gadget : openSocialManager.getAllDBGadgets(false).values())
{
gadgetURLS += gadget.getGadgetURL() + System.getProperty("line.separator");
}
diff --git a/webapp/src/edu/ucsf/vitro/opensocial/GadgetSpec.java b/webapp/src/edu/ucsf/vitro/opensocial/GadgetSpec.java
index 165fdf1c4..6b9666662 100644
--- a/webapp/src/edu/ucsf/vitro/opensocial/GadgetSpec.java
+++ b/webapp/src/edu/ucsf/vitro/opensocial/GadgetSpec.java
@@ -5,7 +5,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -13,33 +12,24 @@ import java.util.Map;
import org.apache.commons.dbcp.BasicDataSource;
public class GadgetSpec {
- private String openSocialGadgetURL;
- private String name;
private int appId = 0;
+ private String name;
+ private String openSocialGadgetURL;
private List channels = new ArrayList();
- private boolean unknownGadget = false;
private Map viewRequirements = new HashMap();
+ boolean enabled;
+ private boolean unknownGadget = false;
- // For preloading
public GadgetSpec(int appId, String name, String openSocialGadgetURL,
- List channels) {
+ List channels, BasicDataSource ds, boolean enabled, boolean unknownGadget)
+ throws SQLException {
this.appId = appId;
this.name = name;
this.openSocialGadgetURL = openSocialGadgetURL;
this.channels.addAll(channels);
- }
-
- public GadgetSpec(int appId, String name, String openSocialGadgetURL,
- String channelsStr) {
- this(appId, name, openSocialGadgetURL, Arrays.asList(channelsStr != null
- && channelsStr.length() > 0 ? channelsStr.split(" ") : new String[0]));
- }
-
- public GadgetSpec(int appId, String name, String openSocialGadgetURL,
- List channels, boolean unknownGadget, BasicDataSource ds)
- throws SQLException {
- this(appId, name, openSocialGadgetURL, channels);
+ this.enabled = enabled;
this.unknownGadget = unknownGadget;
+
// Load gadgets from the DB first
if (!unknownGadget) {
Connection conn = null;
@@ -47,7 +37,7 @@ public class GadgetSpec {
ResultSet rset = null;
try {
- String sqlCommand = "select page, viewer_req, owner_req, view, closed_width, open_width, start_closed, chromeId, display_order from shindig_app_views where appId = "
+ String sqlCommand = "select page, viewer_req, owner_req, view, closed_width, open_width, start_closed, chromeId, display_order from orng_app_views where appId = "
+ appId;
conn = ds.getConnection();
stmt = conn.createStatement();
@@ -63,25 +53,16 @@ public class GadgetSpec {
}
} finally {
try {
- if (rset != null) {
- rset.close();
- }
+ rset.close();
} catch (Exception e) {
- e.printStackTrace();
}
try {
- if (stmt != null) {
- stmt.close();
- }
+ stmt.close();
} catch (Exception e) {
- e.printStackTrace();
}
try {
- if (conn != null) {
- conn.close();
- }
+ conn.close();
} catch (Exception e) {
- e.printStackTrace();
}
}
}
@@ -103,7 +84,7 @@ public class GadgetSpec {
return channels;
}
- public boolean listensTo(String channel) { // if an unknown gadget just say yes,
+ public boolean listensTo(String channel) { // if an unknownd gadget just say yes,
// we don't care about
// performance in this situation
return unknownGadget || channels.contains(channel);
@@ -129,7 +110,7 @@ public class GadgetSpec {
if (viewRequirements.containsKey(page)) {
show = true;
GadgetViewRequirements req = getGadgetViewRequirements(page);
- if ('U' == req.getViewerReq() && viewerId != null) {
+ if ('U' == req.getViewerReq() && viewerId == null) {
show = false;
} else if ('R' == req.getViewerReq()) {
show &= isRegisteredTo(viewerId, ds);
@@ -152,7 +133,7 @@ public class GadgetSpec {
ResultSet rset = null;
try {
- String sqlCommand = "select count(*) from shindig_app_registry where appId = "
+ String sqlCommand = "select count(*) from orng_app_registry where appId = "
+ getAppId() + " and personId = '" + personId + "';";
conn = ds.getConnection();
stmt = conn.createStatement();
@@ -162,25 +143,16 @@ public class GadgetSpec {
}
} finally {
try {
- if (rset != null) {
- rset.close();
- }
+ rset.close();
} catch (Exception e) {
- e.printStackTrace();
}
try {
- if (stmt != null) {
- stmt.close();
- }
+ stmt.close();
} catch (Exception e) {
- e.printStackTrace();
}
try {
- if (conn != null) {
- conn.close();
- }
+ conn.close();
} catch (Exception e) {
- e.printStackTrace();
}
}
@@ -191,6 +163,10 @@ public class GadgetSpec {
return unknownGadget;
}
+ public boolean isEnabled() {
+ return enabled;
+ }
+
// who sees it? Return the viewerReq for the ProfileDetails page
public char getVisibleScope() {
GadgetViewRequirements req = getGadgetViewRequirements("/display");
diff --git a/webapp/src/edu/ucsf/vitro/opensocial/GadgetViewRequirements.java b/webapp/src/edu/ucsf/vitro/opensocial/GadgetViewRequirements.java
index bedbc3ba9..d482e3585 100644
--- a/webapp/src/edu/ucsf/vitro/opensocial/GadgetViewRequirements.java
+++ b/webapp/src/edu/ucsf/vitro/opensocial/GadgetViewRequirements.java
@@ -1,7 +1,6 @@
package edu.ucsf.vitro.opensocial;
public class GadgetViewRequirements {
- private String page;
private char viewerReq; // U for User or null for no requirement
private char ownerReq; // R for Registered or null for no requirement
private String view;
@@ -11,10 +10,9 @@ public class GadgetViewRequirements {
private String chromeId;
private int display_order;
- public GadgetViewRequirements(String page, char viewerReq, char ownerReq,
+ public GadgetViewRequirements(char viewerReq, char ownerReq,
String view, int closedWidth, int openWidth, boolean startClosed,
String chromeId, int display_order) {
- this.page = page;
this.viewerReq = viewerReq;
this.ownerReq = ownerReq;
this.view = view;
@@ -28,7 +26,7 @@ public class GadgetViewRequirements {
public GadgetViewRequirements(String page, String viewerReq,
String ownerReq, String view, int closedWidth, int openWidth,
boolean startClosed, String chromeId, int display_order) {
- this(page, viewerReq != null ? viewerReq.charAt(0) : ' ',
+ this(viewerReq != null ? viewerReq.charAt(0) : ' ',
ownerReq != null ? ownerReq.charAt(0) : ' ', view, closedWidth,
openWidth, startClosed, chromeId, display_order);
}
diff --git a/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java b/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java
index 16b35a5d0..df89c33c3 100644
--- a/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java
+++ b/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialManager.java
@@ -8,6 +8,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -39,6 +40,9 @@ public class OpenSocialManager {
private static final String DEFAULT_DRIVER = "com.mysql.jdbc.Driver";
+ // for performance
+ private static Map gadgetCache;
+
private List gadgets = new ArrayList();
private Map pubsubdata = new HashMap();
private String viewerId = null;
@@ -79,15 +83,13 @@ public class OpenSocialManager {
}
else {
UserAccount viewer = LoginStatusBean.getCurrentUser(vreq);
- this.viewerId = viewer != null ? viewer.getUri() : null;
+ // attempt to use profile URI if present, otherwise user user oriented URI
+ this.viewerId = viewer != null && viewer.getProxiedIndividualUris().size() == 1 ?
+ viewer.getProxiedIndividualUris().toArray()[0].toString() : (viewer != null ? viewer.getUri() : null);
}
- boolean gadgetSandbox = "gadgetSandbox".equals(pageName);
String requestAppId = vreq.getParameter("appId");
- Map dbApps = new HashMap();
- Map officialApps = new HashMap();
-
dataSource = new BasicDataSource();
dataSource.setDriverClassName(DEFAULT_DRIVER);
dataSource.setUsername(configuration
@@ -98,116 +100,26 @@ public class OpenSocialManager {
.getProperty("VitroConnection.DataSource.url"));
// Load gadgets from the DB first
- Connection conn = null;
- Statement stmt = null;
- ResultSet rset = null;
- try {
+ Map allDBGadgets = getAllDBGadgets(!noCache);
- String sqlCommand = "select appId, name, url, channels, enabled from shindig_apps";
- // if a specific app is requested, only grab it
- if (requestAppId != null) {
- sqlCommand += " where appId = " + requestAppId;
- }
- conn = dataSource.getConnection();
- stmt = conn.createStatement();
- rset = stmt.executeQuery(sqlCommand);
-
- while (rset.next()) {
- GadgetSpec spec = new GadgetSpec(rset.getInt(1),
- rset.getString(2), rset.getString(3), rset.getString(4));
- String gadgetFileName = getGadgetFileNameFromURL(rset
- .getString(3));
-
- dbApps.put(gadgetFileName, spec);
- if (requestAppId != null || rset.getBoolean(5)) {
- officialApps.put(gadgetFileName, spec);
- }
- }
- } finally {
- try {
- if (rset != null) {
- rset.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- try {
- if (stmt != null) {
- stmt.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- try {
- if (conn != null) {
- conn.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ // Add sandbox gadgets if they are present
+ if (vreq.getSession() != null && vreq.getSession().getAttribute(OPENSOCIAL_GADGETS) != null) {
+ gadgets = getSandboxGadgets(vreq, allDBGadgets, requestAppId);
}
-
- // Add manual gadgets if there are any
- // Note that this block of code only gets executed after someone fills in the
- // gadget/sandbox form!
- int moduleId = 0;
- if (vreq.getSession() != null
- && vreq.getSession().getAttribute(OPENSOCIAL_GADGETS) != null) {
- String openSocialGadgetURLS = (String) vreq.getSession()
- .getAttribute(OPENSOCIAL_GADGETS);
- String[] urls = openSocialGadgetURLS.split(System.getProperty("line.separator"));
- for (String openSocialGadgetURL : urls) {
- if (openSocialGadgetURL.length() == 0)
- continue;
- int appId = 0; // if URL matches one in the DB, use DB provided
- // appId, otherwise generate one
- String gadgetFileName = getGadgetFileNameFromURL(openSocialGadgetURL);
- String name = gadgetFileName;
- List channels = new ArrayList();
- boolean unknownGadget = true;
- if (dbApps.containsKey(gadgetFileName)) {
- appId = dbApps.get(gadgetFileName).getAppId();
- name = dbApps.get(gadgetFileName).getName();
- channels = dbApps.get(gadgetFileName).getChannels();
- unknownGadget = false;
- } else {
- appId = openSocialGadgetURL.hashCode();
- }
- // if they asked for a specific one, only let it in
- if (requestAppId != null
- && Integer.getInteger(requestAppId) != appId) {
- continue;
- }
- GadgetSpec gadget = new GadgetSpec(appId, name,
- openSocialGadgetURL, channels, unknownGadget, dataSource);
+ else {
+ // if no manual one were added, use the ones from the DB
+ for (GadgetSpec gadgetSpec : allDBGadgets.values()) {
// only add ones that are visible in this context!
- if (unknownGadget
- || gadget.show(viewerId, ownerId, pageName, dataSource)) {
- String securityToken = socketSendReceive(viewerId, ownerId,
- "" + gadget.getAppId());
- gadgets.add(new PreparedGadget(gadget, this, moduleId++,
- securityToken));
- }
- }
- }
-
- // if no manual one were added, use the ones from the DB
- if (gadgets.size() == 0) {
- // Load DB gadgets
- if (gadgetSandbox) {
- officialApps = dbApps;
- }
- for (GadgetSpec spec : officialApps.values()) {
- GadgetSpec gadget = new GadgetSpec(spec.getAppId(),
- spec.getName(), spec.getGadgetURL(),
- spec.getChannels(), false, dataSource);
- // only add ones that are visible in this context!
- if (gadgetSandbox
- || gadget.show(viewerId, ownerId, pageName, dataSource)) {
- String securityToken = socketSendReceive(viewerId, ownerId,
- "" + gadget.getAppId());
- gadgets.add(new PreparedGadget(gadget, this, moduleId++,
- securityToken));
+ int moduleId = 0;
+ if (
+ (
+ (requestAppId == null && gadgetSpec.isEnabled()) ||
+ (requestAppId != null && gadgetSpec.getAppId() == Integer.parseInt(requestAppId))
+ ) &&
+ gadgetSpec.show(viewerId, ownerId, pageName, dataSource)
+ ) {
+ String securityToken = socketSendReceive(viewerId, ownerId, "" + gadgetSpec.getAppId());
+ gadgets.add(new PreparedGadget(gadgetSpec, this, moduleId++, securityToken));
}
}
}
@@ -215,6 +127,10 @@ public class OpenSocialManager {
// sort the gadgets
Collections.sort(gadgets);
}
+
+ public static void clearCache() {
+ gadgetCache = null;
+ }
private String figureOwnerId(VitroRequest vreq) {
IndividualRequestAnalyzer requestAnalyzer = new IndividualRequestAnalyzer(vreq,
@@ -278,17 +194,6 @@ public class OpenSocialManager {
personIds.add(ind.getURI());
return buildJSONPersonIds(personIds, message);
}
- /****
- * public static String BuildJSONPubMedIds(Person person) { List
- * pubIds = new List(); foreach (Publication pub in
- * person.PublicationList) { foreach (PublicationSource pubSource in
- * pub.PublicationSourceList) { if ("PubMed".Equals(pubSource.Name)) {
- * pubIds.Add(Int32.Parse(pubSource.ID)); } } } Dictionary
- * foundPubs = new Dictionary(); foundPubs.Add("pubIds",
- * pubIds); foundPubs.Add("message", "PubMedIDs for " +
- * person.Name.FullName); JavaScriptSerializer serializer = new
- * JavaScriptSerializer(); return serializer.Serialize(foundPubs); }
- ***/
public void setPubsubData(String key, String value) {
if (pubsubdata.containsKey(key)) {
@@ -374,7 +279,7 @@ public class OpenSocialManager {
String xtraId1Type, String xtraId1Value) throws SQLException {
Connection conn = null;
Statement stmt = null;
- String sqlCommand = "INSERT INTO shindig_activity (userId, activity, xtraId1Type, xtraId1Value) VALUES ('"
+ String sqlCommand = "INSERT INTO orng_activity (userId, activity, xtraId1Type, xtraId1Value) VALUES ('"
+ userId + "','"
+ System.currentTimeMillis() + "" + title + ""
+ (body != null ? "" + body + "" : "") + "','"
@@ -385,18 +290,12 @@ public class OpenSocialManager {
stmt.executeUpdate(sqlCommand);
} finally {
try {
- if (stmt != null) {
- stmt.close();
- }
+ stmt.close();
} catch (Exception e) {
- e.printStackTrace();
}
try {
- if (conn != null) {
- conn.close();
- }
+ conn.close();
} catch (Exception e) {
- e.printStackTrace();
}
}
@@ -427,22 +326,20 @@ public class OpenSocialManager {
// The following will block until the page is transmitted.
while ((bytes = s.getInputStream().read(bytesReceived)) > 0) {
page += new String(bytesReceived, 0, bytes);
- }
+ };
return page;
}
public String getContainerJavascriptSrc() {
return configuration.getProperty(SHINDIG_URL_PROP)
- + "/gadgets/js/core:dynamic-height:osapi:pubsub:rpc:views:shindig-container.js?c=1"
+ + "/gadgets/js/core:dynamic-height:osapi:pubsub:rpc:views:rdf:shindig-container.js?c=1"
+ (isDebug ? "&debug=1" : "");
}
public String getGadgetJavascript() {
String lineSeparator = System.getProperty("line.separator");
- String gadgetScriptText = lineSeparator
- + "var my = {};"
- + lineSeparator
+ String gadgetScriptText = "var my = {};" + lineSeparator
+ "my.gadgetSpec = function(appId, name, url, secureToken, view, closed_width, open_width, start_closed, chrome_id, visible_scope) {"
+ lineSeparator + "this.appId = appId;" + lineSeparator
+ "this.name = name;" + lineSeparator + "this.url = url;"
@@ -480,4 +377,98 @@ public class OpenSocialManager {
return gadgetScriptText;
}
+
+ Map getAllDBGadgets(boolean useCache) throws SQLException
+ {
+ // great place to add cache
+ // check cache first
+ Map allDBGadgets = useCache ? gadgetCache : null;
+ if (allDBGadgets == null) {
+ allDBGadgets = new HashMap();
+ Connection conn = null;
+ Statement stmt = null;
+ ResultSet rset = null;
+ try {
+
+ String sqlCommand = "select appId, name, url, channels, enabled from orng_apps";
+
+ conn = dataSource.getConnection();
+ stmt = conn.createStatement();
+ rset = stmt.executeQuery(sqlCommand);
+
+ while (rset.next()) {
+ String channelsStr = rset.getString(4);
+ List channels = Arrays.asList(channelsStr != null && channelsStr.length() > 0 ? channelsStr.split(" ") : new String[0]);
+ GadgetSpec spec = new GadgetSpec(rset.getInt(1),
+ rset.getString(2), rset.getString(3), channels, dataSource, rset.getBoolean(5), false);
+ String gadgetFileName = getGadgetFileNameFromURL(rset.getString(3));
+
+ allDBGadgets.put(gadgetFileName, spec);
+ }
+ }
+ finally {
+ try {
+ rset.close();
+ } catch (Exception e) {
+ }
+ try {
+ stmt.close();
+ } catch (Exception e) {
+ }
+ try {
+ conn.close();
+ } catch (Exception e) {
+ }
+ }
+ if (useCache) {
+ gadgetCache = allDBGadgets;
+ }
+ }
+
+ return allDBGadgets;
+ }
+
+ private List getSandboxGadgets(VitroRequest vreq, Map allDBGadgets, String requestAppId) throws SQLException, IOException {
+ List sandboxGadgets = new ArrayList();
+ // Note that this block of code only gets executed after someone fills in the
+ // gadget/sandbox form!
+ String openSocialGadgetURLS = (String) vreq.getSession()
+ .getAttribute(OPENSOCIAL_GADGETS);
+ String[] urls = openSocialGadgetURLS.split(System.getProperty("line.separator"));
+ for (String openSocialGadgetURL : urls) {
+ if (openSocialGadgetURL.length() == 0)
+ continue;
+ int appId = 0; // if URL matches one in the DB, use DB provided
+ // appId, otherwise generate one
+ String gadgetFileName = getGadgetFileNameFromURL(openSocialGadgetURL);
+ String name = gadgetFileName;
+ List channels = new ArrayList();
+ boolean unknownGadget = true;
+ if (allDBGadgets.containsKey(gadgetFileName)) {
+ appId = allDBGadgets.get(gadgetFileName).getAppId();
+ name = allDBGadgets.get(gadgetFileName).getName();
+ channels = allDBGadgets.get(gadgetFileName).getChannels();
+ unknownGadget = false;
+ } else {
+ appId = openSocialGadgetURL.hashCode();
+ }
+ // if they asked for a specific one, only let it in
+ if (requestAppId != null && Integer.parseInt(requestAppId) != appId) {
+ continue;
+ }
+ GadgetSpec gadget = new GadgetSpec(appId, name,
+ openSocialGadgetURL, channels, dataSource, true, unknownGadget);
+ // only add ones that are visible in this context!
+ int moduleId = 0;
+ if (unknownGadget
+ || gadget.show(viewerId, ownerId, pageName, dataSource)) {
+ String securityToken = socketSendReceive(viewerId, ownerId,
+ "" + gadget.getAppId());
+ sandboxGadgets.add(new PreparedGadget(gadget, this, moduleId++,
+ securityToken));
+ }
+ }
+ return sandboxGadgets;
+
+ }
}
diff --git a/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialSmokeTests.java b/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialSmokeTests.java
index 76a9b54e5..81b2cc997 100644
--- a/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialSmokeTests.java
+++ b/webapp/src/edu/ucsf/vitro/opensocial/OpenSocialSmokeTests.java
@@ -44,7 +44,7 @@ public class OpenSocialSmokeTests implements ServletContextListener {
private static final String PROPERTY_DB_USERNAME = "VitroConnection.DataSource.username";
private static final String PROPERTY_DB_PASSWORD = "VitroConnection.DataSource.password";
- private static final String FILENAME_SHINDIG_PROPERTIES = "shindig.orng.properties";
+ private static final String FILENAME_SHINDIG_PROPERTIES = "shindigorng.properties";
/*
* If a connection fails in the tester thread, how long do we wait before
@@ -133,7 +133,7 @@ public class OpenSocialSmokeTests implements ServletContextListener {
conn = dataSource.getConnection();
stmt = conn.createStatement();
- rset = stmt.executeQuery("select * from shindig_apps");
+ rset = stmt.executeQuery("select * from orng_apps");
} catch (NoSuchPropertyException e) {
warnings.add(new Warning(e.getMessage()));
} catch (SQLException e) {
@@ -182,8 +182,7 @@ public class OpenSocialSmokeTests implements ServletContextListener {
message += "Has the Tomcat classpath been set to include the "
+ "Shindig config directory? "
+ "(inside the Vitro home directory) ";
- message += "Was the openSocial build script run? "
- + "('ant -file openSocialBuild.xml')";
+ message += "Was the openSocial build script run? ('ant orng')";
warnings.add(new Warning(message));
}
}
@@ -346,12 +345,14 @@ public class OpenSocialSmokeTests implements ServletContextListener {
private static final int SOCKET_TIMEOUT_STATUS = -500;
private final String shindigBaseUrl;
+ private final String shindigTestUrl;
private final HttpClient httpClient = new HttpClient();
private int statusCode = Integer.MIN_VALUE;
public ShindigTester(String shindigBaseUrl) {
this.shindigBaseUrl = shindigBaseUrl;
+ this.shindigTestUrl = shindigBaseUrl + "/rest/appdata";
}
public void connect() throws ShindigTesterException {
@@ -368,12 +369,12 @@ public class OpenSocialSmokeTests implements ServletContextListener {
}
if (statusCode != HttpStatus.SC_OK) {
- throw new ShindigTesterException(statusCode);
+ throw new ShindigTesterException(statusCode, shindigBaseUrl,
+ shindigTestUrl);
}
}
private void testConnection() throws ShindigTesterException {
- String shindigTestUrl = shindigBaseUrl + "/rest/activities";
GetMethod method = new GetMethod(shindigTestUrl);
try {
log.debug("Trying to connect to Shindig");
@@ -388,7 +389,8 @@ public class OpenSocialSmokeTests implements ServletContextListener {
// Save the status so we know why we failed.
statusCode = SOCKET_TIMEOUT_STATUS;
} catch (Exception e) {
- throw new ShindigTesterException(e);
+ throw new ShindigTesterException(e, shindigBaseUrl,
+ shindigTestUrl);
} finally {
method.releaseConnection();
}
@@ -415,14 +417,18 @@ public class OpenSocialSmokeTests implements ServletContextListener {
protected static class ShindigTesterException extends Exception {
private final int httpStatusCode;
- protected ShindigTesterException(Integer httpStatusCode) {
- super("Failed to connect to the Shindig service. "
+ protected ShindigTesterException(Integer httpStatusCode,
+ String baseUrl, String testUrl) {
+ super("Failed to connect to the Shindig service at '" + baseUrl
+ + "' (tried for a response at '" + testUrl + "'). "
+ "status code was " + httpStatusCode);
this.httpStatusCode = httpStatusCode;
}
- protected ShindigTesterException(Throwable cause) {
- super("Failed to connect to the Shindig service.", cause);
+ protected ShindigTesterException(Throwable cause, String baseUrl,
+ String testUrl) {
+ super("Failed to connect to the Shindig service at '" + baseUrl
+ + "' (tried for a response at '" + testUrl + "').", cause);
this.httpStatusCode = Integer.MIN_VALUE;
}
diff --git a/webapp/web/WEB-INF/web.xml b/webapp/web/WEB-INF/web.xml
index 85e3375d0..082e182b6 100644
--- a/webapp/web/WEB-INF/web.xml
+++ b/webapp/web/WEB-INF/web.xml
@@ -1327,13 +1327,10 @@
GadgetController
- /gadget
-
-
- GadgetController
- /gadget/sandbox
+ /orng/*
+
diff --git a/webapp/web/js/openSocial/shindig.js b/webapp/web/js/openSocial/orng.js
similarity index 88%
rename from webapp/web/js/openSocial/shindig.js
rename to webapp/web/js/openSocial/orng.js
index b4ca23091..26a8e65ec 100644
--- a/webapp/web/js/openSocial/shindig.js
+++ b/webapp/web/js/openSocial/orng.js
@@ -1,457 +1,457 @@
-/*
- Profiles Shindig Helper functions for gadget-to-container commands
-
- */
-
- // dummy function so google analytics does not break for institutions who do not use it
-
-_gaq = {};
-_gaq.push = function(data) { //
- };
-
-// pubsub
-gadgets.pubsubrouter.init(function(id) {
- return my.gadgets[shindig.container.gadgetService.getGadgetIdFromModuleId(id)].url;
- }, {
- onSubscribe: function(sender, channel) {
- setTimeout("my.onSubscribe('" + sender + "', '" + channel + "')", 3000);
- // return true to reject the request.
- return false;
- },
- onUnsubscribe: function(sender, channel) {
- //alert(sender + " unsubscribes from channel '" + channel + "'");
- // return true to reject the request.
- return false;
- },
- onPublish: function(sender, channel, message) {
- // return true to reject the request.
-
- // track with google analytics
- if (sender != '..' ) {
- var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(sender);
- }
-
- if (channel == 'VISIBLE') {
- var statusId = document.getElementById(sender + '_status');
- if (statusId) {
- // only act on these in HOME view since they are only meant to be seen when viewer=owner
- if (my.gadgets[moduleId].view != 'home') {
- return true;
- }
- if (message == 'Y') {
-/* statusId.style.color = 'GREEN';
- statusId.innerHTML = 'This section is VISIBLE';
- if (my.gadgets[moduleId].visible_scope == 'U') {
- statusId.innerHTML += ' to UCSF';
- }
- else {
- statusId.innerHTML += ' to the public';
- }
-*/
- /* changed the gui here -- tlw72 */
- statusId.style.color = '#5e6363';
- statusId.innerHTML = 'public';
- }
- else {
-/* statusId.style.color = '#CC0000';
- statusId.innerHTML = 'This section is HIDDEN';
- if (my.gadgets[moduleId].visible_scope == 'U') {
- statusId.innerHTML += ' from UCSF';
- }
- else {
- statusId.innerHTML += ' from the public';
- }
-*/
- /* changed the gui here -- tlw72 */
- statusId.style.color = '#5e6363';
- statusId.innerHTML = 'private';
- }
- }
- }
- else if (channel == 'added' && my.gadgets[moduleId].view == 'home') {
- if (message == 'Y') {
- _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'SHOW', 'profile_edit_view']);
- osapi.activities.create(
- { 'userId': gadgets.util.getUrlParameters()['Person'],
- '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){});
- }
- else {
- _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'HIDE', 'profile_edit_view']);
- }
- }
- else if (channel == 'status') {
- // message should be of the form 'COLOR:Message Content'
- var statusId = document.getElementById(sender + '_status');
- if (statusId) {
- var messageSplit = message.split(':');
- if (messageSplit.length == 2) {
- statusId.style.color = messageSplit[0];
- statusId.innerHTML = messageSplit[1];
- }
- else {
- statusId.innerHTML = message;
- }
- }
- }
- else if (channel == 'analytics') {
- // publish to google analytics
- // message should be JSON encoding object with required action and optional label and value
- // as documented here: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
- // note that event category will be set to the gadget name automatically by this code
- // Note: message will be already converted to an object
- if (message.hasOwnProperty('value')) {
- _gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action, message.label, message.value]);
- }
- else if (message.hasOwnProperty('label')) {
- _gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action, message.label]);
- }
- else {
- _gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action]);
- }
- }
- else if (channel == 'profile') {
- _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'go_to_profile', message]);
- document.location.href = '/' + location.pathname.split('/')[1] + '/display/n' + message;
- }
- else if (channel == 'JSONPersonIds' || channel == 'JSONPubMedIds') {
- // do nothing, no need to alert
- }
- else {
- alert(sender + " publishes '" + message + "' to channel '" + channel + "'");
- }
- return false;
- }
-});
-
-// helper functions
-my.findGadgetsAttachingTo = function(chromeId) {
- var retval = [];
- for (var i = 0; i < my.gadgets.length; i++) {
- if (my.gadgets[i].chrome_id == chromeId) {
- retval[retval.length] = my.gadgets[i];
- }
- }
- return retval;
-};
-
-my.removeGadgets = function(gadgetsToRemove) {
- for (var i = 0; i < gadgetsToRemove.length; i++) {
- for (var j = 0; j < my.gadgets.length; j++) {
- if (gadgetsToRemove[i].url == my.gadgets[j].url) {
- my.gadgets.splice(j, 1);
- break;
- }
- }
- }
-};
-
-my.onSubscribe = function(sender, channel) {
- // lookup pubsub data based on channel and if a match is found, publish the data to that channel after a delay
- if (my.pubsubData[channel]) {
- gadgets.pubsubrouter.publish(channel, my.pubsubData[channel]);
- }
- else {
- alert(sender + " subscribes to channel '" + channel + "'");
- }
- //PageMethods.onSubscribe(sender, channel, my.pubsubHint, my.CallSuccess, my.CallFailed);
-};
-
-my.removeParameterFromURL = function(url, parameter) {
- var urlparts= url.split('?'); // prefer to use l.search if you have a location/link object
- if (urlparts.length>=2) {
- var prefix= encodeURIComponent(parameter)+'=';
- var pars= urlparts[1].split(/[&;]/g);
- for (var i= pars.length; i-->0;) //reverse iteration as may be destructive
- if (pars[i].lastIndexOf(prefix, 0)!==-1) //idiom for string.startsWith
- pars.splice(i, 1);
- url= urlparts[0]+'?'+pars.join('&');
- }
- return url;
-};
-
- // publish the people
-my.CallSuccess = function(result) {
- gadgets.pubsubrouter.publish('person', result);
-};
-
- // alert message on some failure
-my.CallFailed = function(error) {
- alert(error.get_message());
-};
-
-my.requestGadgetMetaData = function(view, opt_callback) {
- var request = {
- context: {
- country: "default",
- language: "default",
- view: view,
- ignoreCache : my.noCache,
- container: "default"
- },
- gadgets: []
- };
-
- for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
- // only add those with matching views
- if (my.gadgets[moduleId].view == view) {
- request.gadgets[request.gadgets.length] = {'url': my.gadgets[moduleId].url, 'moduleId': moduleId};
- }
- }
-
- var makeRequestParams = {
- "CONTENT_TYPE" : "JSON",
- "METHOD" : "POST",
- "POST_DATA" : gadgets.json.stringify(request)};
-
- gadgets.io.makeNonProxiedRequest(my.openSocialURL + "/gadgets/metadata",
- function(data) {
- data = data.data;
- if (opt_callback) {
- opt_callback(data);
- }
- },
- makeRequestParams,
- "application/javascript"
- );
-};
-
-my.renderableGadgets = [];
-
-my.generateGadgets = function(metadata) {
- // put them in moduleId order
- for (var i = 0; i < metadata.gadgets.length; i++) {
- var moduleId = metadata.gadgets[i].moduleId;
- // Notes by Eric. Not sure if I should have to calculate this myself, but I will.
- var height = metadata.gadgets[i].height;
- var width = metadata.gadgets[i].width;
- var viewPrefs = metadata.gadgets[i].views[my.gadgets[moduleId].view];
- if (viewPrefs) {
- height = viewPrefs.preferredHeight || height;
- width = viewPrefs.preferredWidth || width;
- }
- my.renderableGadgets[moduleId] = shindig.container.createGadget({'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
- 'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs,
- 'height': height, 'width': width, 'debug': my.debug});
- // set the metadata for easy access
- my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]);
- }
- // this will be called multiple times, only render when all gadgets have been processed
- var ready = my.renderableGadgets.length == my.gadgets.length;
- for (var i = 0; ready && i < my.renderableGadgets.length; i++) {
- if (!my.renderableGadgets[i]) {
- ready = false;
- }
- }
-
- if (ready) {
- shindig.container.addGadgets(my.renderableGadgets );
- shindig.container.renderGadgets();
- }
-};
-
-my.init = function() {
- // overwrite this RPC function. Do it at this level so that rpc.f (this.f) is accessible for getting module ID
-// gadgets.rpc.register('requestNavigateTo', doProfilesNavigation);
-
- shindig.container.gadgetClass = ProfilesGadget;
- shindig.container.layoutManager = new ProfilesLayoutManager();
- shindig.container.setNoCache(my.noCache);
- shindig.container.gadgetService = new ProfilesGadgetService();
-
- // since we render multiple views, we need to do somethign fancy by swapping out this value in getIframeUrl
- shindig.container.setView('REPLACE_THIS_VIEW');
-
- // do multiple times as needed if we have multiple views
- // find out what views are being used and call requestGadgetMetaData for each one
- var views = {};
- for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
- var view = my.gadgets[moduleId].view;
- if (!views[view]) {
- views[view] = view;
- my.requestGadgetMetaData(view, my.generateGadgets);
- }
- }
-};
-
-// ProfilesGadgetService
-
-ProfilesGadgetService = function() {
- shindig.IfrGadgetService.call(this);
-};
-
-ProfilesGadgetService.inherits(shindig.IfrGadgetService);
-
-ProfilesGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
- var urlTemplate = gadgets.config.get('views')[view].urlTemplate;
- var url = urlTemplate || 'OpenSocial.aspx?';
-
- url += window.location.search.substring(1);
-
- // remove appId if present
- url = my.removeParameterFromURL(url, 'appId');
-
- // Add appId if the URL Template begins with the word 'gadget'
- if (urlTemplate.toLowerCase().indexOf('gadget') == 0) {
- var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
- var appId = my.gadgets[moduleId].appId;
- url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appId=' + appId;
- }
-
- if (opt_params) {
- var paramStr = gadgets.json.stringify(opt_params);
- if (paramStr.length > 0) {
- url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appParams=' + encodeURIComponent(paramStr);
- }
- }
- if (url && document.location.href.indexOf(url) == -1) {
- document.location.href = url;
- }
-};
-
-// ProfilesGadget
-
-ProfilesGadget = function(opt_params) {
- shindig.Gadget.call(this, opt_params);
- this.debug = my.debug;
- this.serverBase_ = my.openSocialURL + "/gadgets/";
- var gadget = this;
- var subClass = shindig.IfrGadget;
- this.metadata = {};
- for (var name in subClass) if (subClass.hasOwnProperty(name)) {
- if (name == 'getIframeUrl') {
- // we need to keep this old one
- gadget['originalGetIframeUrl'] = subClass[name];
- }
- else if (name != 'finishRender') {
- gadget[name] = subClass[name];
- }
- }
-};
-
-ProfilesGadget.inherits(shindig.BaseIfrGadget);
-
-ProfilesGadget.prototype.setMetadata = function(metadata) {
- this.metadata = metadata;
-};
-
-ProfilesGadget.prototype.hasFeature = function(feature) {
- for (var i = 0; i < this.metadata.features.length; i++) {
- if (this.metadata.features[i] == feature) {
- return true;
- }
- }
- return false;
-};
-
-ProfilesGadget.prototype.getAdditionalParams = function() {
- var params = '';
- for (var key in my.gadgets[this.id].additionalParams) {
- params += '&' + key + '=' + my.gadgets[this.id].additionalParams[key];
- }
- return params;
-};
-
-ProfilesGadget.prototype.finishRender = function(chrome) {
- window.frames[this.getIframeId()].location = this.getIframeUrl();
- if (my.gadgets[this.id].start_closed) {
- this.handleToggle();
- }
- else if (chrome) {
- // set the gadget box width, and remember that we always render as open
- chrome.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
- }
-};
-
-ProfilesGadget.prototype.getIframeUrl = function() {
- var url = this.originalGetIframeUrl();
- return url.replace('REPLACE_THIS_VIEW', my.gadgets[this.id].view);
-};
-
-ProfilesGadget.prototype.handleToggle = function() {
- var gadgetIframe = document.getElementById(this.getIframeId());
- if (gadgetIframe) {
- var gadgetContent = gadgetIframe.parentNode;
- var gadgetImg = document.getElementById('gadgets-gadget-title-image-' + this.id);
- if (gadgetContent.style.display) {
- //OPEN
- gadgetContent.parentNode.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
- gadgetContent.style.display = '';
- gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_minus_sign.gif';
- // refresh if certain features require so
- //if (this.hasFeature('dynamic-height')) {
- if (my.gadgets[this.id].chrome_id == 'gadgets-search') {
- this.refresh();
- document.getElementById(this.getIframeId()).contentWindow.location.reload(true);
- }
-
- if (my.gadgets[this.id].view == 'home') {
- // record in google analytics
- _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN_IN_EDIT', 'profile_edit_view']);
- }
- else {
- osapi.activities.create(
- { 'userId': gadgets.util.getUrlParameters()['Person'],
- '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){});
- // record in google analytics
- _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN']);
- }
- }
- else {
- //CLOSE
- gadgetContent.parentNode.style.width = (my.gadgets[this.id].closed_width || 600) + 'px';
- gadgetContent.style.display = 'none';
- gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_plus_sign.gif';
- if (my.gadgets[this.id].view == 'home') {
- // record in google analytics
- _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE_IN_EDIT', 'profile_edit_view']);
- }
- else {
- // record in google analytics
- _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE']);
- }
- }
- }
-};
-
-ProfilesGadget.prototype.getTitleBarContent = function(continuation) {
- if (my.gadgets[this.id].view == 'canvas') {
- document.getElementById("gadgets-title").innerHTML = (this.title ? this.title : 'Gadget');
- continuation('');
- }
- else {
- continuation(
- '');
- }
-};
-
-// ProfilesLayoutManager. Creates a FloatLeftLayoutManager for every chromeId in our gadgets
-ProfilesLayoutManager = function() {
- shindig.LayoutManager.call(this);
- // find out what chromeId's are being used, create a FloatLeftLayoutManager for each
- this.layoutManagers = {};
- for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
- var chromeId = my.gadgets[moduleId].chrome_id;
- if (!this.layoutManagers[chromeId]) {
- this.layoutManagers[chromeId] = new shindig.FloatLeftLayoutManager(chromeId);
- }
- }
-};
-
-ProfilesLayoutManager.inherits(shindig.LayoutManager);
-
-ProfilesLayoutManager.prototype.getGadgetChrome = function(gadget) {
- return this.layoutManagers[my.gadgets[gadget.id].chrome_id].getGadgetChrome(gadget);
+/*
+ ORNG Shindig Helper functions for gadget-to-container commands
+
+ */
+
+ // dummy function so google analytics does not break for institutions who do not use it
+
+_gaq = {};
+_gaq.push = function(data) { //
+ };
+
+// pubsub
+gadgets.pubsubrouter.init(function(id) {
+ return my.gadgets[shindig.container.gadgetService.getGadgetIdFromModuleId(id)].url;
+ }, {
+ onSubscribe: function(sender, channel) {
+ setTimeout("my.onSubscribe('" + sender + "', '" + channel + "')", 3000);
+ // return true to reject the request.
+ return false;
+ },
+ onUnsubscribe: function(sender, channel) {
+ //alert(sender + " unsubscribes from channel '" + channel + "'");
+ // return true to reject the request.
+ return false;
+ },
+ onPublish: function(sender, channel, message) {
+ // return true to reject the request.
+
+ // track with google analytics
+ if (sender != '..' ) {
+ var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(sender);
+ }
+
+ if (channel == 'VISIBLE') {
+ var statusId = document.getElementById(sender + '_status');
+ if (statusId) {
+ // only act on these in HOME view since they are only meant to be seen when viewer=owner
+ if (my.gadgets[moduleId].view != 'home') {
+ return true;
+ }
+ if (message == 'Y') {
+/* statusId.style.color = 'GREEN';
+ statusId.innerHTML = 'This section is VISIBLE';
+ if (my.gadgets[moduleId].visible_scope == 'U') {
+ statusId.innerHTML += ' to UCSF';
+ }
+ else {
+ statusId.innerHTML += ' to the public';
+ }
+*/
+ /* changed the gui here -- tlw72 */
+ statusId.style.color = '#5e6363';
+ statusId.innerHTML = 'public';
+ }
+ else {
+/* statusId.style.color = '#CC0000';
+ statusId.innerHTML = 'This section is HIDDEN';
+ if (my.gadgets[moduleId].visible_scope == 'U') {
+ statusId.innerHTML += ' from UCSF';
+ }
+ else {
+ statusId.innerHTML += ' from the public';
+ }
+*/
+ /* changed the gui here -- tlw72 */
+ statusId.style.color = '#5e6363';
+ statusId.innerHTML = 'private';
+ }
+ }
+ }
+ else if (channel == 'added' && my.gadgets[moduleId].view == 'home') {
+ if (message == 'Y') {
+ _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'SHOW', 'profile_edit_view']);
+ osapi.activities.create(
+ { 'userId': gadgets.util.getUrlParameters()['Person'],
+ '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){});
+ }
+ else {
+ _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'HIDE', 'profile_edit_view']);
+ }
+ }
+ else if (channel == 'status') {
+ // message should be of the form 'COLOR:Message Content'
+ var statusId = document.getElementById(sender + '_status');
+ if (statusId) {
+ var messageSplit = message.split(':');
+ if (messageSplit.length == 2) {
+ statusId.style.color = messageSplit[0];
+ statusId.innerHTML = messageSplit[1];
+ }
+ else {
+ statusId.innerHTML = message;
+ }
+ }
+ }
+ else if (channel == 'analytics') {
+ // publish to google analytics
+ // message should be JSON encoding object with required action and optional label and value
+ // as documented here: http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
+ // note that event category will be set to the gadget name automatically by this code
+ // Note: message will be already converted to an object
+ if (message.hasOwnProperty('value')) {
+ _gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action, message.label, message.value]);
+ }
+ else if (message.hasOwnProperty('label')) {
+ _gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action, message.label]);
+ }
+ else {
+ _gaq.push(['_trackEvent', my.gadgets[moduleId].name, message.action]);
+ }
+ }
+ else if (channel == 'profile') {
+ _gaq.push(['_trackEvent', my.gadgets[moduleId].name, 'go_to_profile', message]);
+ document.location.href = '/' + location.pathname.split('/')[1] + '/display/n' + message;
+ }
+ else if (channel == 'JSONPersonIds' || channel == 'JSONPubMedIds') {
+ // do nothing, no need to alert
+ }
+ else {
+ alert(sender + " publishes '" + message + "' to channel '" + channel + "'");
+ }
+ return false;
+ }
+});
+
+// helper functions
+my.findGadgetsAttachingTo = function(chromeId) {
+ var retval = [];
+ for (var i = 0; i < my.gadgets.length; i++) {
+ if (my.gadgets[i].chrome_id == chromeId) {
+ retval[retval.length] = my.gadgets[i];
+ }
+ }
+ return retval;
+};
+
+my.removeGadgets = function(gadgetsToRemove) {
+ for (var i = 0; i < gadgetsToRemove.length; i++) {
+ for (var j = 0; j < my.gadgets.length; j++) {
+ if (gadgetsToRemove[i].url == my.gadgets[j].url) {
+ my.gadgets.splice(j, 1);
+ break;
+ }
+ }
+ }
+};
+
+my.onSubscribe = function(sender, channel) {
+ // lookup pubsub data based on channel and if a match is found, publish the data to that channel after a delay
+ if (my.pubsubData[channel]) {
+ gadgets.pubsubrouter.publish(channel, my.pubsubData[channel]);
+ }
+ else {
+ alert(sender + " subscribes to channel '" + channel + "'");
+ }
+ //PageMethods.onSubscribe(sender, channel, my.pubsubHint, my.CallSuccess, my.CallFailed);
+};
+
+my.removeParameterFromURL = function(url, parameter) {
+ var urlparts= url.split('?'); // prefer to use l.search if you have a location/link object
+ if (urlparts.length>=2) {
+ var prefix= encodeURIComponent(parameter)+'=';
+ var pars= urlparts[1].split(/[&;]/g);
+ for (var i= pars.length; i-->0;) //reverse iteration as may be destructive
+ if (pars[i].lastIndexOf(prefix, 0)!==-1) //idiom for string.startsWith
+ pars.splice(i, 1);
+ url= urlparts[0]+'?'+pars.join('&');
+ }
+ return url;
+};
+
+ // publish the people
+my.CallSuccess = function(result) {
+ gadgets.pubsubrouter.publish('person', result);
+};
+
+ // alert message on some failure
+my.CallFailed = function(error) {
+ alert(error.get_message());
+};
+
+my.requestGadgetMetaData = function(view, opt_callback) {
+ var request = {
+ context: {
+ country: "default",
+ language: "default",
+ view: view,
+ ignoreCache : my.noCache,
+ container: "default"
+ },
+ gadgets: []
+ };
+
+ for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
+ // only add those with matching views
+ if (my.gadgets[moduleId].view == view) {
+ request.gadgets[request.gadgets.length] = {'url': my.gadgets[moduleId].url, 'moduleId': moduleId};
+ }
+ }
+
+ var makeRequestParams = {
+ "CONTENT_TYPE" : "JSON",
+ "METHOD" : "POST",
+ "POST_DATA" : gadgets.json.stringify(request)};
+
+ gadgets.io.makeNonProxiedRequest(my.openSocialURL + "/gadgets/metadata",
+ function(data) {
+ data = data.data;
+ if (opt_callback) {
+ opt_callback(data);
+ }
+ },
+ makeRequestParams,
+ "application/javascript"
+ );
+};
+
+my.renderableGadgets = [];
+
+my.generateGadgets = function(metadata) {
+ // put them in moduleId order
+ for (var i = 0; i < metadata.gadgets.length; i++) {
+ var moduleId = metadata.gadgets[i].moduleId;
+ // Notes by Eric. Not sure if I should have to calculate this myself, but I will.
+ var height = metadata.gadgets[i].height;
+ var width = metadata.gadgets[i].width;
+ var viewPrefs = metadata.gadgets[i].views[my.gadgets[moduleId].view];
+ if (viewPrefs) {
+ height = viewPrefs.preferredHeight || height;
+ width = viewPrefs.preferredWidth || width;
+ }
+ my.renderableGadgets[moduleId] = shindig.container.createGadget({'specUrl': metadata.gadgets[i].url, 'secureToken': my.gadgets[moduleId].secureToken,
+ 'title': metadata.gadgets[i].title, 'userPrefs': metadata.gadgets[i].userPrefs,
+ 'height': height, 'width': width, 'debug': my.debug});
+ // set the metadata for easy access
+ my.renderableGadgets[moduleId].setMetadata(metadata.gadgets[i]);
+ }
+ // this will be called multiple times, only render when all gadgets have been processed
+ var ready = my.renderableGadgets.length == my.gadgets.length;
+ for (var i = 0; ready && i < my.renderableGadgets.length; i++) {
+ if (!my.renderableGadgets[i]) {
+ ready = false;
+ }
+ }
+
+ if (ready) {
+ shindig.container.addGadgets(my.renderableGadgets );
+ shindig.container.renderGadgets();
+ }
+};
+
+my.init = function() {
+ // overwrite this RPC function. Do it at this level so that rpc.f (this.f) is accessible for getting module ID
+// gadgets.rpc.register('requestNavigateTo', doOrngNavigation);
+
+ shindig.container.gadgetClass = OrngGadget;
+ shindig.container.layoutManager = new OrngLayoutManager();
+ shindig.container.setNoCache(my.noCache);
+ shindig.container.gadgetService = new OrngGadgetService();
+
+ // since we render multiple views, we need to do somethign fancy by swapping out this value in getIframeUrl
+ shindig.container.setView('REPLACE_THIS_VIEW');
+
+ // do multiple times as needed if we have multiple views
+ // find out what views are being used and call requestGadgetMetaData for each one
+ var views = {};
+ for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
+ var view = my.gadgets[moduleId].view;
+ if (!views[view]) {
+ views[view] = view;
+ my.requestGadgetMetaData(view, my.generateGadgets);
+ }
+ }
+};
+
+// OrngGadgetService
+
+OrngGadgetService = function() {
+ shindig.IfrGadgetService.call(this);
+};
+
+OrngGadgetService.inherits(shindig.IfrGadgetService);
+
+OrngGadgetService.prototype.requestNavigateTo = function(view, opt_params) {
+ var viewConfig = gadgets.config.get('views')[view];
+ var url = viewConfig.urlTemplate;
+
+ url += window.location.search.substring(1);
+
+ // remove appId if present
+ url = my.removeParameterFromURL(url, 'appId');
+
+ // Add appId if isOnlyVisible is TRUE for this view
+ if (viewConfig.isOnlyVisible) {
+ var moduleId = shindig.container.gadgetService.getGadgetIdFromModuleId(this.f);
+ var appId = my.gadgets[moduleId].appId;
+ url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appId=' + appId;
+ }
+
+ if (opt_params) {
+ var paramStr = gadgets.json.stringify(opt_params);
+ if (paramStr.length > 0) {
+ url += (url.indexOf('?') != url.length - 1 ? '&' : '') + 'appParams=' + encodeURIComponent(paramStr);
+ }
+ }
+ if (url && document.location.href.indexOf(url) == -1) {
+ document.location.href = url;
+ }
+};
+
+// OrngGadget
+
+OrngGadget = function(opt_params) {
+ shindig.Gadget.call(this, opt_params);
+ this.debug = my.debug;
+ this.serverBase_ = my.openSocialURL + "/gadgets/";
+ var gadget = this;
+ var subClass = shindig.IfrGadget;
+ this.metadata = {};
+ for (var name in subClass) if (subClass.hasOwnProperty(name)) {
+ if (name == 'getIframeUrl') {
+ // we need to keep this old one
+ gadget['originalGetIframeUrl'] = subClass[name];
+ }
+ else if (name != 'finishRender') {
+ gadget[name] = subClass[name];
+ }
+ }
+};
+
+OrngGadget.inherits(shindig.BaseIfrGadget);
+
+OrngGadget.prototype.setMetadata = function(metadata) {
+ this.metadata = metadata;
+};
+
+OrngGadget.prototype.hasFeature = function(feature) {
+ for (var i = 0; i < this.metadata.features.length; i++) {
+ if (this.metadata.features[i] == feature) {
+ return true;
+ }
+ }
+ return false;
+};
+
+OrngGadget.prototype.getAdditionalParams = function() {
+ var params = '';
+ for (var key in my.gadgets[this.id].additionalParams) {
+ params += '&' + key + '=' + my.gadgets[this.id].additionalParams[key];
+ }
+ return params;
+};
+
+OrngGadget.prototype.finishRender = function(chrome) {
+ window.frames[this.getIframeId()].location = this.getIframeUrl();
+ if (my.gadgets[this.id].start_closed) {
+ this.handleToggle();
+ }
+ else if (chrome) {
+ // set the gadget box width, and remember that we always render as open
+ chrome.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
+ }
+};
+
+OrngGadget.prototype.getIframeUrl = function() {
+ var url = this.originalGetIframeUrl();
+ return url.replace('REPLACE_THIS_VIEW', my.gadgets[this.id].view);
+};
+
+OrngGadget.prototype.handleToggle = function() {
+ var gadgetIframe = document.getElementById(this.getIframeId());
+ if (gadgetIframe) {
+ var gadgetContent = gadgetIframe.parentNode;
+ var gadgetImg = document.getElementById('gadgets-gadget-title-image-' + this.id);
+ if (gadgetContent.style.display) {
+ //OPEN
+ gadgetContent.parentNode.style.width = (my.gadgets[this.id].open_width || 600) + 'px';
+ gadgetContent.style.display = '';
+ gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_minus_sign.gif';
+ // refresh if certain features require so
+ //if (this.hasFeature('dynamic-height')) {
+ if (my.gadgets[this.id].chrome_id == 'gadgets-search') {
+ this.refresh();
+ document.getElementById(this.getIframeId()).contentWindow.location.reload(true);
+ }
+
+ if (my.gadgets[this.id].view == 'home') {
+ // record in google analytics
+ _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN_IN_EDIT', 'profile_edit_view']);
+ }
+ else {
+ osapi.activities.create(
+ { 'userId': gadgets.util.getUrlParameters()['Person'],
+ '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){});
+ // record in google analytics
+ _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'OPEN']);
+ }
+ }
+ else {
+ //CLOSE
+ gadgetContent.parentNode.style.width = (my.gadgets[this.id].closed_width || 600) + 'px';
+ gadgetContent.style.display = 'none';
+ gadgetImg.src = '/' + location.pathname.split('/')[1] + '/themes/wilma/images/green_plus_sign.gif';
+ if (my.gadgets[this.id].view == 'home') {
+ // record in google analytics
+ _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE_IN_EDIT', 'profile_edit_view']);
+ }
+ else {
+ // record in google analytics
+ _gaq.push(['_trackEvent', my.gadgets[this.id].name, 'CLOSE']);
+ }
+ }
+ }
+};
+
+OrngGadget.prototype.getTitleBarContent = function(continuation) {
+ if (my.gadgets[this.id].view == 'canvas') {
+ document.getElementById("gadgets-title").innerHTML = (this.title ? this.title : 'Gadget');
+ continuation('');
+ }
+ else {
+ continuation(
+ '');
+ }
+};
+
+// OrngLayoutManager. Creates a FloatLeftLayoutManager for every chromeId in our gadgets
+OrngLayoutManager = function() {
+ shindig.LayoutManager.call(this);
+ // find out what chromeId's are being used, create a FloatLeftLayoutManager for each
+ this.layoutManagers = {};
+ for (var moduleId = 0; moduleId < my.gadgets.length; moduleId++) {
+ var chromeId = my.gadgets[moduleId].chrome_id;
+ if (!this.layoutManagers[chromeId]) {
+ this.layoutManagers[chromeId] = new shindig.FloatLeftLayoutManager(chromeId);
+ }
+ }
+};
+
+OrngLayoutManager.inherits(shindig.LayoutManager);
+
+OrngLayoutManager.prototype.getGadgetChrome = function(gadget) {
+ return this.layoutManagers[my.gadgets[gadget.id].chrome_id].getGadgetChrome(gadget);
};
\ No newline at end of file