Search in sources :

Example 1 with IssueAlreadyExistsException

use of com.enonic.xp.issue.IssueAlreadyExistsException in project xp by enonic.

the class CreateIssueCommentCommand method doExecute.

private IssueComment doExecute() {
    validateBlockingChecks();
    final Node issueNode = nodeService.getById(NodeId.from(params.getIssue()));
    final String commentName = IssueCommentNameFactory.create(params.getCreated());
    final CreateNodeParams createNodeParams = CreateNodeParamsFactory.create(this.params, issueNode.name(), commentName);
    final Node createdNode;
    try {
        createdNode = nodeService.create(createNodeParams);
    } catch (NodeAlreadyExistAtPathException e) {
        throw new IssueAlreadyExistsException(IssueName.from(createNodeParams.getName()));
    }
    nodeService.refresh(RefreshMode.SEARCH);
    return IssueCommentNodeTranslator.fromNode(createdNode);
}
Also used : IssueAlreadyExistsException(com.enonic.xp.issue.IssueAlreadyExistsException) Node(com.enonic.xp.node.Node) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) CreateNodeParams(com.enonic.xp.node.CreateNodeParams)

Example 2 with IssueAlreadyExistsException

use of com.enonic.xp.issue.IssueAlreadyExistsException in project xp by enonic.

the class CreateIssueCommand method doExecute.

private Issue doExecute() {
    validateBlockingChecks();
    final long index = countTotalIssues() + 1;
    final IssueName issueName = IssueNameFactory.create(index);
    final CreateNodeParams createNodeParams = CreateNodeParamsFactory.create(this.params, this.getCurrentUser(), index, issueName);
    final Node createdNode;
    try {
        createdNode = nodeService.create(createNodeParams);
    } catch (NodeAlreadyExistAtPathException e) {
        throw new IssueAlreadyExistsException(IssueName.from(createNodeParams.getName()));
    }
    nodeService.refresh(RefreshMode.SEARCH);
    return IssueNodeTranslator.fromNode(createdNode);
}
Also used : IssueAlreadyExistsException(com.enonic.xp.issue.IssueAlreadyExistsException) IssueName(com.enonic.xp.issue.IssueName) Node(com.enonic.xp.node.Node) NodeAlreadyExistAtPathException(com.enonic.xp.node.NodeAlreadyExistAtPathException) CreateNodeParams(com.enonic.xp.node.CreateNodeParams)

Aggregations

IssueAlreadyExistsException (com.enonic.xp.issue.IssueAlreadyExistsException)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2 Node (com.enonic.xp.node.Node)2 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)2 IssueName (com.enonic.xp.issue.IssueName)1