Example #1
0
func (k *kernel) Tree(path string) (api.Tree, error) {
	treeModel, err := k.backend.Tree(path)

	if err != nil {
		return nil, err
	}
	tree := gotree.NewTree(treeModel, k)
	return tree, nil
}
Example #2
0
func (k *kernel) AddChild(parentPath, name string) (api.Tree, error) {

	parentWillExists := k.transactionManager.EnsureTreeWillExists(parentPath)
	if !parentWillExists {
		parentModel, err := k.backend.Tree(parentPath)
		if !parentModel.Exists || err != nil {
			return nil, fmt.Errorf("Parent %s does not exis, please create the parent tree first", parentPath)
		}
	}
	childPath := path.Join(parentPath, name)
	childModel := model.NewTree(childPath, false)
	k.transactionManager.Add(transaction.Add, childModel)
	tree := gotree.NewTree(childModel, k)
	return tree, nil
}