Package com.google.api.services.gmail.model

Examples of com.google.api.services.gmail.model.Message


                    List<History> histories = historyResponse.getHistory();
                    for (History history : histories){
                        if (history.getMessages() == null)
                            continue;
                        for (Message messageStub : history.getMessages()){
                            Message message = invokeGetMessage(gmail, email, messageStub.getId());
                            if (message == null)
                                continue;
                            if (historyId.compareTo(message.getHistoryId()) < 0)
                                historyId = message.getHistoryId();
                            byte[] emailBytes = Base64.decodeBase64(message.getRaw());
                            MimeMessage mimeMessage = new MimeMessage(session, new ByteArrayInputStream(emailBytes));

                            if (flushEntry(updateInfo, email, mimeMessage, SmsEntryFacet.class) == null){
                                throw new Exception("Could not persist SMS");
                            }
                        }
                    }
                } while (historyResponse.getNextPageToken() != null);
            }
            if (historyId == null){
                ListMessagesResponse listResponse = null;
                do{
                    listResponse = invokeList(gmail,email,smsLabel.getId(),listResponse == null ? null : listResponse.getNextPageToken());
                    if (listResponse.getMessages() == null){
                        continue;
                    }
                    for (Message messageStub : listResponse.getMessages()){
                        Message message = invokeGetMessage(gmail, email, messageStub.getId());
                        if (message == null)
                            continue;
                        if (historyId == null || historyId.compareTo(message.getHistoryId()) < 0)
                            historyId = message.getHistoryId();
                        byte[] emailBytes = Base64.decodeBase64(message.getRaw());
                        MimeMessage mimeMessage = new MimeMessage(session, new ByteArrayInputStream(emailBytes));

                        if (flushEntry(updateInfo, email, mimeMessage, SmsEntryFacet.class) == null){
                            throw new Exception("Could not persist SMS");
                        }
View Full Code Here


                    List<History> histories = historyResponse.getHistory();
                    for (History history : histories){
                        if (history.getMessages() == null)
                            continue;
                        for (Message messageStub : history.getMessages()){
                            Message message = invokeGetMessage(gmail, email, messageStub.getId());
                            if (message == null)
                                continue;
                            if (historyId.compareTo(message.getHistoryId()) < 0)
                                historyId = message.getHistoryId();
                            byte[] emailBytes = Base64.decodeBase64(message.getRaw());
                            MimeMessage mimeMessage = new MimeMessage(session, new ByteArrayInputStream(emailBytes));

                            if (flushEntry(updateInfo, email, mimeMessage, CallLogEntryFacet.class) == null){
                                throw new Exception("Could not persist Call log");
                            }
                        }
                    }
                } while (historyResponse.getNextPageToken() != null);
            }
            if (historyId == null){
                ListMessagesResponse listResponse = null;
                do{
                    listResponse = invokeList(gmail,email,callLogLabel.getId(),listResponse == null ? null : listResponse.getNextPageToken());
                    if (listResponse.getMessages() == null){
                        continue;
                    }
                    for (Message messageStub : listResponse.getMessages()){
                        Message message = invokeGetMessage(gmail, email, messageStub.getId());
                        if (message == null)
                            continue;
                        if (historyId == null || historyId.compareTo(message.getHistoryId()) < 0)
                            historyId = message.getHistoryId();
                        byte[] emailBytes = Base64.decodeBase64(message.getRaw());
                        MimeMessage mimeMessage = new MimeMessage(session, new ByteArrayInputStream(emailBytes));

                        if (flushEntry(updateInfo, email, mimeMessage, CallLogEntryFacet.class) == null){
                            throw new Exception("Could not persist Call log");
                        }
View Full Code Here

    }

    private Message invokeGetMessage(Gmail gmail, String email, String messageId) throws IOException {
        Gmail.Users.Messages.Get messageQuery = gmail.users().messages().get(email, messageId).setFormat("raw");

        Message message = null;

        int sleepTime = baseSleepAmount;

        while (message == null){
            try{
View Full Code Here

TOP

Related Classes of com.google.api.services.gmail.model.Message

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.