Package in.partake.model.dto

Examples of in.partake.model.dto.UserTwitterLink


import java.util.UUID;

public class UserTwitterLinkTestDataProvider extends TestDataProvider<UserTwitterLink> {
    @Override
    public UserTwitterLink create(long pkNumber, String pkSalt, int objNumber) {
        return new UserTwitterLink(
                new UUID(pkNumber, pkSalt.hashCode()), objNumber, "userId" + objNumber,
                "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL");
    }
View Full Code Here


    }

    @Override
    public List<UserTwitterLink> createSamples() {
        List<UserTwitterLink> array = new ArrayList<UserTwitterLink>();
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId", "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 1), 0, "userId", "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 1, "userId", "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId1", "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId", "screenName1", "name", "accessToken", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId", "screenName", "name1", "accessToken", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId", "screenName", "name", "accessToken1", "accessTokenSecret", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId", "screenName", "name", "accessToken", "accessTokenSecret1", "profileImageURL"));
        array.add(new UserTwitterLink(new UUID(0, 0), 0, "userId", "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL1"));
        return array;
    }
View Full Code Here

        IUserTwitterLinkAccess dao = daos.getTwitterLinkageAccess();
        dao.truncate(con);


        for (int i = 0; i < DEFAULT_USER_IDS.length; ++i)
            dao.put(con, new UserTwitterLink(DEFAULT_TWITTER_LINK_IDS[i], DEFAULT_USER_TWITTER_IDS[i], DEFAULT_USER_IDS[i], DEFAULT_USER_TWITTER_SCREENNAME[i], "testUser 1", "accessToken", "accessTokenSecret", "http://www.example.com/"));

        dao.put(con, new UserTwitterLink(DEFAULT_TWITTER_LINK_ID, DEFAULT_TWITTER_ID, DEFAULT_USER_ID, DEFAULT_TWITTER_SCREENNAME, "testUser 1", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(DEFAULT_ANOTHER_TWITTER_LINK_ID, DEFAULT_ANOTHER_TWITTER_ID, DEFAULT_ANOTHER_USER_ID, DEFAULT_ANOTHER_TWITTER_SCREENNAME, "testUser 1", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(ADMIN_USER_TWITTER_LINK_ID, ADMIN_USER_TWITTER_ID, ADMIN_USER_ID, ADMIN_USER_SCREENNAME, "testUser 2", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(USER_WITHOUT_PREF_TWITTER_LINK_ID, USER_WITHOUT_PREF_TWITTER_ID, USER_WITHOUT_PREF_ID, USER_WITHOUT_PREF_SCREENNAME, "testUser 3", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(USER_WITH_PRIVATE_PREF_TWITTER_LINK_ID, USER_WITH_PRIVATE_PREF_TWITTER_ID, USER_WITH_PRIVATE_PREF_ID, USER_WITHOUT_PREF_SCREENNAME, "testUser 3", "accessToken", "accessTokenSecret", "http://www.example.com/"));

        dao.put(con, new UserTwitterLink(EVENT_OWNER_TWITTER_LINK_ID, EVENT_OWNER_TWITTER_ID, EVENT_OWNER_ID, EVENT_OWNER_TWITTER_SCREENNAME, "testUser 3", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(EVENT_EDITOR_TWITTER_LINK_ID, EVENT_EDITOR_TWITTER_ID, EVENT_EDITOR_ID, EVENT_EDITOR_TWITTER_SCREENNAME, "testUser 4", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(EVENT_COMMENTOR_TWITTER_LINK_ID, EVENT_COMMENTOR_TWITTER_ID, EVENT_COMMENTOR_ID, EVENT_COMMENTOR_TWITTER_SCREENNAME, "partakein", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(EVENT_ENROLLED_USER_TWITTER_LINK_ID, EVENT_ENROLLED_USER_TWITTER_ID, EVENT_ENROLLED_USER_ID, EVENT_ENROLLED_USER_TWITTER_SCREENNAME, "testUser 4", "accessToken", "accessTokenSecret", "http://www.example.com/"));

        dao.put(con, new UserTwitterLink(EVENT_RESERVED_USER_TWITTER_LINK_ID, EVENT_RESERVED_USER_TWITTER_ID, EVENT_RESERVED_USER_ID, EVENT_RESERVED_USER_TWITTER_SCREENNAME, "partakein", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(EVENT_CANCELLED_USER_TWITTER_LINK_ID, EVENT_CANCELLED_USER_TWITTER_ID, EVENT_CANCELLED_USER_ID, EVENT_CANCELLED_USER_TWITTER_SCREENNAME, "testUser 4", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(EVENT_UNRELATED_USER_TWITTER_LINK_ID, EVENT_UNRELATED_USER_TWITTER_ID, EVENT_UNRELATED_USER_ID, EVENT_UNRELATED_USER_TWITTER_SCREENNAME, "partakein", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(ATTENDANCE_PRESENT_USER_TWITTER_LINK_ID, ATTENDANCE_PRESENT_USER_TWITTER_ID, ATTENDANCE_PRESENT_USER_ID, ATTENDANCE_PRESENT_USER_TWITTER_SCREENNAME, "partakein", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(ATTENDANCE_ABSENT_USER_TWITTER_LINK_ID, ATTENDANCE_ABSENT_USER_TWITTER_ID, ATTENDANCE_ABSENT_USER_ID, ATTENDANCE_ABSENT_USER_TWITTER_SCREENNAME, "partakein", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(ATTENDANCE_UNKNOWN_USER_TWITTER_LINK_ID, ATTENDANCE_UNKNOWN_USER_TWITTER_ID, ATTENDANCE_UNKNOWN_USER_ID, ATTENDANCE_UNKNOWN_USER_TWITTER_SCREENNAME, "partakein", "accessToken", "accessTokenSecret", "http://www.example.com/"));

        dao.put(con, new UserTwitterLink(DEFAULT_SENDER_TWITTER_LINK_ID, DEFAULT_SENDER_TWITTER_ID, DEFAULT_SENDER_ID, DEFAULT_SENDER_TWITTER_SCREENNAME, "testUser 1", "accessToken", "accessTokenSecret", "http://www.example.com/"));
        dao.put(con, new UserTwitterLink(DEFAULT_RECEIVER_TWITTER_LINK_ID, DEFAULT_RECEIVER_TWITTER_ID, DEFAULT_RECEIVER_ID, DEFAULT_RECEIVER_TWITTER_SCREENNAME, "testUser 1", "accessToken", "accessTokenSecret", "http://www.example.com/"));

        dao.put(con, new UserTwitterLink(IMAGE_OWNER_TWITTER_LINK_ID, IMAGE_OWNER_TWITTER_ID, IMAGE_OWNER_ID, IMAGE_OWNER_TWITTER_SCREENNAME, "testUser 1", "accessToken", "accessTokenSecret", "http://www.example.com/"));

        // accessToken and accessTokenSecret are null for this user.
        dao.put(con, new UserTwitterLink(USER_TWITTER_NOAUTH_TWITTER_LINK_ID, USER_TWITTER_NOAUTH_TWITTER_ID, USER_TWITTER_NOAUTH_ID, USER_TWITTER_NOAUTH_TWITTER_SCREENNAME, "testUser 1", null, null, "http://www.example.com/"));
    }
View Full Code Here

    }

    @Override
    protected UserTwitterLink create(long pkNumber, String pkSalt, int objNumber) {
        UUID uuid = new UUID(pkNumber, pkSalt.hashCode());
        return new UserTwitterLink(uuid, objNumber, "userId" + objNumber, "screenName", "name", "accessToken", "accessTokenSecret", "profileImageURL");
    }
View Full Code Here

    @Test
    public void testToFindByTwitterId() throws Exception {
        new Transaction<Void>() {
            @Override
            protected Void doExecute(PartakeConnection con, IPartakeDAOs daos) throws DAOException, PartakeException {
                UserTwitterLink link1 = create(0, "hoge", 1);
                link1.setTwitterId(0);
                UserTwitterLink link2 = create(1, "hoge", 2);
                link2.setTwitterId(1);

                dao.put(con, link1);
                dao.put(con, link2);


                assertThat(dao.findByTwitterId(con, 0).getId(), is(link1.getId()));
                assertThat(dao.findByTwitterId(con, 1).getId(), is(link2.getId()));
                return null;
            }
        }.execute();
    }
View Full Code Here

    @Test
    public void testToFindByUserId() throws Exception {
        new Transaction<Void>() {
            @Override
            protected Void doExecute(PartakeConnection con, IPartakeDAOs daos) throws DAOException, PartakeException {
                UserTwitterLink link1 = create(0, "hoge", 1);
                link1.setUserId("userId1");
                UserTwitterLink link2 = create(1, "hoge", 2);
                link2.setUserId("userId2");

                dao.put(con, link1);
                dao.put(con, link2);

                assertThat(dao.findByUserId(con, "userId1").getId(), is(link1.getId()));
                assertThat(dao.findByUserId(con, "userId2").getId(), is(link2.getId()));
                return null;
            }
        }.execute();
    }
View Full Code Here

        Twitter twitter = information.getTwitter();
        RequestToken requestToken = information.getRequestToken();
        AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier);

        twitter4j.User twitterUser = twitter.showUser(twitter.getId());
        return new UserTwitterLink(
                null, twitter.getId(), null, twitter.getScreenName(), twitterUser.getName(), accessToken.getToken(), accessToken.getTokenSecret(),
                twitter.showUser(twitter.getId()).getProfileImageURL().toString());
    }
View Full Code Here

        if (!pref.isReceivingTwitterMessage()) {
            didSendUserMessage(con, daos, it, envelope, userMessage, MessageDelivery.NOT_DELIVERED);
            return;
        }

        UserTwitterLink twitterLinkage = receiver.getTwitterLinkage();
        if (twitterLinkage == null || !twitterLinkage.isAuthorized()) {
            Logger.warn("sendDirectMessage : envelope id " + envelope.getId() + " could not be sent : No access token");
            didSendUserMessage(con, daos, it, envelope, userMessage, MessageDelivery.FAIL);
            return;
        }

        try {
            Message message = daos.getMessageAccess().find(con, UUID.fromString(userMessage.getMessageId()));
            long twitterId = twitterLinkage.getTwitterId();

            Event event = null;
            if (userMessage.getEventId() != null)
                event = daos.getEventAccess().find(con, userMessage.getEventId());

            String url = "http://partake.in/messages/" + userMessage.getId();
            String messageBody;
            if (event != null) {
                int rest = 140;
                String format = "[PRTK] %s 「%s」に関する新着メッセージがあります。 : %s";
                rest -= Util.codePointCount(format);

                rest -= EventDAOFacade.URL_LENGTH;

                String title = Util.shorten(event.getTitle(), 30);
                rest -= Util.codePointCount(title);

                String body = Util.shorten(message.getSubject(), rest);
                messageBody = String.format(format, url, title, body);
            } else {
                int rest = 140;

                String format = "[PRTK] %s 新着メッセージがあります。: %s";
                rest -= Util.codePointCount(format);

                rest -= EventDAOFacade.URL_LENGTH;

                String subject = Util.shorten(message.getSubject(), rest);

                messageBody = String.format(format, url, subject);
            }

            PartakeApp.getTwitterService().sendDirectMesage(
                    twitterLinkage.getAccessToken(), twitterLinkage.getAccessTokenSecret(), twitterId, messageBody);
            didSendUserMessage(con, daos, it, envelope, userMessage, MessageDelivery.SUCCESS);
            Logger.info("sendDirectMessage : direct message has been sent to " + twitterLinkage.getScreenName());
        } catch (NumberFormatException e) {
            Logger.error("twitterId has not a number.", e);
            didSendUserMessage(con, daos, it, envelope, userMessage, MessageDelivery.FAIL);
        } catch (TwitterException e) {
            if (updateEnvelopeByTwitterException(con, daos, receiver, envelope, it, e))
View Full Code Here

            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

            Logger.warn("sendTwitterMessage : sender is null.");
            failedSendingUserNotification(con, daos, it, envelope, notification);
            return;
        }

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

        EventTicket ticket = daos.getEventTicketAccess().find(con, notification.getTicketId());
        if (ticket == null) {
            failedSendingUserNotification(con, daos, it, envelope, notification);
            return;
        }

        Event event = daos.getEventAccess().find(con, ticket.getEventId());
        if (event == null) {
            failedSendingUserNotification(con, daos, it, envelope, notification);
            return;
        }

        String messageBody = buildUserNotificationMessageBody(notification, event, ticket);
        assert messageBody != null;
        if (messageBody == null) {
            failedSendingUserNotification(con, daos, it, envelope, notification);
            return;
        }

        try {
            PartakeApp.getTwitterService().sendDirectMesage(
                    twitterLinkage.getAccessToken(), twitterLinkage.getAccessTokenSecret(), twitterLinkage.getTwitterId(), messageBody);
            succeededSendingUserNotification(con, daos, it, envelope, notification);
            return;
        } catch (TwitterException e) {
            if (updateEnvelopeByTwitterException(con, daos, sender, envelope, it, e))
                failedSendingUserNotification(con, daos, it, envelope, notification);
View Full Code Here

TOP

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

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.