geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/controller ListDeployments.java
Date Fri, 23 Jul 2004 07:27:50 GMT
gdamour     2004/07/23 00:27:50

  Modified:    modules/core/src/java/org/apache/geronimo/console/cli/controller
                        ListDeployments.java
  Log:
  Fix a NullPointerException when no module is identified.
  
  Revision  Changes    Path
  1.6       +17 -21    incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/controller/ListDeployments.java
  
  Index: ListDeployments.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/console/cli/controller/ListDeployments.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ListDeployments.java	22 Jul 2004 03:14:48 -0000	1.5
  +++ ListDeployments.java	23 Jul 2004 07:27:50 -0000	1.6
  @@ -36,6 +36,13 @@
    */
   public class ListDeployments extends TextController {
       private static final Log log = LogFactory.getLog(ListDeployments.class);
  +
  +    private static final ModuleType[] ALL = new ModuleType[] {ModuleType.CAR,
  +        ModuleType.EAR,
  +        ModuleType.EJB,
  +        ModuleType.RAR,
  +        ModuleType.WAR};
  +    
       ModuleType type = null;
       boolean selected = false;
   
  @@ -102,31 +109,20 @@
           try {
               if(type != null) {
                   ids = context.deployer.getAvailableModules(type, context.targets);
  +                if ( null == ids ) {
  +                    ids = new TargetModuleID[0];
  +                }
               } else {
                   List list = new ArrayList();
  -                TargetModuleID[] modules = context.deployer.getAvailableModules(ModuleType.CAR,
context.targets);
  -                if ( null != modules ) {
  -                    list.addAll(Arrays.asList(modules));
  -                }
  -                modules = context.deployer.getAvailableModules(ModuleType.EAR, context.targets);
  -                if ( null != modules ) {
  -                    list.addAll(Arrays.asList(modules));
  -                }
  -                modules = context.deployer.getAvailableModules(ModuleType.EJB, context.targets);
  -                if ( null != modules ) {
  -                    list.addAll(Arrays.asList(modules));
  -                }
  -                modules = context.deployer.getAvailableModules(ModuleType.RAR, context.targets);
  -                if ( null != modules ) {
  -                    list.addAll(Arrays.asList(modules));
  -                }
  -                modules = context.deployer.getAvailableModules(ModuleType.WAR, context.targets);
  -                if ( null != modules ) {
  -                    list.addAll(Arrays.asList(modules));
  +                for (int i = 0; i < ALL.length; i++) {
  +                    TargetModuleID[] modules = context.deployer.getAvailableModules(ALL[i],
context.targets);
  +                    if ( null != modules ) {
  +                        list.addAll(Arrays.asList(modules));
  +                    }
                   }
                   ids = (TargetModuleID[])list.toArray(new TargetModuleID[list.size()]);
               }
  -            println(null == ids || ids.length == 0 ? "No matching modules found." : "Found
"+ids.length+" matching module"+(ids.length == 1 ? "" : "s"));
  +            println(ids.length == 0 ? "No matching modules found." : "Found "+ids.length+"
matching module"+(ids.length == 1 ? "" : "s"));
               for(int i=0; i<ids.length; i++) {
                   println("  "+ids[i].toString());
               }
  
  
  

Mime
View raw message