Skip to content

Commit 9ad638a

Browse files
committed
implement LogStatusNotification
1 parent a47ed12 commit 9ad638a

File tree

3 files changed

+38
-24
lines changed

3 files changed

+38
-24
lines changed

src/main/java/de/rwth/idsg/steve/repository/SecurityRepository.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface SecurityRepository {
3030

3131
void insertSecurityEvent(String chargeBoxId, String eventType, DateTime timestamp, String techInfo);
3232

33+
void insertLogUploadStatus(String chargeBoxIdentity, Integer requestId, String status, DateTime timestamp);
34+
3335
List<SecurityEvent> getSecurityEvents(String chargeBoxId, Integer limit);
3436

3537
int insertCertificate(String chargeBoxId, String certificateType, String certificateData,

src/main/java/de/rwth/idsg/steve/repository/impl/SecurityRepositoryImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.Collections;
3333
import java.util.List;
3434

35+
import static jooq.steve.db.Tables.CHARGE_BOX_LOG_UPLOAD_STATUS;
3536
import static jooq.steve.db.tables.ChargeBox.CHARGE_BOX;
3637
import static jooq.steve.db.tables.ChargeBoxSecurityEvent.CHARGE_BOX_SECURITY_EVENT;
3738

@@ -61,6 +62,22 @@ public void insertSecurityEvent(String chargeBoxId, String eventType, DateTime t
6162
log.info("Security event '{}' recorded for chargeBox '{}'", eventType, chargeBoxId);
6263
}
6364

65+
@Override
66+
public void insertLogUploadStatus(String chargeBoxId, Integer requestId, String status, DateTime timestamp) {
67+
var chargeBoxPk = getChargeBoxPk(chargeBoxId);
68+
if (chargeBoxPk == null) {
69+
log.error("Cannot insert log upload status for unknown chargeBoxId: {}", chargeBoxId);
70+
return;
71+
}
72+
73+
ctx.insertInto(CHARGE_BOX_LOG_UPLOAD_STATUS)
74+
.set(CHARGE_BOX_LOG_UPLOAD_STATUS.CHARGE_BOX_PK, chargeBoxPk)
75+
.set(CHARGE_BOX_LOG_UPLOAD_STATUS.JOB_ID, requestId)
76+
.set(CHARGE_BOX_LOG_UPLOAD_STATUS.EVENT_STATUS, status)
77+
.set(CHARGE_BOX_LOG_UPLOAD_STATUS.EVENT_TIMESTAMP, timestamp)
78+
.execute();
79+
}
80+
6481
@Override
6582
public List<SecurityEvent> getSecurityEvents(String chargeBoxId, Integer limit) {
6683
return Collections.emptyList();

src/main/java/de/rwth/idsg/steve/service/CentralSystemService16_Service.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,25 @@ public SecurityEventNotificationResponse securityEventNotification(SecurityEvent
359359

360360
return new SecurityEventNotificationResponse();
361361
}
362+
public LogStatusNotificationResponse logStatusNotification(LogStatusNotification parameters,
363+
String chargeBoxIdentity) {
364+
try {
365+
if (parameters.getRequestId() == null) {
366+
log.warn("No requestId in {}", parameters);
367+
} else {
368+
securityRepository.insertLogUploadStatus(
369+
chargeBoxIdentity,
370+
parameters.getRequestId(),
371+
parameters.getStatus().value(),
372+
DateTime.now()
373+
);
374+
}
375+
} catch (Exception e) {
376+
log.error("Error processing log status notification from '{}': {}", chargeBoxIdentity, e.getMessage(), e);
377+
}
378+
379+
return new LogStatusNotificationResponse();
380+
}
362381

363382
public SignedFirmwareStatusNotificationResponse signedFirmwareStatusNotification(
364383
SignedFirmwareStatusNotification parameters, String chargeBoxIdentity) {
@@ -384,30 +403,6 @@ public SignedFirmwareStatusNotificationResponse signedFirmwareStatusNotification
384403
return new SignedFirmwareStatusNotificationResponse();
385404
}
386405

387-
public LogStatusNotificationResponse logStatusNotification(LogStatusNotification parameters, String chargeBoxIdentity) {
388-
var status = parameters.getStatus() != null ? parameters.getStatus().toString() : "Unknown";
389-
var requestId = parameters.getRequestId();
390-
391-
log.info("LogStatus from '{}': status={}, requestId={}", chargeBoxIdentity, status, requestId);
392-
393-
try {
394-
if (requestId != null) {
395-
var logFile = securityRepository.getLogFile(requestId);
396-
397-
if (logFile != null) {
398-
securityRepository.updateLogFileStatus(requestId, status, null);
399-
log.info("Updated log file status for requestId {} to '{}'", requestId, status);
400-
} else {
401-
log.warn("No log file found for requestId {}", requestId);
402-
}
403-
}
404-
} catch (Exception e) {
405-
log.error("Error processing log status notification from '{}': {}", chargeBoxIdentity, e.getMessage(), e);
406-
}
407-
408-
return new LogStatusNotificationResponse();
409-
}
410-
411406
// -------------------------------------------------------------------------
412407
// Helpers
413408
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)