Package in.partake.model.dto

Examples of in.partake.model.dto.MessageEnvelope


        String twitterMessageId = daos.getTwitterMessageAccess().getFreshId(con);
        TwitterMessage message = new TwitterMessage(twitterMessageId, user.getId(), messageStr, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
        daos.getTwitterMessageAccess().put(con, message);

        String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId, twitterMessageId, null);
        daos.getMessageEnvelopeAccess().put(con, envelope);
    }
View Full Code Here


            if (delivery == MessageDelivery.NOT_DELIVERED)
                continue;

            String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
            MessageEnvelope envelope = MessageEnvelope.createForUserMessage(envelopeId, userMessageId.toString(), null);
            daos.getMessageEnvelopeAccess().put(con, envelope);
        }
    }
View Full Code Here

    @Override
    protected Void doExecute(PartakeConnection con, IPartakeDAOs daos) throws DAOException, PartakeException {
        DataIterator<MessageEnvelope> it = daos.getMessageEnvelopeAccess().getIterator(con);
        try {
            while (it.hasNext()) {
                MessageEnvelope envelope = it.next();
                if (envelope == null) {
                    it.remove();
                    continue;
                }

                // InvalidAfter 後であれば、message を update して envelope を消去
                // TODO: Refine this code!
                if (envelope.getInvalidAfter() != null && envelope.getInvalidAfter().isBefore(TimeUtil.getCurrentDateTime())) {
                    Logger.warn("run : envelope id " + envelope.getId() + " could not be sent : Time out.");
                    if (envelope.getUserMessageId() != null) {
                        UserReceivedMessage userMessage = daos.getUserReceivedMessageAccess().find(con, UUID.fromString(envelope.getUserMessageId()));
                        if (userMessage != null) {
                            UserReceivedMessage message = new UserReceivedMessage(userMessage);
                            message.setDelivery(MessageDelivery.FAIL);
                            message.setModifiedAt(TimeUtil.getCurrentDateTime());
                            daos.getUserReceivedMessageAccess().put(con, message);
                        }
                    }

                    if (envelope.getTwitterMessageId() != null) {
                        TwitterMessage twitterMessage = daos.getTwitterMessageAccess().find(con, envelope.getTwitterMessageId());
                        if (twitterMessage != null) {
                            TwitterMessage message = new TwitterMessage(twitterMessage);
                            message.setDelivery(MessageDelivery.FAIL);
                            message.setModifiedAt(TimeUtil.getCurrentDateTime());
                            daos.getTwitterMessageAccess().put(con, message);
                        }
                    }

                    if (envelope.getUserNotificationId() != null) {
                        UserNotification notification = daos.getUserNotificationAccess().find(con, envelope.getUserNotificationId());
                        if (notification != null) {
                            UserNotification message = new UserNotification(notification);
                            message.setDelivery(MessageDelivery.FAIL);
                            message.setModifiedAt(TimeUtil.getCurrentDateTime());
                            daos.getUserNotificationAccess().put(con, message);
                        }
                    }

                    it.remove();
                    continue;
                }

                // tryAfter 前であれば送らない。
                if (envelope.getTryAfter() != null && !envelope.getTryAfter().isBefore(TimeUtil.getCurrentDateTime())) {
                    Logger.debug("run : envelope id " + envelope.getId() + " should be sent after " + envelope.getTryAfter());
                    continue;
                }

                if (envelope.getTwitterMessageId() != null)
                    sendTwitterMessage(con, daos, it, envelope);
                else if (envelope.getUserMessageId() != null)
                    sendUserMessage(con, daos, it, envelope);
                else if (envelope.getUserNotificationId() != null)
                    sendUserNotification(con, daos, it, envelope);
                else {
                    // Hmm... shouldn't happen.
                    Logger.error("Shouldn't happen");
                    assert false;
View Full Code Here

import in.partake.model.dao.postgres9.Postgres9EntityDataMapper;
import in.partake.model.dto.MessageEnvelope;

class EntityMessageEnvelopeMapper extends Postgres9EntityDataMapper<MessageEnvelope> {
    public MessageEnvelope map(ObjectNode obj) {
        return new MessageEnvelope(obj).freeze();
    }
View Full Code Here

        } catch (JsonMappingException e) {
            throw new IllegalArgumentException(e);
        } catch (IOException e) {
            throw new DAOException(e);
        }
        return new MessageEnvelope(json).freeze();
    }
View Full Code Here

TOP

Related Classes of in.partake.model.dto.MessageEnvelope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.