Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V3] updates from V2 #524

Closed
wants to merge 88 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
e4f7f55
Use zowe standard network config
1000TurquoisePogs Oct 11, 2023
0d39b61
Update changelog with PR #511 description
zowe-robot Oct 11, 2023
4ab73ac
Zowe Suite v2.12.0
zowe-robot Oct 11, 2023
dc061df
Correcting Content-Length calculation to take into account multi-byte…
GintautasMickus Nov 13, 2023
955469a
Set saf type to be a collection of those that start with safkeyring...
1000TurquoisePogs Nov 15, 2023
a850f87
Comment on secure protocol
1000TurquoisePogs Nov 15, 2023
a2cc8b5
Overhauled cipher customization. Now includes IANA names. Added tls v…
1000TurquoisePogs Nov 16, 2023
02c4560
Merge branch 'v2.x/staging' into feature/use-networking-standard-config
sakshibobade21 Nov 17, 2023
2e55443
Merge pull request #511 from zowe/feature/use-networking-standard-config
1000TurquoisePogs Nov 17, 2023
20b5b5f
Merge branch 'v2.x/staging' into v2.x/staging
1000TurquoisePogs Nov 17, 2023
b7ef16c
Merge pull request #516 from GintautasMickus/v2.x/staging
1000TurquoisePogs Nov 17, 2023
bbee063
Merge branch 'v2.x/staging' into feature/various-keyring
1000TurquoisePogs Nov 21, 2023
1662049
Do not allow downgrade below TLSv1.2
1000TurquoisePogs Nov 22, 2023
b16156c
Merge pull request #517 from zowe/1000TurquoisePogs-patch-8
1000TurquoisePogs Nov 22, 2023
a208aa9
Merge branch 'v2.x/staging' into feature/various-keyring
1000TurquoisePogs Nov 28, 2023
933fda0
Merge pull request #467 from zowe/feature/various-keyring
1000TurquoisePogs Nov 28, 2023
749d294
Zowe Suite v2.13.0
zowe-robot Nov 28, 2023
8837572
Fix saf list concat
1000TurquoisePogs Dec 4, 2023
0cc59f6
Merge pull request #519 from zowe/bugfix/v2/saf-concat-keyring
1000TurquoisePogs Dec 4, 2023
899840e
Merge pull request #520 from zowe/v2.x/staging
1000TurquoisePogs Dec 4, 2023
9a52425
Fix for detecting whether or not in HA mode. Effected detecting ZSS c…
1000TurquoisePogs Dec 11, 2023
1a5ab9e
Fix hostname versus gatewayHostname in various places. Fix missing 40…
1000TurquoisePogs Dec 12, 2023
36c2645
Fixes upon testing behavior in HA
1000TurquoisePogs Dec 12, 2023
15eca84
Fix fallback variable for developers
1000TurquoisePogs Dec 12, 2023
9aa80ff
parameter fix for semi auth
1000TurquoisePogs Dec 21, 2023
698a5ea
Merge pull request #523 from zowe/bugfix/saf-check-on-get-plugins
DivergentEuropeans Dec 28, 2023
0ff9044
Zowe Suite v2.14.0
zowe-robot Jan 9, 2024
8e8ac6a
Merge branch 'v2.x/staging' into bugfix/v2/ha-mode-detection
1000TurquoisePogs Jan 9, 2024
565283d
Merge pull request #521 from zowe/bugfix/v2/ha-mode-detection
1000TurquoisePogs Jan 9, 2024
33d0e55
Merge branch 'v2.x/staging' into bugfix/v2/multiple-discovery
1000TurquoisePogs Jan 9, 2024
bba0d74
Merge pull request #522 from zowe/bugfix/v2/multiple-discovery
1000TurquoisePogs Jan 9, 2024
9139f1c
Zowe Suite v2.14.0
zowe-robot Jan 9, 2024
2e0f416
Fix gatway gateway typo
1000TurquoisePogs Jan 19, 2024
f9cf52f
Merge pull request #528 from zowe/bugfix/rc/gatway-typo
1000TurquoisePogs Jan 19, 2024
4bf97dd
Merge pull request #531 from zowe/v2.x/rc
timgerstel Jan 23, 2024
337495f
Bugfix for https and http addresses merge
skurnevich Jan 24, 2024
b9db5e3
Changelog
skurnevich Jan 24, 2024
a7e5b99
Fix keyring existence check
1000TurquoisePogs Jan 24, 2024
f16ae37
Bump axios 0.22.0 -> 1.6.7
timgerstel Jan 31, 2024
1b98966
Update type of headers in ApimlResponse interface
timgerstel Jan 31, 2024
71b81c3
my mind went blank on the last commit
timgerstel Jan 31, 2024
aa4766b
Add header instace type
timgerstel Jan 31, 2024
c94ce3d
Test type any
timgerstel Jan 31, 2024
620851e
Theyre just http headers, right????
timgerstel Jan 31, 2024
cfb3d1b
Remove unused eps
timgerstel Jan 31, 2024
05ff06f
Remove coma
timgerstel Jan 31, 2024
072abcb
Merge pull request #534 from zowe/deps/axios
1000TurquoisePogs Feb 2, 2024
f6bb567
Merge branch 'v2.x/staging' into bugfix/http-https-address-merge
1000TurquoisePogs Feb 2, 2024
5b6422c
Merge pull request #532 from zowe/bugfix/http-https-address-merge
1000TurquoisePogs Feb 2, 2024
c824fd2
Merge pull request #533 from zowe/1000TurquoisePogs-patch-9
1000TurquoisePogs Feb 2, 2024
7cbbda0
Zowe Suite v2.15.0
zowe-robot Feb 20, 2024
656ad63
Update axios used in testbed
1000TurquoisePogs Mar 6, 2024
e1fd845
Merge pull request #537 from zowe/fix/v2/testbed-axios
1000TurquoisePogs Mar 6, 2024
236290b
Fix not being able to run in an http mode and still do https client c…
1000TurquoisePogs Apr 5, 2024
fdea588
Make discovery registration always https. add zoweconfig json to secu…
1000TurquoisePogs Apr 5, 2024
257ec95
Fix detection of client attls
1000TurquoisePogs Apr 8, 2024
b956f2b
Fix ref to zoweconf
1000TurquoisePogs Apr 9, 2024
fbad8fb
Proper read file
Martin-Zeithaml Apr 10, 2024
4555e87
Merge pull request #545 from zowe/readManifest
1000TurquoisePogs Apr 12, 2024
c55e402
Fix missing ref to zoweconf
1000TurquoisePogs Apr 17, 2024
8f98d15
Fix this reference
1000TurquoisePogs Apr 17, 2024
b87fdbd
Flipped boolean on checking how to contact apiml
1000TurquoisePogs Apr 17, 2024
96db748
bump axios 1.6.8 to resolve follow-redirects vuln
timgerstel Apr 23, 2024
15480b2
Bump express 4.18.0 -> 4.19.2
timgerstel Apr 23, 2024
c0a2358
Merge pull request #547 from zowe/deps/axios1.6.8v2
timgerstel Apr 25, 2024
e4dd4c9
Merge branch 'v2.x/staging' into deps/express4.19.2
timgerstel Apr 25, 2024
0924297
Axios update
Martin-Zeithaml Apr 30, 2024
a1180c0
Merge pull request #548 from zowe/deps/express4.19.2
1000TurquoisePogs Apr 30, 2024
d05c04e
Merge branch 'v2.x/staging' into v2.x/axiosUpdate
1000TurquoisePogs Apr 30, 2024
806be15
Merge pull request #550 from zowe/v2.x/axiosUpdate
1000TurquoisePogs Apr 30, 2024
5e6323b
fix merge
May 1, 2024
d1460e0
Merge pull request #552 from zowe/users/jstruga/merge-staging-into-rc
1000TurquoisePogs May 2, 2024
c528a27
Merge branch 'v2.x/staging' into bugfix/v2/attls
skurnevich May 24, 2024
f7aaa30
Make client attls follow server attls if not defined
1000TurquoisePogs May 28, 2024
a0ee0bd
Fix highly confusing english
1000TurquoisePogs May 28, 2024
2305d68
Bugfix spotted by Sakshi
1000TurquoisePogs May 28, 2024
f0d5298
Update CHANGELOG.md
1000TurquoisePogs May 28, 2024
d2a02a2
Merge pull request #544 from zowe/bugfix/v2/attls
1000TurquoisePogs May 28, 2024
f674faa
Update @rocketsoftware/eureka-js-client to update peer dep request
timgerstel May 29, 2024
1f5d923
Merge pull request #556 from zowe/deps/eureka-js-client-v2.x
1000TurquoisePogs May 31, 2024
713c314
Updated libraries to latest non-breaking versions, and removed unneed…
1000TurquoisePogs Mar 7, 2024
f4a6879
Fix problems found during testing
1000TurquoisePogs Apr 9, 2024
6bc9106
Fix var
1000TurquoisePogs Apr 9, 2024
d032301
Update util.js
1000TurquoisePogs Jun 17, 2024
3284682
Revert last change
1000TurquoisePogs Jun 17, 2024
7252bc1
Merge pull request #538 from zowe/feature/update-libraries
1000TurquoisePogs Jun 18, 2024
f4fbf6b
Zowe Suite v2.17.0
zowe-robot Jul 2, 2024
ef8078c
Merge pull request #561 from zowe/v2.x/rc
1000TurquoisePogs Aug 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to the Zlux Server Framework package will be documented in this file..
This repo is part of the app-server Zowe Component, and the change logs here may appear on Zowe.org in that section.

## 2.17.0
- Enhancement: Added function `isClientAttls(zoweConfig)` within `libs/util.js`. Whenever a plugin makes a network request, it should always use this to determine if a normally HTTPS request should instead be made as HTTP due to AT-TLS handling the TLS when enabled. (#544)
- Bugfix: Fixed function `isServerAttls(zoweConfig)` within `libs/util.js`, which was preventing using AT-TLS with app-server. (#544)

## 2.15.0
- Bugfix: App-server could not run in HTTP mode for AT-TLS setup because it was not able to merge HTTPS and HTTP addresses. (#984)

## 2.14.0
- Bugfix: App-server could not load when multiple discovery servers were present and the app-server was unable to reach the first one specified. Now, the app-server will iterate through the list of servers until an accessible one is reached. (#522)
- Bugfix: App-server would not correctly detect when it was running in a high-availability configuration environment. (#521)
- Bugfix: A call to GET /plugins would trigger an authorization check regardless of if rbac was set on or off (#523)

## 2.13.0
- Added support for using zowe.network and components.app-server.zowe.network to set listener IP and TLS properties including max and min version, ciphers, and ECDH curves. (#511)
- Enhanced cipher customization to allow for ciphers to be specified in IANA format in addition to the existing OpenSSL format. (#511)

## 2.12.0

- Enhancement: Auth plugins that are not requested by any dataservice found at startup are no longer loaded by the server.
Expand Down
78 changes: 42 additions & 36 deletions lib/apiml.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Promise = require("bluebird");
const eureka = require('@rocketsoftware/eureka-js-client').Eureka;
const zluxUtil = require('./util');
const https = require('https');
const http = require('http');

const log = zluxUtil.loggers.apiml;

Expand Down Expand Up @@ -77,10 +78,10 @@ const MEDIATION_LAYER_INSTANCE_DEFAULTS = (zluxProto, zluxHostname, zluxPort) =>
}
}};

function ApimlConnector({ hostName, port, isHttps, discoveryHost,
discoveryPort, tlsOptions, eurekaOverrides }) {
Object.assign(this, { hostName, port, isHttps, discoveryHost,
discoveryPort, tlsOptions, eurekaOverrides });
function ApimlConnector({ hostName, port, discoveryUrls,
discoveryPort, tlsOptions, eurekaOverrides, isClientAttls }) {
Object.assign(this, { hostName, port, discoveryUrls,
discoveryPort, tlsOptions, eurekaOverrides, isClientAttls });
this.vipAddress = hostName;
}

Expand Down Expand Up @@ -110,29 +111,21 @@ ApimlConnector.prototype = {
const end = Date.now() + timer;

return new Promise((resolve, reject) => {
const options = Object.assign({
host: this.discoveryHost,
port: this.discoveryPort,
method: 'GET',
path: `/eureka/apps/${serviceName}`,
headers: {'accept':'application/json'}
}, this.tlsOptions);

if (!this.tlsOptions.rejectUnauthorized) {
//Keeping these certs causes an openssl error 46, unknown cert error in a dev environment
delete options.cert;
delete options.key;
} //else, apiml expects a cert and will give a 403.
const optionsArray = this.getRequestOptionsArray('GET', `/eureka/apps/${serviceName}`);
let optionsIndex = 0;

const issueRequest = () => {
const options = optionsArray[optionsIndex];
if (Date.now() > end) {
log.warn(`ZWED0045`, this.discoveryHost, this.discoveryPort);
log.warn(`ZWED0045W`, this.discoveryHost, this.discoveryPort);
return reject(new Error(`Call timeout when fetching agent status from APIML`));
}

let data = [];

let httpModule = this.isClientAttls ? http : https;

const req = https.request(options, (res) => {
const req = httpModule.request(options, (res) => {
res.on('data', (chunk) => data.push(chunk));
res.on('end', () => {
log.debug(`Query rc=`,res.statusCode);
Expand All @@ -156,7 +149,9 @@ ApimlConnector.prototype = {
reject(new Error(`Call timeout when fetching agent status from APIML`));
});
req.on('error', (error) => {
log.warn("APIML query error:", error.message);
log.warn("ZWED0180W", options.host, options.port, error.message);
//
optionsIndex = (optionsIndex+1) % optionsArray.length;
setTimeout(issueRequest, AGENT_CHECK_RECONNECT_DELAY);
});
req.end();
Expand All @@ -173,10 +168,10 @@ ApimlConnector.prototype = {
// If the HTTP port is set to 0 then the API ML doesn't load zlux
httpPort: Number(this.port),
httpsPort: Number(this.port),
httpEnabled: !this.isHttps,
httpsEnabled: this.isHttps
httpEnabled: false,
httpsEnabled: true
};
const proto = this.isHttps? 'https' : 'http';
const proto = 'https';

log.debug("ZWED0141I", proto, this.port); //"Protocol:", proto, "Port", port);
log.debug("ZWED0142I", JSON.stringify(protocolObject)); //"Protocol Object:", JSON.stringify(protocolObject));
Expand Down Expand Up @@ -249,8 +244,7 @@ ApimlConnector.prototype = {
}
log.debug("ZWED0144I", JSON.stringify(zluxProxyServerInstanceConfig, null, 2)); //log.debug("zluxProxyServerInstanceConfig: "
//+ JSON.stringify(zluxProxyServerInstanceConfig, null, 2))
const defaultUrl = `https://${this.discoveryHost}:${this.discoveryPort}/eureka/apps`;
const serviceUrls = this.getServiceUrls(defaultUrl);
const serviceUrls = this.getServiceUrls();
zluxProxyServerInstanceConfig.eureka.serviceUrls = { default: serviceUrls };
log.info(`ZWED0020I`, serviceUrls.join(',')); //log.info(`Registering at ${url}...`);
log.debug("ZWED0145I", JSON.stringify(zluxProxyServerInstanceConfig)); //log.debug(`zluxProxyServerInstanceConfig ${JSON.stringify(zluxProxyServerInstanceConfig)}`)
Expand Down Expand Up @@ -285,17 +279,29 @@ ApimlConnector.prototype = {
});
},

getServiceUrls(defaultUrl) {
const discoveryServiceList = process.env['ZWE_DISCOVERY_SERVICES_LIST'] || '';
const serviceUrls = discoveryServiceList
.split(',')
.map(url => url.trim())
.filter(url => url.length > 0)
.map(url => url + (url.endsWith('/') ? '' : '/') + 'apps');
if (serviceUrls.length === 0) {
serviceUrls.push(defaultUrl);
}
return serviceUrls;
getServiceUrls() {
return this.discoveryUrls.map(url => url + (url.endsWith('/') ? '' : '/') + 'apps');
},

getRequestOptionsArray(method, path) {
return this.discoveryUrls.map((url)=>{
//in the form of https://host:port/eureka/, trim from https:// and following slash.
const hostAndPort = url.substring(8, url.indexOf('/', 8)).split(':');
const options = Object.assign({
host: hostAndPort[0],
port: hostAndPort[1],
method: method,
path: path,
headers: {'accept':'application/json'}
}, this.tlsOptions);

if (!this.tlsOptions.rejectUnauthorized) {
//Keeping these certs causes an openssl error 46, unknown cert error in a dev environment
delete options.cert;
delete options.key;
} //else, apiml expects a cert and will give a 403.
return options;
});
}

/*
Expand Down
20 changes: 14 additions & 6 deletions lib/apimlStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ import { AxiosInstance } from 'axios';
let apimlClient: AxiosInstance;

export function configure(settings: ApimlStorageSettings) {
apimlClient = axios.create({
baseURL: `https://${settings.host}:${settings.port}`,
httpsAgent: new https.Agent(settings.tlsOptions)
});
if (settings.isHttps) {
apimlClient = axios.create({
baseURL: `https://${settings.host}:${settings.port}`,
httpsAgent: new https.Agent(settings.tlsOptions)
});
} else {
apimlClient = axios.create({
baseURL: `https://${settings.host}:${settings.port}`,
httpAgent: new http.Agent()
});
}
}

export function isConfigured(): boolean {
Expand All @@ -30,6 +37,7 @@ export interface ApimlStorageSettings {
host: string;
port: number;
tlsOptions: https.AgentOptions;
isHttps?: boolean;
}


Expand Down Expand Up @@ -162,7 +170,7 @@ async function apimlDoRequest(req: ApimlRequest): Promise<ApimlResponse> {
headers: req.headers,
});
const apimlResponse: ApimlResponse = {
headers: response.headers,
headers: response.headers as http.IncomingHttpHeaders,
statusCode: response.status,
json: response.data
};
Expand Down Expand Up @@ -375,4 +383,4 @@ class ApimlStorage {
SPDX-License-Identifier: EPL-2.0

Copyright Contributors to the Zowe Project.
*/
*/
1 change: 1 addition & 0 deletions lib/assets/i18n/log/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@
"ZWED0177W":"Unable to load %s for '%s' into config",
"ZWED0178W":"Skipping authentication plugin %s because it's not HA compatible",
"ZWED0179W":"Unable to retrieve the list of certificate authorities from the keyring=%s owner=%s Error: %s",
"ZWED0180W":"Failed to query discovery server (%s:%s) for agent access: %s",

"ZWED0001E":"RESERVED: Error: %s",
"ZWED0002E":"Could not stop language manager for types=%s",
Expand Down
3 changes: 2 additions & 1 deletion lib/auth-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ AuthManager.prototype = {
plugin,
this.configuration,
componentConfig,
new AuthPluginContext(plugin, tlsOptions));
new AuthPluginContext(plugin, tlsOptions),
config);
// at this time we should have resolved plugin configuration to have a
// nice list of info about what we are using to authenticate against
if ((typeof authenticationHandler.authenticate) !== 'function') {
Expand Down
16 changes: 8 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,10 @@ Server.prototype = {
this.apiml = new ApimlConnector({
hostName: webAppOptions.hostname,
port: this.port,
isHttps: util.isServerHttps(this.zoweConfig),
discoveryHost: apimlConfig.server.hostname,
discoveryPort: apimlConfig.server.port,
discoveryUrls: apimlConfig.server.discoveryUrls || [`https://${apimlConfig.server.hostname}:${apimlConfig.server.port}/eureka/`],
tlsOptions: this.tlsOptions,
eurekaOverrides: apimlConfig.eureka
eurekaOverrides: apimlConfig.eureka,
isClientAttls: util.isClientAttls(this.zoweConfig)
});
yield this.apiml.setBestIpFromConfig(this.componentConfig.node);
yield this.apiml.registerMainServerInstance();
Expand All @@ -236,7 +235,7 @@ Server.prototype = {
&& this.componentConfig.agent.mediationLayer.serviceName
&& this.componentConfig.node.mediationLayer.server?.gatewayPort) {
//at this point, we expect zss to also be attached to the mediation layer, so lets adjust.
webAppOptions.proxiedHost = apimlConfig.server.hostname;
webAppOptions.proxiedHost = apimlConfig.server.gatewayHostname;
webAppOptions.proxiedPort = this.componentConfig.node.mediationLayer.server.gatewayPort;
if (firstWorker) {
yield this.apiml.checkAgent(this.componentConfig.agent.handshakeTimeout,
Expand Down Expand Up @@ -264,7 +263,7 @@ Server.prototype = {

bootstrapLogger.info('ZWED0302I', util.isHaMode() ? 'enabled' : 'disabled'); // "HA mode is %s"
if (apimlConfig.cachingService?.enabled) {
this.configureApimlStorage(apimlConfig);
this.configureApimlStorage(apimlConfig, util.isClientAttls(this.zoweConfig));
}

const plugins = yield this.loadPlugins();
Expand Down Expand Up @@ -336,11 +335,12 @@ Server.prototype = {
return yield this.pluginLoader.loadPlugins();
}),

configureApimlStorage(apimlConfig) {
configureApimlStorage(apimlConfig, isHttps) {
apimlStorage.configure({
host: apimlConfig.server.gatewayHostname,
port: apimlConfig.server.gatewayPort,
tlsOptions: this.tlsOptions
tlsOptions: this.tlsOptions,
isHttps: isHttps
});
bootstrapLogger.info(`ZWED0300I`); // Caching Service configured
},
Expand Down
4 changes: 2 additions & 2 deletions lib/swagger-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Promise = require('bluebird');
const zLuxUrl = require('./url')
const path = require('path');
const fs = require('fs');
const jsyaml = require('js-yaml');
const yaml = require('yaml');
const swaggerParser = require('swagger-parser')
const os = require('os');
const zluxUtil = require('./util');
Expand Down Expand Up @@ -201,7 +201,7 @@ function readSingleSwaggerFile (dirName, serviceName, serviceVersion) {
if (err) {
return reject(err);
}
let swaggerJson = jsyaml.safeLoad(fileContent);
let swaggerJson = yaml.parse(fileContent);
swaggerParser.validate(swaggerJson).then(function(valid) {
return resolve(swaggerJson)
}).catch(function(err) {
Expand Down
10 changes: 4 additions & 6 deletions lib/tomcatManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ unpack the wars ahead of time, so the symbolic links are the unpacked dirs
import { Path, TomcatConfig, TomcatShutdown, TomcatHttps, JavaServerManager, AppServerInfo } from './javaTypes';
import * as fs from 'graceful-fs';
import * as path from 'path';
import * as mkdirp from 'mkdirp';
import * as child_process from 'child_process';
//import * as xml2js from 'xml2js';
import * as yauzl from 'yauzl';
import * as utils from './util';
import * as rimraf from 'rimraf';

const log = utils.loggers.langManager;
const spawn = child_process.spawn;
Expand Down Expand Up @@ -63,7 +61,7 @@ export class TomcatManager implements JavaServerManager {

private makeRoot():Promise<void> {
return new Promise((resolve,reject)=> {
mkdirp(this.appdir, {mode: DIR_WRITE_MODE}, (err)=> {
fs.mkdir(this.appdir, {recursive: true, mode: DIR_WRITE_MODE}, (err)=> {
if (err) {
reject(err);
} else {
Expand Down Expand Up @@ -279,7 +277,7 @@ export class TomcatManager implements JavaServerManager {
log.info(`ZWED0092I`, this.id); //log.info(`Tomcat Manager ID=${this.id} stopping`);
TomcatManager.isWindows ? this.stopForWindows() : this.stopForUnix();
return new Promise((resolve, reject) => {
rimraf(this.appdir, (error)=> {
fs.rm(this.appdir, { recursive: true, force: true }, (error)=> {
if (error) {
reject(error);
} else {
Expand Down Expand Up @@ -368,7 +366,7 @@ export class TomcatManager implements JavaServerManager {
zipfile.on("entry", function(entry) {
if (entry.fileName.endsWith('/')) {
//directory
mkdirp(path.join(destPath,entry.fileName), {mode: DIR_WRITE_MODE}, (err)=> {
fs.mkdir(path.join(destPath,entry.fileName), {recursive: true, mode: DIR_WRITE_MODE}, (err)=> {
if (err) {
error = err;
zipfile.close();
Expand All @@ -380,7 +378,7 @@ export class TomcatManager implements JavaServerManager {
zipfile.readEntry(); //TODO is it correct to skip this?
} else {
//file
mkdirp(path.join(destPath,path.dirname(entry.fileName)), {mode: DIR_WRITE_MODE}, (err)=> {
fs.mkdir(path.join(destPath,path.dirname(entry.fileName)), {recursive: true, mode: DIR_WRITE_MODE}, (err)=> {
if (err) {
error = err;
zipfile.close();
Expand Down
23 changes: 15 additions & 8 deletions lib/translation-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';
const path = require('path');
const fs = require('fs');
const jsonUtils = require('./jsonUtils.js');
const glob = require('glob');
const zluxUtil = require('./util');
const acceptLanguageParser = require('accept-language-parser');

Expand All @@ -31,15 +31,22 @@ const utilLog = zluxUtil.loggers.utilLogger;
*/
function loadTranslations(pluginLocation) {
const translationMaps = {};
const relativePath = 'web/assets/i18n';
const filePrefix = 'pluginDefinition.i18n.';
const fileExt = '.json';
const pattern = path.join(
pluginLocation,
relativePath,
`${filePrefix}*${fileExt}`
);
const files = glob.sync(pattern, {});
const folder = path.join(pluginLocation, 'web/assets/i18n');
let files = [];
try {
files = fs.readdirSync(folder)
.filter((filename)=> {
return filename.startsWith(filePrefix) && filename.endsWith(fileExt);
})
.map((filename)=> {
return path.join(folder, filename);
});
} catch (e) {
//A plugin may not have translations and that is OK.
return translationMaps;
}
for (const file of files) {
const basename = path.basename(file);
const languageCountry = basename.substring(
Expand Down
Loading
Loading