Search in sources :

Example 41 with RepositoryId

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

the class CreateNodeCommand method storeAndAttachBinaries.

private AttachedBinaries storeAndAttachBinaries() {
    final PropertyTree data = params.getData();
    final AttachedBinaries.Builder builder = AttachedBinaries.create();
    final ImmutableList<Property> binaryReferences = data.getProperties(ValueTypes.BINARY_REFERENCE);
    for (final Property binaryRef : binaryReferences) {
        final BinaryAttachment binaryAttachment = this.params.getBinaryAttachments().get(binaryRef.getBinaryReference());
        if (binaryAttachment == null) {
            throw new NodeBinaryReferenceException("No binary with reference " + binaryRef + " attached in createNodeParams");
        }
        final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
        final AttachedBinary attachedBinary = this.binaryService.store(repositoryId, binaryAttachment);
        builder.add(attachedBinary);
    }
    return builder.build();
}
Also used : NodeBinaryReferenceException(com.enonic.xp.node.NodeBinaryReferenceException) PropertyTree(com.enonic.xp.data.PropertyTree) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) Property(com.enonic.xp.data.Property) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) RepositoryId(com.enonic.xp.repository.RepositoryId) AttachedBinary(com.enonic.xp.node.AttachedBinary)

Example 42 with RepositoryId

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

the class NodeServiceImpl method verifyBranchExists.

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

Example 43 with RepositoryId

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

the class RefreshCommand method execute.

public void execute() {
    final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
    if (!indexServiceInternal.indicesExists(IndexNameResolver.resolveStorageIndexName(repositoryId))) {
        throw new IndexException("Cannot refresh index, index for repository [" + repositoryId + "] does not exist");
    }
    final List<String> indices = new ArrayList<>();
    if (refreshMode.equals(RefreshMode.ALL)) {
        indices.addAll(IndexNameResolver.resolveIndexNames(repositoryId));
    } else if (refreshMode.equals(RefreshMode.SEARCH)) {
        indices.add(IndexNameResolver.resolveSearchIndexName(repositoryId));
    } else {
        indices.add(IndexNameResolver.resolveStorageIndexName(repositoryId));
    }
    this.indexServiceInternal.refresh(indices.toArray(new String[0]));
}
Also used : IndexException(com.enonic.xp.repository.IndexException) ArrayList(java.util.ArrayList) RepositoryId(com.enonic.xp.repository.RepositoryId)

Example 44 with RepositoryId

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

the class UpdatedAttachedBinariesResolver method storeAndAttachBinary.

private void storeAndAttachBinary(final Map<BinaryReference, AttachedBinary> resolved, final BinaryAttachment newBinaryAttachment) {
    final RepositoryId repositoryId = ContextAccessor.current().getRepositoryId();
    final AttachedBinary attachedBinary = binaryService.store(repositoryId, newBinaryAttachment);
    resolved.put(newBinaryAttachment.getReference(), attachedBinary);
}
Also used : RepositoryId(com.enonic.xp.repository.RepositoryId) AttachedBinary(com.enonic.xp.node.AttachedBinary)

Example 45 with RepositoryId

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

the class RepositoryEntryServiceImpl method findRepositoryEntryIds.

@Override
public RepositoryIds findRepositoryEntryIds() {
    final ImmutableList.Builder<RepositoryId> repositoryIds = ImmutableList.builder();
    final FindNodesByParentParams findNodesByParentParams = FindNodesByParentParams.create().parentPath(RepositoryConstants.REPOSITORY_STORAGE_PARENT_PATH).size(-1).build();
    final FindNodesByParentResult findNodesByParentResult = createContext().callWith(() -> FindNodesByParentCommand.create().params(findNodesByParentParams).indexServiceInternal(this.indexServiceInternal).storageService(this.nodeStorageService).searchService(this.nodeSearchService).build().execute());
    findNodesByParentResult.getNodeIds().stream().map(nodeId -> RepositoryId.from(nodeId.toString())).forEach(repositoryIds::add);
    return RepositoryIds.from(repositoryIds.build());
}
Also used : RefreshMode(com.enonic.xp.node.RefreshMode) NodeStorageService(com.enonic.xp.repo.impl.storage.NodeStorageService) EventPublisher(com.enonic.xp.event.EventPublisher) Node(com.enonic.xp.node.Node) RepositoryIds(com.enonic.xp.repository.RepositoryIds) Branch(com.enonic.xp.branch.Branch) Component(org.osgi.service.component.annotations.Component) RepositoryId(com.enonic.xp.repository.RepositoryId) ImmutableList(com.google.common.collect.ImmutableList) UpdateNodeCommand(com.enonic.xp.repo.impl.node.UpdateNodeCommand) ContextAccessor(com.enonic.xp.context.ContextAccessor) RefreshCommand(com.enonic.xp.repo.impl.node.RefreshCommand) NodeEvents(com.enonic.xp.repo.impl.NodeEvents) ContextBuilder(com.enonic.xp.context.ContextBuilder) ByteSource(com.google.common.io.ByteSource) SystemConstants(com.enonic.xp.security.SystemConstants) RepositoryEvents(com.enonic.xp.repo.impl.RepositoryEvents) FindNodesByParentCommand(com.enonic.xp.repo.impl.node.FindNodesByParentCommand) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeSearchService(com.enonic.xp.repo.impl.search.NodeSearchService) AttachedBinary(com.enonic.xp.node.AttachedBinary) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) BinaryService(com.enonic.xp.repo.impl.binary.BinaryService) IndexServiceInternal(com.enonic.xp.repo.impl.index.IndexServiceInternal) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) DeleteNodeByIdCommand(com.enonic.xp.repo.impl.node.DeleteNodeByIdCommand) Context(com.enonic.xp.context.Context) Reference(org.osgi.service.component.annotations.Reference) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) RepositoryConstants(com.enonic.xp.repository.RepositoryConstants) Repository(com.enonic.xp.repository.Repository) FindNodesByParentParams(com.enonic.xp.node.FindNodesByParentParams) ImmutableList(com.google.common.collect.ImmutableList) FindNodesByParentResult(com.enonic.xp.node.FindNodesByParentResult) 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