code refactoring take 2 05/57505/1
authorseshukm <seshu.kumar.m@huawei.com>
Wed, 25 Jul 2018 11:36:49 +0000 (19:36 +0800)
committerseshukm <seshu.kumar.m@huawei.com>
Wed, 25 Jul 2018 11:36:49 +0000 (19:36 +0800)
Issue-ID: SO-729

Change-Id: I82efa7420f9b9917175e6c47caa0929fa697d78d
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleCreate.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleDelete.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleList.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneServiceList.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantCreate.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantDelete.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantList.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserCreate.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserDelete.java
openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserList.java

index 9214149..7dbba41 100644 (file)
@@ -28,58 +28,58 @@ import com.woorea.openstack.keystone.Keystone;
 import com.woorea.openstack.keystone.model.Role;
 
 public class KeystoneRoleCreate extends KeystoneCommand {
-       
-       public KeystoneRoleCreate() {
-               super( "role-create");
-       }
+    
+    public KeystoneRoleCreate() {
+        super( "role-create");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               Role role = new Role();
-               role.setName(cmd.getOptionValue("name"));
-               role.setDescription(cmd.getOptionValue("description"));
-               if(cmd.getOptionValue("enabled") != null) {
-                       role.setEnabled("True");
-               }
-               
-               role = keystone.roles().create(role).execute();
-               
-               Table t = new Table(new TableModel<Role>(Arrays.asList(role)) {
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        Role role = new Role();
+        role.setName(cmd.getOptionValue("name"));
+        role.setDescription(cmd.getOptionValue("description"));
+        if(cmd.getOptionValue("enabled") != null) {
+            role.setEnabled("True");
+        }
+        
+        role = keystone.roles().create(role).execute();
+        
+        Table t = new Table(new TableModel<Role>(Arrays.asList(role)) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("name", 10, Column.ALIGN_LEFT),
-                                       new Column("description", 32, Column.ALIGN_LEFT),
-                                       new Column("enabled", 7, Column.ALIGN_LEFT)
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("name", 10, Column.ALIGN_LEFT),
+                    new Column("description", 32, Column.ALIGN_LEFT),
+                    new Column("enabled", 7, Column.ALIGN_LEFT)
+                };
+            }
 
-                       @Override
-                       public String[] getRow(Role tenant) {
-                               return new String[]{
-                                       tenant.getId(),
-                                       tenant.getName(),
-                                       tenant.getDescription(),
-                                       tenant.getEnabled().toString()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(Role tenant) {
+                return new String[]{
+                    tenant.getId(),
+                    tenant.getName(),
+                    tenant.getDescription(),
+                    tenant.getEnabled().toString()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
-       /* (non-Javadoc)
-        * @see com.billingstack.commands.Command#getOptions()
-        */
-       @Override
-       public Options getOptions() {
-               Options opts = super.getOptions();
-               opts.addOption(null, "name", true, "tenant name");
-               opts.addOption(null, "description", true, "tenant description");
-               opts.addOption(null, "enabled", false, "enabled");
-               return opts;
-       }
-       
+    /* (non-Javadoc)
+     * @see com.billingstack.commands.Command#getOptions()
+     */
+    @Override
+    public Options getOptions() {
+        Options opts = super.getOptions();
+        opts.addOption(null, "name", true, "tenant name");
+        opts.addOption(null, "description", true, "tenant description");
+        opts.addOption(null, "enabled", false, "enabled");
+        return opts;
+    }
+    
 }
index 5dde646..9adf5c8 100644 (file)
@@ -22,20 +22,20 @@ import com.woorea.openstack.console.utils.ConsoleUtils;
 import com.woorea.openstack.keystone.Keystone;
 
 public class KeystoneRoleDelete extends KeystoneCommand {
-       
-       public KeystoneRoleDelete() {
-               super("role-delete");
-       }
+    
+    public KeystoneRoleDelete() {
+        super("role-delete");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               String[] args = cmd.getArgs();
-               if(args.length == 1) {
-                       keystone.roles().delete(args[0]).execute();
-                       System.out.println(new ConsoleUtils().green("OK"));
-               }
-               
-       }
-       
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        String[] args = cmd.getArgs();
+        if(args.length == 1) {
+            keystone.roles().delete(args[0]).execute();
+            System.out.println(new ConsoleUtils().green("OK"));
+        }
+        
+    }
+    
 }
index bc59140..a6c7f2a 100644 (file)
@@ -26,39 +26,39 @@ import com.woorea.openstack.keystone.model.Role;
 import com.woorea.openstack.keystone.model.Roles;
 
 public class KeystoneRoleList extends KeystoneCommand {
-       
-       public KeystoneRoleList() {
-               super("role-list");
-       }
+    
+    public KeystoneRoleList() {
+        super("role-list");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               final Roles roles = keystone.roles().list().execute();
-               
-               Table t = new Table(new TableModel<Role>(roles.getList()) {
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        final Roles roles = keystone.roles().list().execute();
+        
+        Table t = new Table(new TableModel<Role>(roles.getList()) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("name", 10, Column.ALIGN_LEFT),
-                                       new Column("description", 32, Column.ALIGN_LEFT),
-                                       new Column("enabled", 7, Column.ALIGN_LEFT),
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("name", 10, Column.ALIGN_LEFT),
+                    new Column("description", 32, Column.ALIGN_LEFT),
+                    new Column("enabled", 7, Column.ALIGN_LEFT),
+                };
+            }
 
-                       @Override
-                       public String[] getRow(Role role) {
-                               return new String[]{
-                                               role.getId(),
-                                               role.getName(),
-                                               role.getDescription(),
-                                               role.getEnabled()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(Role role) {
+                return new String[]{
+                        role.getId(),
+                        role.getName(),
+                        role.getDescription(),
+                        role.getEnabled()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
 }
index 931d1ab..9070bd9 100644 (file)
@@ -26,39 +26,39 @@ import com.woorea.openstack.keystone.model.Service;
 import com.woorea.openstack.keystone.model.Services;
 
 public class KeystoneServiceList extends KeystoneCommand {
-       
-       public KeystoneServiceList() {
-               super("service-list");
-       }
+    
+    public KeystoneServiceList() {
+        super("service-list");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               final Services services = keystone.services().list().execute();
-               
-               Table t = new Table(new TableModel<Service>(services.getList()) {
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        final Services services = keystone.services().list().execute();
+        
+        Table t = new Table(new TableModel<Service>(services.getList()) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("type", 10, Column.ALIGN_LEFT),
-                                       new Column("name", 10, Column.ALIGN_LEFT),
-                                       new Column("description", 32, Column.ALIGN_LEFT)
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("type", 10, Column.ALIGN_LEFT),
+                    new Column("name", 10, Column.ALIGN_LEFT),
+                    new Column("description", 32, Column.ALIGN_LEFT)
+                };
+            }
 
-                       @Override
-                       public String[] getRow(Service service) {
-                               return new String[]{
-                                       service.getId(),
-                                       service.getType(),
-                                       service.getName(),
-                                       service.getDescription()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(Service service) {
+                return new String[]{
+                    service.getId(),
+                    service.getType(),
+                    service.getName(),
+                    service.getDescription()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
 }
index 04177a6..c77c5b1 100644 (file)
@@ -28,58 +28,58 @@ import com.woorea.openstack.keystone.Keystone;
 import com.woorea.openstack.keystone.model.Tenant;
 
 public class KeystoneTenantCreate extends KeystoneCommand {
-       
-       public KeystoneTenantCreate() {
-               super("tenant-create");
-       }
+    
+    public KeystoneTenantCreate() {
+        super("tenant-create");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               Tenant tenant = new Tenant();
-               tenant.setName(cmd.getOptionValue("name"));
-               tenant.setDescription(cmd.getOptionValue("description"));
-               if(cmd.getOptionValue("enabled") != null) {
-                       tenant.setEnabled(Boolean.TRUE);
-               }
-               
-               tenant = keystone.tenants().create(tenant).execute();
-               
-               Table t = new Table(new TableModel<Tenant>(Arrays.asList(tenant)) {
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        Tenant tenant = new Tenant();
+        tenant.setName(cmd.getOptionValue("name"));
+        tenant.setDescription(cmd.getOptionValue("description"));
+        if(cmd.getOptionValue("enabled") != null) {
+            tenant.setEnabled(Boolean.TRUE);
+        }
+        
+        tenant = keystone.tenants().create(tenant).execute();
+        
+        Table t = new Table(new TableModel<Tenant>(Arrays.asList(tenant)) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("name", 10, Column.ALIGN_LEFT),
-                                       new Column("description", 32, Column.ALIGN_LEFT),
-                                       new Column("enabled", 7, Column.ALIGN_LEFT)
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("name", 10, Column.ALIGN_LEFT),
+                    new Column("description", 32, Column.ALIGN_LEFT),
+                    new Column("enabled", 7, Column.ALIGN_LEFT)
+                };
+            }
 
-                       @Override
-                       public String[] getRow(Tenant tenant) {
-                               return new String[]{
-                                       tenant.getId(),
-                                       tenant.getName(),
-                                       tenant.getDescription(),
-                                       tenant.getEnabled().toString()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(Tenant tenant) {
+                return new String[]{
+                    tenant.getId(),
+                    tenant.getName(),
+                    tenant.getDescription(),
+                    tenant.getEnabled().toString()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
-       /* (non-Javadoc)
-        * @see com.billingstack.commands.Command#getOptions()
-        */
-       @Override
-       public Options getOptions() {
-               Options opts = super.getOptions();
-               opts.addOption(null, "name", true, "tenant name");
-               opts.addOption(null, "description", true, "tenant description");
-               opts.addOption(null, "enabled", false, "enabled");
-               return opts;
-       }
-       
+    /* (non-Javadoc)
+     * @see com.billingstack.commands.Command#getOptions()
+     */
+    @Override
+    public Options getOptions() {
+        Options opts = super.getOptions();
+        opts.addOption(null, "name", true, "tenant name");
+        opts.addOption(null, "description", true, "tenant description");
+        opts.addOption(null, "enabled", false, "enabled");
+        return opts;
+    }
+    
 }
index bd34ca9..1e9a649 100644 (file)
@@ -22,20 +22,20 @@ import com.woorea.openstack.console.utils.ConsoleUtils;
 import com.woorea.openstack.keystone.Keystone;
 
 public class KeystoneTenantDelete extends KeystoneCommand {
-       
-       public KeystoneTenantDelete() {
-               super("tenant-delete");
-       }
+    
+    public KeystoneTenantDelete() {
+        super("tenant-delete");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               String[] args = cmd.getArgs();
-               if(args.length == 1) {
-                       keystone.tenants().delete(args[0]).execute();
-                       System.out.println(new ConsoleUtils().green("OK"));
-               }
-               
-       }
-       
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        String[] args = cmd.getArgs();
+        if(args.length == 1) {
+            keystone.tenants().delete(args[0]).execute();
+            System.out.println(new ConsoleUtils().green("OK"));
+        }
+        
+    }
+    
 }
index 31d0899..ac8994b 100644 (file)
@@ -26,39 +26,39 @@ import com.woorea.openstack.keystone.model.Tenant;
 import com.woorea.openstack.keystone.model.Tenants;
 
 public class KeystoneTenantList extends KeystoneCommand {
-       
-       public KeystoneTenantList() {
-               super("tenant-list");
-       }
+    
+    public KeystoneTenantList() {
+        super("tenant-list");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine args) {
-               
-               final Tenants tenants = keystone.tenants().list().execute();
-               
-               Table t = new Table(new TableModel<Tenant>(tenants.getList()) {
+    @Override
+    public void execute(Keystone keystone, CommandLine args) {
+        
+        final Tenants tenants = keystone.tenants().list().execute();
+        
+        Table t = new Table(new TableModel<Tenant>(tenants.getList()) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("name", 32, Column.ALIGN_LEFT),
-                                       new Column("description", 32, Column.ALIGN_LEFT),
-                                       new Column("enabled", 7, Column.ALIGN_LEFT)
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("name", 32, Column.ALIGN_LEFT),
+                    new Column("description", 32, Column.ALIGN_LEFT),
+                    new Column("enabled", 7, Column.ALIGN_LEFT)
+                };
+            }
 
-                       @Override
-                       public String[] getRow(Tenant tenant) {
-                               return new String[]{
-                                       tenant.getId(),
-                                       tenant.getName(),
-                                       tenant.getDescription(),
-                                       tenant.getEnabled().toString()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(Tenant tenant) {
+                return new String[]{
+                    tenant.getId(),
+                    tenant.getName(),
+                    tenant.getDescription(),
+                    tenant.getEnabled().toString()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
 }
index baa799b..2da50fc 100644 (file)
@@ -28,64 +28,64 @@ import com.woorea.openstack.keystone.Keystone;
 import com.woorea.openstack.keystone.model.User;
 
 public class KeystoneUserCreate extends KeystoneCommand {
-       
-       public KeystoneUserCreate() {
-               super("user-create");
-       }
+    
+    public KeystoneUserCreate() {
+        super("user-create");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               User user = new User();
-               user.setName(cmd.getOptionValue("name"));
-               user.setPassword(cmd.getOptionValue("password"));
-               user.setEmail(cmd.getOptionValue("email"));
-               user.setTenantId(cmd.getOptionValue("tenant"));
-               if(cmd.getOptionValue("enabled") != null) {
-                       user.setEnabled(Boolean.TRUE);
-               }
-               
-               user = keystone.users().create(user).execute();
-               
-               Table t = new Table(new TableModel<User>(Arrays.asList(user)) {
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        User user = new User();
+        user.setName(cmd.getOptionValue("name"));
+        user.setPassword(cmd.getOptionValue("password"));
+        user.setEmail(cmd.getOptionValue("email"));
+        user.setTenantId(cmd.getOptionValue("tenant"));
+        if(cmd.getOptionValue("enabled") != null) {
+            user.setEnabled(Boolean.TRUE);
+        }
+        
+        user = keystone.users().create(user).execute();
+        
+        Table t = new Table(new TableModel<User>(Arrays.asList(user)) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("name", 10, Column.ALIGN_LEFT),
-                                       new Column("email", 22, Column.ALIGN_LEFT),
-                                       new Column("tenant", 32, Column.ALIGN_LEFT),
-                                       new Column("enabled", 7, Column.ALIGN_LEFT)
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("name", 10, Column.ALIGN_LEFT),
+                    new Column("email", 22, Column.ALIGN_LEFT),
+                    new Column("tenant", 32, Column.ALIGN_LEFT),
+                    new Column("enabled", 7, Column.ALIGN_LEFT)
+                };
+            }
 
-                       @Override
-                       public String[] getRow(User user) {
-                               return new String[]{
-                                       user.getId(),
-                                       user.getName(),
-                                       user.getEmail(),
-                                       user.getTenantId(),
-                                       user.getEnabled().toString()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(User user) {
+                return new String[]{
+                    user.getId(),
+                    user.getName(),
+                    user.getEmail(),
+                    user.getTenantId(),
+                    user.getEnabled().toString()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
-       /* (non-Javadoc)
-        * @see com.billingstack.commands.Command#getOptions()
-        */
-       @Override
-       public Options getOptions() {
-               Options opts = super.getOptions();
-               opts.addOption(null, "name", true, "user name");
-               opts.addOption(null, "password", true, "user password");
-               opts.addOption(null, "email", true, "user email");
-               opts.addOption(null, "tenant", true, "tenant id");
-               opts.addOption(null, "enabled", false, "enabled");
-               return opts;
-       }
-       
+    /* (non-Javadoc)
+     * @see com.billingstack.commands.Command#getOptions()
+     */
+    @Override
+    public Options getOptions() {
+        Options opts = super.getOptions();
+        opts.addOption(null, "name", true, "user name");
+        opts.addOption(null, "password", true, "user password");
+        opts.addOption(null, "email", true, "user email");
+        opts.addOption(null, "tenant", true, "tenant id");
+        opts.addOption(null, "enabled", false, "enabled");
+        return opts;
+    }
+    
 }
index 59626c6..0c02887 100644 (file)
@@ -22,20 +22,20 @@ import com.woorea.openstack.console.utils.ConsoleUtils;
 import com.woorea.openstack.keystone.Keystone;
 
 public class KeystoneUserDelete extends KeystoneCommand {
-       
-       public KeystoneUserDelete() {
-               super("user-delete");
-       }
+    
+    public KeystoneUserDelete() {
+        super("user-delete");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               String[] args = cmd.getArgs();
-               if(args.length == 1) {
-                       keystone.users().delete(args[0]).execute();
-                       System.out.println(new ConsoleUtils().green("OK"));
-               }
-               
-       }
-       
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        String[] args = cmd.getArgs();
+        if(args.length == 1) {
+            keystone.users().delete(args[0]).execute();
+            System.out.println(new ConsoleUtils().green("OK"));
+        }
+        
+    }
+    
 }
index 919c765..06362f9 100644 (file)
@@ -26,41 +26,41 @@ import com.woorea.openstack.keystone.model.User;
 import com.woorea.openstack.keystone.model.Users;
 
 public class KeystoneUserList extends KeystoneCommand {
-       
-       public KeystoneUserList() {
-               super("user-list");
-       }
+    
+    public KeystoneUserList() {
+        super("user-list");
+    }
 
-       @Override
-       public void execute(Keystone keystone, CommandLine cmd) {
-               
-               final Users users = keystone.users().list().execute();
-               
-               Table t = new Table(new TableModel<User>(users.getList()) {
+    @Override
+    public void execute(Keystone keystone, CommandLine cmd) {
+        
+        final Users users = keystone.users().list().execute();
+        
+        Table t = new Table(new TableModel<User>(users.getList()) {
 
-                       @Override
-                       public Column[] getHeaders() {
-                               return new Column[]{
-                                       new Column("id", 32, Column.ALIGN_LEFT),
-                                       new Column("name", 10, Column.ALIGN_LEFT),
-                                       new Column("email", 22, Column.ALIGN_LEFT),
-                                       new Column("tenant", 32, Column.ALIGN_LEFT),
-                                       new Column("enabled", 7, Column.ALIGN_LEFT)
-                               };
-                       }
+            @Override
+            public Column[] getHeaders() {
+                return new Column[]{
+                    new Column("id", 32, Column.ALIGN_LEFT),
+                    new Column("name", 10, Column.ALIGN_LEFT),
+                    new Column("email", 22, Column.ALIGN_LEFT),
+                    new Column("tenant", 32, Column.ALIGN_LEFT),
+                    new Column("enabled", 7, Column.ALIGN_LEFT)
+                };
+            }
 
-                       @Override
-                       public String[] getRow(User user) {
-                               return new String[]{
-                                       user.getId(),
-                                       user.getName(),
-                                       user.getEmail(),
-                                       user.getTenantId(),
-                                       user.getEnabled().toString()
-                               };
-                       }
-               });
-               System.out.println(t.render());
-       }
+            @Override
+            public String[] getRow(User user) {
+                return new String[]{
+                    user.getId(),
+                    user.getName(),
+                    user.getEmail(),
+                    user.getTenantId(),
+                    user.getEnabled().toString()
+                };
+            }
+        });
+        System.out.println(t.render());
+    }
 
 }