<commit_before>package org.openmrs.scheduler.tasks;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.api.AdministrationService;
import org.openmrs.api.context.Context;
import org.openmrs.api.context.ContextAuthenticationException;
import org.openmrs.scheduler.Task;
import org.openmrs.scheduler.TaskDefinition;

/**
 * Base class for all other task classes.  
 * 
 * @author <NAME>
 */
@SuppressWarnings("unused")
public abstract class AbstractTask implements Task {

	// Logger 
	private Log log = LogFactory.getLog( AbstractTask.class );
	
	// Indicates whether the task is currently running
	protected boolean isExecuting = false;

	// The task definition of the running task 
	protected TaskDefinition taskDefinition;

	/**
	 * Default constructor
	 */
	protected AbstractTask() { }
	
	/**
	 * Constructor
	 * 
	 * @param definition	the task definition 
	 */
	protected AbstractTask(TaskDefinition taskDefinition) { 
		initialize(taskDefinition);
	}

	/**
	 * @see org.openmrs.scheduler.Task#execute()
	 */
	public abstract void execute();
	
	/**
	 * @see org.openmrs.scheduler.Task#isExecuting()
	 */
	public boolean isExecuting() { 
		return isExecuting;
	}
	
		
	
	/**
	 * @see org.openmrs.scheduler.Task#initialize(org.openmrs.scheduler.TaskConfig)
	 */
	public void initialize(final TaskDefinition definition) { 
		log.info("Initializing task " + definition.getName() + " ...");		
		this.taskDefinition = definition;
	}
	
	/**
	 * @see org.openmrs.scheduler.Task#shutdown()
	 */
	public void shutdown() { 		
    	log.info("Shutting down task " + taskDefinition.getName() + " ...");
    	taskDefinition = null;
	}


	
	/**
	 * Callback method that tells the task that it has started executing.
	 */
	public void startExecuting() { 
    	log.info("Starting execution for task " + taskDefinition.getName() + " ...");
		this.isExecuting = true;
	}
	
	
	/**
	 * Callback method that tells the task that it has stopped executing.
	 */
	public void stopExecuting() { 
    	log.info("Stopping execution for task " + taskDefinition.getName() + " ...");
		this.isExecuting = false;
	}
		
	
	/**
	 * Authenticate the context so the task can call service layer.
	 */
	protected void authenticate() {
		log.info("Authenticating for task " + taskDefinition.getName() + " ...");
		try {
			AdministrationService adminService = Context.getAdministrationService();
			Context.authenticate(adminService.getGlobalProperty("scheduler.username"),
				adminService.getGlobalProperty("scheduler.password"));
			
		} catch (ContextAuthenticationException e) {
			log.error("Error authenticating user", e);
		}
	}


	
	
	
}
<commit_msg>Minor bug fix to remove unnecessary log messages from the AbstractTask.<commit_after>package org.openmrs.scheduler.tasks;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.api.AdministrationService;
import org.openmrs.api.context.Context;
import org.openmrs.api.context.ContextAuthenticationException;
import org.openmrs.scheduler.Task;
import org.openmrs.scheduler.TaskDefinition;

/**
 * Base class for all other task classes.  
 * 
 * @author <NAME>
 */
@SuppressWarnings("unused")
public abstract class AbstractTask implements Task {

	// Logger 
	private Log log = LogFactory.getLog( AbstractTask.class );
	
	// Indicates whether the task is currently running
	protected boolean isExecuting = false;

	// The task definition of the running task 
	protected TaskDefinition taskDefinition;

	/**
	 * Default constructor
	 */
	protected AbstractTask() { }
	
	/**
	 * Constructor
	 * 
	 * @param definition	the task definition 
	 */
	protected AbstractTask(TaskDefinition taskDefinition) { 
		initialize(taskDefinition);
	}

	/**
	 * @see org.openmrs.scheduler.Task#execute()
	 */
	public abstract void execute();
	
	/**
	 * @see org.openmrs.scheduler.Task#isExecuting()
	 */
	public boolean isExecuting() { 
		return isExecuting;
	}
	
		
	
	/**
	 * @see org.openmrs.scheduler.Task#initialize(org.openmrs.scheduler.TaskConfig)
	 */
	public void initialize(final TaskDefinition definition) { 
		this.taskDefinition = definition;
	}
	
	/**
	 * @see org.openmrs.scheduler.Task#shutdown()
	 */
	public void shutdown() { 		
    	taskDefinition = null;
	}


	
	/**
	 * Callback method that tells the task that it has started executing.
	 */
	public void startExecuting() { 
		this.isExecuting = true;
	}
	
	
	/**
	 * Callback method that tells the task that it has stopped executing.
	 */
	public void stopExecuting() { 
		this.isExecuting = false;
	}
		
	
	/**
	 * Authenticate the context so the task can call service layer.
	 */
	protected void authenticate() {
		try {
			AdministrationService adminService = Context.getAdministrationService();
			Context.authenticate(adminService.getGlobalProperty("scheduler.username"),
				adminService.getGlobalProperty("scheduler.password"));
			
		} catch (ContextAuthenticationException e) {
			log.error("Error authenticating user", e);
		}
	}


	
	
	
}

{'fraction_non_alphanumeric': 0.11043295823002099, 'fraction_numerical': 0.0, 'mean_word_length': 3.080933852140078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1457323', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1496, 'n_words': 351}