(node *tview.TreeNode, attrsTable *tview.Table, useCache bool, cache *EntryCache)
| 649 | } |
| 650 | |
| 651 | func 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 | } |
no test coverage detected