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 35 public class CmdUnlock extends AbstractCmd { 36 37 41 public CmdUnlock() { 42 super(); 43 } 44 45 48 public Object execute(Context context) throws CommandException { 49 if ((m_commandObj instanceof Editable) == false) { 50 throw new InvalidCommandException( 51 "Command is not valid for this object:" 52 + m_commandObj.getClass()); 53 } 54 55 User usr = getExecutingUser(); 56 57 if (usr == null) { 58 throw new InvalidCommandException( 59 "Command is not valid with out specifying a user"); 60 } 61 62 if (isAvailable(context) == false) { 63 throw new InvalidCommandException( 64 "Command is not available for this object"); 65 } 66 67 Editable editable = (Editable) getCommandObject(context); 68 69 try { 70 editable.unlock(usr); 71 } catch(InvalidLockOwnerException e) { 72 throw new InvalidCommandException(e); 73 } catch (EditException e) { 74 throw new CommandException("Error locking object", e); 75 } 76 77 logCommand(context); 78 79 return null; 80 } 81 82 85 public String getName() { 86 return "Unlock"; 87 } 88 89 92 public boolean isValidCommandObject(Object obj) { 93 return (obj instanceof Editable); 94 } 95 } | Popular Tags |