use of com.enonic.xp.repo.impl.binary.BinaryService in project xp by enonic.
the class CreateNodeCommand_path_integrity_test method create.
@Test
public void create() {
final int concurrentAttempts = 5;
final int expectedSuccessfulAttempts = 1;
final AtomicInteger exceptionCounter = new AtomicInteger();
CompletableFuture.allOf(IntStream.range(0, concurrentAttempts).mapToObj(i -> CompletableFuture.runAsync(CreateNodeTask.create().binaryService(this.binaryService).storageService(this.storageService).nodeSearchService(this.searchService).indexServiceInternal(this.indexServiceInternal).context(ContextAccessor.current()).build()).exceptionally(throwable -> {
exceptionCounter.incrementAndGet();
return null;
})).toArray(CompletableFuture[]::new)).join();
assertEquals(concurrentAttempts - expectedSuccessfulAttempts, exceptionCounter.get());
refresh();
final FindNodesByQueryResult result = doFindByQuery(NodeQuery.create().path(NodePath.create(NodePath.ROOT, "myNode").build()).build());
assertEquals(expectedSuccessfulAttempts, result.getTotalHits());
}
use of com.enonic.xp.repo.impl.binary.BinaryService in project xp by enonic.
the class DuplicateNodeCommand method updateNodeReferences.
private void updateNodeReferences(final Node node, final NodeReferenceUpdatesHolder nodeReferenceUpdatesHolder) {
final PropertyTree data = node.data();
boolean changes = false;
for (final Property property : node.data().getProperties(ValueTypes.REFERENCE)) {
final Reference reference = property.getReference();
if (reference != null && nodeReferenceUpdatesHolder.mustUpdate(reference)) {
changes = true;
data.setReference(property.getPath(), nodeReferenceUpdatesHolder.getNewReference(reference));
}
}
if (changes) {
UpdateNodeCommand.create(this).params(UpdateNodeParams.create().id(node.id()).editor(toBeEdited -> toBeEdited.data = data).build()).binaryService(this.binaryService).build().execute();
}
nodeReferencesUpdated(1);
}
Aggregations