Search in sources :

Example 21 with RepositoryId

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;
}
Also used : ArrayList(java.util.ArrayList) RepositoryId(com.enonic.xp.repository.RepositoryId) Segment(com.enonic.xp.blob.Segment)

Example 22 with RepositoryId

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));
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 23 with RepositoryId

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));
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 24 with RepositoryId

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));
    }
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 25 with RepositoryId

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");
    }
}
Also used : MultiRepoNodeHits(com.enonic.xp.node.MultiRepoNodeHits) RepositoryId(com.enonic.xp.repository.RepositoryId)

Aggregations

RepositoryId (com.enonic.xp.repository.RepositoryId)61 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)19 Branch (com.enonic.xp.branch.Branch)14 Repository (com.enonic.xp.repository.Repository)11 Node (com.enonic.xp.node.Node)9 ByteSource (com.google.common.io.ByteSource)8 IOException (java.io.IOException)7 PropertyTree (com.enonic.xp.data.PropertyTree)6 Segment (com.enonic.xp.blob.Segment)5 Context (com.enonic.xp.context.Context)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)5 ContextBuilder (com.enonic.xp.context.ContextBuilder)5 BlobKey (com.enonic.xp.blob.BlobKey)4 EventPublisher (com.enonic.xp.event.EventPublisher)4 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)4 Project (com.enonic.xp.project.Project)4 DumpConstants (com.enonic.xp.repo.impl.dump.DumpConstants)4 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)4 RepositoryIds (com.enonic.xp.repository.RepositoryIds)4