1 package org.kuali.common.deploy; 2 3 import java.util.List; 4 5 import org.kuali.common.util.CollectionUtils; 6 import org.kuali.common.util.FormatUtils; 7 import org.kuali.common.util.execute.Executable; 8 import org.kuali.common.util.secure.SecureChannel; 9 import org.slf4j.Logger; 10 import org.slf4j.LoggerFactory; 11 12 public class SysAdminExecutable implements Executable { 13 14 private static final Logger logger = LoggerFactory.getLogger(SysAdminExecutable.class); 15 16 SecureChannel channel; 17 List<String> commands; 18 boolean skip; 19 20 @Override 21 public void execute() { 22 if (skip) { 23 logger.info("[sysadmin:skipped]"); 24 return; 25 } 26 if (CollectionUtils.isEmpty(commands)) { 27 logger.info("[sysadmin:nocmds]"); 28 return; 29 } 30 long start = System.currentTimeMillis(); 31 logger.info("[sysadmin:begin]"); 32 logger.info(" executing {} commands", commands.size()); 33 for (String command : commands) { 34 logger.debug(command); 35 channel.executeCommand(command); 36 } 37 logger.info("[sysadmin:complete] - {}", FormatUtils.getTime(System.currentTimeMillis() - start)); 38 } 39 40 public SecureChannel getChannel() { 41 return channel; 42 } 43 44 public void setChannel(SecureChannel channel) { 45 this.channel = channel; 46 } 47 48 public List<String> getCommands() { 49 return commands; 50 } 51 52 public void setCommands(List<String> commands) { 53 this.commands = commands; 54 } 55 56 public boolean isSkip() { 57 return skip; 58 } 59 60 public void setSkip(boolean skip) { 61 this.skip = skip; 62 } 63 64 }