Skip to content

Commit 03c14ad

Browse files
revert
1 parent 9862466 commit 03c14ad

File tree

1 file changed

+2
-63
lines changed
  • JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi

1 file changed

+2
-63
lines changed

JeMPI_Apps/JeMPI_LibAPI/src/main/java/org/jembi/jempi/libapi/BackEnd.java

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import akka.actor.typed.Behavior;
55
import akka.actor.typed.javadsl.*;
66
import akka.http.javadsl.server.directives.FileInfo;
7-
8-
import com.fasterxml.jackson.core.JsonProcessingException;
97
import com.fasterxml.jackson.databind.ObjectMapper;
108
import io.vavr.control.Either;
119
import org.apache.commons.io.FileUtils;
@@ -32,15 +30,11 @@
3230
import java.sql.Timestamp;
3331
import java.time.LocalDateTime;
3432
import java.util.*;
35-
import java.sql.PreparedStatement;
36-
import java.sql.ResultSet;
3733

3834
public final class BackEnd extends AbstractBehavior<BackEnd.Event> {
3935

4036
private static final Logger LOGGER = LogManager.getLogger(BackEnd.class);
41-
private final PsqlClient psqlClient;
4237
private final String pgIP;
43-
private final int pgPort;
4438
private final String pgUser;
4539
private final String pgPassword;
4640
private final String pgNotificationsDb;
@@ -80,7 +74,7 @@ private BackEnd(
8074
this.dgraphHosts = dgraphHosts;
8175
this.dgraphPorts = dgraphPorts;
8276
this.pgIP = sqlIP;
83-
this.pgPort = sqlPort;
77+
Integer pgPort = sqlPort;
8478
this.pgUser = sqlUser;
8579
this.pgPassword = sqlPassword;
8680
this.pgNotificationsDb = sqlNotificationsDb;
@@ -93,7 +87,6 @@ private BackEnd(
9387
psqlNotifications = new PsqlNotifications(sqlIP, sqlPort, sqlNotificationsDb, sqlUser, sqlPassword);
9488
psqlAuditTrail = new PsqlAuditTrail(sqlIP, sqlPort, sqlAuditDb, sqlUser, sqlPassword);
9589
openMPI(kafkaBootstrapServers, kafkaClientId, debugLevel);
96-
psqlClient = new PsqlClient(sqlIP, sqlPort, sqlConfigurationDb, sqlUser, sqlPassword);
9790
} catch (Exception e) {
9891
LOGGER.error(e.getMessage(), e);
9992
throw e;
@@ -505,7 +498,7 @@ private Behavior<Event> getSqlDashboardDataHandler(final SQLDashboardDataRequest
505498
return Behaviors.same();
506499
}
507500

508-
private Behavior<Event> getConfigurationHandlers(final GetConfigurationRequest request) {
501+
private Behavior<Event> getConfigurationHandler(final GetConfigurationRequest request) {
509502
Path configMasterJsonFilePath = Paths.get(systemConfigDirectory, configMasterFileName);
510503
Path configReferenceJsonFilePath = Paths.get(systemConfigDirectory, configReferenceFileName);
511504

@@ -526,61 +519,7 @@ private Behavior<Event> getConfigurationHandlers(final GetConfigurationRequest r
526519
return Behaviors.same();
527520
}
528521

529-
private Behavior<Event> getConfigurationHandler(final GetConfigurationRequest request) {
530-
try {
531-
psqlClient.connect();
532-
String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config' ORDER BY id DESC LIMIT 1";
533-
try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql);
534-
ResultSet rs = preparedStatement.executeQuery()) {
535-
536-
if (rs.next()) {
537-
LOGGER.info("rs.....getConfigurationHandler.........................................: {}", rs);
538-
String configFileContent = rs.getString("json");
539-
LOGGER.info("configFileContent..........getConfigurationHandler....................................: {}", configFileContent);
540-
ObjectMapper mapper = new ObjectMapper();
541-
Configuration configuration = mapper.readValue(configFileContent, Configuration.class);
542-
request.replyTo.tell(new GetConfigurationResponse(configuration));
543-
} else {
544-
LOGGER.warn("No configuration found in the database.");
545-
request.replyTo.tell(new GetConfigurationResponse(null));
546-
}
547-
}
548-
} catch (SQLException | JsonProcessingException e) {
549-
LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage());
550-
}
551-
552-
return Behaviors.same();
553-
}
554-
555522
private Behavior<Event> getFieldsConfigurationHandler(final GetFieldsConfigurationRequest request) {
556-
try {
557-
psqlClient.connect();
558-
String sql = "SELECT json FROM CONFIGURATION WHERE key = 'config-api' ORDER BY id DESC LIMIT 1";
559-
try (PreparedStatement preparedStatement = psqlClient.prepareStatement(sql);
560-
ResultSet rs = preparedStatement.executeQuery()) {
561-
562-
if (rs.next()) {
563-
LOGGER.info("rs...............getFieldsConfigurationHandler...............................: {}", rs);
564-
String configFileContent = rs.getString("json");
565-
LOGGER.info("configFileContent...........getFieldsConfigurationHandler...................................: {}", configFileContent);
566-
FieldsConfiguration fieldsConfiguration = AppUtils.OBJECT_MAPPER.readValue(configFileContent, FieldsConfiguration.class);
567-
ArrayList<FieldsConfiguration.Field> fields = new ArrayList<>();
568-
fields.addAll(fieldsConfiguration.systemFields());
569-
fields.addAll(fieldsConfiguration.fields());
570-
request.replyTo.tell(new GetFieldsConfigurationResponse(fields));
571-
} else {
572-
LOGGER.warn("No configuration found in the database.");
573-
request.replyTo.tell(new GetFieldsConfigurationResponse(null));
574-
}
575-
}
576-
} catch (SQLException | JsonProcessingException e) {
577-
LOGGER.error("getConfigurationHandler failed with error: {}", e.getMessage());
578-
}
579-
580-
return Behaviors.same();
581-
}
582-
583-
private Behavior<Event> getFieldsConfigurationHandlers(final GetFieldsConfigurationRequest request) {
584523
final var separator = FileSystems.getDefault().getSeparator();
585524
final String configDir = System.getenv("SYSTEM_CONFIG_DIRS");
586525
Path filePath = Paths.get(""); // Start with an empty path

0 commit comments

Comments
 (0)