Package in.partake.model.dto

Examples of in.partake.model.dto.MessageEnvelope


        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, USER_NO_TWITTER_LINK_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        // The message should be removed from the queue.
        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified, is(nullValue()));
    }
View Full Code Here


        String twitterMessageId = UUID.randomUUID().toString();
        TwitterMessage message = new TwitterMessage(twitterMessageId, USER_TWITTER_NOAUTH_ID, TWITTER_MESSAGE_WILLFAIL_MESSAGE, MessageDelivery.INQUEUE, new DateTime(0), null);
        storeTwitterMessage(message);

        UUID envelopeId = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId.toString(), twitterMessageId, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        // The message should be removed from the queue.
        MessageEnvelope modified = loadEnvelope(envelopeId.toString());
        assertThat(modified, is(nullValue()));
    }
View Full Code Here

    // ----------------------------------------------------------------------

    @Test
    public void sendUserNotification() throws Exception {
        UUID uuid = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForUserNotification(uuid.toString(), USER_NOTIFICATION_INQUEUE_ID, null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        List<MessageEnvelope> rest = loadEnvelopes();
View Full Code Here

    }

    @Test
    public void sendUserMessage() throws Exception {
        UUID uuid = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForUserMessage(uuid.toString(), USER_RECEIVED_MESSAGE_INQUEUE_ID.toString(), null);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        List<MessageEnvelope> rest = loadEnvelopes();
View Full Code Here

    public void sendInvalidatedMessage() throws Exception {
        DateTime now = TimeUtil.getCurrentDateTime();
        DateTime before = now.nDayBefore(1);

        UUID uuid = UUID.randomUUID();
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(uuid.toString(), TWITTER_MESSAGE_INQUEUE_ID, before);
        queueEnvelope(envelope);

        new SendMessageEnvelopeTask().run();

        List<MessageEnvelope> rest = loadEnvelopes();
View Full Code Here

            UserEx user, MessageEnvelope envelope, DataIterator<MessageEnvelope> it, TwitterException e) throws DAOException {
        if (e.isCausedByNetworkIssue()) {
            Logger.warn("Twitter Unreachable?", e);
            // Retry after 10 minutes later.
            DateTime retryAfter = new DateTime(TimeUtil.getCurrentTime() + 600 * 1000);
            MessageEnvelope newEnvelope = new MessageEnvelope(envelope);
            newEnvelope.updateForSendingFailure(retryAfter);
            it.update(newEnvelope);
            return false;
        }

        if (e.exceededRateLimitation()) {
            Logger.warn("Twitter Rate Limination : " + envelope.getId() + " was failed to deliver.", e);
            DateTime retryAfter = new DateTime(TimeUtil.getCurrentTime() + e.getRetryAfter() * 1000);

            MessageEnvelope newEnvelope = new MessageEnvelope(envelope);
            newEnvelope.updateForSendingFailure(retryAfter);
            it.update(newEnvelope);
            return false;
        }

        if (e.getStatusCode() == HttpServletResponse.SC_UNAUTHORIZED) {
            markAsUnauthorizedUser(con, daos, user);
            Logger.info("Unauthorized User : " + envelope.getId() + " was failed to deliver.", e);

            // We cannot send envelopes to unauthorized user.
            it.remove();
            return true;
        }

        // Unknown error. Retry.
        Logger.warn("Unknown Error : " + envelope.getId() + " was failed to deliver.", e);
        // Retry after 5 minutes later.
        DateTime retryAfter = new DateTime(TimeUtil.getCurrentTime() + 600 * 1000);
        MessageEnvelope newEnvelope = new MessageEnvelope(envelope);
        newEnvelope.updateForSendingFailure(retryAfter);
        it.update(newEnvelope);
        return false;
    }
View Full Code Here

            String notificationId = daos.getUserNotificationAccess().getFreshId(con);
            UserNotification userNotification = new UserNotification(notificationId, ticket.getId(), userId, notificationType, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
            daos.getUserNotificationAccess().put(con, userNotification);

            String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
            MessageEnvelope envelope = MessageEnvelope.createForUserNotification(envelopeId, notificationId, invalidAfter);
            daos.getMessageEnvelopeAccess().put(con, envelope);
            Logger.info("sendEnvelope : " + userId + " : " + notificationType);
        }
    }
View Full Code Here

            String notificationId = daos.getUserNotificationAccess().getFreshId(con);
            UserNotification userNotification = new UserNotification(notificationId, ticket.getId(), userId, notificationType, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
            daos.getUserNotificationAccess().put(con, userNotification);

            String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
            MessageEnvelope envelope = MessageEnvelope.createForUserNotification(envelopeId, notificationId, invalidAfter);
            daos.getMessageEnvelopeAccess().put(con, envelope);
            Logger.info("sendEnvelope : " + userId + " : " + notificationType);
        }
    }
View Full Code Here

                String userNotificationid = daos.getUserNotificationAccess().getFreshId(con);
                UserNotification userNotification = new UserNotification(userNotificationid, ticket.getId(), userId, NotificationType.BECAME_TO_BE_ENROLLED, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
                daos.getUserNotificationAccess().put(con, userNotification);

                String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
                MessageEnvelope envelope = MessageEnvelope.createForUserNotification(envelopeId, userNotificationid, null);
                daos.getMessageEnvelopeAccess().put(con, envelope);
            }
        }

        List<String> userIdsToBeCancelled = new ArrayList<String>();
        for (UserTicket p : list.getSpareParticipations()) {
            ModificationStatus status = p.getModificationStatus();
            if (status == null) { continue; }

            switch (status) {
            case CHANGED: // 自分自身の力で変化させていた場合は status を not_enrolled にのみ変更して対応
                updateLastStatus(con, daos, eventId, p, ModificationStatus.NOT_ENROLLED);
                break;
            case NOT_ENROLLED:
                break;
            case ENROLLED:
                updateLastStatus(con, daos, eventId, p, ModificationStatus.NOT_ENROLLED);
                userIdsToBeCancelled.add(p.getUserId());
                break;
            }
        }

        for (UserTicket p : list.getCancelledParticipations()) {
            ModificationStatus status = p.getModificationStatus();
            if (status == null) { continue; }

            switch (status) {
            case CHANGED: // 自分自身の力で変化させていた場合は status を not_enrolled にのみ変更して対応
                updateLastStatus(con, daos, eventId, p, ModificationStatus.NOT_ENROLLED);
                break;
            case NOT_ENROLLED:
                break;
            case ENROLLED:
                updateLastStatus(con, daos, eventId, p, ModificationStatus.NOT_ENROLLED);
                userIdsToBeCancelled.add(p.getUserId());
                break;
            }
        }

        if (!userIdsToBeCancelled.isEmpty()) {
            String notificationId = daos.getEventNotificationAccess().getFreshId(con);
            EventTicketNotification notification = new EventTicketNotification(notificationId, ticket.getId(), ticket.getEventId(), userIdsToBeEnrolled, NotificationType.BECAME_TO_BE_CANCELLED, TimeUtil.getCurrentDateTime());
            daos.getEventNotificationAccess().put(con, notification);

            for (String userId : userIdsToBeCancelled) {
                String userNotificationid = daos.getUserNotificationAccess().getFreshId(con);
                UserNotification userNotification = new UserNotification(userNotificationid, ticket.getId(), userId, NotificationType.BECAME_TO_BE_CANCELLED, MessageDelivery.INQUEUE, TimeUtil.getCurrentDateTime(), null);
                daos.getUserNotificationAccess().put(con, userNotification);

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

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

        String envelopeId = daos.getMessageEnvelopeAccess().getFreshId(con);
        MessageEnvelope envelope = MessageEnvelope.createForTwitterMessage(envelopeId, twitterMessageId, null);
        daos.getMessageEnvelopeAccess().put(con, envelope);

        Logger.info("bot will tweet: " + message);
    }
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.