// Path: src/main/java/org/kontalk/xmppserver/messages/OfflineMessages.java
// protected static final String ID = "msgoffline2";
// 
// Path: src/main/java/org/kontalk/xmppserver/messages/OfflineMessages.java
// protected static final String XMLNS = "jabber:client";


import tigase.db.NonAuthUserRepository;
import tigase.db.TigaseDBException;
import tigase.db.UserNotFoundException;
import tigase.server.Packet;
import tigase.util.DNSResolver;
import tigase.util.TigaseStringprepException;
import tigase.xml.Element;
import tigase.xmpp.*;
import tigase.xmpp.impl.C2SDeliveryErrorProcessor;
import tigase.xmpp.impl.FlexibleOfflineMessageRetrieval;
import tigase.xmpp.impl.Message;
import tigase.xmpp.impl.PresenceState;
import tigase.xmpp.impl.annotation.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.kontalk.xmppserver.messages.OfflineMessages.ID;
import static org.kontalk.xmppserver.messages.OfflineMessages.XMLNS;
     *             verified and saved
     * @param repo a {@link MsgRepository} repository handler responsible for
     *             storing messages
     *
     * @return {@code true} if the packet was correctly saved to repository,
     *         {@code false} otherwise.
     *
     * @throws UserNotFoundException
     */
    public boolean savePacketForOffLineUser(Packet pac, MsgRepository repo)
            throws TigaseDBException {
        // save only:
        // message stanza with either {@code <body>} or {@code <event>} child element and only of type normal, chat
        // presence stanza of type subscribe, subscribed, unsubscribe and unsubscribed
        if (isAllowedForOfflineStorage(pac)){
            if ( log.isLoggable( Level.FINEST ) ){
                log.log( Level.FINEST, "Storing packet for offline user: {0}", pac );
            }

            Element elem = pac.getElement().clone();

            C2SDeliveryErrorProcessor.filterErrorElement(elem);

            String stamp;

            synchronized ( formatter ) {
                stamp = formatter.format( new Date() );
            }

            // remove any previous delay element
// Path: src/main/java/org/kontalk/xmppserver/messages/OfflineMessages.java
// protected static final String ID = "msgoffline2";
// 
// Path: src/main/java/org/kontalk/xmppserver/messages/OfflineMessages.java
// protected static final String XMLNS = "jabber:client";


// Path: src/main/java/org/kontalk/xmppserver/messages/OfflineMessages.java
import tigase.db.NonAuthUserRepository;
import tigase.db.TigaseDBException;
import tigase.db.UserNotFoundException;
import tigase.server.Packet;
import tigase.util.DNSResolver;
import tigase.util.TigaseStringprepException;
import tigase.xml.Element;
import tigase.xmpp.*;
import tigase.xmpp.impl.C2SDeliveryErrorProcessor;
import tigase.xmpp.impl.FlexibleOfflineMessageRetrieval;
import tigase.xmpp.impl.Message;
import tigase.xmpp.impl.PresenceState;
import tigase.xmpp.impl.annotation.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import static org.kontalk.xmppserver.messages.OfflineMessages.ID;
import static org.kontalk.xmppserver.messages.OfflineMessages.XMLNS;

     *             verified and saved
     * @param repo a {@link MsgRepository} repository handler responsible for
     *             storing messages
     *
     * @return {@code true} if the packet was correctly saved to repository,
     *         {@code false} otherwise.
     *
     * @throws UserNotFoundException
     */
    public boolean savePacketForOffLineUser(Packet pac, MsgRepository repo)
            throws TigaseDBException {
        // save only:
        // message stanza with either {@code <body>} or {@code <event>} child element and only of type normal, chat
        // presence stanza of type subscribe, subscribed, unsubscribe and unsubscribed
        if (isAllowedForOfflineStorage(pac)){
            if ( log.isLoggable( Level.FINEST ) ){
                log.log( Level.FINEST, "Storing packet for offline user: {0}", pac );
            }

            Element elem = pac.getElement().clone();

            C2SDeliveryErrorProcessor.filterErrorElement(elem);

            String stamp;

            synchronized ( formatter ) {
                stamp = formatter.format( new Date() );
            }

            // remove any previous delay element
            Element delay = elem.getChild("delay", "urn:xmpp:delay");