Unverified Commit 2bd1547e authored by Andrea Orlati's avatar Andrea Orlati Committed by GitHub
Browse files

fix issue #604: he scehdueler checks PROJECT stated into schedule header and...

fix issue #604: he scehdueler checks PROJECT stated into schedule header and the currently active project match. If they don't the execution is abborted and user is provided with a warning message. (#605)
parent df1d6c42
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -101,3 +101,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/
    issue #585 - Fixed misshandled schedule with NULL as backend (Dry Run)
## Changed
    issues #481, #484, #486, #487, #491, #493, #497. SRT Active Surface module has been improved in order to speed up its booting time and optimize its overall behavior
	 issue #604 - The control software will not allow anymore that a schedule, belonging to another project, could be run. In that case a warning message is sent to user console
	              and the execution aborted. 
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -108,4 +108,8 @@

<ErrorCode name="CannotClosePendingTask" shortDescription="Cannot close all pending tasks" description=" "/>

<ErrorCode name="ScheduleProjectNotMatch" shortDescription="Schedule PROJECT keyword does not match with active project" description=" ">
	<Member name="Project" type="string" description="Describes the cause of the error" />
</ErrorCode>

</Type>
+33 −18
Original line number Diff line number Diff line
@@ -559,6 +559,7 @@ void CScheduleExecutor::startSchedule(const char* scheduleFile,const char * subS
 		ManagementErrors::CannotClosePendingTaskExImpl)
{
 	baci::ThreadSyncGuard guard(&m_mutex);
 	bool projectChanged;
 	if (isScheduleActive()) {
 		_EXCPT(ManagementErrors::AlreadyRunningExImpl,dummy,"CScheduleExecutor::startSchedule()");
 		throw dummy;
@@ -574,23 +575,19 @@ void CScheduleExecutor::startSchedule(const char* scheduleFile,const char * subS
 	IRA::CString fullPath;
 	if (projectCode==".") { //no project given......use the current project code
 		fullPath=m_core->m_config->getScheduleDirectory()+m_projectCode+"/";
 		projectCode=m_projectCode;
 		projectChanged=false;
 	}
 	else {
 		fullPath=m_core->m_config->getScheduleDirectory()+projectCode+"/";
 		projectChanged=(projectCode==m_projectCode);
 	}
 	//this also means that the project directory exists, so for discos the project is legal 
 	if (!IRA::CIRATools::fileExists(fullPath+schedule)) { 
 		_EXCPT(ManagementErrors::ScheduleNotExistExImpl,dummy,"CScheduleExecutor::startSchedule()");
 		throw dummy;
 	}
 	ACS_LOG(LM_FULL_INFO,"CScheduleExecutor::startSchedule()",(LM_NOTICE,"Stopping all pending tasks"));
 	try {
 		m_core->closeScan(true);
 	}
 	catch (ACSErr::ACSbaseExImpl& ex) {
 		_ADD_BACKTRACE(ManagementErrors::CannotClosePendingTaskExImpl,impl,ex,"CScheduleExecutor::startSchedule()");
 		m_core->changeSchedulerStatus(Management::MNG_FAILURE);
 		throw impl;
 	}
 
 	try {
 		m_schedule=new CSchedule(fullPath,schedule);
 	}
@@ -605,7 +602,7 @@ void CScheduleExecutor::startSchedule(const char* scheduleFile,const char * subS
 		dummy.setReason((const char *)m_schedule->getLastError());
 		delete m_schedule;
 		m_schedule=NULL;
 		m_core->changeSchedulerStatus(Management::MNG_FAILURE);
 		//m_core->changeSchedulerStatus(Management::MNG_FAILURE);
 		throw dummy;
 	}
 	if (!m_schedule->isComplete()) {
@@ -613,10 +610,32 @@ void CScheduleExecutor::startSchedule(const char* scheduleFile,const char * subS
 		dummy.setReason((const char *)m_schedule->getLastError());
 		delete m_schedule;
 		m_schedule=NULL;		
 		m_core->changeSchedulerStatus(Management::MNG_FAILURE);
 		//m_core->changeSchedulerStatus(Management::MNG_FAILURE);
 		throw dummy;		
 	}
 	if (m_schedule->getProjectName()!=projectCode) {
 		_EXCPT(ManagementErrors::ScheduleProjectNotMatchExImpl,dummy,"CScheduleExecutor::startSchedule()");
 		dummy.setProject((const char *)projectCode);
 		delete m_schedule;
 		m_schedule=NULL;
 		CUSTOM_LOG(LM_FULL_INFO,"CScheduleExecutor::startSchedule()",
 		  (LM_WARNING,"Please make sure the project of the schedule match with the currently active project"));
 		throw dummy;
 	}
	m_projectCode=projectCode;
 	if (projectChanged) {
 		CUSTOM_LOG(LM_FULL_INFO,"CScheduleExecutor::startSchedule()",(LM_NOTICE,"New active project: %s",(const char *)m_projectCode));
 	}
 	m_scheduleLoaded=true;
	ACS_LOG(LM_FULL_INFO,"CScheduleExecutor::startSchedule()",(LM_NOTICE,"Stopping all pending tasks"));
 	try {
 		m_core->closeScan(true);
 	}
 	catch (ACSErr::ACSbaseExImpl& ex) {
 		_ADD_BACKTRACE(ManagementErrors::CannotClosePendingTaskExImpl,impl,ex,"CScheduleExecutor::startSchedule()");
 		m_core->changeSchedulerStatus(Management::MNG_FAILURE);
 		throw impl;
 	} 	 	
 	m_scheduleCounter=m_schedule->getSubScanCounter(subScanidentifier)-1; //need to point before the first scan in the schedule, the first scan has counter==1
 	m_schedReport.addScheduleName(m_schedule->getFileName());
 	if (m_schedule->getScanList()) {
@@ -642,11 +661,7 @@ void CScheduleExecutor::startSchedule(const char* scheduleFile,const char * subS
 	m_startSubScan=m_scheduleCounter+1;
	m_scansCounter=-1;
 	m_scheduleName=schedule;
 	if (projectCode!=".") {
 		m_projectCode=projectCode;
 		ACS_LOG(LM_FULL_INFO,"CScheduleExecutor::startSchedule()",
 		  (LM_NOTICE,"Project: %s",(const char *)m_projectCode));
 	}
 
 	// if the schedule is properly started the status of the scheduler is considered now to be ok.
 	m_core->clearStatus();
 	m_stage=INIT;  // put the executor in the init stage.
+1 −1

File changed.

Contains only whitespace changes.