Skip to content

Commit

Permalink
Zowe Suite v1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zowe-robot authored Mar 25, 2020
2 parents 814d33c + aae9b84 commit 37210c2
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 75 deletions.
113 changes: 59 additions & 54 deletions base/src/dispatcher/dispatcher.ts

Large diffs are not rendered by default.

29 changes: 21 additions & 8 deletions base/src/plugin-manager/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { Plugin } from './plugin'
export class PluginManager {
private static desktopPlugin: Plugin | null = null;
private static pluginsById:Map<string,ZLUX.Plugin> = new Map();

public static logger:ZLUX.ComponentLogger;

private static parsePluginDefinitions(pluginData: any): Plugin[] {
if (pluginData["pluginDefinitions"] != null) {
const pluginDefinitions: any[] = pluginData["pluginDefinitions"];
Expand All @@ -25,9 +26,11 @@ export class PluginManager {
PluginManager.pluginsById.set(plugin.getIdentifier(),plugin);
return plugin;
} catch (error) {
console.error(error);
console.error("Skipping invalid plugin definition");
console.error(definition);
PluginManager.logger.severe("ZWED5036E", error);
PluginManager.logger.warn("ZWED5018W", definition);
//console.error(error);
//console.error("Skipping invalid plugin definition");
//console.error(definition);

return null;
}
Expand All @@ -36,16 +39,20 @@ export class PluginManager {
/* Remove skipped plugins */
return plugins.filter(x => x) as Plugin[];
} else {
throw new Error("Unable to parse plugin definitions: Missing field 'pluginDefinitions'");
throw new Error("ZWED5037E - Unable to parse plugin definitions: Missing field 'pluginDefinitions'");
}
}

static getPlugin(id:string):ZLUX.Plugin|undefined {
return PluginManager.pluginsById.get(id);
}

static loadPlugins(pluginType?: ZLUX.PluginType): Promise<ZLUX.Plugin[]> {
static loadPlugins(pluginType?: ZLUX.PluginType, update?: boolean): Promise<ZLUX.Plugin[]> {
return new Promise((resolve, reject) => {
if (PluginManager.pluginsById.size > 0 && !update) {
return resolve(Array.from(PluginManager.pluginsById.values()).filter(plugin => plugin.getType() == pluginType));
}

var request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (this.readyState == 4) {
Expand All @@ -55,7 +62,13 @@ export class PluginManager {
case 304:
try {
var result = JSON.parse(this.responseText);
resolve(PluginManager.parsePluginDefinitions(result));
let allPlugins = PluginManager.parsePluginDefinitions(result);
if (!pluginType) {
resolve(allPlugins);
} else {
const filtered = allPlugins.filter(plugin => plugin.getType() == pluginType)
resolve(filtered);
}
} catch (error) {
reject(error);
}
Expand All @@ -66,7 +79,7 @@ export class PluginManager {
}
}
};
request.open("GET", ZoweZLUX.uriBroker.pluginListUri(pluginType), true);
request.open("GET", ZoweZLUX.uriBroker.pluginListUri(undefined, update), true);
request.send();
});
}
Expand Down
24 changes: 18 additions & 6 deletions base/src/plugin-manager/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function parsePluginType(value: string): ZLUX.PluginType | null {
return ZLUX.PluginType.Application;
case "bootstrap":
return ZLUX.PluginType.Bootstrap;
case "library":
return ZLUX.PluginType.Library;
case "nodeAuthentication":
return ZLUX.PluginType.NodeAuthentication;
default:
return null;
}
Expand All @@ -40,7 +44,7 @@ export abstract class Plugin implements ZLUX.Plugin {
case 1:
return new Plugin_1(definition);
default:
throw new Error("Unrecognized plugin definition major version");
throw new Error("ZWED5038E - Unrecognized plugin definition major version");
}
}

Expand All @@ -58,6 +62,8 @@ export abstract class Plugin implements ZLUX.Plugin {

abstract hasComponents(): boolean;

abstract getBasePlugin(): any;

public toString():string {
return "<ZLUX.plugin "+this.getKey()+">";
}
Expand All @@ -71,31 +77,32 @@ class Plugin_0 extends Plugin {
readonly key:string;
readonly copyright:string;
readonly _hasComponents: boolean;
readonly _definition: any;

constructor(definition: any) {
super()

if (typeof definition.identifier === "string") {
this.identifier = definition.identifier;
} else {
throw new Error("Plugin identifier is not a string");
throw new Error("ZWED5039E - Plugin identifier is not a string");
}

if (typeof definition.pluginVersion === "string") {
this.version = definition.pluginVersion;
} else {
throw new Error("Plugin version is not a string");
throw new Error("ZWED5040E - Plugin version is not a string");
}

if (typeof definition.pluginType === "string") {
const pluginType = parsePluginType(definition.pluginType);
if (pluginType != null) {
this.type = pluginType;
} else {
throw new Error("Plugin type is not present");
throw new Error("ZWED5041E - Plugin type is not present");
}
} else {
throw new Error("Plugin type is not a string");
throw new Error("ZWED5042E - Plugin type is not a string");
}

this.key = definition.identifier + '@' + definition.pluginVersion;
Expand All @@ -112,7 +119,8 @@ class Plugin_0 extends Plugin {

if (typeof definition.copyright === "string") {
this.copyright = definition.copyright;
}
}
this._definition = definition;
}

getIdentifier():string{
Expand Down Expand Up @@ -143,6 +151,10 @@ class Plugin_0 extends Plugin {
return this._hasComponents;
}

getBasePlugin():any{
return this._definition;
}

}

class Plugin_1 extends Plugin_0 {
Expand Down
2 changes: 1 addition & 1 deletion base/src/util/semantic-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SemanticVersion {
this.identifiers = match[4] || null;
this.build = match[5] || null;
} else {
throw new Error(`${version} is not a valid semantic version`);
throw new Error(`ZWED5043E - ${version} is not a valid semantic version`);
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions interface/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ declare namespace ZLUX {
rasUri(uri: string): string;
serverRootUri(uri: string): string;
pluginResourceUri(pluginDefinition: Plugin, relativePath: string): string;
pluginListUri(pluginType?: PluginType): string;
pluginListUri(pluginType?: PluginType, update?:boolean): string;
pluginConfigForScopeUri(pluginDefinition: ZLUX.Plugin, scope: string, resourcePath: string, resourceName?: string): string;
/**
Returns a URI for accessing a resource for a particular user. NOTE: This command should be gated by authorization that restricts it to administrative use.
Expand All @@ -236,7 +236,6 @@ declare namespace ZLUX {
pluginRESTUri(pluginDefinition: Plugin, serviceName: string,
relativePath: string, version?: string): string;
}


interface PluginWatcher {
instanceAdded(instanceId: MVDHosting.InstanceId, isEmbedded: boolean|undefined): void;
Expand All @@ -246,7 +245,9 @@ declare namespace ZLUX {
const enum PluginType {
Desktop = "desktop",
Application = "application",
Bootstrap = "bootstrap"
Bootstrap = "bootstrap",
NodeAuthentication = "nodeAuthentication",
Library = "library"
}

interface Plugin {
Expand All @@ -257,6 +258,7 @@ declare namespace ZLUX {
getType():PluginType;
getCopyright(): string;
hasComponents(): boolean;
getBasePlugin(): any;
}

interface ContainerPluginDefinition {
Expand Down
8 changes: 5 additions & 3 deletions interface/src/mvd-hosting.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ declare namespace MVDHosting {
}

export interface PluginManagerInterface {
loadApplicationPluginDefinitions(): Promise<DesktopPluginDefinition[]>;
loadApplicationPluginDefinitionsMap(): Promise<Map<string, DesktopPluginDefinition>>;
findPluginDefinition(identifier: string): Promise<DesktopPluginDefinition | null>;
loadApplicationPluginDefinitions(update?: boolean): Promise<DesktopPluginDefinition[]>;
loadApplicationPluginDefinitionsMap(update?: boolean): Promise<Map<string, DesktopPluginDefinition>>;
findPluginDefinition(identifier: string, update?: boolean): Promise<DesktopPluginDefinition | null>;
updateMap(): Promise<Map<string, DesktopPluginDefinition>>;
pluginsAdded: EventEmitter<MVDHosting.DesktopPluginDefinition[]>
}

export interface LoginActionInterface {
Expand Down

0 comments on commit 37210c2

Please sign in to comment.