@Test @FixFor( "MODE-2302" ) public void shouldRun4_0_0_Beta3_UpgradeFunction() throws Exception { FileUtil.delete("target/legacy_fs_binarystore"); String config = "config/repo-config-persistent-legacy-fsbinary.json"; // copy the test-resources legacy structure onto the configured one FileUtil.copy(new File("src/test/resources/legacy_fs_binarystore"), new File("target/legacy_fs_binarystore")); // this is coming from the test resources final BinaryKey binaryKey = new BinaryKey("ef2138973a86a8929eebe7bf52419b7cde73ba0a"); // first run is empty, so no upgrades will be performed but we'll decrement the last upgrade ID to force an upgrade next // restart startRunStop(repository -> { changeLastUpgradeId(repository, Upgrades.ModeShape_4_0_0_Beta3.INSTANCE.getId() - 1); FileSystemBinaryStore binaryStore = (FileSystemBinaryStore)repository.runningState().binaryStore(); assertFalse("No used binaries expected", binaryStore.getAllBinaryKeys().iterator().hasNext()); assertFalse("The binary should not be found", binaryStore.hasBinary(binaryKey)); File mainStorageDirectory = binaryStore.getDirectory(); File[] files = mainStorageDirectory.listFiles(); assertEquals("Just the trash directory was expected", 1, files.length); File trash = files[0]; assertTrue(trash.isDirectory()); }, config); // run the repo a second time, which should run the upgrade startRunStop(repository -> { FileSystemBinaryStore binaryStore = (FileSystemBinaryStore)repository.runningState().binaryStore(); assertFalse("No used binaries expected", binaryStore.getAllBinaryKeys().iterator().hasNext()); assertTrue("The binary should be found", binaryStore.hasBinary(binaryKey)); }, config); }
@Override public void apply( Context resources ) { LOGGER.info(JcrI18n.upgrade4_0_0_Beta3_Running); RunningState runningState = resources.getRepository(); BinaryStore binaryStore = runningState.binaryStore(); try { if (binaryStore instanceof FileSystemBinaryStore) { ((FileSystemBinaryStore)binaryStore).upgradeTrashContentFormat(); } } catch (BinaryStoreException e) { LOGGER.error(e, JcrI18n.upgrade4_0_0_Beta3_Failed, e.getMessage()); } } }
@Override public void apply( Context resources ) { LOGGER.info(JcrI18n.upgrade4_0_0_Beta3_Running); RunningState runningState = resources.getRepository(); BinaryStore binaryStore = runningState.binaryStore(); try { if (binaryStore instanceof FileSystemBinaryStore) { ((FileSystemBinaryStore)binaryStore).upgradeTrashContentFormat(); } } catch (BinaryStoreException e) { LOGGER.error(e, JcrI18n.upgrade4_0_0_Beta3_Failed, e.getMessage()); } } }
private BinaryStore binaryStore() { return repository.runningState().binaryStore(); }
protected BackupService( RunningState runningState ) { this.runningState = runningState; // backup restore should not care about federation, hence only the local store should be used documentStore = this.runningState.documentStore().localStore(); binaryStore = this.runningState.binaryStore(); repositoryCache = this.runningState.repositoryCache(); }
protected BackupService( RunningState runningState ) { this.runningState = runningState; // backup restore should not care about federation, hence only the local store should be used documentStore = this.runningState.documentStore().localStore(); binaryStore = this.runningState.binaryStore(); repositoryCache = this.runningState.repositoryCache(); }