MCPcopy Create free account
hub / github.com/Macmod/godap / reloadAttributesPanel

Function reloadAttributesPanel

tui/tree.go:651–771  ·  view source on GitHub ↗
(node *tview.TreeNode, attrsTable *tview.Table, useCache bool, cache *EntryCache)

Source from the content-addressed store, hash-verified

649}
650
651func reloadAttributesPanel(node *tview.TreeNode, attrsTable *tview.Table, useCache bool, cache *EntryCache) error {
652 ref := node.GetReference()
653 if ref == nil {
654 return fmt.Errorf("Couldn't reload attributes: no node selected")
655 }
656
657 var attributes []*ldap.EntryAttribute
658
659 baseDN := ref.(string)
660
661 attrsTable.Clear()
662
663 if useCache {
664 entry, ok := cache.Get(baseDN)
665 if ok {
666 attributes = entry.Attributes
667 } else {
668 return fmt.Errorf("Couldn't reload attributes: node not cached")
669 }
670 } else {
671 entries, err := lc.QueryWithAttrs(baseDN, SearchFilter, ldap.ScopeBaseObject, Deleted, getPageAttrs(attrsTable))
672 if err != nil {
673 handleLDAPError(err)
674 return err
675 }
676
677 if len(entries) != 1 {
678 return fmt.Errorf("Entry not found")
679 }
680
681 entry := entries[0]
682 cache.Add(baseDN, entry)
683
684 attributes = entry.Attributes
685 }
686
687 if len(attributes) > 0 {
688 attributes = sortAttributes(attributes)
689 }
690
691 row := 0
692 for _, attribute := range attributes {
693 var myCell *tview.TableCell
694 var cellName string = attribute.Name
695 var fmtAttrs ldaputils.FormattedAttr
696
697 if FormatAttrs {
698 fmtAttrs = ldaputils.FormatLDAPAttribute(attribute, TimeFormat, TimeOffset)
699 } else {
700 for _, val := range attribute.Values {
701 fmtAttrs.Values = append(
702 fmtAttrs.Values,
703 ldaputils.FormattedAttrValue{
704 OriginalValue: val,
705 FormattedValue: val,
706 },
707 )
708 }

Callers 7

handleAttrsKeyCtrlEFunction · 0.85
handleAttrsKeyDeleteFunction · 0.85
handleAttrsKeyCtrlNFunction · 0.85
attrsPanelKeyHandlerFunction · 0.85
reloadSearchAttrsPanelFunction · 0.85
reloadExplorerAttrsPanelFunction · 0.85
treePanelKeyHandlerFunction · 0.85

Calls 11

ValuesStrMethod · 0.95
FormatLDAPAttributeFunction · 0.92
getPageAttrsFunction · 0.85
handleLDAPErrorFunction · 0.85
sortAttributesFunction · 0.85
GetAttrCellColorFunction · 0.85
insertEntriesHiddenRowFunction · 0.85
ClearMethod · 0.80
GetMethod · 0.80
QueryWithAttrsMethod · 0.80
AddMethod · 0.80

Tested by

no test coverage detected