Author: scottbw
Date: Fri Mar 25 09:34:55 2011
New Revision: 1085299
URL: http://svn.apache.org/viewvc?rev=1085299&view=rev
Log:
Added experimental OpenSocial API (osapi) feature to the scratchpad
Added:
incubator/wookie/trunk/scratchpad/osapi/
incubator/wookie/trunk/scratchpad/osapi/README
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/README
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/build.xml
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/shared/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/shared/osapi-appdata.js
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/osapi/
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/osapi/OsapiAppData.java
incubator/wookie/trunk/scratchpad/osapi/osapi.person/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/README
incubator/wookie/trunk/scratchpad/osapi/osapi.person/build.xml
incubator/wookie/trunk/scratchpad/osapi/osapi.person/shared/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/shared/osapi-person.js
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/osapi/
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/osapi/OsapiPeople.java
incubator/wookie/trunk/scratchpad/osapi/widgets/
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/config.xml
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/images/
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/images/icon.png
(with props)
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/index.html
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/legal/
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/lib/
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/scripts/
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/scripts/osapi.js
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/style/
Added: incubator/wookie/trunk/scratchpad/osapi/README
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/README?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/README (added)
+++ incubator/wookie/trunk/scratchpad/osapi/README Fri Mar 25 09:34:55 2011
@@ -0,0 +1,5 @@
+This is an experimental implementation of some parts of the OpenSocial
JavaScript API (OSAPI) in Wookie as a Feature extension.
+
+It works by mapping OSAPI calls onto existing Wookie functionality as used in
the Wave feature.
+
+Its very out of date (OSAPI 1.0) and needs a lot more work to be usable.
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/README
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/README?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/README (added)
+++ incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/README Fri Mar 25
09:34:55 2011
@@ -0,0 +1,4 @@
+This is an implementation of the OpenSocial 1.0 API for AppData
+
+It is a facade onto the existing sharedData functionality offered in Wookie,
and also
+exposed through the Wave feature.
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/build.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/build.xml?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/build.xml (added)
+++ incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/build.xml Fri Mar 25
09:34:55 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project default="build-feature" basedir="." name="feature build file">
+ <property name="wookie.features.dir" location="../"/>
+ <property name="feature.shortname" value="osapi.appdata"/>
+ <property name="feature.uri"
value="http://opensocial.org/osapi.appdata"/>
+ <import file="../build.xml"/>
+</project>
\ No newline at end of file
Added:
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/shared/osapi-appdata.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/shared/osapi-appdata.js?rev=1085299&view=auto
==============================================================================
---
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/shared/osapi-appdata.js
(added)
+++
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/shared/osapi-appdata.js
Fri Mar 25 09:34:55 2011
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+ var osapi = osapi || {};
+ osapi.appdata = {};
+
+ osapi.appdata.get = function(options) {
+ var returnObject = {};
+ var data = {};
+ if (options.keys){
+ for (idx in options.keys){
+ data[options.keys[idx]] =
wave.getState().get(options.keys[idx]);
+ }
+ } else {
+ data = wave.getState();
+ }
+ returnObject.execute = function(callback){
+ callback(data);
+ }
+ return returnObject;
+ };
+
+ osapi.appdata.update = function(options) {
+ var returnObject = {};
+ var data = options.data;
+
+ returnObject.execute = function(callback){
+ wave.getState().submitDelta(data);
+ osapi.appdata.__addCallback(callback);
+ }
+ return returnObject;
+ };
+
+
+ osapi.appdata.Delete = function(options) {
+ var returnObject = {};
+ var data = {};
+ if (options.keys){
+ for (idx in options.keys){
+ data[options.keys[idx]] = null;
+ }
+ }
+ returnObject.execute = function(callback){
+ wave.getState().submitDelta(data);
+ osapi.appdata.__addCallback(callback);
+ }
+ return returnObject;
+ };
+
+ // Push a callback onto the stack
+ osapi.appdata.__addCallback = function(callback){
+ osapi.appdata.callbacks = osapi.appdata.callbacks || [];
+ osapi.appdata.callbacks.push(callback);
+ }
+ // Call all callbacks when state updated
+ osapi.appdata.__updated = function(){
+ osapi.appdata.callbacks = osapi.appdata.callbacks || [];
+ while (osapi.appdata.callbacks.length > 0){
+ var callback = osapi.appdata.callbacks.pop();
+ setTimeout(callback,100);
+ }
+ }
+
+ wave.setStateCallback( osapi.appdata.__updated);
\ No newline at end of file
Added:
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/osapi/OsapiAppData.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/osapi/OsapiAppData.java?rev=1085299&view=auto
==============================================================================
---
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/osapi/OsapiAppData.java
(added)
+++
incubator/wookie/trunk/scratchpad/osapi/osapi.appdata/src/org/apache/wookie/feature/osapi/OsapiAppData.java
Fri Mar 25 09:34:55 2011
@@ -0,0 +1,24 @@
+package org.apache.wookie.feature.osapi;
+
+import org.apache.wookie.feature.IFeature;
+import org.apache.wookie.feature.wave.WaveAPIImpl;
+
+public class OsapiAppData implements IFeature {
+
+ public String getName() {
+ return "http://opensocial.org/osapi.appdata";
+ }
+
+ public String[] scripts() {
+ String[] waveScripts = new WaveAPIImpl().scripts();
+ String[] scripts = new String[waveScripts.length+1];
+ scripts[0] =
"/wookie/shared/feature/osapi.appdata/osapi-appdata.js";
+ System.arraycopy(waveScripts, 0, scripts, 1,
waveScripts.length);
+ return scripts;
+ }
+
+ public String[] stylesheets() {
+ return null;
+ }
+
+}
Added: incubator/wookie/trunk/scratchpad/osapi/osapi.person/README
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.person/README?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/osapi.person/README (added)
+++ incubator/wookie/trunk/scratchpad/osapi/osapi.person/README Fri Mar 25
09:34:55 2011
@@ -0,0 +1,4 @@
+This is an implementation of the OpenSocial 1.0 API for People
+
+It is a facade onto the existing participants functionality offered in Wookie,
and also
+exposed through the Wave feature.
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/osapi/osapi.person/build.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.person/build.xml?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/osapi.person/build.xml (added)
+++ incubator/wookie/trunk/scratchpad/osapi/osapi.person/build.xml Fri Mar 25
09:34:55 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+ 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.
+-->
+<project default="build-feature" basedir="." name="feature build file">
+ <property name="wookie.features.dir" location="../"/>
+ <property name="feature.shortname" value="osapi.person"/>
+ <property name="feature.uri"
value="http://opensocial.org/osapi.person"/>
+ <import file="../build.xml"/>
+</project>
\ No newline at end of file
Added:
incubator/wookie/trunk/scratchpad/osapi/osapi.person/shared/osapi-person.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.person/shared/osapi-person.js?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/osapi.person/shared/osapi-person.js
(added)
+++ incubator/wookie/trunk/scratchpad/osapi/osapi.person/shared/osapi-person.js
Fri Mar 25 09:34:55 2011
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+ var osapi = osapi || {};
+ osapi.people = {};
+
+ /**
+ * Function to get Viewer profile.
+ * Options specifies parameters to the call as outlined in the
+ * JSON RPC Opensocial Spec
+ *
http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
+ * @param {object.<JSON>} The JSON object of parameters for the specific
request
+ */
+ osapi.people.getViewer = function(options) {
+ var returnObject = {};
+ returnObject.execute = function(callback){
+ callback(wave.getViewer());
+ }
+ return returnObject;
+ };
+
+ /**
+ * Function to get Viewer's friends' profiles.
+ * Options specifies parameters to the call as outlined in the
+ * JSON RPC Opensocial Spec
+ *
http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
+ * @param {object.<JSON>} The JSON object of parameters for the specific
request
+ */
+ osapi.people.getViewerFriends = function(options) {
+ var returnObject = {};
+ returnObject.execute = function(callback){
+ callback(wave.getParticipants());
+ }
+ return returnObject;
+ };
+
+ /**
+ * Function to get Owner profile.
+ * Options specifies parameters to the call as outlined in the
+ * JSON RPC Opensocial Spec
+ *
http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
+ * @param {object.<JSON>} The JSON object of parameters for the specific
request
+ */
+ osapi.people.getOwner = function(options) {
+ var returnObject = {};
+ returnObject.execute = function(callback){
+ callback(wave.getHost());
+ }
+ return returnObject;
+ };
+
+ /**
+ * Function to get Owner's friends' profiles.
+ * Options specifies parameters to the call as outlined in the
+ * JSON RPC Opensocial Spec
+ *
http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
+ * @param {object.<JSON>} The JSON object of parameters for the specific
request
+ */
+ osapi.people.getOwnerFriends = function(options) {
+ var returnObject = {};
+ returnObject.execute = function(callback){
+ callback(wave.getParticipants());
+ }
+ return returnObject;
+ };
Added:
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/osapi/OsapiPeople.java
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/osapi/OsapiPeople.java?rev=1085299&view=auto
==============================================================================
---
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/osapi/OsapiPeople.java
(added)
+++
incubator/wookie/trunk/scratchpad/osapi/osapi.person/src/org/apache/wookie/feature/osapi/OsapiPeople.java
Fri Mar 25 09:34:55 2011
@@ -0,0 +1,24 @@
+package org.apache.wookie.feature.osapi;
+
+import org.apache.wookie.feature.IFeature;
+import org.apache.wookie.feature.wave.WaveAPIImpl;
+
+public class OsapiPeople implements IFeature {
+
+ public String getName() {
+ return "http://opensocial.org/osapi.person";
+ }
+
+ public String[] scripts() {
+ String[] waveScripts = new WaveAPIImpl().scripts();
+ String[] scripts = new String[waveScripts.length+1];
+ scripts[0] =
"/wookie/shared/feature/osapi.person/osapi-person.js";
+ System.arraycopy(waveScripts, 0, scripts, 1,
waveScripts.length);
+ return scripts;
+ }
+
+ public String[] stylesheets() {
+ return null;
+ }
+
+}
Added: incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/config.xml?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/config.xml (added)
+++ incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/config.xml Fri
Mar 25 09:34:55 2011
@@ -0,0 +1,48 @@
+<!--
+ 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.
+-->
+<widget xmlns="http://www.w3.org/ns/widgets"
+ id="http://wookie.apache.org/widgets/osapitest"
+ version="0.1"
+ width="200"
+ height="320"
+ >
+ <name>osapitest</name>
+ <description>testing osapi api</description>
+ <content src="index.html"/>
+ <icon src="images/icon.png"/>
+ <feature required="true" name="http://opensocial.org/osapi.person"/>
+ <feature required="true" name="http://opensocial.org/osapi.appdata"/>
+ <author>Apache Wookie (Incubating) Team</author>
+ <licence>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.</licence>
+
+</widget>
+
+
+
Added: incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/images/icon.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/images/icon.png?rev=1085299&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/images/icon.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/index.html
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/index.html?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/index.html (added)
+++ incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/index.html Fri
Mar 25 09:34:55 2011
@@ -0,0 +1,28 @@
+<!--
+ 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.
+-->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="pragma" content="no-cache"/>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>osapitest</title>
+ <script src="scripts/osapi.js"></script>
+ </head>
+ <body>
+ <h1>Hello World...</h1>
+ </body>
+</html>
\ No newline at end of file
Added:
incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/scripts/osapi.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/scripts/osapi.js?rev=1085299&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/scripts/osapi.js
(added)
+++ incubator/wookie/trunk/scratchpad/osapi/widgets/osapitest/scripts/osapi.js
Fri Mar 25 09:34:55 2011
@@ -0,0 +1,34 @@
+osapi.people.getViewer().execute(
+ function(viewer){
+ alert(viewer.getDisplayName());
+ }
+);
+
+
+function setMonkey(){
+ osapi.appdata.update({userId: '@viewer', data: {gifts: 'a crazed
monkey'}}).execute(
+ function(data){
+ alert("added");
+ getMonkey();
+ deleteMonkey();
+ }
+ );
+}
+
+function getMonkey(){
+osapi.appdata.get({userId: '@viewer', groupId: '@friends', keys:
['gifts']}).execute(
+ function(data){
+ alert(data['gifts']);
+ }
+);
+}
+
+function deleteMonkey(){
+osapi.appdata.Delete({keys: ['gifts']}).execute(
+ function(){
+ alert("deleted");
+ getMonkey();
+ }
+);
+}
+setMonkey();