use of org.datatransferproject.types.client.transfer.TransferJob in project data-transfer-project by google.
the class StartTransferJobAction method handle.
@Override
public TransferJob handle(StartTransferJob startTransferJob) {
String id = startTransferJob.getId();
Preconditions.checkNotNull(id, "transfer job ID required for StartTransferJobAction");
UUID jobId = decodeJobId(id);
PortabilityJob job = jobStore.findJob(jobId);
String authData = startTransferJob.getEncryptedAuthData();
job = updateJobWithCredentials(jobId, job, authData);
return new TransferJob(id, job.exportService(), job.importService(), job.transferDataType(), null, null, null, null, null, null);
}
use of org.datatransferproject.types.client.transfer.TransferJob in project data-transfer-project by google.
the class CreateTransferJobAction method handle.
@Override
public TransferJob handle(CreateTransferJob request) {
String dataType = request.getDataType();
String exportService = request.getExportService();
String importService = request.getImportService();
Optional<ExportInformation> exportInformation = Optional.ofNullable(request.getExportInformation());
String exportCallbackUrl = request.getExportCallbackUrl();
String importCallbackUrl = request.getImportCallbackUrl();
// Create a new job and persist
UUID jobId = UUID.randomUUID();
SecretKey sessionKey = symmetricKeyGenerator.generate();
String encodedSessionKey = BaseEncoding.base64Url().encode(sessionKey.getEncoded());
String encryptionScheme = request.getEncryptionScheme();
PortabilityJob job;
try {
job = createJob(encodedSessionKey, dataType, exportService, importService, exportInformation, encryptionScheme);
} catch (IOException e) {
throw new RuntimeException(e);
}
AuthDataGenerator exportGenerator = registry.getAuthDataGenerator(job.exportService(), job.transferDataType(), EXPORT);
Preconditions.checkNotNull(exportGenerator, "Generator not found for type: %s, service: %s", job.transferDataType(), job.exportService());
AuthDataGenerator importGenerator = registry.getAuthDataGenerator(job.importService(), job.transferDataType(), IMPORT);
Preconditions.checkNotNull(importGenerator, "Generator not found for type: %s, service: %s", job.transferDataType(), job.importService());
try {
String encodedJobId = encodeJobId(jobId);
AuthFlowConfiguration exportConfiguration = exportGenerator.generateConfiguration(exportCallbackUrl, encodedJobId);
AuthFlowConfiguration importConfiguration = importGenerator.generateConfiguration(importCallbackUrl, encodedJobId);
job = setInitialAuthDataOnJob(sessionKey, job, exportConfiguration, importConfiguration);
jobStore.createJob(jobId, job);
monitor.debug(() -> format("Created new transfer of type '%s' from '%s' to '%s' with jobId: %s", dataType, exportService, importService, jobId), jobId, EventCode.API_JOB_CREATED);
return new TransferJob(encodedJobId, job.exportService(), job.importService(), job.transferDataType(), exportConfiguration.getAuthUrl(), importConfiguration.getAuthUrl(), exportConfiguration.getTokenUrl(), importConfiguration.getTokenUrl(), exportConfiguration.getAuthProtocol(), importConfiguration.getAuthProtocol());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.datatransferproject.types.client.transfer.TransferJob in project data-transfer-project by google.
the class GetTransferJobAction method handle.
@Override
public TransferJob handle(GetTransferJob transferRequest) {
String id = transferRequest.getId();
Preconditions.checkNotNull(id, "transfer job ID required for GetTransferJobAction");
UUID jobId = decodeJobId(id);
PortabilityJob job = jobStore.findJob(jobId);
monitor.debug(() -> format("Fetched job with jobId: %s", jobId), jobId, EventCode.API_GOT_TRANSFER_JOB);
// TODO(#553): This list of nulls should be cleaned up when we refactor TransferJob.
return new TransferJob(id, job.exportService(), job.importService(), job.transferDataType(), null, null, null, null, null, null);
}
Aggregations