Subversion Repositories SmartDukaan

Rev

Rev 4793 | Rev 11890 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4793 Rev 4854
Line 49... Line 49...
49
    private static final String MAILOR_DAEMON_EMAIL_ID = "mailer-daemon@googlemail.com";
49
    private static final String MAILOR_DAEMON_EMAIL_ID = "mailer-daemon@googlemail.com";
50
    private static final Log log                   = LogFactory
50
    private static final Log log                   = LogFactory
51
                                                           .getLog(CRMEmailProcessor.class);
51
                                                           .getLog(CRMEmailProcessor.class);
52
    private Client           client;
52
    private Client           client;
53
 
53
 
54
    public void processEmail(Message message) throws MessagingException,
54
    public void processEmail(Message message) throws Exception {
55
            IOException, TException, UserContextException {
-
 
56
        // Ignoring mails from Mailor daemon
55
        // Ignoring mails from Mailor daemon
57
        if (MAILOR_DAEMON_EMAIL_ID.equals(parseEmailId(message.getFrom()[0].toString()))) {
56
        if (MAILOR_DAEMON_EMAIL_ID.equals(parseEmailId(message.getFrom()[0].toString()))) {
58
            return;
57
            return;
59
        }
58
        }
60
 
59
 
Line 105... Line 104...
105
    public void updateLastProcessedTimestamp(Date date) throws TException {
104
    public void updateLastProcessedTimestamp(Date date) throws TException {
106
        client = new CRMClient().getClient();
105
        client = new CRMClient().getClient();
107
        client.updateLastEmailProcessedTimestamp(date.getTime());
106
        client.updateLastEmailProcessedTimestamp(date.getTime());
108
    }
107
    }
109
 
108
 
110
    private void updateTicket(Long ticketId, Message message) {
109
    private void updateTicket(Long ticketId, Message message) throws Exception {
111
        try {
110
        try {
112
            SearchFilter searchFilter = new SearchFilter();
111
            SearchFilter searchFilter = new SearchFilter();
113
            searchFilter.setTicketId(ticketId);
112
            searchFilter.setTicketId(ticketId);
114
            client = new CRMClient().getClient();
113
            client = new CRMClient().getClient();
115
            List<Ticket> tickets = client.getTickets(searchFilter);
114
            List<Ticket> tickets = client.getTickets(searchFilter);
Line 148... Line 147...
148
 
147
 
149
            activity.setTicketStatus(ticket.getStatus());
148
            activity.setTicketStatus(ticket.getStatus());
150
 
149
 
151
            client = new CRMClient().getClient();
150
            client = new CRMClient().getClient();
152
            client.updateTicket(ticket, activity);
151
            client.updateTicket(ticket, activity);
153
        } catch (TTransportException e) {
-
 
154
            log.error("Could not update ticket " + ticketId + " with mail "
-
 
155
                    + message, e);
-
 
156
        } catch (TException e) {
152
        } catch (Exception e) {
157
            log.error("Could not update ticket " + ticketId + " with mail "
-
 
158
                    + message, e);
-
 
159
        } catch (MessagingException e) {
-
 
160
            log.error("Could not update ticket " + ticketId + " with mail "
-
 
161
                    + message, e);
-
 
162
        } catch (IOException e) {
-
 
163
            log.error("Could not update ticket " + ticketId + " with mail "
153
            log.error("Could not update ticket " + ticketId + " with mail "
164
                    + message, e);
154
                    + message, e);
-
 
155
            throw e;
165
        }
156
        }
166
    }
157
    }
167
 
158
 
168
    private void createTicket(Message message) throws MessagingException,
159
    private void createTicket(Message message) throws MessagingException,
169
            IOException, TException, UserContextException {
160
            IOException, TException, UserContextException {