Search in sources :

Example 16 with RepositoryId

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

the class RepositoryServiceImpl method createBranch.

@Override
public Branch createBranch(final CreateBranchParams createBranchParams) {
    requireAdminRole();
    final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
    repositoryMap.compute(repositoryId, (key, previousRepository) -> doCreateBranch(createBranchParams, repositoryId, previousRepository));
    return createBranchParams.getBranch();
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 17 with RepositoryId

use of com.enonic.xp.repository.RepositoryId 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 18 with RepositoryId

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

the class RepositoryServiceImpl method doUpdateRepository.

private Repository doUpdateRepository(final UpdateRepositoryParams updateRepositoryParams, Repository previousRepository) {
    RepositoryId repositoryId = updateRepositoryParams.getRepositoryId();
    previousRepository = previousRepository == null ? repositoryEntryService.getRepositoryEntry(repositoryId) : previousRepository;
    if (previousRepository == null) {
        throw new RepositoryNotFoundException(repositoryId);
    }
    final EditableRepository editableRepository = new EditableRepository(previousRepository);
    updateRepositoryParams.getEditor().accept(editableRepository);
    UpdateRepositoryEntryParams params = UpdateRepositoryEntryParams.create().repositoryId(repositoryId).repositoryData(editableRepository.data).attachments(ImmutableList.copyOf(editableRepository.binaryAttachments)).build();
    return repositoryEntryService.updateRepositoryEntry(params);
}
Also used : RepositoryNotFoundException(com.enonic.xp.repository.RepositoryNotFoundException) RepositoryId(com.enonic.xp.repository.RepositoryId) EditableRepository(com.enonic.xp.repository.EditableRepository)

Example 19 with RepositoryId

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

the class NodeRepositoryServiceImpl method create.

@Override
public void create(final CreateRepositoryParams params) {
    final RepositoryId repositoryId = params.getRepositoryId();
    final RepositorySettings repositorySettings = params.getRepositorySettings();
    createIndex(params, IndexType.VERSION, Map.ofEntries(mergeWithDefaultMapping(repositorySettings, repositoryId, IndexType.VERSION), mergeWithDefaultMapping(repositorySettings, repositoryId, IndexType.BRANCH), mergeWithDefaultMapping(repositorySettings, repositoryId, IndexType.COMMIT)));
    createIndex(params, IndexType.SEARCH, Map.ofEntries(mergeWithDefaultMapping(repositorySettings, repositoryId, IndexType.SEARCH)));
    indexServiceInternal.waitForYellowStatus(resolveIndexNames(repositoryId));
}
Also used : RepositorySettings(com.enonic.xp.repository.RepositorySettings) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 20 with RepositoryId

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

the class NodeRepositoryServiceImpl method createIndex.

private void createIndex(final CreateRepositoryParams params, final IndexType indexType, final Map<IndexType, IndexMapping> mappings) {
    final RepositoryId repositoryId = params.getRepositoryId();
    final IndexSettings mergedSettings = mergeWithDefaultSettings(params, indexType);
    indexServiceInternal.createIndex(CreateIndexRequest.create().indexName(resolveIndexName(repositoryId, indexType)).mappings(mappings).indexSettings(mergedSettings).build());
}
Also used : IndexSettings(com.enonic.xp.repository.IndexSettings) 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