Karaf
  1. Karaf
  2. KARAF-1499

InfoAction shell command should sort the properties from InfoProvider instances

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 2.2.4
    • Fix Version/s: 2.2.8, 2.3.0, 3.0.0
    • Component/s: karaf-shell
    • Labels:
      None

      Description

      The class org.apache.karaf.shell.commands.InfoAction accepts input from InfoProvider services. The items from those providers are printed via this code:

          for (String section : properties.keySet()) {
              System.out.println(section);
      
              for (Object key : properties.get(section).keySet()) {
                  printValue(String.valueOf(key), maxNameLen, String.valueOf(properties.get(section).get(key)));
              }
          }
      

      The .keySet() method returns keys in effectively random order, making the output hard to read. I propose instead the following presentation:

          List<String> sections = new ArrayList<String>(properties.keySet());
          Collections.sort(sections);
          for (String section : sections) {
              List<Object> keys = new ArrayList<Object>(properties.get(section).keySet());
              if (keys.size() > 0) {
                  System.out.println(section);
      
                  Collections.sort(keys, new Comparator<Object>() {
                      public int compare(Object o1, Object o2) {
                          return String.valueOf(o1).compareTo(String.valueOf(o2));
                      }
                  });
      
                  for (Object key : keys) {
                      printValue(String.valueOf(key), maxNameLen, String.valueOf(properties.get(section).get(key)));
                  }
              }
          }
      

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        6d 12h 33m 1 Freeman Fang 30/May/12 04:14
        In Progress In Progress Resolved Resolved
        1d 23h 51m 1 Freeman Fang 01/Jun/12 04:05
        Resolved Resolved Closed Closed
        78d 11h 27m 1 Jamie goodyear 18/Aug/12 15:32
        Jamie goodyear made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Freeman Fang made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.2.8 [ 12320756 ]
        Fix Version/s 2.3.0 [ 12320554 ]
        Fix Version/s 3.0.0 [ 12316040 ]
        Resolution Fixed [ 1 ]
        Hide
        Chris Dolan added a comment -

        Heh, I just updated svn to create a "real patch" but it looks like you've already committed it in rev 1344087. Thanks.

        Show
        Chris Dolan added a comment - Heh, I just updated svn to create a "real patch" but it looks like you've already committed it in rev 1344087. Thanks.
        Freeman Fang made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Freeman Fang added a comment -

        Hi Chris,

        Sounds good.
        Wanna attach a real patch with "Grant Apache License"?

        Freeman

        Show
        Freeman Fang added a comment - Hi Chris, Sounds good. Wanna attach a real patch with "Grant Apache License"? Freeman
        Freeman Fang made changes -
        Field Original Value New Value
        Assignee Freeman Fang [ ffang ]
        Chris Dolan created issue -

          People

          • Assignee:
            Freeman Fang
            Reporter:
            Chris Dolan
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development