cloudcms-server 3.3.1-beta.9 → 4.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/broadcast/broadcast.js +6 -3
  4. package/broadcast/providers/redis.js +24 -49
  5. package/clients/nrp.js +117 -0
  6. package/clients/redis.js +64 -0
  7. package/cloudcms-server.iml +1 -0
  8. package/d1/index.js +629 -0
  9. package/d1/index.js.works +203 -0
  10. package/d1/package.json +86 -0
  11. package/d1/package.json.works +14 -0
  12. package/duster/helpers/sample/nyt.js +2 -1
  13. package/framework/controllers.js +4 -4
  14. package/index.js +21 -14
  15. package/insight/insight.js +1 -1
  16. package/launchpad/index.js +203 -11
  17. package/launchpad/launchers/cluster.js +103 -110
  18. package/launchpad/launchers/redis.js +70 -0
  19. package/launchpad/launchers/single.js +36 -22
  20. package/locks/locks.js +63 -9
  21. package/locks/providers/cluster.js +3 -1
  22. package/locks/providers/memory.js +10 -7
  23. package/locks/providers/redis.js +62 -82
  24. package/middleware/admin/admin.js +3 -3
  25. package/middleware/authentication/adapters/session.js +11 -8
  26. package/middleware/authentication/authentication.js +28 -16
  27. package/middleware/authentication/authenticators/default.js +5 -2
  28. package/middleware/authentication/authenticators/session.js +5 -2
  29. package/middleware/authentication/providers/saml.js +2 -2
  30. package/middleware/authorization/authorization.js +11 -8
  31. package/middleware/awareness/awareness.js +63 -38
  32. package/middleware/awareness/plugins/api_event.js +105 -0
  33. package/middleware/awareness/plugins/editorial.js +8 -7
  34. package/middleware/awareness/plugins/resources.js +13 -5
  35. package/middleware/awareness/providers/abstract-async.js +107 -84
  36. package/middleware/awareness/providers/abstract.js +1 -1
  37. package/middleware/awareness/providers/memory.js +0 -14
  38. package/middleware/awareness/providers/redis.js +186 -279
  39. package/middleware/cache/cache.js +4 -2
  40. package/middleware/cache/providers/redis.js +127 -89
  41. package/middleware/cache/providers/shared-memory.js +3 -3
  42. package/middleware/cloudcms/cloudcms.js +22 -16
  43. package/middleware/driver-config/driver-config.js +0 -6
  44. package/middleware/form/form.js +3 -3
  45. package/middleware/modules/modules.js +17 -8
  46. package/middleware/perf/perf.js +3 -2
  47. package/middleware/proxy/proxy.js +8 -21
  48. package/middleware/stores/store.js +0 -1
  49. package/middleware/stores/stores.js +4 -4
  50. package/middleware/virtual-config/virtual-config.js +11 -11
  51. package/middleware/virtual-files/virtual-files.js +0 -3
  52. package/middleware/wcm/wcm.js +4 -4
  53. package/middleware/welcome/welcome.js +0 -3
  54. package/notifications/notifications.js +74 -12
  55. package/notifications/providers/kafka.js +182 -0
  56. package/notifications/providers/stomp.js +4 -0
  57. package/package.json +33 -30
  58. package/server/index.js +508 -416
  59. package/server/standalone.js +9 -0
  60. package/temp/clusterlock/index.js +3 -3
  61. package/temp/clusterlock/package.json +1 -1
  62. package/temp/passport-saml/LICENSE +23 -0
  63. package/temp/passport-saml/README.md +406 -0
  64. package/temp/passport-saml/lib/node-saml/algorithms.d.ts +5 -0
  65. package/temp/passport-saml/lib/node-saml/algorithms.js +41 -0
  66. package/temp/passport-saml/lib/node-saml/algorithms.js.map +1 -0
  67. package/temp/passport-saml/lib/node-saml/index.d.ts +3 -0
  68. package/temp/passport-saml/lib/node-saml/index.js +6 -0
  69. package/temp/passport-saml/lib/node-saml/index.js.map +1 -0
  70. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.d.ts +45 -0
  71. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js +86 -0
  72. package/temp/passport-saml/lib/node-saml/inmemory-cache-provider.js.map +1 -0
  73. package/temp/passport-saml/lib/node-saml/saml-post-signing.d.ts +3 -0
  74. package/temp/passport-saml/lib/node-saml/saml-post-signing.js +15 -0
  75. package/temp/passport-saml/lib/node-saml/saml-post-signing.js.map +1 -0
  76. package/temp/passport-saml/lib/node-saml/saml.d.ts +77 -0
  77. package/temp/passport-saml/lib/node-saml/saml.js +1170 -0
  78. package/temp/passport-saml/lib/node-saml/saml.js.map +1 -0
  79. package/temp/passport-saml/lib/node-saml/types.d.ts +95 -0
  80. package/temp/passport-saml/lib/node-saml/types.js +8 -0
  81. package/temp/passport-saml/lib/node-saml/types.js.map +1 -0
  82. package/temp/passport-saml/lib/node-saml/utility.d.ts +3 -0
  83. package/temp/passport-saml/lib/node-saml/utility.js +19 -0
  84. package/temp/passport-saml/lib/node-saml/utility.js.map +1 -0
  85. package/temp/passport-saml/lib/node-saml/xml.d.ts +21 -0
  86. package/temp/passport-saml/lib/node-saml/xml.js +140 -0
  87. package/temp/passport-saml/lib/node-saml/xml.js.map +1 -0
  88. package/temp/passport-saml/lib/passport-saml/index.d.ts +6 -0
  89. package/temp/passport-saml/lib/passport-saml/index.js +11 -0
  90. package/temp/passport-saml/lib/passport-saml/index.js.map +1 -0
  91. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.d.ts +13 -0
  92. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js +63 -0
  93. package/temp/passport-saml/lib/passport-saml/multiSamlStrategy.js.map +1 -0
  94. package/temp/passport-saml/lib/passport-saml/strategy.d.ts +20 -0
  95. package/temp/passport-saml/lib/passport-saml/strategy.js +167 -0
  96. package/temp/passport-saml/lib/passport-saml/strategy.js.map +1 -0
  97. package/temp/passport-saml/lib/passport-saml/types.d.ts +51 -0
  98. package/temp/passport-saml/lib/passport-saml/types.js +11 -0
  99. package/temp/passport-saml/lib/passport-saml/types.js.map +1 -0
  100. package/temp/passport-saml/package.json +96 -0
  101. package/util/auth.js +16 -10
  102. package/util/cloudcms.js +108 -120
  103. package/util/proxy-factory.js +103 -237
  104. package/util/redis.js +113 -0
  105. package/util/renditions.js +12 -6
  106. package/util/request.js +12 -6
  107. package/util/util.js +16 -2
  108. package/.last_command +0 -7
  109. package/launchpad/launchers/sticky-cluster.js +0 -43
  110. package/temp/memored/.jshintrc +0 -4
  111. package/temp/memored/README.md +0 -240
  112. package/temp/memored/demo/demo1.js +0 -37
  113. package/temp/memored/demo/demo2.js +0 -32
  114. package/temp/memored/gulpfile.js +0 -8
  115. package/temp/memored/index.js +0 -343
  116. package/temp/memored/package.json +0 -54
  117. package/temp/memored/spec/memored.spec.js +0 -265
  118. package/web/cms/ice.js +0 -109
  119. package/web/cms/preview.js +0 -106
@@ -17,8 +17,8 @@ exports = module.exports = function()
17
17
  if (ref)
18
18
  {
19
19
  var z = ref.indexOf("://");
20
-
21
- var type = ref.substring(0, z + 3);
20
+
21
+ var type = ref.substring(0, z);
22
22
  var identifier = ref.substring(z + 3);
23
23
 
24
24
  var parts = identifier.split("/").reverse();
@@ -132,7 +132,7 @@ exports = module.exports = function()
132
132
  {
133
133
  assertAuthenticated(req, res, function() {
134
134
 
135
- doResetCache(req.virtualHost, req.ref, function(err) {
135
+ doResetCache(req.virtualHost, req.query.ref, function(err) {
136
136
  completionFn(req.virtualHost, res, err);
137
137
  });
138
138
 
@@ -9,15 +9,18 @@ class SessionAdapter extends AbstractAdapter
9
9
 
10
10
  identify(req, callback)
11
11
  {
12
- if (req.session && req.session._auth_profile)
12
+ if (req.session)
13
13
  {
14
- var properties = {
15
- "token": req.session._auth_profile.unique_name,
16
- "trusted": true,
17
- "profile": req.session._auth_profile
18
- };
19
-
20
- return callback(null, properties);
14
+ if (req.session._auth_profile)
15
+ {
16
+ var properties = {
17
+ "token": req.session._auth_profile.unique_name,
18
+ "trusted": true,
19
+ "profile": req.session._auth_profile
20
+ };
21
+
22
+ return callback(null, properties);
23
+ }
21
24
  }
22
25
 
23
26
  return super.identify(req, callback);
@@ -436,15 +436,21 @@ exports = module.exports = function()
436
436
  }
437
437
  else
438
438
  {
439
- req.session.registration_strategy_id = strategyId;
440
- req.session.registration_user_object = userObject;
441
- req.session.registration_user_identifier = userIdentifier;
442
- req.session.registration_groups_array = groupsArray;
443
- req.session.registration_mandatory_groups_array = mandatoryGroupsArray;
444
- req.session.registration_token = info.token;
445
- req.session.registration_refresh_token = info.refresh_token;
446
-
447
- return res.redirect(registrationRedirectUrl);
439
+ return req.session.reload(function() {
440
+
441
+ req.session.registration_strategy_id = strategyId;
442
+ req.session.registration_user_object = userObject;
443
+ req.session.registration_user_identifier = userIdentifier;
444
+ req.session.registration_groups_array = groupsArray;
445
+ req.session.registration_mandatory_groups_array = mandatoryGroupsArray;
446
+ req.session.registration_token = info.token;
447
+ req.session.registration_refresh_token = info.refresh_token;
448
+
449
+ req.session.save(function() {
450
+ res.redirect(registrationRedirectUrl);
451
+ });
452
+
453
+ });
448
454
  }
449
455
  });
450
456
  }
@@ -765,13 +771,19 @@ exports = module.exports = function()
765
771
  }
766
772
  else
767
773
  {
768
- req.session.registration_strategy_id = strategyId;
769
- req.session.registration_user_object = properties.user_object;
770
- req.session.registration_user_identifier = properties.user_identifier;
771
- req.session.registration_token = properties.token;
772
- req.session.registration_refresh_token = properties.refresh_token;
773
-
774
- return res.redirect(registrationRedirect);
774
+ return req.session.reload(function() {
775
+
776
+ req.session.registration_strategy_id = strategyId;
777
+ req.session.registration_user_object = properties.user_object;
778
+ req.session.registration_user_identifier = properties.user_identifier;
779
+ req.session.registration_token = properties.token;
780
+ req.session.registration_refresh_token = properties.refresh_token;
781
+
782
+ req.session.save(function() {
783
+ res.redirect(registrationRedirect);
784
+ });
785
+
786
+ });
775
787
  }
776
788
  }
777
789
 
@@ -15,8 +15,11 @@ class DefaultAuthenticator extends AbstractAuthenticator
15
15
  {
16
16
  return req.logIn(gitanaUser, function() {
17
17
 
18
- if (req.session && req.session.save) {
19
- req.session.save();
18
+ if (req.session)
19
+ {
20
+ return req.session.save(function() {
21
+ callback();
22
+ });
20
23
  }
21
24
 
22
25
  callback();
@@ -25,8 +25,11 @@ class SessionAuthenticator extends DefaultAuthenticator
25
25
 
26
26
  req.user = gitanaUser;
27
27
 
28
- if (req.session && req.session.save) {
29
- req.session.save();
28
+ if (req.session)
29
+ {
30
+ return req.session.save(function() {
31
+ callback();
32
+ });
30
33
  }
31
34
 
32
35
  callback();
@@ -1,6 +1,6 @@
1
- var auth = require("../../../util/auth");
1
+ //var auth = require("../../../util/auth");
2
2
 
3
- var SamlStrategy = require('passport-saml').Strategy;
3
+ var SamlStrategy = require('@node-saml/passport-saml').Strategy;
4
4
  var AbstractProvider = require("./abstract");
5
5
 
6
6
  if (!process.configuration) {
@@ -41,17 +41,20 @@ exports = module.exports = function()
41
41
  }
42
42
  */
43
43
 
44
- if (pathRequiresAuthorization) {
45
- if (req.session && req.session.requestContext) {
46
- next();
47
- }
48
- else {
49
- res.redirect("/login");
50
- }
44
+ if (!pathRequiresAuthorization)
45
+ {
46
+ return next();
51
47
  }
52
- else {
48
+
49
+ if (req.session && req.session.requestContext)
50
+ {
53
51
  next();
54
52
  }
53
+ else
54
+ {
55
+ res.redirect("/login");
56
+ }
57
+
55
58
  });
56
59
  };
57
60
 
@@ -16,7 +16,8 @@ exports = module.exports = function()
16
16
 
17
17
  var pluginPaths = [
18
18
  "./plugins/editorial",
19
- "./plugins/resources"
19
+ "./plugins/resources",
20
+ "./plugins/api_event"
20
21
  ];
21
22
  var plugins = {};
22
23
 
@@ -46,8 +47,10 @@ exports = module.exports = function()
46
47
  if (!process.env.CLOUDCMS_AWARENESS_TYPE)
47
48
  {
48
49
  process.env.CLOUDCMS_AWARENESS_TYPE = "memory";
49
-
50
- if (process.configuration.setup !== "single") {
50
+
51
+ // auto-configure
52
+ if (process.env.CLOUDCMS_LAUNCHPAD_SETUP === "redis")
53
+ {
51
54
  process.env.CLOUDCMS_AWARENESS_TYPE = "redis";
52
55
  }
53
56
  }
@@ -63,10 +66,15 @@ exports = module.exports = function()
63
66
  if (!process.configuration.awareness.config) {
64
67
  process.configuration.awareness.config = {};
65
68
  }
66
-
69
+
70
+ // init any plugins?
71
+ if (!process.configuration.awareness.plugins) {
72
+ process.configuration.awareness.plugins = [];
73
+ }
74
+
67
75
  var type = process.configuration.awareness.type;
68
76
  var config = process.configuration.awareness.config;
69
-
77
+
70
78
  var providerFactory = require("./providers/" + type);
71
79
  provider = new providerFactory(config);
72
80
 
@@ -77,12 +85,6 @@ exports = module.exports = function()
77
85
  return callback(err);
78
86
  }
79
87
 
80
- // init any plugins?
81
- if (!process.configuration.awareness.plugins) {
82
- process.configuration.awareness.plugins = [];
83
- }
84
-
85
-
86
88
  var fns = [];
87
89
  for (var i = 0; i < pluginPaths.length; i++)
88
90
  {
@@ -118,15 +120,18 @@ exports = module.exports = function()
118
120
  /**
119
121
  * This gets called whenever a new socket is connected to the Cloud CMS server.
120
122
  *
123
+ * @param io
124
+ * @param callback
125
+ *
121
126
  * @type {Function}
122
127
  */
123
- var initSocketIO = r.initSocketIO = function(callback) {
124
-
128
+ var initSocketIO = r.initSocketIO = function(io, callback) {
129
+
125
130
  // initialize socket IO event handlers so that awareness binds to any new, incoming sockets
126
- socketInit(process.IO);
131
+ socketInit(io);
127
132
 
128
133
  // ensure the reaper is initialized
129
- reaperInit(process.IO, REAP_FREQUENCY_MS, REAP_MAX_AGE_MS, function(err) {
134
+ reaperInit(io, REAP_FREQUENCY_MS, REAP_MAX_AGE_MS, function(err) {
130
135
  callback(err);
131
136
  });
132
137
  };
@@ -145,21 +150,21 @@ exports = module.exports = function()
145
150
  var r = {};
146
151
 
147
152
  // allow plugins to bind on("connection") handlers
148
- r.bindOnSocketConnection = function(socket, provider, callback)
153
+ r.bindOnSocketConnection = function(socket, provider, io, callback)
149
154
  {
150
155
  var fns = [];
151
156
  for (var pluginPath in plugins)
152
157
  {
153
158
  var plugin = plugins[pluginPath];
154
159
 
155
- var fn = function(pluginPath, plugin, socket) {
160
+ var fn = function(pluginPath, plugin, socket, io) {
156
161
  return function(done) {
157
-
158
- plugin.bindSocket(socket, provider);
162
+
163
+ plugin.bindSocket(socket, provider, io);
159
164
 
160
165
  done();
161
166
  }
162
- }(pluginPath, plugin, socket);
167
+ }(pluginPath, plugin, socket, io);
163
168
  fns.push(fn);
164
169
  }
165
170
 
@@ -175,7 +180,7 @@ exports = module.exports = function()
175
180
  // when a socket.io connection is established, we set up some default listeners for events that the client
176
181
  // may emit to us
177
182
  io.on("connection", function(socket) {
178
-
183
+
179
184
  // "register" -> indicates that a user is in a channel
180
185
  socket.on("register", function(channelId, user, dirty, callback) {
181
186
 
@@ -196,24 +201,32 @@ exports = module.exports = function()
196
201
  return callback(err);
197
202
  }
198
203
 
199
- // if we were already registered, just callback
200
- // however, if "dirty" is set, then we always hand back membership
201
- if (!dirty && alreadyRegistered)
202
- {
203
- return callback();
204
- }
205
-
206
- if (!alreadyRegistered)
207
- {
208
- // logger.info("New registration - channelId: " + channelId + ",userId=" + user.id + " (" + user.name + ")");
209
-
204
+ // // if we were already registered, just callback
205
+ // // however, if "dirty" is set, then we always hand back membership
206
+ // if (!dirty && alreadyRegistered)
207
+ // {
208
+ // logger.info("Already registered, not dirty - channelId: " + channelId + ",userId=" + user.id + " (" + user.name + ")");
209
+ //
210
+ // return callback();
211
+ // }
212
+ //
213
+ // if (!alreadyRegistered)
214
+ // {
215
+ // logger.info("New registration - channelId: " + channelId + ",userId=" + user.id + " (" + user.name + ")");
216
+
217
+ //logger.info("Register - channelId: " + channelId + ", userId=" + user.id + " (" + user.name + ")");
210
218
  socket.join(channelId);
211
- }
219
+ //}
212
220
 
213
221
  discover(channelId, function(err, userArray) {
214
222
 
215
- if (!err) {
216
- logger.info("Discover - channelId: " + channelId + ", userId=" + user.id + " (" + user.name + ") handing back: " + userArray.length);
223
+ if (err)
224
+ {
225
+ logger.info("Discover - channelId: " + channelId + ", err: " + JSON.stringify(err));
226
+ }
227
+ else
228
+ {
229
+ //logger.info("Discover - channelId: " + channelId + ", userId=" + user.id + " (" + user.name + ") handing back: " + userArray.length);
217
230
  io.sockets.in(channelId).emit("membershipChanged", channelId, userArray);
218
231
  }
219
232
 
@@ -297,7 +310,7 @@ exports = module.exports = function()
297
310
  });
298
311
 
299
312
  // allow plugins to register more on() handlers if they wish
300
- pluginProxy.bindOnSocketConnection(socket, provider, function() {
313
+ pluginProxy.bindOnSocketConnection(socket, provider, io, function() {
301
314
  // done
302
315
  });
303
316
 
@@ -415,6 +428,8 @@ exports = module.exports = function()
415
428
  */
416
429
  var register = r.register = function(channelId, user, callback)
417
430
  {
431
+ //console.log("Awareness - heard register, channel: " + channelId + ", user: " + user.id);
432
+
418
433
  provider.register(channelId, user, callback);
419
434
  };
420
435
 
@@ -461,7 +476,12 @@ exports = module.exports = function()
461
476
  {
462
477
  // take out a cluster-wide lock on the "channelId"
463
478
  // so that two "threads" can't acquire/release at the same time for a given channel
464
- _LOCK(channelId, function (releaseLockFn) {
479
+ _LOCK(channelId, function (err, releaseLockFn) {
480
+
481
+ if (err) {
482
+ return callback(err);
483
+ }
484
+
465
485
  provider.acquireLock(channelId, user, function(err, success) {
466
486
  releaseLockFn();
467
487
  callback(err, success);
@@ -480,7 +500,12 @@ exports = module.exports = function()
480
500
  {
481
501
  // take out a cluster-wide lock on the "channelId"
482
502
  // so that two "threads" can't acquire/release at the same time for a given channel
483
- _LOCK(channelId, function (releaseLockFn) {
503
+ _LOCK(channelId, function (err, releaseLockFn) {
504
+
505
+ if (err) {
506
+ return callback(err);
507
+ }
508
+
484
509
  provider.releaseLock(channelId, userId, function(err, success) {
485
510
  releaseLockFn();
486
511
  callback(err, success);
@@ -0,0 +1,105 @@
1
+ /*
2
+
3
+ this awareness plugin adds support for general purpose API events
4
+ the API in 4.0 supports passing API events forward via the message queue to the app server
5
+ the app server then converts these into notifications
6
+
7
+ the UI can register and event listener via socket.io ("onApiEvent").
8
+ a listener binds to an event type + an optional reference
9
+
10
+ when an event is received by the API, it triggers to socket.io emits (one for the general event and the other for the
11
+ event + the reference being acted upon)
12
+ */
13
+ exports = module.exports = {};
14
+
15
+ var util = require("../../../util/util");
16
+ var socketUtil = require("../../../util/socket");
17
+
18
+ var subscriptionsBound = false;
19
+
20
+ var bindSubscriptions = function(io)
21
+ {
22
+ if (subscriptionsBound) {
23
+ return;
24
+ }
25
+
26
+ subscriptionsBound = true;
27
+
28
+ // LISTEN: "api_event"
29
+ process.broadcast.subscribe("api_event", function (message, channel, done) {
30
+
31
+ if (!done) {
32
+ done = function () {};
33
+ }
34
+
35
+ // the message
36
+ // {
37
+ // "applicationId": applicationId,
38
+ // "deploymentKey": deploymentKey,
39
+ // "host": host,
40
+ // "eventType": eventType,
41
+ // "eventId": eventId,
42
+ // "objectType": objectType,
43
+ // "objectId": objectId,
44
+ // "objectRef": objectRef,
45
+ // "object": object.object
46
+ // };
47
+
48
+ var apiEvent = {};
49
+ apiEvent.type = message.eventType;
50
+ apiEvent.id = message.eventId;
51
+ apiEvent.objectType = message.objectType;
52
+ apiEvent.objectId = message.objectId;
53
+ apiEvent.objectRef = message.objectRef;
54
+ apiEvent.object = message.object;
55
+
56
+ // dispatch for event + reference
57
+ if (apiEvent.objectRef)
58
+ {
59
+ try {
60
+ apiEvent.channelId = "apiEvent-" + apiEvent.type + "_" + apiEvent.objectRef;
61
+ //console.log("api_event -> " + apiEvent.channelId);
62
+ io.to(apiEvent.channelId).emit("apiEvent", apiEvent);
63
+ } catch (e) {
64
+ console.log(e);
65
+ }
66
+ }
67
+
68
+ // dispatch for event
69
+ try {
70
+ apiEvent.channelId = "apiEvent-" + apiEvent.type;
71
+ //console.log("apiEvent -> " + apiEvent.channelId);
72
+ io.to(apiEvent.channelId).emit("apiEvent", apiEvent);
73
+ } catch (e) {
74
+ console.log(e);
75
+ }
76
+
77
+ done();
78
+ });
79
+ };
80
+
81
+ exports.bindSocket = function(socket, provider, io)
82
+ {
83
+ bindSubscriptions(io);
84
+
85
+ socketUtil.bindGitana(socket, function() {
86
+
87
+ socket.on("onApiEvent", function(eventName, reference, callback) {
88
+
89
+ if (eventName)
90
+ {
91
+ var channelId = "apiEvent-" + eventName;
92
+
93
+ if (reference)
94
+ {
95
+ channelId = eventName + "-" + reference;
96
+ }
97
+
98
+ // join room for this event
99
+ socket.join(channelId);
100
+ }
101
+
102
+ callback();
103
+ });
104
+ });
105
+ };
@@ -5,7 +5,7 @@ var socketUtil = require("../../../util/socket");
5
5
 
6
6
  var request = require("../../../util/request");
7
7
 
8
- exports.bindSocket = function(socket, provider)
8
+ exports.bindSocket = function(socket, provider, io)
9
9
  {
10
10
  socketUtil.bindGitana(socket, function() {
11
11
 
@@ -41,7 +41,7 @@ exports.bindSocket = function(socket, provider)
41
41
  var acquireEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, type, force, callback)
42
42
  {
43
43
  // send an HTTP command to acquire an editorial workspace for this repository and branch
44
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/acquire";
44
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/acquire";
45
45
 
46
46
  var headers = {};
47
47
  //headers["Authorization"] = socket.gitana.platform().getDriver().getHttpHeaders()["Authorization"];
@@ -97,7 +97,7 @@ exports.bindSocket = function(socket, provider)
97
97
  var releaseEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
98
98
  {
99
99
  // send an HTTP command to release the session
100
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/release";
100
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/release";
101
101
 
102
102
  var json = {};
103
103
  json.repositoryId = repositoryId;
@@ -141,7 +141,7 @@ exports.bindSocket = function(socket, provider)
141
141
  */
142
142
  var commitEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
143
143
  {
144
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/commit";
144
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/commit";
145
145
 
146
146
  var json = {};
147
147
  json.repositoryId = repositoryId;
@@ -184,7 +184,7 @@ exports.bindSocket = function(socket, provider)
184
184
  */
185
185
  var editorialWorkspaceInfo = function(socket, provider, sessionKey, repositoryId, branchId, callback)
186
186
  {
187
- var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT) + "/oneteam/editorial/workspace/info";
187
+ var URL = util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH) + "/oneteam/editorial/workspace/info";
188
188
 
189
189
  var json = {};
190
190
  json.repositoryId = repositoryId;
@@ -231,10 +231,11 @@ exports.bindSocket = function(socket, provider)
231
231
  var x1 = cookieValue.indexOf("GITANA_TICKET=");
232
232
  if (x1 > -1)
233
233
  {
234
- var x2 = cookieValue.indexOf(";", x1 + 14);
234
+ ticket = cookieValue.substring(x1 + 14);
235
+ var x2 = ticket.indexOf(";");
235
236
  if (x2 > -1)
236
237
  {
237
- ticket = cookieValue.substring(x1 + 14, x2);
238
+ ticket = ticket.substring(0, x2);
238
239
  }
239
240
  }
240
241
  }
@@ -5,7 +5,7 @@ var socketUtil = require("../../../util/socket");
5
5
 
6
6
  var subscriptionsBound = false;
7
7
 
8
- var bindSubscriptions = function()
8
+ var bindSubscriptions = function(io)
9
9
  {
10
10
  if (subscriptionsBound) {
11
11
  return;
@@ -43,19 +43,27 @@ var bindSubscriptions = function()
43
43
  };
44
44
 
45
45
  // fire to reference
46
- process.IO.to(reference).emit("watchResource", reference, watchObject);
46
+ try {
47
+ if (reference) {
48
+ io.to(reference).emit("watchResource", reference, watchObject);
49
+ }
50
+ } catch (e) { }
47
51
 
48
52
  // fire to head reference
49
- process.IO.to(headReference).emit("watchResource", headReference, watchObject);
53
+ try {
54
+ if (headReference) {
55
+ io.to(headReference).emit("watchResource", headReference, watchObject);
56
+ }
57
+ } catch (e) { }
50
58
  }
51
59
 
52
60
  done();
53
61
  });
54
62
  };
55
63
 
56
- exports.bindSocket = function(socket, provider)
64
+ exports.bindSocket = function(socket, provider, io)
57
65
  {
58
- bindSubscriptions();
66
+ bindSubscriptions(io);
59
67
 
60
68
  socketUtil.bindGitana(socket, function() {
61
69