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

ISPN-7148 Unable to create/edit Cache Configurations when Security is not enabled #137

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/module/cache-templates/CacheTemplates.ts
Expand Up @@ -50,13 +50,11 @@ module.config(($stateProvider: ng.ui.IStateProvider) => {
($q: ng.IQService, $stateParams, container, cacheConfigService) => {
let deferred: ng.IDeferred<any> = $q.defer<any>();
if (isNotNullOrUndefined($stateParams.baseType) && isNotNullOrUndefined($stateParams.baseName)) {
cacheConfigService.getTemplate(container, $stateParams.baseType, $stateParams.baseName)
.then(template => {
template.name = $stateParams.templateName;
template["template-name"] = $stateParams.templateName;
deferred.resolve(template);
});
return deferred.promise;
cacheConfigService.getTemplate(container, $stateParams.baseType, $stateParams.baseName).then(template => {
template.name = $stateParams.templateName;
template["template-name"] = $stateParams.templateName;
deferred.resolve(template);
});
} else {
deferred.resolve({
name: $stateParams.name,
Expand Down
2 changes: 1 addition & 1 deletion src/module/cache-templates/CacheTemplatesCtrl.ts
Expand Up @@ -9,7 +9,7 @@ import IModalService = angular.ui.bootstrap.IModalService;
import {LaunchTypeService} from "../../services/launchtype/LaunchTypeService";

export class CacheTemplatesCtrl extends AbstractConfigurationCtrl {
static $inject: string[] = ["$state", "$scope", "$uibModal", "domainService", "cacheConfigService", "container",
static $inject: string[] = ["$state", "$scope", "$uibModal", "domainService", "launchType", "cacheConfigService", "container",
"template", "meta"];

profile: string;
Expand Down
28 changes: 20 additions & 8 deletions src/services/cache-config/CacheConfigService.ts
Expand Up @@ -131,7 +131,7 @@ export class CacheConfigService {
}

removeConfiguration(container: ICacheContainer, type: string, name: string): ng.IPromise<void> {
let address: string[] = this.getConfigAddress(container.name, container.profile).concat(type, name);
let address: string[] = this.getConfigAddress(container.name, container.profile).concat(type + "-configuration", name);
return this.dmrService.executePost({
address: address,
operation: "remove"
Expand Down Expand Up @@ -298,9 +298,9 @@ export class CacheConfigService {
this.createHelper(builder, address.concat("state-transfer", "STATE_TRANSFER"), config["state-transfer"]);
this.createHelper(builder, address.concat("backup", "BACKUP"), config.backup);

this.updateSecurityAuthorization(config);
this.createHelper(builder, address.concat("security", "SECURITY"), config.security);
if (isNotNullOrUndefined(config.security)) {
if (this.isSecurityAuthorizationEnabled(config)) {
this.updateSecurityAuthorization(config);
this.createHelper(builder, address.concat("security", "SECURITY"), config.security);
this.createHelper(builder, address.concat("security", "SECURITY", "authorization", "AUTHORIZATION"), config.security.SECURITY.authorization);
}

Expand Down Expand Up @@ -376,9 +376,9 @@ export class CacheConfigService {
this.updateHelper(builder, address.concat("state-transfer", "STATE_TRANSFER"), config["state-transfer"]);
this.updateHelper(builder, address.concat("backup", "BACKUP"), config.backup);

this.updateSecurityAuthorization(config);
this.updateHelper(builder, address.concat("security", "SECURITY"), config.security);
if (isNotNullOrUndefined(config.security)) {
if (this.isSecurityAuthorizationDefined(config)) {
this.updateSecurityAuthorization(config);
this.updateHelper(builder, address.concat("security", "SECURITY"), config.security);
this.updateHelper(builder, address.concat("security", "SECURITY", "authorization", "AUTHORIZATION"), config.security.SECURITY.authorization);
}

Expand All @@ -401,12 +401,24 @@ export class CacheConfigService {

private updateSecurityAuthorization(config: any): void {
let auth: any = deepValue(config, "security.SECURITY.authorization.AUTHORIZATION");
if (isNotNullOrUndefined(auth) && auth["is-new-node"] && auth.enabled) {
let newlyCreatedNode: boolean = isNotNullOrUndefined(auth) && isNotNullOrUndefined(auth["is-new-node"]);
if (newlyCreatedNode) {
// special case handling to update the parent of AUTHORIZATION, that is SECURITY node
config.security.SECURITY["is-new-node"] = true;
config.security.SECURITY["required-node"] = true;
}
}

private isSecurityAuthorizationEnabled(config: any): boolean {
let auth: any = deepValue(config, "security.SECURITY.authorization.AUTHORIZATION");
return isNotNullOrUndefined(auth) && auth.enabled;
}

private isSecurityAuthorizationDefined(config: any): boolean {
let auth: any = deepValue(config, "security.SECURITY.authorization.AUTHORIZATION");
return isNotNullOrUndefined(auth);
}

private updateCacheLoader(builder: CompositeOpBuilder, address: string[], config: any): void {
let loader: any = deepGet(config, "loader.LOADER");
let loaderIsNewAndEmpty: boolean = isNullOrUndefined(loader) || (loader["is-new-node"] && Object.keys(loader).length < 2);
Expand Down
3 changes: 2 additions & 1 deletion src/services/cache/CacheService.ts
Expand Up @@ -93,7 +93,8 @@ export class CacheService {
createCacheAndConfiguration(container: ICacheContainer, type: string, name: string, config: any): ng.IPromise<void> {
let deferred: ng.IDeferred<void> = this.$q.defer<void>();
this.cacheConfigService.createCacheConfiguration(container, type, name, config)
.then(() => deferred.resolve(this.createCacheFromConfiguration(container, type, name, name)));
.then(() => deferred.resolve(this.createCacheFromConfiguration(container, type, name, name)),
error => deferred.reject(error));
return deferred.promise;
}

Expand Down
6 changes: 5 additions & 1 deletion src/services/dmr/DmrService.ts
Expand Up @@ -212,7 +212,11 @@ export class DmrService {
console.log(response.data);
let result: any = response.data;
if (result && result["failure-description"] != null) {
msg = result["failure-description"];
if (isNotNullOrUndefined(result["failure-description"]["domain-failure-description"])) {
msg = result["failure-description"]["domain-failure-description"];
} else {
msg = result["failure-description"];
}
}
}
return msg;
Expand Down