protected void doExecute()

in gshell/gshell-obr/src/main/java/org/apache/servicemix/kernel/gshell/obr/ListCommand.java [31:83]


    protected void doExecute(RepositoryAdmin admin) throws Exception {
        String substr = null;

        if (args != null) {
            for (String arg : args)
            {
                // Add a space in between tokens.
                if (substr == null)
                {
                    substr = "";
                }
                else
                {
                    substr += " ";
                }

                substr += arg;
            }
        }
        
        StringBuffer sb = new StringBuffer();
        if ((substr == null) || (substr.length() == 0))
        {
            sb.append("(|(presentationname=*)(symbolicname=*))");
        }
        else
        {
            sb.append("(|(presentationname=*");
            sb.append(substr);
            sb.append("*)(symbolicname=*");
            sb.append(substr);
            sb.append("*))");
        }
        Resource[] resources = admin.discoverResources(sb.toString());
        for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
        {
            String name = resources[resIdx].getPresentationName();
            Version version = resources[resIdx].getVersion();
            if (version != null)
            {
                io.out.println(name + " (" + version + ")");
            }
            else
            {
                io.out.println(name);
            }
        }

        if (resources == null)
        {
            io.out.println("No matching bundles.");
        }
    }