Skip to content

Commit

Permalink
Merge pull request #160 from GoogleCloudPlatform/jk/159
Browse files Browse the repository at this point in the history
Adjusted fileName creation, fixes #159
  • Loading branch information
danielbeaudreau authored Feb 10, 2023
2 parents 67db06c + 28e84ff commit 3566612
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public void run() {
}
} else {
MonitoringService.addEvent(Event.CSTORE_ERROR);
throwOnHttpFilterFail(dwe, dwe.getHttpStatus());
throwOnHttpFilterFail(dwe, dwe.getHttpStatus(), uniqueFileName);
}
}
}
Expand Down Expand Up @@ -256,9 +256,9 @@ private boolean filterHttpCode(Integer actualHttpStatus) {
return actualHttpStatus >= 500 || httpErrorCodesToRetry.contains(actualHttpStatus);
}

private void throwOnHttpFilterFail(DicomWebException dwe, int httpCode) throws CompletionException {
String errorMessage = "Not retried due to HTTP code=" + httpCode;
log.debug(errorMessage);
private void throwOnHttpFilterFail(DicomWebException dwe, int httpCode, String uniqueFileName) throws CompletionException {
String errorMessage = "filename=" + uniqueFileName + ". Not retried due to HTTP code=" + httpCode;
log.error(errorMessage);
throw new CompletionException(new BackupException(dwe.getStatus(), dwe, errorMessage));
}

Expand All @@ -268,7 +268,7 @@ private void throwOnNoResendAttemptsLeft(DicomWebException dwe, String uniqueFil

private BackupException getNoResendAttemptLeftException(DicomWebException dwe, String uniqueFileName) {
String errorMessage = "fileName=" + uniqueFileName + ". No upload attempt left.";
log.debug(errorMessage);
log.error(errorMessage);
if (dwe != null) {
return new BackupException(dwe.getStatus(), dwe, errorMessage);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
Expand All @@ -23,6 +23,7 @@

public class MultipleDestinationUploadService implements IMultipleDestinationUploadService {

private static Random rand = new Random();
private Logger log = LoggerFactory.getLogger(MultipleDestinationUploadService.class);

private CStoreSenderFactory cStoreSenderFactory;
Expand Down Expand Up @@ -57,7 +58,7 @@ public void start(
}

List<Throwable> asyncUploadProcessingExceptions = new ArrayList<>();
String uniqueFileName = UUID.randomUUID().toString() + ".dcm";
String uniqueFileName = String.format("%s_%s.dcm", sopInstanceUID, rand.nextInt(1000));

try {
backupUploadService.createBackup(inputStream, uniqueFileName);
Expand Down

0 comments on commit 3566612

Please sign in to comment.