You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by ds...@apache.org on 2013/10/28 23:05:12 UTC
svn commit: r1536540 [3/3] - in /incubator/streams/branches/webservice:
streams-components/src/main/java/org/apache/streams/components/storm/
streams-web/src/main/java/org/apache/streams/mvc/controller/
streams-web/src/main/webapp/demo/ streams-web/src...
Added: incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/publisher.js
URL: http://svn.apache.org/viewvc/incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/publisher.js?rev=1536540&view=auto
==============================================================================
--- incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/publisher.js (added)
+++ incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/publisher.js Mon Oct 28 22:05:11 2013
@@ -0,0 +1,43 @@
+var publisher = publisher || (function(){
+
+ //registers a new publisher, and returns the publisher's unique URL that you can use to POST activities
+ var registerPublisher = function(){
+
+ var registrationUrl;
+ console.log($("#publisherRegistrationJSON").val());
+ $.ajax({
+ data: $("#publisherRegistrationJSON").val(),
+ contentType:'application/json',
+ type:'POST',
+ url:'/streams-web/app/publisherRegister',
+ success:function(data){
+ console.log(data);
+ console.log( $("#publisherRegistrationJSON").html());
+ registrationUrl = data;
+ $("#registrationUrl").val(registrationUrl);
+ }
+ });
+ };
+
+ //uses the publisher's unique URL to POST activities
+ var postActivity = function(){
+ var registrationUrl;
+ $.ajax({
+ data: $("#publisherActivityJSON").val(),
+ url: $("#registrationUrl").val(),
+ contentType:'application/json',
+ type:'POST',
+ success:function(data){
+ console.log(data);
+ $("#successMessage").html("Success! Activity Posted");
+ }
+ })
+ };
+
+ return{
+ registerPublisher: registerPublisher,
+ postActivity: postActivity
+ };
+
+
+})();
Added: incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/subscriber.js
URL: http://svn.apache.org/viewvc/incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/subscriber.js?rev=1536540&view=auto
==============================================================================
--- incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/subscriber.js (added)
+++ incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/js/subscriber.js Mon Oct 28 22:05:11 2013
@@ -0,0 +1,40 @@
+var subscriber = subscriber || (function(){
+
+ //registers a new subscriber, and returns the subscriber's unique URL
+ var registerSubscriber = function(){
+
+ var registrationUrl;
+ console.log($("").val());
+ $.ajax({
+ data:$("#subscriberRegistrationJSON").val(),
+ contentType:"application/json",
+ type:"POST",
+ url:"/streams-web/app/subscriberRegister",
+ success:function(data){
+ console.log(data);
+ registrationUrl = data;
+ $("#registrationUrl").val(registrationUrl);
+ }
+ });
+ };
+
+ //returns activity streams (JSON) that have the same tag specified in the subscriber's filters
+ var getActivities = function(){
+ var registrationUrl;
+ $.ajax({
+ contentType: "text/plain",
+ type:"GET",
+ url: $("#registrationUrl").val(),
+ success:function(data){
+ console.log(data);
+ $("#successMessage").val(data);
+ }
+ })
+ };
+
+ return{
+ registerSubscriber: registerSubscriber,
+ getActivities: getActivities
+ };
+
+})();
Added: incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/publisher.html
URL: http://svn.apache.org/viewvc/incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/publisher.html?rev=1536540&view=auto
==============================================================================
--- incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/publisher.html (added)
+++ incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/publisher.html Mon Oct 28 22:05:11 2013
@@ -0,0 +1,74 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
+ <script type="text/javascript" src="js/publisher.js"></script>
+
+ <title>Publisher Demo</title>
+</head>
+
+<body>
+ <form>
+ <p>
+
+ <label>Enter your Publisher Registration JSON here:</label>
+ <textarea id="publisherRegistrationJSON"
+ rows="12"
+ cols="80">{
+ "authToken": "token",
+ "@class":"org.apache.streams.osgi.components.activityconsumer.impl.PushActivityConsumer",
+ "input_type": "http",
+ "method": "post",
+ "src": "http.example.com:8888",
+ "delivery_frequency": "60",
+ "auth_type": "none",
+ "username": "username",
+ "password": "password"
+ }
+ </textarea><br>
+ </p>
+ </form>
+ <button type="button" onclick="publisher.registerPublisher()">Submit Registration JSON</button><br>
+
+ <input id="registrationUrl">
+
+ <form>
+ <p>
+
+ <label>Enter your Publisher Registration JSON here:</label>
+ <textarea id="publisherActivityJSON"
+ rows="12"
+ cols="80">
+ {
+ "id": "id",
+ "verb": "verb",
+ "tags": "tags",
+ "provider": {
+ "url": "http.example.com:8888"
+ },
+ "actor": {
+ "id": "actorid",
+ "objectType": "actorobject",
+ "displayName": "actorname",
+ "url": "www.actorexampleurl.com"
+ },
+ "target": {
+ "id": "targetid",
+ "displayName": "targetname",
+ "url": "www.targeturl.com"
+ },
+ "object": {
+ "id": "objectid",
+ "displayName": "objectname",
+ "objectType": "object",
+ "url": "www.objecturl.org"
+ }
+ }
+ </textarea><br>
+ </p>
+ </form>
+
+ <button type="button" onclick="publisher.postActivity()">Submit Activity JSON</button><br>
+ <p id="successMessage"></p>
+</body>
+</html>
Added: incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/subscriber.html
URL: http://svn.apache.org/viewvc/incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/subscriber.html?rev=1536540&view=auto
==============================================================================
--- incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/subscriber.html (added)
+++ incubator/streams/branches/webservice/streams-web/src/main/webapp/demo/subscriber.html Mon Oct 28 22:05:11 2013
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
+ <script type="text/javascript" src="js/subscriber.js"></script>
+ <title>Subscriber Demo</title>
+</head>
+
+<body>
+<form>
+ <p>
+ <label>Enter your Subscriber Registration JSON here:</label>
+ <textarea id="subscriberRegistrationJSON"
+ rows="12"
+ cols="80">
+ {
+ "authToken": "token",
+ "@class":"org.apache.streams.persistence.model.cassandra.CassandraSubscription",
+ "filters": [
+ "tags"
+ ]
+ }
+ </textarea><br>
+ </p>
+</form>
+
+<button type="button" onclick="subscriber.registerSubscriber()">Submit Registration JSON</button>
+<br>
+<textarea id="registrationUrl"
+ rows="2"
+ cols="80"></textarea><br>
+
+<button type="button" onclick="subscriber.getActivities()">Get Activities</button>
+<br>
+<textarea id="successMessage"
+ rows="16"
+ cols="80"></textarea>
+
+</body>
+</html>