CmdReactivate.java :  » Content-Management-System » harmonise » org » openharmonise » rm » commands » Java Open Source

Java Open Source » Content Management System » harmonise 
harmonise » org » openharmonise » rm » commands » CmdReactivate.java
/*
 * The contents of this file are subject to the 
 * Mozilla Public License Version 1.1 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
 * See the License for the specific language governing rights and 
 * limitations under the License.
 *
 * The Initial Developer of the Original Code is Simulacra Media Ltd.
 * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
 *
 * All Rights Reserved.
 *
 * Contributor(s):
 */
package org.openharmonise.rm.commands;

import org.openharmonise.rm.resources.lifecycle.*;


/**
 * Reactivates the 'command object', if it implements <code>Editable</code>.
 * 
 * @author Michael Bell
 * @version $Revision: 1.3 $
 *
 */
public class CmdReactivate extends AbstractCmd {
  
  /**
   * Creates an instance of command.
   *
   */
    public CmdReactivate() {
        super();
    }

  /* (non-Javadoc)
   * @see org.openharmonise.rm.commands.AbstractCmd#execute()
   */
  public Object execute(Context context) throws CommandException {
    if((m_commandObj instanceof Editable) == false) {
      throw new InvalidCommandException("Command is not valid for this object:" + m_commandObj.getClass());
    }

      if (isAvailable(context) == false) {
        throw new InvalidCommandException("Command is not available for this object");
      }
    
    Editable eObj = (Editable)getCommandObject(context);
    Editable rtnObj = null;
        
    try {
      rtnObj = eObj.reactivate();
    } catch(Exception e) {
      throw new CommandException(e.getMessage());
    }
        
    return rtnObj;
  }

  /* (non-Javadoc)
   * @see org.openharmonise.rm.commands.AbstractCmd#getName()
   */
  public String getName() {
    
    return "Reactivate";
  }
  
  /* (non-Javadoc)
   * @see org.openharmonise.rm.commands.AbstractCmd#isValidCommandObject(java.lang.Object)
   */
  public boolean isValidCommandObject(Object obj) {
    return (obj instanceof Editable);
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.