<commit_before>package edu.wustl.catissuecore.interceptor;

import java.io.File;
import java.util.Calendar;
import java.util.Date;

import javax.jms.JMSException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.datatype.DatatypeConfigurationException;

import edu.wustl.catissuecore.bizlogic.CatissueDefaultBizLogic;
import edu.wustl.catissuecore.bizlogic.CollectionProtocolBizLogic;
import edu.wustl.catissuecore.bizlogic.ParticipantBizLogic;
import edu.wustl.catissuecore.bizlogic.SiteBizLogic;
import edu.wustl.catissuecore.bizlogic.SpecimenCollectionGroupBizLogic;
import edu.wustl.catissuecore.domain.CollectionEventParameters;
import edu.wustl.catissuecore.domain.CollectionProtocol;
import edu.wustl.catissuecore.domain.CollectionProtocolRegistration;
import edu.wustl.catissuecore.domain.Site;
import edu.wustl.catissuecore.domain.Specimen;
import edu.wustl.catissuecore.domain.SpecimenCiderMessage;
import edu.wustl.catissuecore.domain.SpecimenCollectionGroup;
import edu.wustl.catissuecore.domain.SpecimenEventParameters;
import edu.wustl.catissuecore.domain.SpecimenPosition;
import edu.wustl.catissuecore.domain.User;
import edu.wustl.catissuecore.interceptor.wmq.SpecimenWmqProcessor;
import edu.wustl.catissuecore.util.global.AppUtility;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.cider.jaxb.domain.CollectionEventType;
import edu.wustl.cider.jaxb.domain.CollectionProtocolRegistrationType;
import edu.wustl.cider.jaxb.domain.CollectionProtocolType;
import edu.wustl.cider.jaxb.domain.CoordinatorType;
import edu.wustl.cider.jaxb.domain.ObjectFactory;
import edu.wustl.cider.jaxb.domain.ParticipantType;
import edu.wustl.cider.jaxb.domain.PrincipalInvestigatorType;
import edu.wustl.cider.jaxb.domain.SCGCollectionType;
import edu.wustl.cider.jaxb.domain.SiteType;
import edu.wustl.cider.jaxb.domain.SpecimenCharacteristicsType;
import edu.wustl.cider.jaxb.domain.SpecimenCollectionGroupType;
import edu.wustl.cider.jaxb.domain.SpecimenCollectionType;
import edu.wustl.cider.jaxb.domain.SpecimenEventsType;
import edu.wustl.cider.jaxb.domain.SpecimenPositionType;
import edu.wustl.cider.jaxb.domain.SpecimenType;
import edu.wustl.cider.jaxb.domain.StorageContainerType;
import edu.wustl.cider.jaxb.domain.impl.CollectionEventTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.CollectionProtocolRegistrationTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.CollectionProtocolTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.CoordinatorTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.PrincipalInvestigatorTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SCGCollectionTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SiteTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenCharacteristicsTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenCollectionGroupTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenCollectionTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenEventsTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenPositionTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.StorageContainerTypeImpl;
import edu.wustl.common.exception.ApplicationException;
import edu.wustl.common.exception.BizLogicException;
import edu.wustl.common.util.global.ApplicationProperties;
import edu.wustl.common.util.logger.Logger;
import edu.wustl.dao.DAO;
import edu.wustl.dao.exception.InterceptProcessorException;
import edu.wustl.dao.interceptor.InterceptProcessor;
import edu.wustl.dao.interceptor.SaveUpdateInterceptThread.eventType;
import gov.nih.nci.system.dao.DAOException;

/**
 * This class is responsible for processing any activites that needs to be done whenever a specimen object is
 * saved or updated in the databse using hibernate.
 * @author Pavan
 *
 */
public class SpecimenInterceptor implements InterceptProcessor
{

	/**
	 * Logger
	 */
	private static Logger LOGGER = Logger.getCommonLogger(SpecimenInterceptor.class);

	/**
	 * User temp dir location.
	 */
	private static final String TEMP_DIR_LOCATION=System.getProperty("java.io.tmpdir");

	/**
	 * temporary file name prefix.
	 */
	private static final String FILE_NAME_PREFIX="specimen_";


	/**
	 * Package name for generated JAXB domain Objects.
	 */
	private static final String JAXB_PACKAGE_NAME="edu.wustl.cider.jaxb.domain";
	static int no = 0;

	/**
	 * This method does the processing for given obj which is inserted or updates using hibernate session.
	 * @param obj object to be processed.
	 * @param type event type occured.
	 * @throws InterceptProcessorException exception.
	 */
	public void process(Object obj, eventType type) throws InterceptProcessorException
	{
		// TODO Auto-generated method stub
		Specimen specimen = (Specimen)obj;
		if(Constants.COLLECTION_STATUS_COLLECTED.equalsIgnoreCase(specimen.getCollectionStatus()))
		{
			Long objId = specimen.getId();
			try
			{

				ObjectFactory factory = new ObjectFactory();
				ParticipantType xmlParticipant = factory.createParticipantType();

				updateJaxbDomainObject(specimen, xmlParticipant);
				String fileName = TEMP_DIR_LOCATION+FILE_NAME_PREFIX+specimen.getId()+Constants.XML_SUFFIX;

				marshall(xmlParticipant, fileName);
				writeMessage(fileName);
				updateSpecimenCiderMessageLog(specimen,type);
				if(no%2==0)
				{
					no++;
					throw new DAOException();
				}
				no++;
			}catch (JAXBException e) {
				throw new InterceptProcessorException("001",objId,e,ApplicationProperties.getValue("error.interceptor.specimen.message",objId.toString()));
			}
			catch (JMSException e)
			{
					throw new InterceptProcessorException("002",objId,e,ApplicationProperties.getValue("error.interceptor.specimen.wmq",objId.toString()));
			}
			catch(Exception e)
			{
				throw new InterceptProcessorException("000",objId,e,ApplicationProperties.getValue("error.interceptor.specimen.message",objId.toString()));
			}
			LOGGER.info("Processing successfull for object id = "+objId);
		}
<commit_msg>added the loggers for use<commit_after>package edu.wustl.catissuecore.interceptor;

import java.io.File;
import java.util.Calendar;
import java.util.Date;

import javax.jms.JMSException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.datatype.DatatypeConfigurationException;

import edu.wustl.catissuecore.bizlogic.CatissueDefaultBizLogic;
import edu.wustl.catissuecore.bizlogic.CollectionProtocolBizLogic;
import edu.wustl.catissuecore.bizlogic.ParticipantBizLogic;
import edu.wustl.catissuecore.bizlogic.SiteBizLogic;
import edu.wustl.catissuecore.bizlogic.SpecimenCollectionGroupBizLogic;
import edu.wustl.catissuecore.domain.CollectionEventParameters;
import edu.wustl.catissuecore.domain.CollectionProtocol;
import edu.wustl.catissuecore.domain.CollectionProtocolRegistration;
import edu.wustl.catissuecore.domain.Site;
import edu.wustl.catissuecore.domain.Specimen;
import edu.wustl.catissuecore.domain.SpecimenCiderMessage;
import edu.wustl.catissuecore.domain.SpecimenCollectionGroup;
import edu.wustl.catissuecore.domain.SpecimenEventParameters;
import edu.wustl.catissuecore.domain.SpecimenPosition;
import edu.wustl.catissuecore.domain.User;
import edu.wustl.catissuecore.interceptor.wmq.SpecimenWmqProcessor;
import edu.wustl.catissuecore.util.global.AppUtility;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.cider.jaxb.domain.CollectionEventType;
import edu.wustl.cider.jaxb.domain.CollectionProtocolRegistrationType;
import edu.wustl.cider.jaxb.domain.CollectionProtocolType;
import edu.wustl.cider.jaxb.domain.CoordinatorType;
import edu.wustl.cider.jaxb.domain.ObjectFactory;
import edu.wustl.cider.jaxb.domain.ParticipantType;
import edu.wustl.cider.jaxb.domain.PrincipalInvestigatorType;
import edu.wustl.cider.jaxb.domain.SCGCollectionType;
import edu.wustl.cider.jaxb.domain.SiteType;
import edu.wustl.cider.jaxb.domain.SpecimenCharacteristicsType;
import edu.wustl.cider.jaxb.domain.SpecimenCollectionGroupType;
import edu.wustl.cider.jaxb.domain.SpecimenCollectionType;
import edu.wustl.cider.jaxb.domain.SpecimenEventsType;
import edu.wustl.cider.jaxb.domain.SpecimenPositionType;
import edu.wustl.cider.jaxb.domain.SpecimenType;
import edu.wustl.cider.jaxb.domain.StorageContainerType;
import edu.wustl.cider.jaxb.domain.impl.CollectionEventTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.CollectionProtocolRegistrationTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.CollectionProtocolTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.CoordinatorTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.PrincipalInvestigatorTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SCGCollectionTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SiteTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenCharacteristicsTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenCollectionGroupTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenCollectionTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenEventsTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenPositionTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.SpecimenTypeImpl;
import edu.wustl.cider.jaxb.domain.impl.StorageContainerTypeImpl;
import edu.wustl.common.exception.ApplicationException;
import edu.wustl.common.exception.BizLogicException;
import edu.wustl.common.util.global.ApplicationProperties;
import edu.wustl.common.util.logger.Logger;
import edu.wustl.dao.DAO;
import edu.wustl.dao.exception.InterceptProcessorException;
import edu.wustl.dao.interceptor.InterceptProcessor;
import edu.wustl.dao.interceptor.SaveUpdateInterceptThread.eventType;
import gov.nih.nci.system.dao.DAOException;

/**
 * This class is responsible for processing any activites that needs to be done whenever a specimen object is
 * saved or updated in the databse using hibernate.
 * @author Pavan
 *
 */
public class SpecimenInterceptor implements InterceptProcessor
{

	/**
	 * Logger
	 */
	private static Logger LOGGER = Logger.getCommonLogger(SpecimenInterceptor.class);

	/**
	 * User temp dir location.
	 */
	private static final String TEMP_DIR_LOCATION=System.getProperty("java.io.tmpdir");

	/**
	 * temporary file name prefix.
	 */
	private static final String FILE_NAME_PREFIX="specimen_";


	/**
	 * Package name for generated JAXB domain Objects.
	 */
	private static final String JAXB_PACKAGE_NAME="edu.wustl.cider.jaxb.domain";
	static int no = 0;

	/**
	 * This method does the processing for given obj which is inserted or updates using hibernate session.
	 * @param obj object to be processed.
	 * @param type event type occured.
	 * @throws InterceptProcessorException exception.
	 */
	public void process(Object obj, eventType type) throws InterceptProcessorException
	{
		// TODO Auto-generated method stub
		Specimen specimen = (Specimen)obj;
		if(Constants.COLLECTION_STATUS_COLLECTED.equalsIgnoreCase(specimen.getCollectionStatus()))
		{
			Long objId = specimen.getId();
			try
			{

				ObjectFactory factory = new ObjectFactory();
				ParticipantType xmlParticipant = factory.createParticipantType();

				updateJaxbDomainObject(specimen, xmlParticipant);
				String fileName = TEMP_DIR_LOCATION+FILE_NAME_PREFIX+specimen.getId()+Constants.XML_SUFFIX;

				marshall(xmlParticipant, fileName);
				writeMessage(fileName);
				updateSpecimenCiderMessageLog(specimen,type);
				if(no%2==0)
				{
					no++;
					throw new DAOException();
				}
				no++;
			}catch (JAXBException e) {
				e.printStackTrace();
				throw new InterceptProcessorException("001",objId,e,ApplicationProperties.getValue("error.interceptor.specimen.message",objId.toString()));

			}
			catch (JMSException e)
			{
				e.printStackTrace();
					throw new InterceptProcessorException("002",objId,e,ApplicationProperties.getValue("error.interceptor.specimen.wmq",objId.toString()));
			}
			catch(Exception e)
			{
				throw new InterceptProcessorException("000",objId,e,ApplicationProperties.getValue("error.interceptor.specimen.message",objId.toString()));
			}
			LOGGER.info("Processing successfull for object id = "+objId);
		}

{'fraction_non_alphanumeric': 0.10115773051974711, 'fraction_numerical': 0.0019706051399950735, 'mean_word_length': 5.920454545454546, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, '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': '5528824', 'n_tokens_mistral': 4291, 'n_tokens_neox': 4037, 'n_words': 606}