IHMInputOutputParamsKillPlotClass.php 1.19 KB
<?php

/**
 * @class IHMInputOutputParamsKillPlotClass
 * @brief Implementation of IHMInputOutputParamsKillPlotClass to kill plot request
 * @details
*/
class IHMInputOutputParamsKillPlotClass extends IHMInputOutputParamsAbstractClass
{
	/*
	 * @brief method to unmarshall a plot request
	*/
	protected function unmarshallRequest($input)
	{
		
		$this->paramsData->setType(ProcessTypeEnumClass::KILL);
		
		$requestIdFilePath = $this->getWorkingPath().'process_id';
		
		if (!file_exists($requestIdFilePath))
			throw new Exception('Cannot retrieve current running plot request.');
		
		$process_id = file_get_contents($requestIdFilePath);
		
		if ($process_id === false)
			throw new Exception('Cannot retrieve current running plot request.');
		
		$process_id = str_replace(array("\r", "\n"), '', $process_id);
		
		$this->paramsData->setId($process_id);
		
		return $this->paramsData;
	}

	/*
	 * @brief method to marshall the result of a kill plot request
	*/
	protected function marshallResult($data)
	{
		if (!$data->getSuccess())
			return array(
					'success' => false,
					'message' => $data->getLastErrorMessage());
		
		return array('success' => true);
	}
}
?>