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
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ import {SmpConstants} from "../../smp.constants"; ...@@ -6,6 +6,7 @@ import {SmpConstants} from "../../smp.constants";
import {SecurityService} from "../../security/security.service"; import {SecurityService} from "../../security/security.service";
import {User} from "../../security/user.model"; import {User} from "../../security/user.model";
import {SMLResult} from "../model/sml-result.model"; import {SMLResult} from "../model/sml-result.model";
import {DomainRo} from "../model/domain-ro.model";
@Injectable() @Injectable()
export class SmlIntegrationService { export class SmlIntegrationService {
...@@ -15,13 +16,17 @@ export class SmlIntegrationService { ...@@ -15,13 +16,17 @@ export class SmlIntegrationService {
private securityService: SecurityService) { private securityService: SecurityService) {
} }
registerDomainToSML$(domainCode): Observable<SMLResult> { registerDomainToSML$(domain: DomainRo): Observable<SMLResult> {
const currentUser: User = this.securityService.getCurrentUser(); 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(); 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 { ...@@ -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_RESOURCE_TYPES: string = 'update-resource-types';
public static readonly PATH_ACTION_UPDATE_SML_INTEGRATION: string = 'update-sml-integration-data'; 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_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 */ /* URL variables */
public static readonly PATH_PARAM_ENC_USER_ID: string = '{user-id}'; public static readonly PATH_PARAM_ENC_USER_ID: string = '{user-id}';
public static readonly PATH_PARAM_ENC_DOMAIN_ID: string = '{domain-id}'; public static readonly PATH_PARAM_ENC_DOMAIN_ID: string = '{domain-id}';
...@@ -188,6 +190,11 @@ export class SmpConstants { ...@@ -188,6 +190,11 @@ export class SmpConstants {
public static readonly REST_INTERNAL_DOMAIN_MANAGE_CREATE = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE public static readonly REST_INTERNAL_DOMAIN_MANAGE_CREATE = SmpConstants.REST_INTERNAL_DOMAIN_MANAGE
+ '/' + SmpConstants.PATH_ACTION_CREATE; + '/' + 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 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; + '/' + SmpConstants.PATH_PARAM_ENC_DOMAIN_ID + '/' + SmpConstants.PATH_ACTION_UPDATE_SML_INTEGRATION;
......
...@@ -161,10 +161,8 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { ...@@ -161,10 +161,8 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
} }
if (!this._domain.smlClientKeyAlias ) { if (!this._domain.smlClientKeyAlias ) {
console.log("enableSMLRegister 4")
return false; return false;
} }
console.log("enableSMLRegister 5")
// entity must be first persisted in order to be enabled to register to SML // entity must be first persisted in order to be enabled to register to SML
return !this._domain.smlRegistered; return !this._domain.smlRegistered;
} }
...@@ -222,10 +220,7 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard { ...@@ -222,10 +220,7 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
} }
smlRegisterDomain(domain: DomainRo) { smlRegisterDomain(domain: DomainRo) {
//this.searchTable.showSpinner = true; this.smlIntegrationService.registerDomainToSML$(domain).toPromise().then(async (res: SMLResult) => {
this.smlIntegrationService.registerDomainToSML$(domain.domainCode).toPromise().then(async (res: SMLResult) => {
// this.searchTable.showSpinner = false;
if (res) { if (res) {
if (res.success) { if (res.success) {
this.alertService.success(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.success.register", {domainCode: domain.domainCode}))); 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 { ...@@ -243,16 +238,14 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) { if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) {
return; return;
} }
// this.searchTable.showSpinner = false;
this.alertService.exception(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.error.register", {domainCode: domain.domainCode})), err); this.alertService.exception(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.error.register", {domainCode: domain.domainCode})), err);
} }
) )
} }
smlUnregisterDomain(domain: DomainRo) { smlUnregisterDomain(domain: DomainRo) {
// this.searchTable.showSpinner = true;
this.smlIntegrationService.unregisterDomainToSML$(domain.domainCode).toPromise().then(async (res: SMLResult) => { this.smlIntegrationService.unregisterDomainToSML$(domain).toPromise().then(async (res: SMLResult) => {
// this.searchTable.showSpinner = false;
if (res) { if (res) {
if (res.success) { if (res.success) {
this.alertService.success(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.success.unregister", {domainCode: domain.domainCode}))); 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 { ...@@ -271,7 +264,6 @@ export class DomainSmlIntegrationPanelComponent implements BeforeLeaveGuard {
if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) { if (this.httpErrorHandlerService.logoutOnInvalidSessionError(err)) {
return; return;
} }
// this.searchTable.showSpinner = false;
this.alertService.exception(await lastValueFrom(this.translateService.get("domain.sml.integration.panel.error.unregister", {domainCode: domain.domainCode})), err); 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