From d0a6670bfc3f1a9ccff66fd4c7cbf19aab08fdf3 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Tue, 12 Nov 2024 16:48:35 +0300 Subject: [PATCH] [feature] Add "multitenancy" flag as alternative to "alias" --- Common/sources/license.js | 3 ++- Common/sources/tenantManager.js | 9 +++++++-- Common/sources/utils.js | 1 + DocService/sources/server.js | 7 ++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Common/sources/license.js b/Common/sources/license.js index 8813cbac..d43ee210 100644 --- a/Common/sources/license.js +++ b/Common/sources/license.js @@ -59,7 +59,8 @@ exports.readLicense = async function () { startDate: startDate, endDate: null, customerId: "", - alias: "" + alias: "", + multitenancy: false }, null]; }; diff --git a/Common/sources/tenantManager.js b/Common/sources/tenantManager.js index a7c07ded..8a91d746 100644 --- a/Common/sources/tenantManager.js +++ b/Common/sources/tenantManager.js @@ -246,7 +246,8 @@ function fixTenantLicense(ctx, licenseInfo, licenseInfoTenant) { async function getTenantLicense(ctx) { let res = licenseTuple; if (isMultitenantMode(ctx) && !isDefaultTenant(ctx)) { - if (licenseInfo.alias) { + //todo alias is deprecated. remove one year after 8.3 + if (licenseInfo.multitenancy || licenseInfo.alias) { let tenantPath = utils.removeIllegalCharacters(ctx.tenant); let licensePath = path.join(cfgTenantsBaseDir, tenantPath, cfgTenantsFilenameLicense); let licenseTupleTenant = nodeCache.get(licensePath); @@ -263,7 +264,7 @@ async function getTenantLicense(ctx) { res = [...res]; res[0] = {...res[0]}; res.type = constants.LICENSE_RESULT.Error; - ctx.logger.error('getTenantLicense error: missing "alias" field'); + ctx.logger.error('getTenantLicense error: missing "multitenancy" or "alias" field'); } } return res; @@ -312,6 +313,10 @@ async function readLicenseTenant(ctx, licenseFile, baseVerifiedLicense) { res.alias = oLicense['alias']; } + if (oLicense['multitenancy']) { + res.multitenancy = oLicense['multitenancy']; + } + if (true === oLicense['timelimited']) { res.mode |= c_LM.Limited; } diff --git a/Common/sources/utils.js b/Common/sources/utils.js index a4a067fd..9c15ac56 100644 --- a/Common/sources/utils.js +++ b/Common/sources/utils.js @@ -1159,6 +1159,7 @@ exports.convertLicenseInfoToFileParams = function(licenseInfo) { license.users_expire = licenseInfo.usersExpire / constants.LICENSE_EXPIRE_USERS_ONE_DAY; license.customer_id = licenseInfo.customerId; license.alias = licenseInfo.alias; + license.multitenancy = licenseInfo.multitenancy; return license; }; exports.convertLicenseInfoToServerParams = function(licenseInfo) { diff --git a/DocService/sources/server.js b/DocService/sources/server.js index 32918edb..adfd1339 100644 --- a/DocService/sources/server.js +++ b/DocService/sources/server.js @@ -152,15 +152,16 @@ docsCoServer.install(server, () => { let [licenseInfo] = yield tenantManager.getTenantLicense(ctx); let buildVersion = commonDefines.buildVersion; let buildNumber = commonDefines.buildNumber; - let buildDate, packageType, customerId = "", alias = ""; + let buildDate, packageType, customerId = "", alias = "", multitenancy=""; if (licenseInfo) { buildDate = licenseInfo.buildDate.toISOString(); packageType = licenseInfo.packageType; customerId = licenseInfo.customerId; - alias = licenseInfo.alias; + multitenancy = licenseInfo.multitenancy; } let output = `Server is functioning normally. Version: ${buildVersion}. Build: ${buildNumber}`; - output += `. Release date: ${buildDate}. Package type: ${packageType}. Customer Id: ${customerId}. Alias: ${alias}`; + output += `. Release date: ${buildDate}. Package type: ${packageType}. Customer Id: ${customerId}`; + output += `. Multitenancy: ${multitenancy}. Alias: ${alias}`; res.send(output); } catch (err) { ctx.logger.error('index.html error: %s', err.stack);