From c1c87a3660f3af96a5fc5b33eb31686e96f9192c Mon Sep 17 00:00:00 2001 From: konovalovsergey Date: Tue, 18 Oct 2016 19:15:35 +0300 Subject: [PATCH] add 'version' command Commandservice.ashx --- Common/sources/license.js | 2 ++ DocService/sources/DocsCoServer.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Common/sources/license.js b/Common/sources/license.js index 5869587d..4188f0c1 100644 --- a/Common/sources/license.js +++ b/Common/sources/license.js @@ -130,3 +130,5 @@ function* _updateFileState(state) { const val = constants.PACKAGE_TYPE_OS === oPackageType ? redisKeyLicense : (state ? new Date(1) : new Date()); yield utils.promiseRedis(redisClient, redisClient.hset, redisKeyLicense, redisKeyLicense, val); } +exports.buildVersion = buildVersion; +exports.buildNumber = buildNumber; diff --git a/DocService/sources/DocsCoServer.js b/DocService/sources/DocsCoServer.js index 25f8ae0f..f8c14cc5 100644 --- a/DocService/sources/DocsCoServer.js +++ b/DocService/sources/DocsCoServer.js @@ -84,6 +84,7 @@ const constants = require('./../../Common/sources/constants'); var utils = require('./../../Common/sources/utils'); var commonDefines = require('./../../Common/sources/commondefines'); var statsDClient = require('./../../Common/sources/statsdclient'); +const license = require('./../../Common/sources/license'); var config = require('config').get('services.CoAuthoring'); var sqlBase = require('./baseConnector'); var canvasService = require('./canvasservice'); @@ -2130,10 +2131,11 @@ exports.commandFromServer = function (req, res) { var result = commonDefines.c_oAscServerCommandErrors.NoError; var docId = 'null'; try { + var version = undefined; var query = req.query; // Ключ id-документа docId = query.key; - if (null == docId) { + if (null == docId && 'version' != query.c) { result = commonDefines.c_oAscServerCommandErrors.DocumentIdError; } else { logger.debug('Start commandFromServer: docId = %s c = %s', docId, query.c); @@ -2192,6 +2194,9 @@ exports.commandFromServer = function (req, res) { result = commonDefines.c_oAscServerCommandErrors.NotModify; } break; + case 'version': + version = license.buildVersion + '.' + license.buildNumber; + break; default: result = commonDefines.c_oAscServerCommandErrors.UnknownCommand; break; @@ -2201,7 +2206,8 @@ exports.commandFromServer = function (req, res) { result = commonDefines.c_oAscServerCommandErrors.UnknownError; logger.error('Error commandFromServer: docId = %s\r\n%s', docId, err.stack); } finally { - var output = JSON.stringify({'key': req.query.key, 'error': result}); + //undefined value are excluded in JSON.stringify + var output = JSON.stringify({'key': req.query.key, 'error': result, 'version': version}); logger.debug('End commandFromServer: docId = %s %s', docId, output); var outputBuffer = new Buffer(output, 'utf8'); res.setHeader('Content-Type', 'application/json');