Examples of TwitterMessage


Examples of in.partake.model.dto.TwitterMessage

        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Remaining"));
        doReturn(null).when(res).getResponseHeader(eq("X-RateLimit-Reset"));
        doThrow(new TwitterException("message", res)).when(PartakeApp.getTwitterService()).updateStatus(anyString(), anyString(), eq(TWITTER_MESSAGE_WILLFAIL_MESSAGE));

        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);
View Full Code Here

Examples of in.partake.model.dto.TwitterMessage

                            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();
View Full Code Here

Examples of in.partake.model.dto.TwitterMessage

        daos.getUserReceivedMessageAccess().put(con, userMessage);
        it.remove();
    }

    private void sendTwitterMessage(PartakeConnection con, IPartakeDAOs daos, DataIterator<MessageEnvelope> it, MessageEnvelope envelope) throws DAOException {
        TwitterMessage message = daos.getTwitterMessageAccess().find(con, envelope.getTwitterMessageId());

        if (message == null) {
            Logger.warn("SendMessageEnvelopeTask.sendTwitterMessage : message was null.");

            // Since the message was null, we cannot update the message status. So we silently remove this MessageEnvelope.
            it.remove();
            return;
        }

        UserEx sender = UserDAOFacade.getUserEx(con, daos, message.getUserId());
        if (sender == null) {
            Logger.warn("sendTwitterMessage : sender is null.");
            failedSendingTwitterMessage(con, daos, it, envelope, message);
            return;
        }

        UserTwitterLink twitterLinkage = sender.getTwitterLinkage();
        if (twitterLinkage == null || !twitterLinkage.isAuthorized()) {
            Logger.warn("sendTwitterMessage : envelope id " + envelope.getId() + " could not be sent : No access token");
            failedSendingTwitterMessage(con, daos, it, envelope, message);
            return;
        }

        try {
            PartakeApp.getTwitterService().updateStatus(twitterLinkage.getAccessToken(), twitterLinkage.getAccessTokenSecret(), message.getMessage());
            succeededSendingTwitterMessage(con, daos, it, envelope, message);
            return;
        } catch (TwitterException e) {
            if (updateEnvelopeByTwitterException(con, daos, sender, envelope, it, e))
                failedSendingTwitterMessage(con, daos, it, envelope, message);
View Full Code Here

Examples of in.partake.model.dto.TwitterMessage

                failedSendingTwitterMessage(con, daos, it, envelope, message);
        }
    }

    private void succeededSendingTwitterMessage(PartakeConnection con, IPartakeDAOs daos, DataIterator<MessageEnvelope> it, MessageEnvelope envelope, TwitterMessage message) throws DAOException {
        TwitterMessage twitterMessage = new TwitterMessage(message);
        twitterMessage.setDelivery(MessageDelivery.SUCCESS);
        twitterMessage.setModifiedAt(TimeUtil.getCurrentDateTime());

        daos.getTwitterMessageAccess().put(con, twitterMessage);
        it.remove();
    }
View Full Code Here

Examples of in.partake.model.dto.TwitterMessage

        daos.getTwitterMessageAccess().put(con, twitterMessage);
        it.remove();
    }

    private void failedSendingTwitterMessage(PartakeConnection con, IPartakeDAOs daos, DataIterator<MessageEnvelope> it, MessageEnvelope envelope, TwitterMessage message) throws DAOException {
        TwitterMessage twitterMessage = new TwitterMessage(message);
        twitterMessage.setDelivery(MessageDelivery.FAIL);
        twitterMessage.setModifiedAt(TimeUtil.getCurrentDateTime());

        daos.getTwitterMessageAccess().put(con, twitterMessage);
        it.remove();
    }
View Full Code Here

Examples of in.partake.model.dto.TwitterMessage

            Logger.info("twitter bot does have partake user id. Login using the account once to create the user id.");
            return;
        }

        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);
View Full Code Here

Examples of in.partake.model.dto.TwitterMessage



    public static void tweetMessageImpl(PartakeConnection con, IPartakeDAOs daos, User user, String messageStr) throws DAOException {
        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

Examples of in.partake.model.dto.TwitterMessage

import in.partake.model.dao.postgres9.Postgres9IndexDao;
import in.partake.model.dto.TwitterMessage;

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

Examples of org.springframework.integration.samples.storedprocedure.model.TwitterMessage

  public void addTwitterMessages(Tweet tweet) throws Exception {
    if ("SomeUser".equals(tweet.getFromUser())) {
      Thread.sleep(2000);
    }
    this.totalTweets++;
    this.twitterMessages.put(tweet.getCreatedAt().getTime(), new TwitterMessage(tweet.getCreatedAt(),
        tweet.getText(),
        tweet.getFromUser(),
        tweet.getProfileImageUrl()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.