code: @Override
      @Transactional
      public void finalizeRestores() {
          log.debug("Running finalize restores...");
          List<Restoration> completedRestores =
              restoreRepo.findByStatus(RestoreStatus.RESTORATION_COMPLETE);
  
          for (Restoration restoration : completedRestores) {
              Date expirationDate = restoration.getExpirationDate();
              if (expirationDate.before(new Date())) { // Only continue if expired
                  DuracloudEndPointConfig destination = restoration.getDestination();
                  ContentStore store =
                      storeClientHelper.create(destination,
                                               bridgeConfig.getDuracloudUsername(),
                                               bridgeConfig.getDuracloudPassword());
                  try {
                      String spaceId = destination.getSpaceId();
                      Iterator<String> it = store.getSpaceContents(spaceId);
                      if (!it.hasNext()) { // if space is empty
                          // Call DuraCloud to remove space
                          log.info("Deleting expired restoration space: " + spaceId +
                                   " at host: " + destination.getHost());
                          store.deleteSpace(spaceId);
  
                          // Update restore status
                          validateAndSet(restoration,
                                         RestoreStatus.RESTORATION_EXPIRED,
                                         "Restoration expired");
                          restoration = save(restoration);
                          log.info("Transition of restore " +
                                   restoration.getRestorationId() +
                                   " to expired state completed successfully");
  
                          // Add history event
                          String history =
                              "[{'" + RESTORE_ACTION_TITLE + "':'" + RESTORE_ACTION_EXPIRED + "'}," +
                              "{'" + RESTORE_ID_TITLE + "':'" + restoration.getRestorationId() + "'}]";
                          snapshotManager.updateHistory(restoration.getSnapshot(), history);
                      }
                  } catch (Exception e) {
                      log.error("Failed to transition restore " +
                                restoration.getRestorationId() +
                                " to expired state due to: " + e.getMessage());
                  }
              }
          }
      }
docs: /* (non-Javadoc)
  @see org.duracloud.snapshot.service.RestoreManager#finalizeRestores()