1 19 package org.openharmonise.rm.commands; 20 21 import org.openharmonise.rm.resources.lifecycle.*; 22 23 30 public class CmdChangeStatus extends AbstractCmd { 31 public final static String PARAM_STATUS = "status_code"; 32 33 36 public CmdChangeStatus() { 37 super(); 38 } 39 40 43 public Object execute(Context context) throws CommandException { 44 String status_code = this.getParameter(PARAM_STATUS); 45 if((m_commandObj instanceof Editable) == false) { 46 throw new InvalidCommandException("Command is not valid for this object:" + m_commandObj.getClass()); 47 } 48 49 if (isAvailable(context) == false) { 50 throw new InvalidCommandException("Command is not available for this object"); 51 } 52 53 Editable editable = (Editable) getCommandObject(context); 54 Object cmdResult = null; 55 56 try { 57 Status status = Status.getStatus(Integer.parseInt(status_code)); 58 cmdResult = editable.changeStatus(status); 59 } catch (EditException e) { 60 throw new CommandExecutionException("Error changing status",e); 61 } 62 63 logCommand(context); 64 65 return cmdResult; 66 } 67 68 71 public String getName() { 72 return "ChangeStatus"; 73 } 74 75 78 public boolean isValidCommandObject(Object obj) { 79 return (obj instanceof Editable); 80 } 81 } | Popular Tags |