Search in sources :

Example 11 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class DumpServiceImplTest method number_of_versions_in_other_repo.

@Test
public void number_of_versions_in_other_repo() {
    final Repository myRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("myrepo"), AccessControlList.create().add(AccessControlEntry.create().principal(ctxDefault().getAuthInfo().getUser().getKey()).allowAll().build()).build(), null));
    final Context myRepoContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(myRepo.getId()).branch(RepositoryConstants.MASTER_BRANCH).build();
    final Node myNode = myRepoContext.callWith(() -> createNode(NodePath.ROOT, "myNode"));
    myRepoContext.runWith(() -> updateNode(myNode));
    myRepoContext.runWith(() -> updateNode(myNode));
    myRepoContext.runWith(() -> updateNode(myNode));
    final SystemLoadResult dumpResult = NodeHelper.runAsAdmin(() -> dumpDeleteAndLoad(true, SystemDumpParams.create().dumpName("myTestDump").build()));
    final RepoLoadResult repoLoadResult = getRepoLoadResult(dumpResult, myRepo.getId());
    final VersionsLoadResult versionsLoadResult = repoLoadResult.getVersionsLoadResult();
    assertNotNull(versionsLoadResult);
    // One for root, 4 for myNode
    assertEquals(5, versionsLoadResult.getSuccessful());
}
Also used : BundleContext(org.osgi.framework.BundleContext) Context(com.enonic.xp.context.Context) InternalContext(com.enonic.xp.repo.impl.InternalContext) Repository(com.enonic.xp.repository.Repository) SystemLoadResult(com.enonic.xp.dump.SystemLoadResult) Node(com.enonic.xp.node.Node) VersionsLoadResult(com.enonic.xp.dump.VersionsLoadResult) RepoLoadResult(com.enonic.xp.dump.RepoLoadResult) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 12 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class NodeServiceImpl method verifyRepositoryExists.

private void verifyRepositoryExists() {
    NodeHelper.runAsAdmin(() -> {
        final RepositoryId repoId = ContextAccessor.current().getRepositoryId();
        final Repository repository = this.repositoryService.get(repoId);
        if (repository == null) {
            throw new RepositoryNotFoundException(repoId);
        }
    });
}
Also used : Repository(com.enonic.xp.repository.Repository) RepositoryNotFoundException(com.enonic.xp.repository.RepositoryNotFoundException) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 13 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class RepositoryServiceImpl method doCreateRepo.

private Repository doCreateRepo(final CreateRepositoryParams params) {
    final RepositoryId repositoryId = params.getRepositoryId();
    final boolean repoAlreadyInitialized = this.nodeRepositoryService.isInitialized(repositoryId);
    if (repoAlreadyInitialized) {
        throw new RepositoryAlreadyExistException(repositoryId);
    }
    this.nodeRepositoryService.create(params);
    createRootNode(params);
    final Repository repository = createRepositoryObject(params);
    repositoryEntryService.createRepositoryEntry(repository);
    return repository;
}
Also used : EditableRepository(com.enonic.xp.repository.EditableRepository) Repository(com.enonic.xp.repository.Repository) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 14 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class RepositoryEntryServiceImpl method updateRepositoryNode.

private Repository updateRepositoryNode(final UpdateNodeParams updateNodeParams) {
    final Node updatedNode = createContext().callWith(() -> UpdateNodeCommand.create().params(updateNodeParams).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).binaryService(this.binaryService).build().execute());
    eventPublisher.publish(NodeEvents.updated(updatedNode));
    refresh();
    Repository repository = RepositoryNodeTranslator.toRepository(updatedNode);
    eventPublisher.publish(RepositoryEvents.updated(repository.getId()));
    return repository;
}
Also used : Repository(com.enonic.xp.repository.Repository) Node(com.enonic.xp.node.Node)

Example 15 with Repository

use of com.enonic.xp.repository.Repository in project xp by enonic.

the class RepositoriesJson method create.

public static RepositoriesJson create(final Repositories repositories) {
    final RepositoriesJson json = new RepositoriesJson();
    json.repositories = new ArrayList<>();
    for (final Repository repo : repositories) {
        json.repositories.add(RepositoryJson.create(repo));
    }
    return json;
}
Also used : Repository(com.enonic.xp.repository.Repository)

Aggregations

Repository (com.enonic.xp.repository.Repository)40 Test (org.junit.jupiter.api.Test)21 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)15 RepositoryId (com.enonic.xp.repository.RepositoryId)10 Node (com.enonic.xp.node.Node)9 Branch (com.enonic.xp.branch.Branch)8 PropertyTree (com.enonic.xp.data.PropertyTree)7 Context (com.enonic.xp.context.Context)6 FindNodesByMultiRepoQueryResult (com.enonic.xp.node.FindNodesByMultiRepoQueryResult)5 MultiRepoNodeQuery (com.enonic.xp.node.MultiRepoNodeQuery)5 NodeQuery (com.enonic.xp.node.NodeQuery)5 SearchTargets (com.enonic.xp.node.SearchTargets)5 ContextAccessor (com.enonic.xp.context.ContextAccessor)4 ContextBuilder (com.enonic.xp.context.ContextBuilder)4 CreateRepositoryParams (com.enonic.xp.repository.CreateRepositoryParams)4 RepositoryService (com.enonic.xp.repository.RepositoryService)4 SystemLoadResult (com.enonic.xp.dump.SystemLoadResult)3 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)3 NodeService (com.enonic.xp.node.NodeService)3 Project (com.enonic.xp.project.Project)3