use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class VersionTableVacuumCommand method findVersionsInBranches.
private BRANCH_CHECK_RESULT findVersionsInBranches(final Repository repository, final NodeVersionMetadata versionMetadata) {
final NodeId nodeId = versionMetadata.getNodeId();
final NodeVersionId versionId = versionMetadata.getNodeVersionId();
boolean nodeFound = false;
for (final Branch branch : repository.getBranches()) {
try {
final Node node = ContextBuilder.from(ContextAccessor.current()).branch(branch).repositoryId(repository.getId()).build().callWith(() -> this.nodeService.getById(nodeId));
if (versionId.equals(node.getNodeVersionId())) {
return BRANCH_CHECK_RESULT.SAME_VERSION_FOUND;
}
nodeFound = true;
} catch (NodeNotFoundException e) {
// Ignore
}
}
return nodeFound ? BRANCH_CHECK_RESULT.OTHER_VERSION_FOUND : BRANCH_CHECK_RESULT.NO_VERSION_FOUND;
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class SecurityServiceImpl method query.
@Override
public UserQueryResult query(final UserQuery query) {
try {
final NodeQuery nodeQueryBuilder = UserQueryNodeQueryTranslator.translate(query);
final FindNodesByQueryResult result = callWithContext(() -> this.nodeService.findByQuery(nodeQueryBuilder));
final Nodes nodes = callWithContext(() -> this.nodeService.getByIds(result.getNodeIds()));
final Principals principals = PrincipalNodeTranslator.fromNodes(nodes);
return UserQueryResult.create().addUsers(principals).totalSize(Ints.checkedCast(result.getTotalHits())).build();
} catch (NodeNotFoundException e) {
return UserQueryResult.create().build();
}
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class SecurityServiceImpl method query.
@Override
public PrincipalQueryResult query(final PrincipalQuery query) {
try {
final NodeQuery nodeQueryBuilder = PrincipalQueryNodeQueryTranslator.translate(query);
final FindNodesByQueryResult result = callWithContext(() -> this.nodeService.findByQuery(nodeQueryBuilder));
final Nodes nodes = callWithContext(() -> this.nodeService.getByIds(result.getNodeIds()));
final Principals principals = PrincipalNodeTranslator.fromNodes(nodes);
return PrincipalQueryResult.create().addPrincipals(principals).totalSize(Ints.checkedCast(result.getTotalHits())).build();
} catch (NodeNotFoundException e) {
return PrincipalQueryResult.create().build();
}
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class FindIssueCommentsCommandTest method testFindIssuesIssueNotExists.
@Test
public void testFindIssuesIssueNotExists() throws Exception {
final IssueId issueId = IssueId.create();
final PrincipalKey creator = PrincipalKey.from("user:store:one");
final IssueCommentQuery commentQuery = IssueCommentQuery.create().from(0).size(20).issue(issueId).creator(creator).build();
final FindIssueCommentsCommand command = createCommand(commentQuery);
Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenThrow(new NodeNotFoundException("Node not found"));
assertThrows(NodeNotFoundException.class, () -> command.execute());
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class UpdateIssueCommentCommandTest method updateCommentNotExists.
@Test
public void updateCommentNotExists() {
final UpdateIssueCommentParams params = UpdateIssueCommentParams.create().comment(NodeId.from(UUID.randomUUID())).text("Comment text...").build();
final UpdateIssueCommentCommand command = updateIssueCommentCommand(params);
Mockito.when(this.nodeService.update(Mockito.any(UpdateNodeParams.class))).thenThrow(new NodeNotFoundException("Node not found"));
assertThrows(NodeNotFoundException.class, () -> command.execute());
}
Aggregations