Skip to content

Commit cb36fe7

Browse files
committed
implement SignedFirmwareStatusNotification
1 parent 9ad638a commit cb36fe7

File tree

3 files changed

+37
-21
lines changed

3 files changed

+37
-21
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
@@ -32,6 +32,8 @@ public interface SecurityRepository {
3232

3333
void insertLogUploadStatus(String chargeBoxIdentity, Integer requestId, String status, DateTime timestamp);
3434

35+
void insertFirmwareUpdateStatus(String chargeBoxIdentity, Integer requestId, String value, DateTime timestamp);
36+
3537
List<SecurityEvent> getSecurityEvents(String chargeBoxId, Integer limit);
3638

3739
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_FIRMWARE_UPDATE_STATUS;
3536
import static jooq.steve.db.Tables.CHARGE_BOX_LOG_UPLOAD_STATUS;
3637
import static jooq.steve.db.tables.ChargeBox.CHARGE_BOX;
3738
import static jooq.steve.db.tables.ChargeBoxSecurityEvent.CHARGE_BOX_SECURITY_EVENT;
@@ -78,6 +79,22 @@ public void insertLogUploadStatus(String chargeBoxId, Integer requestId, String
7879
.execute();
7980
}
8081

82+
@Override
83+
public void insertFirmwareUpdateStatus(String chargeBoxId, Integer requestId, String status, DateTime timestamp) {
84+
var chargeBoxPk = getChargeBoxPk(chargeBoxId);
85+
if (chargeBoxPk == null) {
86+
log.error("Cannot insert log upload status for unknown chargeBoxId: {}", chargeBoxId);
87+
return;
88+
}
89+
90+
ctx.insertInto(CHARGE_BOX_FIRMWARE_UPDATE_STATUS)
91+
.set(CHARGE_BOX_FIRMWARE_UPDATE_STATUS.CHARGE_BOX_PK, chargeBoxPk)
92+
.set(CHARGE_BOX_FIRMWARE_UPDATE_STATUS.JOB_ID, requestId)
93+
.set(CHARGE_BOX_FIRMWARE_UPDATE_STATUS.EVENT_STATUS, status)
94+
.set(CHARGE_BOX_FIRMWARE_UPDATE_STATUS.EVENT_TIMESTAMP, timestamp)
95+
.execute();
96+
}
97+
8198
@Override
8299
public List<SecurityEvent> getSecurityEvents(String chargeBoxId, Integer limit) {
83100
return Collections.emptyList();

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

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -359,48 +359,45 @@ public SecurityEventNotificationResponse securityEventNotification(SecurityEvent
359359

360360
return new SecurityEventNotificationResponse();
361361
}
362-
public LogStatusNotificationResponse logStatusNotification(LogStatusNotification parameters,
363-
String chargeBoxIdentity) {
362+
363+
public SignedFirmwareStatusNotificationResponse signedFirmwareStatusNotification(SignedFirmwareStatusNotification parameters,
364+
String chargeBoxIdentity) {
364365
try {
365366
if (parameters.getRequestId() == null) {
366367
log.warn("No requestId in {}", parameters);
367368
} else {
368-
securityRepository.insertLogUploadStatus(
369+
securityRepository.insertFirmwareUpdateStatus(
369370
chargeBoxIdentity,
370371
parameters.getRequestId(),
371372
parameters.getStatus().value(),
372373
DateTime.now()
373374
);
374375
}
375376
} catch (Exception e) {
376-
log.error("Error processing log status notification from '{}': {}", chargeBoxIdentity, e.getMessage(), e);
377+
log.error("Error processing firmware status notification from '{}': {}", chargeBoxIdentity, e.getMessage(), e);
377378
}
378379

379-
return new LogStatusNotificationResponse();
380+
return new SignedFirmwareStatusNotificationResponse();
380381
}
381382

382-
public SignedFirmwareStatusNotificationResponse signedFirmwareStatusNotification(
383-
SignedFirmwareStatusNotification parameters, String chargeBoxIdentity) {
384-
var status = parameters.getStatus() != null ? parameters.getStatus().toString() : "Unknown";
385-
var requestId = parameters.getRequestId();
386-
387-
log.info("FirmwareStatus from '{}': status={}, requestId={}", chargeBoxIdentity, status, requestId);
388-
383+
public LogStatusNotificationResponse logStatusNotification(LogStatusNotification parameters,
384+
String chargeBoxIdentity) {
389385
try {
390-
var firmwareUpdate = securityRepository.getCurrentFirmwareUpdate(chargeBoxIdentity);
391-
392-
if (firmwareUpdate != null) {
393-
securityRepository.updateFirmwareUpdateStatus(firmwareUpdate.getFirmwareUpdateId(), status);
394-
log.info("Updated firmware status for chargeBox '{}' to '{}'", chargeBoxIdentity, status);
386+
if (parameters.getRequestId() == null) {
387+
log.warn("No requestId in {}", parameters);
395388
} else {
396-
log.warn("No firmware update found for chargeBox '{}'", chargeBoxIdentity);
389+
securityRepository.insertLogUploadStatus(
390+
chargeBoxIdentity,
391+
parameters.getRequestId(),
392+
parameters.getStatus().value(),
393+
DateTime.now()
394+
);
397395
}
398396
} catch (Exception e) {
399-
log.error("Error processing firmware status notification from '{}': {}",
400-
chargeBoxIdentity, e.getMessage(), e);
397+
log.error("Error processing log status notification from '{}': {}", chargeBoxIdentity, e.getMessage(), e);
401398
}
402399

403-
return new SignedFirmwareStatusNotificationResponse();
400+
return new LogStatusNotificationResponse();
404401
}
405402

406403
// -------------------------------------------------------------------------

0 commit comments

Comments
 (0)