<commit_before>package org.buddycloud.channelserver.queue;

import java.util.Properties;
import java.util.concurrent.BlockingQueue;

import org.apache.log4j.Logger;
import org.buddycloud.channelserver.channel.ChannelManager;
import org.buddycloud.channelserver.channel.ChannelManagerFactory;
import org.buddycloud.channelserver.db.exception.NodeStoreException;
import org.buddycloud.channelserver.packetprocessor.iq.IQProcessor;
import org.buddycloud.channelserver.packetprocessor.message.MessageProcessor;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;

public class FederatedResponseQueueConsumer extends QueueConsumer {

	private static final Logger logger = Logger
			.getLogger(FederatedResponseQueueConsumer.class);

	private final BlockingQueue<Packet> federatedResponseQueue;
	private final Properties conf;
	private final ChannelManagerFactory channelManagerFactory;

	public FederatedResponseQueueConsumer(BlockingQueue<Packet> federatedResponseQueue, Properties conf,
			ChannelManagerFactory channelManagerFactory) {
		super(federatedResponseQueue);
		this.federatedResponseQueue = federatedResponseQueue;
		this.conf = conf;
		this.channelManagerFactory = channelManagerFactory;
	}

	@Override
	protected void consume(Packet p) {
		ChannelManager channelManager = null;
		try {
			Long start = System.currentTimeMillis();

			String xml = p.toXML();
			logger.debug("Received payload: '" + xml + "'.");
			channelManager = channelManagerFactory.create();
			if (p instanceof IQ) {
			//	new IQProcessor(federatedResponseQueue, conf, channelManager).process((IQ) p);<commit_msg>Only cache if the user wants to, really, really wants to<commit_after>package org.buddycloud.channelserver.queue;

import java.util.Properties;
import java.util.concurrent.BlockingQueue;

import org.apache.log4j.Logger;
import org.buddycloud.channelserver.channel.ChannelManager;
import org.buddycloud.channelserver.channel.ChannelManagerFactory;
import org.buddycloud.channelserver.db.exception.NodeStoreException;
import org.buddycloud.channelserver.packetprocessor.iq.IQProcessor;
import org.buddycloud.channelserver.packetprocessor.message.MessageProcessor;
import org.xmpp.packet.IQ;
import org.xmpp.packet.Message;
import org.xmpp.packet.Packet;

public class FederatedResponseQueueConsumer extends QueueConsumer {

	private static final Logger logger = Logger
			.getLogger(FederatedResponseQueueConsumer.class);

	private final BlockingQueue<Packet> federatedResponseQueue;
	private final Properties conf;
	private final ChannelManagerFactory channelManagerFactory;
	
	private boolean active = false;

	public FederatedResponseQueueConsumer(BlockingQueue<Packet> federatedResponseQueue, Properties conf,
			ChannelManagerFactory channelManagerFactory) {
		super(federatedResponseQueue);
		this.federatedResponseQueue = federatedResponseQueue;
		this.conf = conf;
		this.channelManagerFactory = channelManagerFactory;
		
		if (1 == Integer.parseInt(this.conf.getProperty("cache", "0"))) {
			this.active = true;
		}
	}

	@Override
	protected void consume(Packet p) {
		ChannelManager channelManager = null;
		
		if (false == active) return;
		
		try { 
			Long start = System.currentTimeMillis();

			String xml = p.toXML();
			logger.debug("Received payload: '" + xml + "'.");
			channelManager = channelManagerFactory.create();
			if (p instanceof IQ) {
			//	new IQProcessor(federatedResponseQueue, conf, channelManager).process((IQ) p);
{'fraction_non_alphanumeric': 0.0896551724137931, 'fraction_numerical': 0.0011494252873563218, 'mean_word_length': 6.089613034623218, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6276267', 'n_tokens_mistral': 1026, 'n_tokens_neox': 941, 'n_words': 205}