Package org.apache.james.core

Examples of org.apache.james.core.MimeMessageWrapper


    public synchronized MimeMessageWrapper retrieveUID(int uid, String user)
        throws AccessControlException, AuthorizationException {
        if (!hasReadRights(user)) { //throws AccessControlException
            throw new AuthorizationException("Not authorized to read.");
        }
        MimeMessageWrapper response = null;
        if (sequence.contains(new Integer(uid))) {
            //BufferedInputStream inMsg = null;
            try {
                path = getPath( absoluteName, owner, rootPath );
        MimeMessageFileSource source = new MimeMessageFileSource(path + File.separator + uid + MESSAGE_EXTENSION);
                response = new MimeMessageWrapper(source);
             //   inMsg.close();
            } catch(Exception e) {
                getLogger().error("Error reading message from disc: " + e);
                e.printStackTrace();
                throw new
View Full Code Here


            if (sequence.contains(uidObj)) {
                try  {
                    //SAM
                    try
                    {
                        MimeMessageWrapper message = retrieveUID(uid, user);
                        System.out.println("(before)decrementing mailboxSize ("+getName()+") = " + mailboxSize);
                        System.out.println("decre message.getMessageSize() = " + (int)message.getMessageSize());
                        mailboxSize -= (int)message.getMessageSize();
                        System.out.println("(after)decrementing mailboxSize ("+getName()+") = " + mailboxSize);
                    }
                    catch (MessagingException me)
                    {
                            //ignore
View Full Code Here

            }
            catch ( Exception e ) {
                throw new ProtocolException( "UnexpectedException: " + e.getMessage() );
            }

            return new MimeMessageWrapper( source );
        }
View Full Code Here

                    keys.add(key);
                }
                boolean saveStream = true;

                if (mc.getMessage() instanceof MimeMessageWrapper) {
                    MimeMessageWrapper wrapper = (MimeMessageWrapper) mc.getMessage();
                    if (DEEP_DEBUG) {
                        System.out.println("Retrieving from: " + wrapper.getSourceId());
                        StringBuffer debugBuffer =
                            new StringBuffer(64)
                                    .append("Saving to:       ")
                                    .append(destination)
                                    .append("/")
                                    .append(mc.getName());
                        System.out.println(debugBuffer.toString());
                        System.out.println("Modified: " + wrapper.isModified());
                    }
                    StringBuffer destinationBuffer =
                        new StringBuffer(128)
                            .append(destination)
                            .append("/")
                            .append(mc.getName());
                    if (wrapper.getSourceId().equals(destinationBuffer.toString()) && !wrapper.isModified()) {
                        //We're trying to save to the same place, and it's not modified... we shouldn't save.
                        //More importantly, if we try to save, we will create a 0-byte file since we're
                        //retrying to retrieve from a file we'll be overwriting.
                        saveStream = false;
                    }
View Full Code Here

                getLogger().error(exceptionBuffer.toString());
                remove(key);
                return null;
            }
            MimeMessageAvalonSource source = new MimeMessageAvalonSource(sr, destination, key);
            mc.setMessage(new MimeMessageWrapper(source));

            return mc;
        } catch (Exception me) {
            getLogger().error("Exception retrieving mail: " + me);
            throw new RuntimeException("Exception while retrieving mail: " + me.getMessage());
View Full Code Here

                //Determine whether the message body has changed, and possibly avoid
                //  updating the database.
                MimeMessage messageBody = mc.getMessage();
                boolean saveBody = false;
                if (messageBody instanceof MimeMessageWrapper) {
                    MimeMessageWrapper message = (MimeMessageWrapper)messageBody;
                    saveBody = message.isModified();
                } else {
                    saveBody = true;
                }

                if (saveBody) {
View Full Code Here

            mc.setRemoteHost(rsMessage.getString(5));
            mc.setRemoteAddr(rsMessage.getString(6));
            mc.setLastUpdated(rsMessage.getTimestamp(7));

            MimeMessageJDBCSource source = new MimeMessageJDBCSource(this, key, sr);
            MimeMessageWrapper message = new MimeMessageWrapper(source);
            mc.setMessage(message);
            return mc;
        } catch (SQLException sqle) {
            synchronized (System.err) {
                System.err.println("Error retrieving message");
View Full Code Here

                                Date datetime, ImapMailbox mailbox )
    {
        MimeMessageSource source =
                new MimeMessageByteArraySource( "messageContent:" + System.currentTimeMillis(),
                                                messageContent.getBytes());
        MimeMessage message = new MimeMessageWrapper( source );
        SimpleImapMessage imapMessage = mailbox.createMessage( message, flags, datetime );
        return imapMessage.getUid();
    }
View Full Code Here

                if (messageBody instanceof MimeMessageCopyOnWriteProxy) {
                    MimeMessageCopyOnWriteProxy messageCow = (MimeMessageCopyOnWriteProxy) messageBody;
                    messageBody = messageCow.getWrappedMessage();
                }
                if (messageBody instanceof MimeMessageWrapper) {
                    MimeMessageWrapper message = (MimeMessageWrapper)messageBody;
                    saveBody = message.isModified();
                } else {
                    saveBody = true;
                }
               
                if (saveBody) {
View Full Code Here

                }
                BlobMessage blobMessage = null;
                if (wrapper instanceof MimeMessageWrapper) {
                    URL blobUrl = (URL) mail.getAttribute(JAMES_BLOB_URL);
                    String fromQueue = (String) mail.getAttribute(JAMES_QUEUE_NAME);
                    MimeMessageWrapper mwrapper = (MimeMessageWrapper) wrapper;

                    if (blobUrl != null && fromQueue != null && fromQueue.equals(queuename) && mwrapper.isModified() == false ) {
                        // the message content was not changed so don't need to upload it again and can just point to the url
                        blobMessage = amqSession.createBlobMessage(blobUrl);
                   
                        // thats important so we don't delete the blob file after complete the processing!
                        mail.setAttribute(JAMES_REUSE_BLOB_URL, true);
View Full Code Here

TOP

Related Classes of org.apache.james.core.MimeMessageWrapper

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.