Skip to content

Commit

Permalink
feat: Preserve DID registrar metadata from driver
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed Nov 24, 2023
1 parent e28f6ce commit d40f830
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,13 @@ public CreateState create(String method, CreateRequest createRequest, Map<String

Driver driver = this.getDrivers().get(method);
if (driver == null) throw new RegistrationException(RegistrationException.ERROR_BADREQUEST, "Unsupported method: " + method);
if (log.isDebugEnabled()) log.debug("Attempting to create " + createRequest + " with driver " + driver.getClass().getSimpleName());
if (log.isInfoEnabled()) log.info("Attempting to create " + createRequest + " with driver " + driver.getClass().getSimpleName());

CreateState driverCreateState = driver.create(createRequest);

if (driverCreateState != null) {

createState.setJobId(driverCreateState.getJobId());
createState.setDidState(driverCreateState.getDidState());
createState.setDidRegistrationMetadata(driverCreateState.getDidRegistrationMetadata());
createState.setDidDocumentMetadata(driverCreateState.getDidDocumentMetadata());
}

Expand Down Expand Up @@ -151,12 +150,15 @@ public UpdateState update(String method, UpdateRequest updateRequest, Map<String

Driver driver = this.getDrivers().get(method);
if (driver == null) throw new RegistrationException(RegistrationException.ERROR_BADREQUEST, "Unsupported method: " + method);
if (log.isDebugEnabled()) log.debug("Attempting to update " + updateRequest + " with driver " + driver.getClass().getSimpleName());
if (log.isInfoEnabled()) log.info("Attempting to update " + updateRequest + " with driver " + driver.getClass().getSimpleName());

UpdateState driverUpdateState = driver.update(updateRequest);
updateState.setJobId(driverUpdateState.getJobId());
updateState.setDidState(driverUpdateState.getDidState());
updateState.setDidDocumentMetadata(driverUpdateState.getDidDocumentMetadata());
if (driverUpdateState != null) {
updateState.setJobId(driverUpdateState.getJobId());
updateState.setDidState(driverUpdateState.getDidState());
updateState.setDidRegistrationMetadata(driverUpdateState.getDidRegistrationMetadata());
updateState.setDidDocumentMetadata(driverUpdateState.getDidDocumentMetadata());
}

updateState.getDidRegistrationMetadata().put("method", method);
}
Expand Down Expand Up @@ -212,12 +214,15 @@ public DeactivateState deactivate(String method, DeactivateRequest deactivateReq

Driver driver = this.getDrivers().get(method);
if (driver == null) throw new RegistrationException(RegistrationException.ERROR_BADREQUEST, "Unsupported method: " + method);
if (log.isDebugEnabled()) log.debug("Attempting to deactivate " + deactivateRequest + " with driver " + driver.getClass().getSimpleName());
if (log.isInfoEnabled()) log.info("Attempting to deactivate " + deactivateRequest + " with driver " + driver.getClass().getSimpleName());

DeactivateState driverDeactivateState = driver.deactivate(deactivateRequest);
deactivateState.setJobId(driverDeactivateState.getJobId());
deactivateState.setDidState(driverDeactivateState.getDidState());
deactivateState.setDidDocumentMetadata(driverDeactivateState.getDidDocumentMetadata());
if (driverDeactivateState != null) {
deactivateState.setJobId(driverDeactivateState.getJobId());
deactivateState.setDidState(driverDeactivateState.getDidState());
deactivateState.setDidRegistrationMetadata(driverDeactivateState.getDidRegistrationMetadata());
deactivateState.setDidDocumentMetadata(driverDeactivateState.getDidDocumentMetadata());
}

deactivateState.getDidRegistrationMetadata().put("method", method);
}
Expand Down

0 comments on commit d40f830

Please sign in to comment.