use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class DiffBranchesHandler method execute.
@Override
public Object execute() {
final NodeId nodeId = getNodeId(this.nodeKey);
if (nodeId == null) {
throw new NodeNotFoundException("Node with key [" + this.nodeKey + "] not found");
}
final ResolveSyncWorkResult result = this.nodeService.resolveSyncWork(SyncWorkResolverParams.create().includeChildren(includeChildren).nodeId(nodeId).branch(targetBranch).build());
return new ResolveSyncWorkResultMapper(result);
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class GetContentByIdCommand method execute.
Content execute() {
final Content content;
final NodeId nodeId = NodeId.from(contentId.toString());
try {
final Node node = nodeService.getById(nodeId);
content = filter(translator.fromNode(node, true));
} catch (NodeNotFoundException e) {
return null;
} catch (Exception e) {
throw Exceptions.newRuntime("Error getting node").withCause(e);
}
return content;
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class GetContentByPathAndVersionIdCommand method execute.
public Content execute() {
final NodePath nodePath = ContentNodeHelper.translateContentPathToNodePath(contentPath);
final NodeVersionId nodeVersionId = NodeVersionId.from(contentVersionId.toString());
try {
final Node node = nodeService.getByPathAndVersionId(nodePath, nodeVersionId);
final Content content = filter(translator.fromNode(node, true));
if (content != null) {
return content;
}
throw createContentNotFoundException();
} catch (NodeNotFoundException e) {
throw createContentNotFoundException();
}
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class MoveContentCommandTest method move_non_existing_content.
@Test
public void move_non_existing_content() throws Exception {
PropertyTree existingContentData = new PropertyTree();
existingContentData.addString("myData", "aaa");
ContentId contentId = ContentId.from("mycontent");
MoveContentParams params = MoveContentParams.create().contentId(contentId).parentContentPath(ContentPath.ROOT).build();
MoveContentCommand command = MoveContentCommand.create(params).contentTypeService(this.contentTypeService).nodeService(this.nodeService).translator(this.translator).eventPublisher(this.eventPublisher).build();
Mockito.when(nodeService.getById(Mockito.isA(NodeId.class))).thenThrow(new NodeNotFoundException("Node not found"));
// exercise
assertThrows(ContentNotFoundException.class, () -> command.execute());
}
use of com.enonic.xp.node.NodeNotFoundException in project xp by enonic.
the class UpdateContentCommandTest method given_content_not_found_when_handle_then_NOT_FOUND_is_returned.
@Test
public void given_content_not_found_when_handle_then_NOT_FOUND_is_returned() throws Exception {
// setup
PropertyTree existingContentData = new PropertyTree();
existingContentData.addString("myData", "aaa");
ContentId contentId = ContentId.from("mycontent");
UpdateContentParams params = new UpdateContentParams().contentId(contentId).editor(edit -> {
});
UpdateContentCommand command = UpdateContentCommand.create(params).contentTypeService(this.contentTypeService).nodeService(this.nodeService).translator(this.translator).eventPublisher(this.eventPublisher).mediaInfo(this.mediaInfo).xDataService(this.xDataService).siteService(this.siteService).build();
Mockito.when(nodeService.getById(Mockito.isA(NodeId.class))).thenThrow(new NodeNotFoundException("Node not found"));
// exercise
assertThrows(ContentNotFoundException.class, () -> command.execute());
}
Aggregations