1 6 package org.openharmonise.rm.commands; 7 8 import org.openharmonise.rm.resources.lifecycle.*; 9 10 17 public class CmdSave extends AbstractCmd { 18 19 23 public CmdSave() { 24 super(); 25 } 26 27 30 public Object execute(Context context) throws CommandException { 31 if ((m_commandObj instanceof Editable) == false) { 32 throw new InvalidCommandException( 33 "Command is not valid for this object:" + m_commandObj.getClass()); 34 } 35 36 if (isAvailable(context) == false) { 37 throw new InvalidCommandException("Command is not available for this object"); 38 } 39 40 Editable eObj = (Editable) getCommandObject(context); 41 Editable rtnObj = null; 42 43 try { 44 rtnObj = eObj.save(); 45 } catch (Exception e) { 46 throw new CommandException("Problem executing save", e); 47 } 48 49 addResultContext(rtnObj, context); 50 51 logCommand(context); 52 53 return rtnObj; 54 } 55 56 59 public String getName() { 60 61 return "Save"; 62 } 63 64 67 public boolean isValidCommandObject(Object obj) { 68 return (obj instanceof Editable); 69 } 70 } | Popular Tags |