use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class SegmentVacuumCommand method execute.
public VacuumTaskResult.Builder execute() {
List<Segment> toBeRemoved = new ArrayList<>();
blobStore.listSegments().forEach(segment -> {
final RepositoryId repositoryId = RepositorySegmentUtils.toRepositoryId(segment);
if (isRepositoryToKeep(repositoryId)) {
result.inUse();
} else {
toBeRemoved.add(segment);
}
result.processed();
});
toBeRemoved.forEach(segment -> {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("Deleting segment [" + segment + "]");
}
blobStore.deleteSegment(segment);
result.deleted();
} catch (Exception e) {
LOG.error("Failed to delete segment [" + segment + "]", e);
result.failed();
}
});
return result;
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class SnapshotServiceImplTest method doNonBuiltinReposSnapshotted.
private void doNonBuiltinReposSnapshotted() {
final RepositoryId newRepoId = RepositoryId.from("new-repo");
this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(newRepoId).build());
this.snapshotService.snapshot(SnapshotParams.create().snapshotName("my-snapshot").build());
this.repositoryService.deleteRepository(DeleteRepositoryParams.from(newRepoId));
assertNull(this.repositoryService.get(newRepoId));
this.snapshotService.restore(RestoreParams.create().snapshotName("my-snapshot").build());
assertNotNull(this.repositoryService.get(newRepoId));
assertNotNull(this.repositoryService.get(SystemConstants.SYSTEM_REPO_ID));
assertNotNull(this.repositoryService.get(TEST_REPO_ID));
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class SnapshotServiceImplTest method doRepositoryIdGiven.
private void doRepositoryIdGiven() {
final RepositoryId newRepoId = RepositoryId.from("new-repo");
this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(newRepoId).build());
assertNotNull(this.repositoryService.get(newRepoId));
this.snapshotService.snapshot(SnapshotParams.create().snapshotName("my-snapshot").build());
this.repositoryService.deleteRepository(DeleteRepositoryParams.from(newRepoId));
assertNull(this.repositoryService.get(newRepoId));
this.snapshotService.restore(RestoreParams.create().repositoryId(newRepoId).snapshotName("my-snapshot").build());
// The system repo does not now about this repo now
assertNull(this.repositoryService.get(newRepoId));
this.snapshotService.restore(RestoreParams.create().repositoryId(SystemConstants.SYSTEM_REPO_ID).snapshotName("my-snapshot").build());
assertTrue(this.repositoryService.isInitialized(newRepoId));
assertTrue(this.repositoryService.isInitialized(SystemConstants.SYSTEM_REPO_ID));
assertTrue(this.repositoryService.isInitialized(TEST_REPO_ID));
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class SnapshotServiceImplTest method doRestoreInvalidSnapshot.
private void doRestoreInvalidSnapshot() {
final RepositoryId newRepoId = RepositoryId.from("new-repo");
this.repositoryService.createRepository(CreateRepositoryParams.create().repositoryId(newRepoId).build());
this.snapshotService.snapshot(SnapshotParams.create().snapshotName("my-snapshot").build());
this.snapshotService.delete(DeleteSnapshotParams.create().add("my-snapshot").build());
this.repositoryService.deleteRepository(DeleteRepositoryParams.from(newRepoId));
try {
this.snapshotService.restore(RestoreParams.create().snapshotName("my-snapshot").build());
} finally {
assertNotNull(this.repositoryService.get(TEST_REPO_ID));
}
}
use of com.enonic.xp.repository.RepositoryId in project xp by enonic.
the class FindNodesByMultiRepoQueryCommandTest method assertRepos.
private void assertRepos(final FindNodesByMultiRepoQueryResult result, final RepositoryId... repositoryIds) {
final MultiRepoNodeHits nodeHits = result.getNodeHits();
final Set<RepositoryId> repositories = nodeHits.stream().map(MultiRepoNodeHit::getRepositoryId).collect(Collectors.toSet());
assertEquals(repositoryIds.length, repositories.size(), "Wrong number of repositories");
for (final RepositoryId repoId : repositoryIds) {
assertTrue(repositories.contains(repoId), "missing repo '" + repoId + "' in result set");
}
}
Aggregations