@Test public void updateLocationToReadyOnDiskNonExisting() throws Exception { assertThatThrownBy(() -> archiveReferentialRepository.updateLocationToReadyOnDisk("tarId1", 10L, "digest1")) .isInstanceOf(ArchiveReferentialException.class); }
public void updateLocationToReadyOnDisk(String archiveId, long size, String digest) throws ArchiveReferentialException { try { UpdateResult updateResult = collection.updateOne( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId), Updates.combine( Updates.set(TapeArchiveReferentialEntity.LOCATION, toBson(new TapeLibraryReadyOnDiskArchiveStorageLocation())), Updates.set(TapeArchiveReferentialEntity.SIZE, size), Updates.set(TapeArchiveReferentialEntity.DIGEST, digest), Updates.set(TapeArchiveReferentialEntity.LAST_UPDATE_DATE, LocalDateUtil.now().toString()) ), new UpdateOptions().upsert(false) ); if (updateResult.getMatchedCount() != 1) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId + ". No such archiveId"); } } catch (MongoException ex) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId, ex); } }
ArchiveReferentialRepository { public void updateLocationToReadyOnDisk(String archiveId, long size, String digest) throws ArchiveReferentialException { try { UpdateResult updateResult = collection.updateOne( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId), Updates.combine( Updates.set(TapeArchiveReferentialEntity.LOCATION, toBson(new TapeLibraryReadyOnDiskArchiveStorageLocation())), Updates.set(TapeArchiveReferentialEntity.SIZE, size), Updates.set(TapeArchiveReferentialEntity.DIGEST, digest), Updates.set(TapeArchiveReferentialEntity.LAST_UPDATE_DATE, LocalDateUtil.now().toString()) ), new UpdateOptions().upsert(false) ); if (updateResult.getMatchedCount() != 1) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId + ". No such archiveId"); } } catch (MongoException ex) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId, ex); } } }
ArchiveReferentialRepository { public void updateLocationToReadyOnDisk(String archiveId, long size, String digest) throws ArchiveReferentialException { try { UpdateResult updateResult = collection.updateOne( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId), Updates.combine( Updates.set(TapeArchiveReferentialEntity.LOCATION, toBson(new TapeLibraryReadyOnDiskArchiveStorageLocation())), Updates.set(TapeArchiveReferentialEntity.SIZE, size), Updates.set(TapeArchiveReferentialEntity.DIGEST, digest), Updates.set(TapeArchiveReferentialEntity.LAST_UPDATE_DATE, LocalDateUtil.now().toString()) ), new UpdateOptions().upsert(false) ); if (updateResult.getMatchedCount() != 1) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId + ". No such archiveId"); } } catch (MongoException ex) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId, ex); } } ArchiveReferentialRepository(MongoCollection<Document> collection); }
ArchiveReferentialRepository { public void updateLocationToReadyOnDisk(String archiveId, long size, String digest) throws ArchiveReferentialException { try { UpdateResult updateResult = collection.updateOne( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId), Updates.combine( Updates.set(TapeArchiveReferentialEntity.LOCATION, toBson(new TapeLibraryReadyOnDiskArchiveStorageLocation())), Updates.set(TapeArchiveReferentialEntity.SIZE, size), Updates.set(TapeArchiveReferentialEntity.DIGEST, digest), Updates.set(TapeArchiveReferentialEntity.LAST_UPDATE_DATE, LocalDateUtil.now().toString()) ), new UpdateOptions().upsert(false) ); if (updateResult.getMatchedCount() != 1) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId + ". No such archiveId"); } } catch (MongoException ex) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId, ex); } } ArchiveReferentialRepository(MongoCollection<Document> collection); void insert(TapeArchiveReferentialEntity tapeArchiveReferentialEntity); Optional<TapeArchiveReferentialEntity> find(String archiveId); void updateLocationToReadyOnDisk(String archiveId, long size, String digest); void updateLocationToOnTape(String archiveId,
        TapeLibraryOnTapeArchiveStorageLocation onTapeTarStorageLocation); }
ArchiveReferentialRepository { public void updateLocationToReadyOnDisk(String archiveId, long size, String digest) throws ArchiveReferentialException { try { UpdateResult updateResult = collection.updateOne( Filters.eq(TapeArchiveReferentialEntity.ID, archiveId), Updates.combine( Updates.set(TapeArchiveReferentialEntity.LOCATION, toBson(new TapeLibraryReadyOnDiskArchiveStorageLocation())), Updates.set(TapeArchiveReferentialEntity.SIZE, size), Updates.set(TapeArchiveReferentialEntity.DIGEST, digest), Updates.set(TapeArchiveReferentialEntity.LAST_UPDATE_DATE, LocalDateUtil.now().toString()) ), new UpdateOptions().upsert(false) ); if (updateResult.getMatchedCount() != 1) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId + ". No such archiveId"); } } catch (MongoException ex) { throw new ArchiveReferentialException("Could not update storage location for " + archiveId, ex); } } ArchiveReferentialRepository(MongoCollection<Document> collection); void insert(TapeArchiveReferentialEntity tapeArchiveReferentialEntity); Optional<TapeArchiveReferentialEntity> find(String archiveId); void updateLocationToReadyOnDisk(String archiveId, long size, String digest); void updateLocationToOnTape(String archiveId,
        TapeLibraryOnTapeArchiveStorageLocation onTapeTarStorageLocation);  }