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();
}
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);
}
});
}
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]));
}
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);
}
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());
}
Aggregations