use of com.enonic.xp.node.CreateNodeParams 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);
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class CreateNodeParamsFactory method doCreate.
private CreateNodeParams doCreate(final PropertyTree properties, BinaryAttachments createAttachments) {
final String name = properties.getString(NODE_NAME);
final String parentPath = properties.getString(PARENT_PATH);
final Long manualOrderValue = properties.getLong(MANUAL_ORDER_VALUE);
final String childOrder = properties.getString(CHILD_ORDER);
final String nodeType = properties.getString(NODE_TYPE);
final Iterable<PropertySet> permissions = properties.getSets(PERMISSIONS);
final Boolean inheritPermissions = properties.getBoolean(INHERITS_PERMISSIONS);
final PropertySet indexConfig = properties.getSet(INDEX_CONFIG);
final CreateNodeParams.Builder builder = CreateNodeParams.create();
setName(name, builder);
setUserData(properties, builder);
builder.parent(isNullOrEmpty(parentPath) ? NodePath.ROOT : NodePath.create(parentPath).build()).manualOrderValue(manualOrderValue).childOrder(ChildOrder.from(childOrder)).nodeType(isNullOrEmpty(nodeType) ? NodeType.DEFAULT_NODE_COLLECTION : NodeType.from(nodeType)).indexConfigDocument(new IndexConfigFactory(indexConfig).create()).setBinaryAttachments(createAttachments);
if (inheritPermissions != null && inheritPermissions) {
builder.inheritPermissions(true);
} else {
builder.permissions(new PermissionsFactory(permissions).create());
}
return builder.build();
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class CreateNodeHandler method execute.
@Override
public Object execute() {
final ScriptValueTranslatorResult params = getParams(this.params);
final CreateNodeParams createNodeParams = new CreateNodeParamsFactory().create(params);
final Node node = this.nodeService.create(createNodeParams);
return new NodeMapper(node);
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class CreateNodeParamsFactoryTest method nodeName.
@Test
public void nodeName() throws Exception {
final CreateNodeParams createNodeParams = createWithStringProperty(NODE_NAME, "myNode");
assertEquals("myNode", createNodeParams.getName());
}
use of com.enonic.xp.node.CreateNodeParams in project xp by enonic.
the class CreateNodeParamsFactoryTest method nodeType.
@Test
public void nodeType() throws Exception {
final CreateNodeParams createNodeParams = createWithStringProperty(NODE_TYPE, "myNodeType");
assertEquals(NodeType.from("myNodeType"), createNodeParams.getNodeType());
}
Aggregations