Package javax.mail.internet

Examples of javax.mail.internet.InternetHeaders$InternetHeader


            return null;
        }
        stream.unread(v);


        InternetHeaders headers;
        try {
            headers = new InternetHeaders(stream);
        } catch (MessagingException e) {
            // TODO create custom IOException
            throw new RuntimeException(e);
        }

        String id = headers.getHeader("Content-ID", null);
        if (id != null && id.startsWith("<")) {
            id = id.substring(1, id.length() - 1);
        } else {
            //no Content-ID, set cxf default ID
            id = "Content-ID: <root.message@cxf.apache.org";
View Full Code Here


        }
    }

    public InternetHeaders getInternetHeadersUID(int uid, String user)
        throws AccessControlException, AuthorizationException {
        InternetHeaders response = null;
        if (sequence.contains(new Integer(uid))) {
            BufferedInputStream inMsg = null;
            try {
                inMsg = new BufferedInputStream( new FileInputStream(path + File.separator + uid + MESSAGE_EXTENSION));
                response = new InternetHeaders(inMsg);
                inMsg.close();
            } catch(Exception e) {
                getLogger().error("Error reading headers of message from disc: " + e);
                e.printStackTrace();
                throw new
View Full Code Here

     */
    public String getUniqueID() {
        FileInputStream fin = null;
        try {
            fin = new FileInputStream(articleFile);
            InternetHeaders headers = new InternetHeaders(fin);
            String[] idheader = headers.getHeader("Message-Id");
            fin.close();
            return ( idheader.length > 0 ) ? idheader[0] : null;
        } catch(Exception ex) {
            throw new NNTPException(ex);
        } finally {
View Full Code Here

     */
    public void writeOverview(OutputStream out) {
        FileInputStream fileStream = null;
        try {
            fileStream = new FileInputStream(articleFile);
            InternetHeaders hdr = new InternetHeaders(fileStream);
            String subject = hdr.getHeader("Subject",null);
            String author = hdr.getHeader("From",null);
            String date = hdr.getHeader("Date",null);
            String msgId = hdr.getHeader("Message-Id",null);
            String references = hdr.getHeader("References",null);
            long byteCount = articleFile.length();

            // get line count, if not set, count the lines
            String lineCount = hdr.getHeader("Lines",null);
            if (lineCount == null) {
                BufferedReader rdr = new BufferedReader(new FileReader(fileStream.getFD()));
                int lines = 0;
                while (rdr.readLine() != null) {
                    lines++;
View Full Code Here

     * @see org.apache.james.nntpserver.repository.NNTPArticle#getHeader(String)
     */
    public String getHeader(String header) {
        try {
            FileInputStream fin = new FileInputStream(articleFile);
            InternetHeaders hdr = new InternetHeaders(fin);
            fin.close();
            return hdr.getHeader(header,null);
        } catch(Exception ex) {
            throw new NNTPException(ex);
        }
    }
View Full Code Here

            //  and write to this outputstream

            //First handle the headers
            InputStream in = source.getInputStream();
            try {
                InternetHeaders headers = new InternetHeaders(in);
                PrintWriter pos = new InternetPrintWriter(new BufferedWriter(new OutputStreamWriter(headerOs), 512), true);
                for (Enumeration e = headers.getNonMatchingHeaderLines(ignoreList); e.hasMoreElements(); ) {
                    String header = (String)e.nextElement();
                    pos.println(header);
                }
                pos.println();
                pos.flush();
View Full Code Here

                    (mail.getSender() == null ? "<>" : "<" + mail.getSender()
                            + ">"));
        }

        Enumeration headers;
        InternetHeaders deliveredTo = new InternetHeaders();
        if (deliveryHeader != null) {
            // Copy any Delivered-To headers from the message
            headers = message
                    .getMatchingHeaders(new String[] { deliveryHeader });
            while (headers.hasMoreElements()) {
                Header header = (Header) headers.nextElement();
                deliveredTo.addHeader(header.getName(), header.getValue());
            }
        }

        for (Iterator<MailAddress> i = recipients.iterator(); i.hasNext();) {
            MailAddress recipient = i.next();
            try {
                if (deliveryHeader != null) {
                    // Add qmail's de facto standard Delivered-To header
                    message.addHeader(deliveryHeader, recipient.toString());
                }

                storeMail(mail.getSender(), recipient, mail);

                if (deliveryHeader != null) {
                    if (i.hasNext()) {
                        // Remove headers but leave all placeholders
                        message.removeHeader(deliveryHeader);
                        headers = deliveredTo.getAllHeaders();
                        // And restore any original Delivered-To headers
                        while (headers.hasMoreElements()) {
                            Header header = (Header) headers.nextElement();
                            message.addHeader(header.getName(), header
                                    .getValue());
View Full Code Here

            if (!readTillFirstBoundary(stream, boundary)) {
                throw new IOException("Couldn't find MIME boundary: " + boundaryString);
            }

            try {
                InternetHeaders ih = new InternetHeaders(stream);
                message.put(InternetHeaders.class.getName(), ih);
                String val = ih.getHeader("Content-Type", "; ");
                if (!StringUtils.isEmpty(val)) {
                    String cs = HttpHeaderHelper.findCharset(val);
                    if (!StringUtils.isEmpty(cs)) {
                        message.put(Message.ENCODING, HttpHeaderHelper.mapCharset(cs));
                    }
View Full Code Here

            return null;
        }
        stream.unread(v);


        InternetHeaders headers;
        try {
            headers = new InternetHeaders(stream);
        } catch (MessagingException e) {
            // TODO create custom IOException
            throw new RuntimeException(e);
        }
View Full Code Here

            }
        } else {
            try {
                byte[] bytes = createBytes(value, cls, mimeTypes);
                // Create MIME Body Part
                InternetHeaders ih = new InternetHeaders();
                ih.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, mimeTypes[0]);
                MimeBodyPart mbp = new MimeBodyPart(ih, bytes);

                //Create a data source for the MIME Body Part
                MimePartDataSource ds = new MimePartDataSource(mbp);
View Full Code Here

TOP

Related Classes of javax.mail.internet.InternetHeaders$InternetHeader

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.