use of com.enonic.xp.node.NodePath in project xp by enonic.
the class MoveNodeHandler method moveAndRename.
private Node moveAndRename(final Node node) {
final NodePath targetPath = target.getAsNodePath();
final NodePath targetParent = targetPath.getParentPath();
final boolean movedToNewParent = !targetParent.equals(node.parentPath());
if (movedToNewParent) {
// First rename the node to a temporary unique name to avoid clashing with siblings with target name in source parent or with siblings with source name in target parent
rename(node.id(), uniqueName());
move(node.id(), targetParent);
}
return rename(node.id(), NodeName.from(targetPath.getName()));
}
use of com.enonic.xp.node.NodePath in project xp by enonic.
the class NodeImportResultJson method from.
public static NodeImportResultJson from(final NodeImportResult result) {
final NodeImportResultJson json = new NodeImportResultJson();
json.dryRun = result.isDryRun();
for (final NodePath nodePath : result.getAddedNodes()) {
json.addedNodes.add(nodePath.toString());
}
for (final NodePath nodePath : result.getUpdateNodes()) {
json.updateNodes.add(nodePath.toString());
}
for (final NodeImportResult.ImportError importError : result.getImportErrors()) {
json.importErrors.add(importError.getMessage() + " - " + importError.getException());
}
json.importedBinaries.addAll(result.getImportedBinaries());
return json;
}
use of com.enonic.xp.node.NodePath in project xp by enonic.
the class FindContentByParentCommand method setNodePathOrIdAsIdentifier.
private void setNodePathOrIdAsIdentifier(final FindNodesByParentParams.Builder findNodesParam) {
if (params.getParentPath() == null && params.getParentId() == null) {
final NodePath parentPath = ContentNodeHelper.getContentRoot();
findNodesParam.parentPath(parentPath);
} else if (params.getParentPath() != null) {
final NodePath parentPath = ContentNodeHelper.translateContentPathToNodePath(params.getParentPath());
findNodesParam.parentPath(parentPath);
} else {
final NodeId parentId = NodeId.from(params.getParentId().toString());
findNodesParam.parentId(parentId);
}
}
use of com.enonic.xp.node.NodePath in project xp by enonic.
the class FindContentIdsByParentCommand method setNodePathOrIdAsIdentifier.
private void setNodePathOrIdAsIdentifier(final FindNodesByParentParams.Builder findNodesParam) {
if (params.getParentPath() == null && params.getParentId() == null) {
final NodePath parentPath = ContentNodeHelper.getContentRoot();
findNodesParam.parentPath(parentPath);
} else if (params.getParentPath() != null) {
final NodePath parentPath = ContentNodeHelper.translateContentPathToNodePath(params.getParentPath());
findNodesParam.parentPath(parentPath);
} else {
final NodeId parentId = NodeId.from(params.getParentId().toString());
findNodesParam.parentId(parentId);
}
}
use of com.enonic.xp.node.NodePath 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();
}
}
Aggregations