cloudcms-server 4.0.0-beta.2 → 4.0.0-beta.21
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.
- package/README.md +0 -5
- package/cloudcms-server.iml +1 -0
- package/index.js +58 -32
- package/middleware/authentication/authentication.js +40 -12
- package/middleware/authentication/providers/saml.js +8 -4
- package/middleware/awareness/awareness.js +8 -7
- package/middleware/awareness/plugins/api_event.js +105 -0
- package/middleware/awareness/plugins/editorial.js +54 -3
- package/middleware/awareness/plugins/resources.js +13 -5
- package/middleware/config/adapter.js +0 -44
- package/middleware/deployment/deployment.js +22 -24
- package/middleware/driver/driver.js +24 -1
- package/middleware/driver-config/driver-config.js +0 -6
- package/middleware/modules/modules.js +11 -5
- package/middleware/perf/perf.js +3 -2
- package/middleware/registration/registration.js +0 -5
- package/middleware/stores/engines/empty.js +0 -4
- package/middleware/stores/engines/fs-caching-adapter.js +0 -5
- package/middleware/stores/engines/fs.js +0 -9
- package/middleware/stores/engines/s3.js +0 -5
- package/middleware/stores/engines/s3fs.js +0 -5
- package/middleware/stores/multistore.js +0 -29
- package/middleware/stores/store.js +0 -10
- package/middleware/stores/stores.js +2 -2
- package/middleware/virtual-config/virtual-config.js +253 -206
- package/middleware/virtual-files/virtual-files.js +0 -3
- package/middleware/welcome/welcome.js +0 -3
- package/notifications/notifications.js +72 -10
- package/notifications/providers/kafka.js +182 -0
- package/notifications/providers/stomp.js +4 -0
- package/package.json +40 -56
- package/server/index.js +216 -123
- package/server/standalone.js +1 -6
- package/util/auth.js +10 -4
- package/util/cloudcms.js +77 -35
- package/util/loaders.js +113 -0
- package/util/proxy-factory.js +143 -168
- package/util/request.js +6 -2
- package/util/workqueue.js +111 -0
- package/.last_command +0 -7
- package/duster/helpers/core/cloudcms/associations.js +0 -34
- package/duster/helpers/core/cloudcms/beta/markdown.js +0 -46
- package/duster/helpers/core/cloudcms/beta/nodeAttachmentText.js +0 -46
- package/duster/helpers/core/cloudcms/beta/params.js +0 -33
- package/duster/helpers/core/cloudcms/beta/processTemplate.js +0 -82
- package/duster/helpers/core/cloudcms/content.js +0 -34
- package/duster/helpers/core/cloudcms/expand.js +0 -38
- package/duster/helpers/core/cloudcms/form.js +0 -34
- package/duster/helpers/core/cloudcms/query.js +0 -34
- package/duster/helpers/core/cloudcms/queryOne.js +0 -34
- package/duster/helpers/core/cloudcms/relatives.js +0 -34
- package/duster/helpers/core/cloudcms/search.js +0 -34
- package/duster/helpers/core/cloudcms/searchOne.js +0 -34
- package/duster/helpers/core/cloudcms/wcm/dependency.js +0 -83
- package/duster/helpers/core/cloudcms/wcm/fragment.js +0 -34
- package/duster/helpers/core/dev/debug.js +0 -42
- package/duster/helpers/core/dom/block.js +0 -49
- package/duster/helpers/core/dom/include.js +0 -38
- package/duster/helpers/core/dom/layout.js +0 -49
- package/duster/helpers/core/dom/link.js +0 -81
- package/duster/helpers/core/dom/resource.js +0 -77
- package/duster/helpers/core/engine.js +0 -1580
- package/duster/helpers/core/ice/value.js +0 -65
- package/duster/helpers/core/index.js +0 -49
- package/duster/helpers/core/operators/if.js +0 -64
- package/duster/helpers/core/operators/iter.js +0 -45
- package/duster/helpers/core/operators/iterate.js +0 -129
- package/duster/helpers/sample/nyt.js +0 -114
- package/duster/index.js +0 -319
- package/duster/support.js +0 -436
- package/duster/tracker.js +0 -262
- package/middleware/authentication/providers/cas.js +0 -73
- package/middleware/authentication/providers/facebook.js +0 -120
- package/middleware/authentication/providers/github.js +0 -88
- package/middleware/authentication/providers/linkedin.js +0 -112
- package/middleware/authentication/providers/twitter.js +0 -120
- package/middleware/server-tags/server-tags.js +0 -113
- package/middleware/wcm/wcm.js +0 -1437
package/README.md
CHANGED
package/cloudcms-server.iml
CHANGED
package/index.js
CHANGED
|
@@ -29,12 +29,45 @@ process.logInfo = process.log = function(text, level)
|
|
|
29
29
|
systemLogger.log(text, level);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
// var debugLog = process.debugLog = function(req, message)
|
|
33
|
+
// {
|
|
34
|
+
// var text = "[" + req.id + "] URL: " + req.url;
|
|
35
|
+
// // if (req.headers)
|
|
36
|
+
// // {
|
|
37
|
+
// // text += ", HEADERS: " + JSON.stringify(req.headers);
|
|
38
|
+
// // }
|
|
39
|
+
// if (req.query)
|
|
40
|
+
// {
|
|
41
|
+
// text += ", QUERY: " + JSON.stringify(req.query);
|
|
42
|
+
// }
|
|
43
|
+
// text += ", MESSAGE: " + message;
|
|
44
|
+
//
|
|
45
|
+
// console.log(text);
|
|
46
|
+
// };
|
|
47
|
+
//
|
|
48
|
+
// var debugMiddleware = process.debugMiddleware = function(message)
|
|
49
|
+
// {
|
|
50
|
+
// return function(req, res, next)
|
|
51
|
+
// {
|
|
52
|
+
// debugLog(req, message);
|
|
53
|
+
//
|
|
54
|
+
// next();
|
|
55
|
+
// }
|
|
56
|
+
// };
|
|
57
|
+
|
|
58
|
+
|
|
32
59
|
|
|
33
60
|
// by default, set up Gitana driver so that it limits to five concurrent HTTP requests back to Cloud CMS API at at time
|
|
34
61
|
var Gitana = require("gitana");
|
|
35
62
|
|
|
36
|
-
// default
|
|
37
|
-
process.
|
|
63
|
+
// default keep alive (3 minutes)
|
|
64
|
+
process.defaultKeepAliveMs = (3 * 60 * 1000);
|
|
65
|
+
|
|
66
|
+
// default http timeout (2 minutes)
|
|
67
|
+
process.defaultHttpTimeoutMs = 2 * 60 * 1000;
|
|
68
|
+
|
|
69
|
+
// default exclusive lock timeout (2 minutes)
|
|
70
|
+
process.defaultExclusiveLockTimeoutMs = 2 * 60 * 1000;
|
|
38
71
|
|
|
39
72
|
if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
40
73
|
{
|
|
@@ -51,27 +84,37 @@ if (process.env.DEFAULT_HTTP_TIMEOUT_MS)
|
|
|
51
84
|
// dns fix for Node 17 +
|
|
52
85
|
// see: https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder
|
|
53
86
|
var dns = require("dns");
|
|
54
|
-
dns.setDefaultResultOrder
|
|
87
|
+
if (typeof(dns.setDefaultResultOrder) !== "undefined") {
|
|
88
|
+
dns.setDefaultResultOrder("ipv4first");
|
|
89
|
+
}
|
|
55
90
|
|
|
56
91
|
// default agents
|
|
57
92
|
var HttpKeepAliveAgent = require('agentkeepalive');
|
|
58
93
|
var HttpsKeepAliveAgent = require('agentkeepalive').HttpsAgent;
|
|
59
94
|
http.globalAgent = new HttpKeepAliveAgent({
|
|
60
95
|
keepAlive: true,
|
|
61
|
-
keepAliveMsecs:
|
|
62
|
-
maxSockets:
|
|
96
|
+
keepAliveMsecs: process.defaultKeepAliveMs,
|
|
97
|
+
maxSockets: 1024,
|
|
63
98
|
maxFreeSockets: 256,
|
|
64
99
|
timeout: process.defaultHttpTimeoutMs,
|
|
65
|
-
freeSocketTimeout:
|
|
100
|
+
freeSocketTimeout: 5000
|
|
66
101
|
});
|
|
67
102
|
https.globalAgent = new HttpsKeepAliveAgent({
|
|
68
103
|
keepAlive: true,
|
|
69
|
-
keepAliveMsecs:
|
|
70
|
-
maxSockets:
|
|
104
|
+
keepAliveMsecs: process.defaultKeepAliveMs,
|
|
105
|
+
maxSockets: 1024,
|
|
71
106
|
maxFreeSockets: 256,
|
|
72
107
|
timeout: process.defaultHttpTimeoutMs,
|
|
73
|
-
freeSocketTimeout:
|
|
108
|
+
freeSocketTimeout: 5000
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// install dns cache
|
|
112
|
+
const CacheableLookup = require("cacheable-lookup");
|
|
113
|
+
const cacheable = new CacheableLookup({
|
|
114
|
+
// Set any custom options here
|
|
74
115
|
});
|
|
116
|
+
cacheable.install(http.globalAgent);
|
|
117
|
+
cacheable.install(https.globalAgent);
|
|
75
118
|
|
|
76
119
|
// disable for now
|
|
77
120
|
/*
|
|
@@ -141,8 +184,8 @@ exports = module.exports = function()
|
|
|
141
184
|
// not already specified
|
|
142
185
|
var defaultGitanaProxyScheme = "https";
|
|
143
186
|
var defaultGitanaProxyHost = "api.cloudcms.com";
|
|
144
|
-
var defaultGitanaProxyPort = 443;
|
|
145
187
|
var defaultGitanaProxyPath = "";
|
|
188
|
+
var defaultGitanaProxyPort = 443;
|
|
146
189
|
|
|
147
190
|
var gitanaJsonPath = path.join(process.env.CLOUDCMS_APPSERVER_BASE_PATH, "gitana.json");
|
|
148
191
|
if (fs.existsSync(gitanaJsonPath))
|
|
@@ -153,8 +196,8 @@ exports = module.exports = function()
|
|
|
153
196
|
var parsedUrl = url.parse(gitanaJson.baseURL);
|
|
154
197
|
|
|
155
198
|
defaultGitanaProxyHost = parsedUrl.hostname;
|
|
156
|
-
defaultGitanaProxyScheme = parsedUrl.protocol.substring(0, parsedUrl.protocol.length - 1); // remove the :
|
|
157
199
|
defaultGitanaProxyPath = parsedUrl.path;
|
|
200
|
+
defaultGitanaProxyScheme = parsedUrl.protocol.substring(0, parsedUrl.protocol.length - 1); // remove the :
|
|
158
201
|
|
|
159
202
|
if (parsedUrl.port)
|
|
160
203
|
{
|
|
@@ -178,13 +221,13 @@ exports = module.exports = function()
|
|
|
178
221
|
if (!process.env.GITANA_PROXY_HOST) {
|
|
179
222
|
process.env.GITANA_PROXY_HOST = defaultGitanaProxyHost;
|
|
180
223
|
}
|
|
181
|
-
if (!process.env.GITANA_PROXY_PORT) {
|
|
182
|
-
process.env.GITANA_PROXY_PORT = defaultGitanaProxyPort;
|
|
183
|
-
}
|
|
184
224
|
if (!process.env.GITANA_PROXY_PATH) {
|
|
185
225
|
process.env.GITANA_PROXY_PATH = defaultGitanaProxyPath;
|
|
186
226
|
}
|
|
187
|
-
|
|
227
|
+
if (!process.env.GITANA_PROXY_PORT) {
|
|
228
|
+
process.env.GITANA_PROXY_PORT = defaultGitanaProxyPort;
|
|
229
|
+
}
|
|
230
|
+
|
|
188
231
|
if (cluster.isMaster)
|
|
189
232
|
{
|
|
190
233
|
process.log("Gitana Proxy pointed to: " + util.asURL(process.env.GITANA_PROXY_SCHEME, process.env.GITANA_PROXY_HOST, process.env.GITANA_PROXY_PORT, process.env.GITANA_PROXY_PATH));
|
|
@@ -223,13 +266,11 @@ exports = module.exports = function()
|
|
|
223
266
|
var registration = require("./middleware/registration/registration");
|
|
224
267
|
var resources = require("./middleware/resources/resources");
|
|
225
268
|
var runtime = require("./middleware/runtime/runtime");
|
|
226
|
-
var serverTags = require("./middleware/server-tags/server-tags");
|
|
227
269
|
var storeService = require("./middleware/stores/stores");
|
|
228
270
|
var templates = require("./middleware/templates/templates");
|
|
229
271
|
var themes = require("./middleware/themes/themes");
|
|
230
272
|
var virtualConfig = require("./middleware/virtual-config/virtual-config");
|
|
231
273
|
var virtualFiles = require("./middleware/virtual-files/virtual-files");
|
|
232
|
-
var wcm = require("./middleware/wcm/wcm");
|
|
233
274
|
var welcome = require("./middleware/welcome/welcome");
|
|
234
275
|
var awareness = require("./middleware/awareness/awareness");
|
|
235
276
|
var userAgent = require('express-useragent');
|
|
@@ -469,15 +510,6 @@ exports = module.exports = function()
|
|
|
469
510
|
|
|
470
511
|
// supports user-configured dynamic configuration
|
|
471
512
|
app.use(config.remoteConfigInterceptor());
|
|
472
|
-
|
|
473
|
-
// tag processing, injection of scripts, etc, kind of a catch all at the moment
|
|
474
|
-
app.use(serverTags.interceptor(configuration));
|
|
475
|
-
|
|
476
|
-
if (includeCloudCMS)
|
|
477
|
-
{
|
|
478
|
-
// handles retrieval of content from wcm
|
|
479
|
-
app.use(wcm.wcmInterceptor());
|
|
480
|
-
}
|
|
481
513
|
};
|
|
482
514
|
|
|
483
515
|
r.handlers = function(app, includeCloudCMS)
|
|
@@ -557,12 +589,6 @@ exports = module.exports = function()
|
|
|
557
589
|
// add User-Agent device info to req
|
|
558
590
|
app.use(userAgent.express());
|
|
559
591
|
|
|
560
|
-
if (includeCloudCMS)
|
|
561
|
-
{
|
|
562
|
-
// handles retrieval of content from wcm
|
|
563
|
-
app.use(wcm.wcmHandler());
|
|
564
|
-
}
|
|
565
|
-
|
|
566
592
|
// handles 404
|
|
567
593
|
app.use(final.finalHandler());
|
|
568
594
|
};
|
|
@@ -315,16 +315,11 @@ exports = module.exports = function()
|
|
|
315
315
|
registerAdapter("session", require("./adapters/session"));
|
|
316
316
|
|
|
317
317
|
// providers
|
|
318
|
-
registerProvider("cas", require("./providers/cas"));
|
|
319
|
-
registerProvider("facebook", require("./providers/facebook"));
|
|
320
|
-
registerProvider("github", require("./providers/github"));
|
|
321
318
|
registerProvider("google", require("./providers/google"));
|
|
322
319
|
registerProvider("keycloak", require("./providers/keycloak"));
|
|
323
|
-
registerProvider("linkedin", require("./providers/linkedin"));
|
|
324
320
|
registerProvider("local", require("./providers/local"));
|
|
325
321
|
registerProvider("saml", require("./providers/saml"));
|
|
326
322
|
registerProvider("trusted", require("./providers/trusted"));
|
|
327
|
-
registerProvider("twitter", require("./providers/twitter"));
|
|
328
323
|
|
|
329
324
|
// authenticators
|
|
330
325
|
registerAuthenticator("default", require("./authenticators/default"));
|
|
@@ -361,7 +356,7 @@ exports = module.exports = function()
|
|
|
361
356
|
};
|
|
362
357
|
}
|
|
363
358
|
|
|
364
|
-
console.log("Auth Callback failed, err: " + JSON.stringify(err));
|
|
359
|
+
console.log("Auth Callback failed, err: " + err + ", err json: " + JSON.stringify(err));
|
|
365
360
|
|
|
366
361
|
if (err.message)
|
|
367
362
|
{
|
|
@@ -390,13 +385,19 @@ exports = module.exports = function()
|
|
|
390
385
|
|
|
391
386
|
return function (err, profile, info) {
|
|
392
387
|
|
|
388
|
+
if (err) {
|
|
389
|
+
console.log("Caught error on auth callback function: ", err, JSON.stringify(err));
|
|
390
|
+
}
|
|
391
|
+
|
|
393
392
|
if (err) {
|
|
394
393
|
return handleFailure(err, res);
|
|
395
394
|
}
|
|
396
395
|
|
|
397
396
|
if (!profile || !info)
|
|
398
397
|
{
|
|
399
|
-
return handleFailure(
|
|
398
|
+
return handleFailure({
|
|
399
|
+
"message": "Authentication callback missing both profile and info"
|
|
400
|
+
}, res);
|
|
400
401
|
}
|
|
401
402
|
|
|
402
403
|
// store these onto request
|
|
@@ -695,11 +696,11 @@ exports = module.exports = function()
|
|
|
695
696
|
return function(req, res, next) {
|
|
696
697
|
|
|
697
698
|
// record filter start time
|
|
698
|
-
var _auth_filter_start_ms =
|
|
699
|
+
var _auth_filter_start_ms = Date.now();
|
|
699
700
|
|
|
700
701
|
fn(req, res, function(result, authenticator) {
|
|
701
702
|
|
|
702
|
-
var _auth_filter_end_ms =
|
|
703
|
+
var _auth_filter_end_ms = Date.now() - _auth_filter_start_ms;
|
|
703
704
|
|
|
704
705
|
util.setHeader(res, "x-cloudcms-auth-filter-ms", _auth_filter_end_ms);
|
|
705
706
|
|
|
@@ -736,8 +737,11 @@ exports = module.exports = function()
|
|
|
736
737
|
};
|
|
737
738
|
}
|
|
738
739
|
|
|
739
|
-
if (result.
|
|
740
|
-
|
|
740
|
+
if (!result.skip)
|
|
741
|
+
{
|
|
742
|
+
if (result.err && result.err.message) {
|
|
743
|
+
req.log("Auth strategy: " + strategyId + " - filter error: " + result.err.message);
|
|
744
|
+
}
|
|
741
745
|
}
|
|
742
746
|
|
|
743
747
|
var providerId = null;
|
|
@@ -810,7 +814,31 @@ exports = module.exports = function()
|
|
|
810
814
|
}
|
|
811
815
|
redirectUrl += "requested_url=" + requested_url;
|
|
812
816
|
|
|
813
|
-
|
|
817
|
+
res.status(200);
|
|
818
|
+
res.type("text/html");
|
|
819
|
+
|
|
820
|
+
// serve back a redirect via html
|
|
821
|
+
var html = " \
|
|
822
|
+
<html> \
|
|
823
|
+
<head> \
|
|
824
|
+
<script> \
|
|
825
|
+
var _redirectUrl = '" + redirectUrl + "'; \
|
|
826
|
+
var hash = window.location.hash ? window.location.hash : ''; \
|
|
827
|
+
if (hash && hash.indexOf('#') === 0) { \
|
|
828
|
+
hash = hash.substring(1); \
|
|
829
|
+
} \
|
|
830
|
+
if (hash) { \
|
|
831
|
+
_redirectUrl += '&requested_hash=' + hash; \
|
|
832
|
+
} \
|
|
833
|
+
window.location.href = _redirectUrl; \
|
|
834
|
+
</script> \
|
|
835
|
+
</head> \
|
|
836
|
+
</html> \
|
|
837
|
+
";
|
|
838
|
+
res.send(html);
|
|
839
|
+
return;
|
|
840
|
+
|
|
841
|
+
//return res.redirect(redirectUrl);
|
|
814
842
|
}
|
|
815
843
|
else if (loginHandler)
|
|
816
844
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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) {
|
|
@@ -57,10 +57,14 @@ class SAMLProvider extends AbstractProvider
|
|
|
57
57
|
samlConfig.entryPoint = config.entryPoint;
|
|
58
58
|
}
|
|
59
59
|
if (config.cert) {
|
|
60
|
-
samlConfig.
|
|
60
|
+
samlConfig.idpCert = config.cert;
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
var callbackUrl = config.callbackURL;
|
|
63
|
+
if (!callbackUrl) {
|
|
64
|
+
callbackUrl = config.callbackUrl;
|
|
65
|
+
}
|
|
66
|
+
if (callbackUrl) {
|
|
67
|
+
samlConfig.callbackUrl = "http://localhost:5000" + callbackUrl;
|
|
64
68
|
}
|
|
65
69
|
if (config.issuer) {
|
|
66
70
|
samlConfig.issuer = config.issuer;
|
|
@@ -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
|
|
|
@@ -149,21 +150,21 @@ exports = module.exports = function()
|
|
|
149
150
|
var r = {};
|
|
150
151
|
|
|
151
152
|
// allow plugins to bind on("connection") handlers
|
|
152
|
-
r.bindOnSocketConnection = function(socket, provider, callback)
|
|
153
|
+
r.bindOnSocketConnection = function(socket, provider, io, callback)
|
|
153
154
|
{
|
|
154
155
|
var fns = [];
|
|
155
156
|
for (var pluginPath in plugins)
|
|
156
157
|
{
|
|
157
158
|
var plugin = plugins[pluginPath];
|
|
158
159
|
|
|
159
|
-
var fn = function(pluginPath, plugin, socket) {
|
|
160
|
+
var fn = function(pluginPath, plugin, socket, io) {
|
|
160
161
|
return function(done) {
|
|
161
|
-
|
|
162
|
-
plugin.bindSocket(socket, provider);
|
|
162
|
+
|
|
163
|
+
plugin.bindSocket(socket, provider, io);
|
|
163
164
|
|
|
164
165
|
done();
|
|
165
166
|
}
|
|
166
|
-
}(pluginPath, plugin, socket);
|
|
167
|
+
}(pluginPath, plugin, socket, io);
|
|
167
168
|
fns.push(fn);
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -309,7 +310,7 @@ exports = module.exports = function()
|
|
|
309
310
|
});
|
|
310
311
|
|
|
311
312
|
// allow plugins to register more on() handlers if they wish
|
|
312
|
-
pluginProxy.bindOnSocketConnection(socket, provider, function() {
|
|
313
|
+
pluginProxy.bindOnSocketConnection(socket, provider, io, function() {
|
|
313
314
|
// done
|
|
314
315
|
});
|
|
315
316
|
|
|
@@ -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
|
|
|
@@ -21,6 +21,10 @@ exports.bindSocket = function(socket, provider)
|
|
|
21
21
|
commitEditorialWorkspace(socket, provider, sessionKey, repositoryId, branchId, callback);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
+
socket.on("touchEditorialWorkspace", function(sessionKey, repositoryId, branchId, callback) {
|
|
25
|
+
touchEditorialWorkspace(socket, provider, sessionKey, repositoryId, branchId, callback);
|
|
26
|
+
});
|
|
27
|
+
|
|
24
28
|
socket.on("editorialWorkspaceInfo", function(sessionKey, repositoryId, branchId, callback) {
|
|
25
29
|
editorialWorkspaceInfo(socket, provider, sessionKey, repositoryId, branchId, callback);
|
|
26
30
|
});
|
|
@@ -219,6 +223,52 @@ exports.bindSocket = function(socket, provider)
|
|
|
219
223
|
});
|
|
220
224
|
};
|
|
221
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Touches an editorial workspace.
|
|
228
|
+
*
|
|
229
|
+
* This is a "keep alive" call to prevent a workspace from being cleaned up while it is being
|
|
230
|
+
* worked on.
|
|
231
|
+
*
|
|
232
|
+
* @param socket
|
|
233
|
+
* @param provider
|
|
234
|
+
* @param sessionKey
|
|
235
|
+
* @param repositoryId
|
|
236
|
+
* @param branchId
|
|
237
|
+
* @param callback
|
|
238
|
+
*/
|
|
239
|
+
var touchEditorialWorkspace = function(socket, provider, sessionKey, repositoryId, branchId, callback)
|
|
240
|
+
{
|
|
241
|
+
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/touch";
|
|
242
|
+
|
|
243
|
+
var json = {};
|
|
244
|
+
json.repositoryId = repositoryId;
|
|
245
|
+
json.branchId = branchId;
|
|
246
|
+
json.key = sessionKey;
|
|
247
|
+
|
|
248
|
+
var headers = {};
|
|
249
|
+
var gitanaTicket = extractTicket(socket);
|
|
250
|
+
if (gitanaTicket)
|
|
251
|
+
{
|
|
252
|
+
headers["GITANA_TICKET"] = gitanaTicket;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
request({
|
|
256
|
+
"method": "POST",
|
|
257
|
+
"url": URL,
|
|
258
|
+
"qs": {},
|
|
259
|
+
"json": json,
|
|
260
|
+
"headers": headers,
|
|
261
|
+
"timeout": process.defaultHttpTimeoutMs
|
|
262
|
+
}, function(err, response, json) {
|
|
263
|
+
|
|
264
|
+
if (err || (json && json.error)) {
|
|
265
|
+
return callback(err);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
callback(null, json);
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
|
|
222
272
|
var extractTicket = function(socket)
|
|
223
273
|
{
|
|
224
274
|
var ticket = null;
|
|
@@ -231,10 +281,11 @@ exports.bindSocket = function(socket, provider)
|
|
|
231
281
|
var x1 = cookieValue.indexOf("GITANA_TICKET=");
|
|
232
282
|
if (x1 > -1)
|
|
233
283
|
{
|
|
234
|
-
|
|
284
|
+
ticket = cookieValue.substring(x1 + 14);
|
|
285
|
+
var x2 = ticket.indexOf(";");
|
|
235
286
|
if (x2 > -1)
|
|
236
287
|
{
|
|
237
|
-
ticket =
|
|
288
|
+
ticket = ticket.substring(0, x2);
|
|
238
289
|
}
|
|
239
290
|
}
|
|
240
291
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -359,50 +359,6 @@ module.exports = function(configStore)
|
|
|
359
359
|
|
|
360
360
|
// all done
|
|
361
361
|
callback(null, registry);
|
|
362
|
-
|
|
363
|
-
var _watchLog = function(text) {
|
|
364
|
-
process.log("[Configuration Watch] " + text);
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
if (process.env.CLOUDCMS_APPSERVER_CONFIG_WATCH === "true" || process.env.CLOUDCMS_APPSERVER_CONFIG_WATCH === true)
|
|
368
|
-
{
|
|
369
|
-
_watchLog("Setting up live watch...");
|
|
370
|
-
|
|
371
|
-
// set a watch
|
|
372
|
-
// watch for changes and when they happen, reload context
|
|
373
|
-
(function (registry) {
|
|
374
|
-
|
|
375
|
-
configStore.watchDirectory("/", function () {
|
|
376
|
-
|
|
377
|
-
_watchLog("Detected changes on disk - reloading...");
|
|
378
|
-
|
|
379
|
-
var t1 = new Date().getTime();
|
|
380
|
-
|
|
381
|
-
// reload context
|
|
382
|
-
loadContext(function (err, context) {
|
|
383
|
-
|
|
384
|
-
if (err) {
|
|
385
|
-
return _watchLog("Failed to load configuration context: " + err);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
try
|
|
389
|
-
{
|
|
390
|
-
compileContextToRegistry(context);
|
|
391
|
-
registry.reloadContext(context);
|
|
392
|
-
|
|
393
|
-
var t2 = new Date().getTime();
|
|
394
|
-
_watchLog("Reloaded context in: " + (t2 - t1) + " ms");
|
|
395
|
-
}
|
|
396
|
-
catch (e)
|
|
397
|
-
{
|
|
398
|
-
_watchLog("Caught error while compiling and reloading context: " + err);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
})(registry);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
362
|
});
|
|
407
363
|
};
|
|
408
364
|
|