/**
 * JaDOrT: JASMINe Deployment Orchestration Tool
 * Copyright (C) 2008-2009 Bull S.A.S.
 * Copyright (C) 2008-2009 France Telecom R&D
 * Contact: jasmine@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: RestartServerCommand.as 3500 2009-04-22 13:57:09Z alitokmen $
 * --------------------------------------------------------------------------
 */
package org.ow2.jasmine.jadort.client.flex.command {

    import com.adobe.cairngorm.commands.*;
    import mx.rpc.IResponder;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import org.ow2.jasmine.jadort.client.flex.business.*;
    import org.ow2.jasmine.jadort.client.flex.event.*;
    import org.ow2.jasmine.jadort.client.flex.model.*;
    import org.ow2.jasmine.jadort.client.flex.vo.*;
    import com.adobe.cairngorm.control.*;

    /**
     * This class allows to restart a task on a server(the server will restart the last task)
     */
    public class RestartServerCommand extends SequenceCommandWithErrorHandling implements IResponder {

        private var server : ServerVO;

        override public function execute(event : CairngormEvent) : void {
            // cast the cairngorm event so we can get at the server to be restarted
            var restartServerEvent : RestartServerEvent = event as RestartServerEvent;
            server = restartServerEvent.server;

            // delegate to the RestartServerDelegate to call the restartServer() service
            var delegate : RestartServerDelegate = JadortModelLocator.getInstance().restartServerDelegate;
            delegate.responder = this;
            delegate.restartServer(server);
        }

        public function result(event : Object) : void {
            super.nextEvent = new GetCurrentOperationEvent();
            executeNextCommand();
         }
    }
}
