use of org.datatransferproject.types.client.transfer.GetReservedWorker in project data-transfer-project by google.
the class GetReservedWorkerAction method handle.
@Override
public ReservedWorker handle(GetReservedWorker workerRequest) {
String id = workerRequest.getId();
UUID jobId = decodeJobId(id);
PortabilityJob job = jobStore.findJob(jobId);
Preconditions.checkNotNull(job, "Couldn't lookup worker for job " + id + " because the job doesn't exist");
if (job.jobAuthorization().state() != CREDS_ENCRYPTION_KEY_GENERATED) {
monitor.debug(() -> format("Job %s has not entered state CREDS_ENCRYPTION_KEY_GENERATED yet", jobId), jobId);
return new ReservedWorker(null);
}
monitor.debug(() -> format("Got job %s in state CREDS_ENCRYPTION_KEY_GENERATED, returning its public key", jobId), jobId, EventCode.API_GOT_RESERVED_WORKER);
return new ReservedWorker(job.jobAuthorization().authPublicKey());
}
Aggregations