// CreateChild runs the create-child action.
501862
func (c *AreaController) CreateChild(ctx *app.CreateChildAreaContext) error {
	currentUser, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	parentID, err := uuid.FromString(ctx.ID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
	}
	var a *area.Area
	err = application.Transactional(c.db, func(appl application.Application) error {
		parent, err := appl.Areas().Load(ctx, parentID)
		if err != nil {
			return err
		}
		s, err := appl.Spaces().Load(ctx, parent.SpaceID)
		if err != nil {
			return err
		}
		if !uuid.Equal(*currentUser, s.OwnerID) {
			log.Warn(ctx, map[string]interface{}{
				"space_id":     s.ID,
				"space_owner":  s.OwnerID,
				"current_user": *currentUser,
			}, "user is not the space owner")
			return errors.NewForbiddenError("user is not the space owner")
		}

		reqArea := ctx.Payload.Data
		if reqArea.Attributes.Name == nil {
			return errors.NewBadParameterError("data.attributes.name", nil).Expected("not nil")
		}

		a = &area.Area{
			SpaceID: parent.SpaceID,
			Name:    *reqArea.Attributes.Name,
		}
		a.MakeChildOf(*parent)
		return appl.Areas().Create(ctx, a)
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	result := &app.AreaSingle{
		Data: ConvertArea(c.db, ctx.Request, *a, addResolvedPath),
	}
	ctx.ResponseData.Header().Set("Location", rest.AbsoluteURL(ctx.Request, app.AreaHref(result.Data.ID)))
	return ctx.Created(result)
}
11853
func (o *Domain) CreateLink(child *Link) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
1290485
func (o *Enterprise) CreateUser(child *User) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
512499
func (b *Factory) CreateElement(recorded, local, remote map[string]interface{}) (apply.Element, error) {
	// Create an Item from the 3 values.  Use empty name for field
	visitor := &ElementBuildingVisitor{b.Resources}

	gvk, err := getCommonGroupVersionKind(recorded, local, remote)
	if err != nil {
		return nil, err
	}

	// Get the openapi object metadata
	s := visitor.resources.LookupResource(gvk)
	oapiKind, err := getKind(s)
	if err != nil {
		return nil, err
	}

	data := apply.NewRawElementData(recorded, local, remote)
	fieldName := ""
	item, err := visitor.getItem(oapiKind, fieldName, data)
	if err != nil {
		return nil, err
	}

	// Collate each field of the item into a combined Element
	return item.CreateElement(visitor)
}
607368
func NewChildData(path string, stat *zk.Stat, data []byte) *ChildData {
	return &ChildData{
		path: path,
		stat: stat,
		data: data,
	}
}
1069001
func (t *Trie) addChild(b byte, n *Trie) {
	chars, childs := t.ChildChars, t.Childs
	l := len(chars)
	chars, childs = make([]byte, l+1), make([]*Trie, l+1)
	copy(chars, t.ChildChars)
	copy(childs, t.Childs)

	for ; l > 0 && chars[l-1] > b; l-- {
		chars[l], childs[l] = chars[l-1], childs[l-1]
	}
	chars[l], childs[l] = b, n
	t.ChildChars, t.Childs = chars, childs
}
545959
func (p *parser) addChild(n *Node) {
	if p.shouldFosterParent() {
		p.fosterParent(n)
	} else {
		p.top().AppendChild(n)
	}

	if n.Type == ElementNode {
		p.oe = append(p.oe, n)
	}
}
369351
func (n *node) makeChild(path string, params map[string]uint16, re *regexp.Regexp, handler http.Handler, isRoot bool) {
	defer n.sortChildren()
NodesLoop:
	for _, child := range n.children {
		minlen := len(child.s)
		if len(path) < minlen {
			minlen = len(path)
		}
		for i := 0; i < minlen; i++ {
			if child.s[i] == path[i] {
				continue
			}
			if i == 0 { // No match from the first byte: see next same-level node.
				continue NodesLoop
			}
			// Difference in the middle of a node: split current node to make subnode and transfer handler to it.
			*child = node{
				s: child.s[:i],
				children: []*node{
					{s: child.s[i:], params: child.params, re: child.re, children: child.children, handler: child.handler},
					{s: path[i:], params: params, re: re, handler: handler},
				},
			}
			// BUG(arthurwhite): If the client has no route for "/" and this split occurs on the first level because of the 2nd byte (just after the leading "/"), the isRoot flag of the parent node ("/") is false.
			// It's not a problem because it has no handler and will never match a request, but it's not clean.
			// A first solution would be to let makeChild know the current level in tree, but... All that for this?
			return
		}
		if len(path) < len(child.s) { // s fully matched first part of n.s: split node.
			*child = node{
				s:      child.s[:len(path)],
				params: params,
				re:     re,
				children: []*node{
					{s: child.s[len(path):], params: child.params, re: child.re, children: child.children, handler: child.handler},
				},
				handler: handler,
				isRoot:  isRoot,
			}
		} else if len(path) > len(child.s) { // n.s fully matched first part of s: see subnodes for the rest.
			child.makeChild(path[len(child.s):], params, re, handler, false)
		} else { // s == n.s and no rest: node has no handler or route is duplicated.
			if handler == nil { // No handler provided (must be a non-ending path parameter): don't overwrite.
				return
			}
			if child.handler != nil { // Handler provided but child.handler already set: it's a parameter with another re value, or route is duplicated.
				if re == nil && child.re == nil || re != nil && child.re != nil && re.String() == child.re.String() {
					panic("router: two or more routes have same path")
				}
				continue NodesLoop // It's a parameter with a different regular expression: check next child for "same path" error. Otherwise, node will be appended.
			}
			child.params = params
			child.re = re
			child.handler = handler
			child.isRoot = isRoot
		}
		return
	}
	n.children = append(n.children, &node{s: path, params: params, re: re, handler: handler, isRoot: isRoot}) // Not a single byte match on same-level nodes: append a new one.
}
1361526
func (c *FakeProjects) Create(projectResource *project.Project) (result *project.Project, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootCreateAction(projectsResource, projectResource), &project.Project{})
	if obj == nil {
		return nil, err
	}
	return obj.(*project.Project), err
}
225079
func Create(xu *xgbutil.XUtil, parent xproto.Window) (*Window, error) {
	win, err := Generate(xu)
	if err != nil {
		return nil, err
	}

	err = win.CreateChecked(parent, 0, 0, 1, 1, 0)
	if err != nil {
		return nil, err
	}

	return win, nil
}
229370
func (o *Me) CreateVM(child *VM) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
17600
func (o *Me) CreateContainer(child *Container) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
207163
func (a *AST) AppendChild(child AST) {
	a.Children = append(a.Children, child)
}
157190
func (o *VPort) CreateTCA(child *TCA) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
599906
func (o *UplinkConnection) CreateCustomProperty(child *CustomProperty) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
1052355
func (o *NSGateway) CreateNSPort(child *NSPort) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
750008
func (n *XMLNode) AddChild(child *XMLNode) {
	child.parent = n
	if _, ok := n.Children[child.Name.Local]; !ok {
		n.Children[child.Name.Local] = []*XMLNode{}
	}
	n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child)
}