Skip to content

Commit

Permalink
Merge branch 'main' into DATAGO-77753-enable-json-log
Browse files Browse the repository at this point in the history
  • Loading branch information
rudraneel-chakraborty committed Jul 3, 2024
2 parents 11d0ba5 + 082a168 commit 099648e
Show file tree
Hide file tree
Showing 39 changed files with 904 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ hs_err_pid*
**/application-DEV.yml
application.properties
application.yml
**/application-*-local.yml


.idea
.DS_Store
Expand All @@ -46,3 +48,4 @@ application-mysql-*.yml
.env

*dependency-reduced-pom.xml

28 changes: 18 additions & 10 deletions service/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<parent>
<groupId>com.solace.maas</groupId>
<artifactId>maas-event-management-agent-parent</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>event-management-agent</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Solace Event Management Agent - Application</name>
<description>Solace Event Management Agent - Application</description>
<properties>
<spring-boot.version>3.2.5</spring-boot.version>
<snakeyaml.version>2.0</snakeyaml.version>
<spring-security-rsa.version>1.1.1</spring-security-rsa.version>
<spring-security-rsa.version>1.1.3</spring-security-rsa.version>
<spring-kafka.version>3.0.10</spring-kafka.version>
<kafka-clients.version>3.5.0</kafka-clients.version>
<jackson.version>2.16.1</jackson.version>
Expand Down Expand Up @@ -97,6 +97,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-rsa</artifactId>
Expand Down Expand Up @@ -221,7 +225,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.0.Final</version>
<version>8.0.1.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand All @@ -231,32 +235,32 @@
<dependency>
<groupId>com.solace.maas</groupId>
<artifactId>plugin</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.solace.maas.plugin.kafka</groupId>
<artifactId>kafka-plugin</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.solace.maas.plugin.solace</groupId>
<artifactId>solace-plugin</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.solace.maas.plugin.localstorage</groupId>
<artifactId>local-storage-plugin</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.solace.maas.plugin.confluent-schema-registry</groupId>
<artifactId>confluent-schema-registry-plugin</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.solace.maas.plugin.terraform</groupId>
<artifactId>terraform-plugin</artifactId>
<version>1.6.8-SNAPSHOT</version>
<version>1.6.9-SNAPSHOT</version>
</dependency>

<dependency>
Expand All @@ -278,6 +282,10 @@
<artifactId>micrometer-observation-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-statsd</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.solace.maas.ep.common.messages;

import com.solace.maas.ep.common.model.CommandMessageWithResources;
import com.solace.maas.ep.common.model.EventBrokerResourceConfiguration;
import com.solace.maas.ep.event.management.agent.plugin.command.model.CommandBundle;
import com.solace.maas.ep.event.management.agent.plugin.command.model.JobStatus;
import com.solace.maas.ep.event.management.agent.plugin.mop.MOPMessage;
Expand All @@ -11,13 +13,14 @@
import java.util.List;

@Data
public class CommandMessage extends MOPMessage {
public class CommandMessage extends MOPMessage implements CommandMessageWithResources {

private String commandCorrelationId;
private String context;
private String serviceId;
private JobStatus status;
private List<CommandBundle> commandBundles;
private List<EventBrokerResourceConfiguration> resources;

public CommandMessage() {
super();
Expand All @@ -40,6 +43,25 @@ public CommandMessage(String serviceId,
this.commandBundles = commandBundles;
}

public CommandMessage(String serviceId,
String commandCorrelationId,
String context,
JobStatus status,
List<CommandBundle> commandBundles,
List<EventBrokerResourceConfiguration> resources) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.epConfigPush)
.withVersion("1")
.withUhFlag(MOPUHFlag.ignore);
this.serviceId = serviceId;
this.commandCorrelationId = commandCorrelationId;
this.context = context;
this.status = status;
this.commandBundles = commandBundles;
this.resources = resources;
}

@Override
public String toLog() {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.solace.maas.ep.common.messages;

import com.solace.maas.ep.common.model.CommandMessageWithResources;
import com.solace.maas.ep.common.model.EventBrokerResourceConfiguration;
import com.solace.maas.ep.common.model.ScanDestination;
import com.solace.maas.ep.common.model.ScanType;
import com.solace.maas.ep.event.management.agent.plugin.mop.MOPMessage;
Expand All @@ -11,12 +13,13 @@
import java.util.List;

@Data
public class ScanCommandMessage extends MOPMessage {
public class ScanCommandMessage extends MOPMessage implements CommandMessageWithResources {

private String messagingServiceId;
private String scanId;
private List<ScanType> scanTypes;
private List<ScanDestination> destinations;
private List<EventBrokerResourceConfiguration> resources;

public ScanCommandMessage() {
super();
Expand All @@ -25,7 +28,8 @@ public ScanCommandMessage() {
public ScanCommandMessage(String messagingServiceId,
String scanId,
List<ScanType> scanTypes,
List<ScanDestination> destinations) {
List<ScanDestination> destinations,
List<EventBrokerResourceConfiguration> resources) {
super();
withMessageType(MOPMessageType.generic)
.withProtocol(MOPProtocol.scanDataControl)
Expand All @@ -35,8 +39,18 @@ public ScanCommandMessage(String messagingServiceId,
this.scanId = scanId;
this.scanTypes = scanTypes;
this.destinations = destinations;
this.resources = resources;
}

public ScanCommandMessage(String messagingServiceId,
String scanId,
List<ScanType> scanTypes,
List<ScanDestination> destinations) {
this(messagingServiceId, scanId, scanTypes, destinations, null);
}



@Override
public String toLog() {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.solace.maas.ep.common.model;


import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

@Data
public class EventBrokerAuthenticationConfiguration {
private String type;
private String protocol;
@NotNull
@Valid
private EventBrokerCredentialConfiguration credential;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package com.solace.maas.ep.common.model;


import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

@Data
public class EventBrokerConnectionConfiguration {

@NotBlank
private String msgVpn;

private String sempPageSize;
@NotNull
@Valid
private EventBrokerAuthenticationConfiguration authentication;
@NotBlank
private String name;
@NotBlank
private String url;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.solace.maas.ep.common.model;

import jakarta.validation.constraints.NotBlank;
import lombok.Data;

@Data
public class EventBrokerCredentialConfiguration {
@NotBlank
private String userName;
@NotBlank
private String password;
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
package com.solace.maas.ep.common.model;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.List;

@Data
public class EventBrokerResourceConfiguration extends ResourceConfiguration {
@NotBlank
private String id;
private String brokerType;
@NotBlank
private String name;
private List<EventBrokerConnectionConfiguration> connections;
@NotEmpty
private List<@Valid EventBrokerConnectionConfiguration> connections;
@NotNull
private ResourceConfigurationType resourceConfigurationType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,29 @@ public void execute(CommandMessage request) {
CompletableFuture.runAsync(() -> configPush(requestBO), configPushPool)
.exceptionally(e -> {
log.error("Error running command", e);
Command firstCommand = requestBO.getCommandBundles().get(0).getCommands().get(0);
setCommandError(firstCommand, (Exception) e);
finalizeAndSendResponse(requestBO);
handleError((Exception) e, requestBO);
return null;
});
}

public void handleError(Exception e, CommandMessage message) {
handleError(e, commandMapper.map(message));
}

private void handleError(Exception e, CommandRequest requestBO) {
Command firstCommand = requestBO.getCommandBundles().get(0).getCommands().get(0);
setCommandError(firstCommand, e);
finalizeAndSendResponse(requestBO);
}

@SuppressWarnings("PMD")
public void configPush(CommandRequest request) {
Map<String, String> envVars;
try {
envVars = setBrokerSpecificEnvVars(request.getServiceId());
} catch (Exception e) {
log.error("Error getting terraform variables", e);
Command firstCommand = request.getCommandBundles().get(0).getCommands().get(0);
setCommandError(firstCommand, e);
finalizeAndSendResponse(request);
handleError(e, request);
return;
}
List<Path> executionLogFilesToClean = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.solace.maas.ep.event.management.agent.config;

import jakarta.validation.Validator;
import org.springframework.boot.validation.MessageInterpolatorFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import org.springframework.validation.beanvalidation.MethodValidationPostProcessor;

@Configuration
public class ValidationConfiguration {

@Bean
public static LocalValidatorFactoryBean defaultValidator() {
LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean();
MessageInterpolatorFactory interpolatorFactory = new MessageInterpolatorFactory();
factoryBean.setMessageInterpolator(interpolatorFactory.getObject());
return factoryBean;
}

@Bean
public static MethodValidationPostProcessor methodValidationPostProcessor(Environment environment, Validator validator) {
MethodValidationPostProcessor processor = new MethodValidationPostProcessor();
boolean proxyTargetClass = environment.getProperty("spring.aop.proxy-target-class", Boolean.class, true);
processor.setProxyTargetClass(proxyTargetClass);
processor.setValidator(validator);
return processor;
}
}
Loading

0 comments on commit 099648e

Please sign in to comment.