Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit a75a0320 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[URGENT] Fix DomiSML integration: register/unregister

parent 133faef0
Branches EDELIVERY-11518-adoptiumopenjdk-for-dockers
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import {SmpConstants} from "../../smp.constants";
import {SecurityService} from "../../security/security.service";
import {User} from "../../security/user.model";
import {SMLResult} from "../model/sml-result.model";
import {DomainRo} from "../model/domain-ro.model";
@Injectable()
export class SmlIntegrationService {
......@@ -15,13 +16,17 @@ export class SmlIntegrationService {
private securityService: SecurityService) {
}
registerDomainToSML$(domainCode): Observable<SMLResult> {
registerDomainToSML$(domain: DomainRo): Observable<SMLResult> {
const currentUser: User = this.securityService.getCurrentUser();
return this.http.put<SMLResult>(`${SmpConstants.REST_INTERNAL_DOMAIN_MANAGE_DEPRECATED}/${currentUser.userId}/sml-register/${domainCode}`, {});
return this.http.put<SMLResult>(SmpConstants.REST_INTERNAL_DOMAIN_SML_REGISTER
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, currentUser.userId)
.replace(SmpConstants.PATH_PARAM_ENC_DOMAIN_ID, domain.domainId), {});
}
unregisterDomainToSML$(domainCode): Observable<SMLResult> {
unregisterDomainToSML$(domain: DomainRo): Observable<SMLResult> {
const currentUser: User = this.securityService.getCurrentUser();
return this.http.put<SMLResult>(`${SmpConstants.REST_INTERNAL_DOMAIN_MANAGE_DEPRECATED}/${currentUser.userId}/sml-unregister/${domainCode}`, {});
return this.http.put<SMLResult>(SmpConstants.REST_INTERNAL_DOMAIN_SML_UNREGISTER
.replace(SmpConstants.PATH_PARAM_ENC_USER_ID, currentUser.userId)
.replace(SmpConstants.PATH_PARAM_ENC_DOMAIN_ID, domain.domainId), {});
}
}
......@@ -19,6 +19,8 @@ export class SmpConstants {
public static readonly PATH_ACTION_UPDATE_RESOURCE_TYPES: string = 'update-resource-types';
public static readonly PATH_ACTION_UPDATE_SML_INTEGRATION: string = 'update-sml-integration-data';
public static readonly PATH_ACTION_GENERATE_DNS_QUERY: string = 'generate-dns-query';
public static readonly PATH_ACTION_SML_REGISTER: string = 'sml-register';
public static readonly PATH_ACTION_SML_UNREGISTER: string = 'sml-unregister';
/* URL variables */
public static readonly PATH_PARAM_ENC_USER_ID: string = '{user-id}';
public static readonly PATH_PARAM_ENC_DOMAIN_ID: string = '{domain-id}';
......@@ -188,6 +190,11 @@ export class SmpConstants {
public static readonly REST_INTERNAL_DOMAIN_MANAGE_CREATE = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE
+ '/' + SmpConstants.PATH_ACTION_CREATE;
public static readonly REST_INTERNAL_DOMAIN_SML_REGISTER = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE
+ '/' + SmpConstants.PATH_PARAM_ENC_DOMAIN_ID + '/' + SmpConstants.PATH_ACTION_SML_REGISTER;
public static readonly REST_INTERNAL_DOMAIN_SML_UNREGISTER = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE
+ '/' + SmpConstants.PATH_PARAM_ENC_DOMAIN_ID + '/' + SmpConstants.PATH_ACTION_SML_UNREGISTER;
public static readonly REST_INTERNAL_DOMAIN_MANAGE_UPDATE_SML_INTEGRATION = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE
+ '/' + SmpConstants.PATH_PARAM_ENC_DOMAIN_ID + '/' + SmpConstants.PATH_ACTION_UPDATE_SML_INTEGRATION;
......
......@@ -161,10 +161,8 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
}
if (!this._domain.smlClientKeyAlias ) {
console.log("enableSMLRegister 4")
return false;
}
console.log("enableSMLRegister 5")
// entity must be first persisted in order to be enabled to register to SML
return !this._domain.smlRegistered;
}
......@@ -222,10 +220,7 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
}
smlRegisterDomain(domain: DomainRo) {
//this.searchTable.showSpinner = true;
this.smlIntegrationService.registerDomainToSML$(domain.domainCode).toPromise().then(async (res: SMLResult) => {
// this.searchTable.showSpinner = false;
this.smlIntegrationService.registerDomainToSML$(domain).toPromise().then(async (res: SMLResult) => {
if (res) {
if (res.success) {
this.alertService.success(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.success.register", {domainCode: domain.domainCode})));
......@@ -243,16 +238,14 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) {
return;
}
// this.searchTable.showSpinner = false;
this.alertService.exception(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.error.register", {domainCode: domain.domainCode})), err);
}
)
}
smlUnregisterDomain(domain: DomainRo) {
// this.searchTable.showSpinner = true;
this.smlIntegrationService.unregisterDomainToSML$(domain.domainCode).toPromise().then(async (res: SMLResult) => {
// this.searchTable.showSpinner = false;
this.smlIntegrationService.unregisterDomainToSML$(domain).toPromise().then(async (res: SMLResult) => {
if (res) {
if (res.success) {
this.alertService.success(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.success.unregister", {domainCode: domain.domainCode})));
......@@ -271,7 +264,6 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) {
return;
}
// this.searchTable.showSpinner = false;
this.alertService.exception(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.error.unregister", {domainCode: domain.domainCode})), err);
}
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment