Skip to content
Snippets Groups Projects
Commit b2c88fa3 authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Merge branch '260_eventtype' into 'develop'

add WebhookEventType to Webhook body

See merge request !276
parents a1dc1ed7 ca6285ed
No related branches found
No related tags found
2 merge requests!339Develop,!276add WebhookEventType to Webhook body
Pipeline #95530 passed
...@@ -7,6 +7,7 @@ import net.geant.nmaas.orchestration.api.model.AppDeploymentView; ...@@ -7,6 +7,7 @@ import net.geant.nmaas.orchestration.api.model.AppDeploymentView;
import net.geant.nmaas.orchestration.entities.AppDeployment; import net.geant.nmaas.orchestration.entities.AppDeployment;
import net.geant.nmaas.orchestration.exceptions.InvalidDeploymentIdException; import net.geant.nmaas.orchestration.exceptions.InvalidDeploymentIdException;
import net.geant.nmaas.orchestration.exceptions.WebServiceCommunicationException; import net.geant.nmaas.orchestration.exceptions.WebServiceCommunicationException;
import net.geant.nmaas.portal.api.domain.AppDeploymentWebhookDto;
import net.geant.nmaas.portal.api.domain.WebhookEventDto; import net.geant.nmaas.portal.api.domain.WebhookEventDto;
import net.geant.nmaas.portal.api.exceptions.MissingElementException; import net.geant.nmaas.portal.api.exceptions.MissingElementException;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType; import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
...@@ -47,7 +48,7 @@ public class AppDeploymentJob extends WebhookJob { ...@@ -47,7 +48,7 @@ public class AppDeploymentJob extends WebhookJob {
} }
AppDeployment appDeployment = appDeploymentRepositoryManager.load(Identifier.newInstance(deploymentIdStr)); AppDeployment appDeployment = appDeploymentRepositoryManager.load(Identifier.newInstance(deploymentIdStr));
callWebhook(webhook, modelMapper.map(appDeployment, AppDeploymentView.class)); callWebhook(webhook, new AppDeploymentWebhookDto(modelMapper.map(appDeployment, AppDeploymentView.class), WebhookEventType.APPLICATION_DEPLOYMENT));
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId); log.error("Failed to decrypt webhook with id {}", webhookId);
throw new JobExecutionException("Failed webhook decryption"); throw new JobExecutionException("Failed webhook decryption");
... ...
......
...@@ -42,7 +42,7 @@ public class DomainActionJob extends WebhookJob { ...@@ -42,7 +42,7 @@ public class DomainActionJob extends WebhookJob {
return; return;
} }
callWebhook(webhook, new DomainActionDto(domain, action)); callWebhook(webhook, new DomainActionDto(domain, action, WebhookEventType.DOMAIN_ACTION));
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId); log.error("Failed to decrypt webhook with id {}", webhookId);
throw new JobExecutionException("Failed webhook decryption"); throw new JobExecutionException("Failed webhook decryption");
... ...
......
...@@ -40,7 +40,7 @@ public class DomainGroupJob extends WebhookJob { ...@@ -40,7 +40,7 @@ public class DomainGroupJob extends WebhookJob {
log.warn("Webhook's event type with id {} has been updated. DomainGroupJob is abandoned", webhookId); log.warn("Webhook's event type with id {} has been updated. DomainGroupJob is abandoned", webhookId);
return; return;
} }
DomainGroupWebhookDto view = new DomainGroupWebhookDto(domainGroup, action); DomainGroupWebhookDto view = new DomainGroupWebhookDto(domainGroup, action, WebhookEventType.DOMAIN_GROUP_ACTION);
callWebhook(webhook, view); callWebhook(webhook, view);
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId); log.error("Failed to decrypt webhook with id {}", webhookId);
... ...
......
...@@ -56,7 +56,7 @@ public class UserDomainAssignmentJob extends WebhookJob { ...@@ -56,7 +56,7 @@ public class UserDomainAssignmentJob extends WebhookJob {
Domain domain = domainService.findDomain(domainId).orElseThrow(() -> new MissingElementException(String.format("Domain with id: %d cannot be found", domainId))); Domain domain = domainService.findDomain(domainId).orElseThrow(() -> new MissingElementException(String.format("Domain with id: %d cannot be found", domainId)));
User user = userService.findById(userId).orElseThrow(() -> new MissingElementException(String.format("User with id: %d cannot be found", userId))); User user = userService.findById(userId).orElseThrow(() -> new MissingElementException(String.format("User with id: %d cannot be found", userId)));
UserDomainAssignmentWebhookDto dto = new UserDomainAssignmentWebhookDto(modelMapper.map(user, UserView.class), modelMapper.map(domain, DomainView.class), role, action); UserDomainAssignmentWebhookDto dto = new UserDomainAssignmentWebhookDto(modelMapper.map(user, UserView.class), modelMapper.map(domain, DomainView.class), role, action, WebhookEventType.USER_ASSIGNMENT);
callWebhook(webhook, dto); callWebhook(webhook, dto);
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
log.error("Failed to decrypt webhook with id {}", webhookId); log.error("Failed to decrypt webhook with id {}", webhookId);
... ...
......
package net.geant.nmaas.portal.api.domain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.geant.nmaas.orchestration.api.model.AppDeploymentView;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor
@Getter
@Setter
public class AppDeploymentWebhookDto {
private AppDeploymentView appDeployment;
private WebhookEventType webhookEventType;
}
...@@ -3,6 +3,7 @@ package net.geant.nmaas.portal.api.domain; ...@@ -3,6 +3,7 @@ package net.geant.nmaas.portal.api.domain;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
...@@ -11,4 +12,5 @@ public class DomainActionDto { ...@@ -11,4 +12,5 @@ public class DomainActionDto {
private DomainView domainView; private DomainView domainView;
private String action; private String action;
private WebhookEventType webhookEventType;
} }
...@@ -3,6 +3,7 @@ package net.geant.nmaas.portal.api.domain; ...@@ -3,6 +3,7 @@ package net.geant.nmaas.portal.api.domain;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
...@@ -11,5 +12,6 @@ public class DomainGroupWebhookDto { ...@@ -11,5 +12,6 @@ public class DomainGroupWebhookDto {
private DomainGroupView domainGroup; private DomainGroupView domainGroup;
private String action; private String action;
private WebhookEventType webhookEventType;
} }
...@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor; ...@@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import net.geant.nmaas.portal.persistent.entity.Role; import net.geant.nmaas.portal.persistent.entity.Role;
import net.geant.nmaas.portal.persistent.entity.WebhookEventType;
@AllArgsConstructor @AllArgsConstructor
@Getter @Getter
...@@ -14,4 +15,5 @@ public class UserDomainAssignmentWebhookDto { ...@@ -14,4 +15,5 @@ public class UserDomainAssignmentWebhookDto {
private DomainView domain; private DomainView domain;
private Role role; private Role role;
private String action; private String action;
private WebhookEventType webhookEventType;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment