@Test public void shouldStoreNormalMessages() { Message message = new Message(); message.setType(Message.Type.normal); assertTrue(OfflineMessageStore.shouldStoreMessage(message)); Message message2 = new Message(); assertTrue(OfflineMessageStore.shouldStoreMessage(message2)); }
static boolean shouldStoreMessage(final Message message) { if (message.getChildElement("no-store", "urn:xmpp:hints") != null) { return false; } switch (message.getType()) { case chat: Iterator<?> it = message.getElement().elementIterator(); while (it.hasNext()) { Object item = it.next(); if (item instanceof Element) { Element el = (Element) item; if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) { continue; } if (!el.getNamespaceURI().equals("http: && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0"))) ) { return true; } } } return message.getBody() != null && !message.getBody().isEmpty(); case groupchat: case headline: return false; case error: if (message.getChildElement("amp", "http: return false; } break; default: break; } return true; }
OfflineMessageStore extends BasicModule implements UserEventListener { static boolean shouldStoreMessage(final Message message) { if (message.getChildElement("no-store", "urn:xmpp:hints") != null) { return false; } switch (message.getType()) { case chat: Iterator<?> it = message.getElement().elementIterator(); while (it.hasNext()) { Object item = it.next(); if (item instanceof Element) { Element el = (Element) item; if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) { continue; } if (!el.getNamespaceURI().equals("http: && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0"))) ) { return true; } } } return message.getBody() != null && !message.getBody().isEmpty(); case groupchat: case headline: return false; case error: if (message.getChildElement("amp", "http: return false; } break; default: break; } return true; } }
OfflineMessageStore extends BasicModule implements UserEventListener { static boolean shouldStoreMessage(final Message message) { if (message.getChildElement("no-store", "urn:xmpp:hints") != null) { return false; } switch (message.getType()) { case chat: Iterator<?> it = message.getElement().elementIterator(); while (it.hasNext()) { Object item = it.next(); if (item instanceof Element) { Element el = (Element) item; if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) { continue; } if (!el.getNamespaceURI().equals("http: && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0"))) ) { return true; } } } return message.getBody() != null && !message.getBody().isEmpty(); case groupchat: case headline: return false; case error: if (message.getChildElement("amp", "http: return false; } break; default: break; } return true; } OfflineMessageStore(); }
OfflineMessageStore extends BasicModule implements UserEventListener { static boolean shouldStoreMessage(final Message message) { if (message.getChildElement("no-store", "urn:xmpp:hints") != null) { return false; } switch (message.getType()) { case chat: Iterator<?> it = message.getElement().elementIterator(); while (it.hasNext()) { Object item = it.next(); if (item instanceof Element) { Element el = (Element) item; if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) { continue; } if (!el.getNamespaceURI().equals("http: && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0"))) ) { return true; } } } return message.getBody() != null && !message.getBody().isEmpty(); case groupchat: case headline: return false; case error: if (message.getChildElement("amp", "http: return false; } break; default: break; } return true; } OfflineMessageStore(); static OfflineMessageStore getInstance(); boolean addMessage(Message message); Collection<OfflineMessage> getMessages(String username, boolean delete); OfflineMessage getMessage(String username, Date creationDate); void deleteMessages(String username); void deleteMessage(String username, Date creationDate); int getCount(String username); int getSize(String username); int getSize(); @Override void userCreated(User user, Map<String, Object> params); @Override void userDeleting(User user, Map<String, Object> params); @Override void userModified(User user, Map<String, Object> params); @Override void start(); @Override void stop(); }
OfflineMessageStore extends BasicModule implements UserEventListener { static boolean shouldStoreMessage(final Message message) { if (message.getChildElement("no-store", "urn:xmpp:hints") != null) { return false; } switch (message.getType()) { case chat: Iterator<?> it = message.getElement().elementIterator(); while (it.hasNext()) { Object item = it.next(); if (item instanceof Element) { Element el = (Element) item; if (Namespace.NO_NAMESPACE.equals(el.getNamespace())) { continue; } if (!el.getNamespaceURI().equals("http: && !(el.getQName().equals(QName.get("rtt", "urn:xmpp:rtt:0"))) ) { return true; } } } return message.getBody() != null && !message.getBody().isEmpty(); case groupchat: case headline: return false; case error: if (message.getChildElement("amp", "http: return false; } break; default: break; } return true; } OfflineMessageStore(); static OfflineMessageStore getInstance(); boolean addMessage(Message message); Collection<OfflineMessage> getMessages(String username, boolean delete); OfflineMessage getMessage(String username, Date creationDate); void deleteMessages(String username); void deleteMessage(String username, Date creationDate); int getCount(String username); int getSize(String username); int getSize(); @Override void userCreated(User user, Map<String, Object> params); @Override void userDeleting(User user, Map<String, Object> params); @Override void userModified(User user, Map<String, Object> params); @Override void start(); @Override void stop();  }