1 19 package org.openharmonise.rm.commands; 20 21 import org.openharmonise.rm.resources.lifecycle.*; 22 import org.openharmonise.rm.resources.users.*; 23 24 25 33 public class CmdLock extends AbstractCmd { 34 35 39 public CmdLock() { 40 super(); 41 } 42 43 46 public Object execute(Context context) throws CommandException { 47 if((m_commandObj instanceof Editable) == false) { 48 throw new InvalidCommandException("Command is not valid for this object:" + m_commandObj.getClass()); 49 } 50 51 User user = getExecutingUser(); 52 53 if (isAvailable(context) == false) { 54 throw new InvalidCommandException("Command is not available for this object"); 55 } 56 57 Editable editable = (Editable) getCommandObject(context); 58 59 try { 60 editable.lock(user); 61 } catch(InvalidLockOwnerException e) { 62 throw new InvalidCommandException(e); 63 } catch (EditException e) { 64 throw new CommandExecutionException("Error locking object",e); 65 } 66 67 logCommand(context); 68 69 return null; 70 } 71 72 75 public String getName() { 76 return "Lock"; 77 } 78 79 82 public boolean isValidCommandObject(Object obj) { 83 return (obj instanceof Editable); 84 } 85 } | Popular Tags |