test_class.declarator: formatter
test_class.modifier: private static final
test_class.original_string: private static final SimpleDateFormat formatter;
test_class.type: SimpleDateFormat
test_class.var_name: formatter
test_class.declarator: messageProcessor = new Message()
test_class.modifier: private
test_class.original_string: private Message messageProcessor = new Message();
test_class.type: Message
test_class.var_name: messageProcessor
test_class.file: tigase-server 7.1.0/src/test/java/tigase/xmpp/impl/C2SDeliveryErrorProcessorTest.java
test_class.identifier: C2SDeliveryErrorProcessorTest
test_class.superclass: extends ProcessorTestCase
test_case.body: @Test
  	public void testPreprocessingNotSupportedPackets() throws Exception {
  		Element packetEl = null;
  		Packet packet = null;
  		JID from = JID.jidInstance("from@example.com/res");
  		JID to = JID.jidInstance("to@example.com");
  		
  		
  		packetEl = new Element("iq", new String[] { "id", "from", "to" }, 
  				new String[] { UUID.randomUUID().toString(), from.toString(), to.toString() });
  		packet = Packet.packetInstance(packetEl);
  		assertFalse(C2SDeliveryErrorProcessor.preProcess(packet, null, null, null, null, messageProcessor));
  
  		packetEl = new Element("message", new String[] { "id", "from", "to" }, 
  				new String[] { UUID.randomUUID().toString(), from.toString(), to.toString() });
  		packet = Packet.packetInstance(packetEl);
  		assertFalse(C2SDeliveryErrorProcessor.preProcess(packet, null, null, null, null, messageProcessor));	
  
  		// packet is still not supported as session is null
  		packetEl = new Element("message", new String[] { "id", "from", "to" }, 
  				new String[] { UUID.randomUUID().toString(), from.toString(), to.toString() });
  		packetEl.addChild(new Element("delivery-error", new String[] { "xmlns" }, new String[] { "http://tigase.org/delivery-error" }));
  		packet = Packet.packetInstance(packetEl);
  		assertFalse(C2SDeliveryErrorProcessor.preProcess(packet, null, null, null, null, messageProcessor));		
  	}
test_case.class_method_signature: C2SDeliveryErrorProcessorTest.testPreprocessingNotSupportedPackets()
test_case.full_signature: @Test public void testPreprocessingNotSupportedPackets()
test_case.identifier: testPreprocessingNotSupportedPackets
test_case.invocations: jidInstance jidInstance toString randomUUID toString toString packetInstance assertFalse preProcess toString randomUUID toString toString packetInstance assertFalse preProcess toString randomUUID toString toString addChild packetInstance assertFalse preProcess
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPreprocessingNotSupportedPackets()
focal_class.declarator: log = Logger.getLogger(C2SDeliveryErrorProcessor.class.getCanonicalName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = Logger.getLogger(C2SDeliveryErrorProcessor.class.getCanonicalName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: ELEM_NAME = "delivery-error"
focal_class.modifier: public static final
focal_class.original_string: public static final String ELEM_NAME = "delivery-error";
focal_class.type: String
focal_class.var_name: ELEM_NAME
focal_class.declarator: XMLNS = "http://tigase.org/delivery-error"
focal_class.modifier: public static final
focal_class.original_string: public static final String XMLNS = "http://tigase.org/delivery-error";
focal_class.type: String
focal_class.var_name: XMLNS
focal_class.declarator: DELAY_PATH = { Message.ELEM_NAME, "delay" }
focal_class.modifier: private static final
focal_class.original_string: private static final String[] DELAY_PATH = { Message.ELEM_NAME, "delay" };
focal_class.type: String[]
focal_class.var_name: DELAY_PATH
focal_class.file: tigase-server 7.1.0/src/main/java/tigase/xmpp/impl/C2SDeliveryErrorProcessor.java
focal_class.identifier: C2SDeliveryErrorProcessor
focal_class.class_method_signature: C2SDeliveryErrorProcessor.filter(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, JID toIgnore)
focal_class.full_signature: public static void filter(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, JID toIgnore)
focal_class.identifier: filter
focal_class.modifiers: public static
focal_class.parameters: (Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, JID toIgnore)
focal_class.return: void
focal_class.signature: void filter(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, JID toIgnore)
focal_class.class_method_signature: C2SDeliveryErrorProcessor.filterErrorElement(Element messageElem)
focal_class.full_signature: public static void filterErrorElement(Element messageElem)
focal_class.identifier: filterErrorElement
focal_class.modifiers: public static
focal_class.parameters: (Element messageElem)
focal_class.return: void
focal_class.signature: void filterErrorElement(Element messageElem)
focal_class.class_method_signature: C2SDeliveryErrorProcessor.preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_class.full_signature: public static boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_class.identifier: preProcess
focal_class.modifiers: public static
focal_class.parameters: (Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_class.return: boolean
focal_class.signature: boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_class.class_method_signature: C2SDeliveryErrorProcessor.isDeliveryError(Packet packet)
focal_class.full_signature: public static boolean isDeliveryError(Packet packet)
focal_class.identifier: isDeliveryError
focal_class.modifiers: public static
focal_class.parameters: (Packet packet)
focal_class.return: boolean
focal_class.signature: boolean isDeliveryError(Packet packet)
focal_class.class_method_signature: C2SDeliveryErrorProcessor.getDeliveryError(Packet packet)
focal_class.full_signature: public static Element getDeliveryError(Packet packet)
focal_class.identifier: getDeliveryError
focal_class.modifiers: public static
focal_class.parameters: (Packet packet)
focal_class.return: Element
focal_class.signature: Element getDeliveryError(Packet packet)
focal_class.class_method_signature: C2SDeliveryErrorProcessor.makeDeliveryError(Packet packet, Long stamp)
focal_class.full_signature: public static Packet makeDeliveryError(Packet packet, Long stamp)
focal_class.identifier: makeDeliveryError
focal_class.modifiers: public static
focal_class.parameters: (Packet packet, Long stamp)
focal_class.return: Packet
focal_class.signature: Packet makeDeliveryError(Packet packet, Long stamp)
focal_method.body: public static boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor) {
  		if (packet.getElemName() != tigase.server.Message.ELEM_NAME)
  			return false;
  
  		Element deliveryError = getDeliveryError(packet);
  		if (deliveryError == null)
  			return false;
  		
  		try {
  			// We should ignore messages sent to bare jid if message contains delivery-error 
  			// payload and other connection is currently active - this is needed to reduce
  			// issues related to duplication of messages
  			// This would be better if we would check if there is any active session but also
  			// if there was any active session then message was processed!
  			if (packet.getStanzaTo() != null && packet.getStanzaTo().getResource() == null && session != null) {
  				if (packet.getElemName() != Message.ELEM_NAME)
  					return true;
  				
  				List<XMPPResourceConnection> sessionsForMessageDelivery = messageProcessor.getConnectionsForMessageDelivery(session);
  				
  				if (sessionsForMessageDelivery.isEmpty())
  					return false;
  				
  				String delay = deliveryError.getAttributeStaticStr("stamp");
  				if (delay == null)
  					return true;
  				
  				// maybe we should forward data to only active sessions which were not available at this point??
  				// how to get time of error? or maybe original time of message? timestamp might be slow while 
  				// in other case we might get issues with servers in other timezones!
  				long time = Long.parseLong(delay);
  				
  				for (XMPPResourceConnection conn : sessionsForMessageDelivery) {
  					if (conn.getCreationTime() <= time)
  						continue;
  					
  					Packet result = packet.copyElementOnly();
  					result.setPacketFrom(packet.getPacketTo());
  					result.setPacketTo(conn.getConnectionId());
  					results.offer(result);
  				}
  				return true;
  			}
  			
  			return false;
  		} catch (NotAuthorizedException ex) {
  			if (log.isLoggable(Level.FINEST)) {
  				log.finest("NotAuthorizedException while processing undelivered message from "
  					+ "C2S, packet = " + packet);
  			}
  		} catch (NoConnectionIdException ex) {
  			if (log.isLoggable(Level.FINEST)) {
  				log.finest("NotAuthorizedException while processing undelivered message from "
  					+ "C2S, packet = " + packet);
  			}
  		}
  		return false;
  	}
focal_method.class_method_signature: C2SDeliveryErrorProcessor.preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_method.full_signature: public static boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_method.identifier: preProcess
focal_method.invocations: getElemName getDeliveryError getStanzaTo getResource getStanzaTo getElemName getConnectionsForMessageDelivery isEmpty getAttributeStaticStr parseLong getCreationTime copyElementOnly setPacketFrom getPacketTo setPacketTo getConnectionId offer isLoggable finest isLoggable finest
focal_method.modifiers: public static
focal_method.parameters: (Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)
focal_method.return: boolean
focal_method.signature: boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, 
  			Queue<Packet> results, Map<String, Object> settings, Message messageProcessor)