Package org.apache.james.mime4j.dom

Examples of org.apache.james.mime4j.dom.Header


        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        new DefaultMessageWriter().writeHeader(msg.getHeader(), baos);
        String origHdr = baos.toString(MailArchiveServerConstants.DEFAULT_ENCODER.charset().name());
        msgProps.put(X_ORIGINAL_HEADER, origHdr);
       
        final Header hdr = msg.getHeader();
        final String listIdRaw = hdr.getField(LIST_ID).getBody();
        final String listId = listIdRaw.substring(1, listIdRaw.length()-1); // remove < and >

        final String list = getListNodeName(listId);
        final String domain = getDomainNodeName(listId);
        final String subject = (String) msgProps.get(SUBJECT);
View Full Code Here


        int dotIdx = fpath.lastIndexOf(".");
        return specialPathFromFilePath(fpath, suffix, fpath.substring(dotIdx + 1));
    }

    static String getResourcePath(Message msg, MessageStoreImpl store) {
        final Header hdr = msg.getHeader();
        final String listIdRaw = hdr.getField("List-Id").getBody();
        final String listId = listIdRaw.substring(1, listIdRaw.length()-1); // remove < and >

        String msgId;
        final Field msgIdField = hdr.getField("Message-ID");
        if (msgIdField != null) {
            msgId = msgIdField.getBody();
            msgId = msgId.substring(1, msgId.length()-1);
        } else {
            msgId = Integer.toHexString(hdr.getField("Date").hashCode());
        }
        msgId = makeJcrFriendly(msgId);

        String subject = null;
        final Field subjectField = hdr.getField("Subject");
        if (subjectField != null) {
            subject = subjectField.getBody();
        }

        String threadPath = store.threadKeyGen.getThreadKey(subject);
View Full Code Here

    /**
     * @see org.apache.james.mime4j.parser.ContentHandler#endHeader()
     */
    public void endHeader() throws MimeException {
        expect(Header.class);
        Header h = (Header) stack.pop();
        expect(Entity.class);
        ((Entity) stack.peek()).setHeader(h);
    }
View Full Code Here

     * @param hostname
     *            host name to be included in the identifier or
     *            <code>null</code> if no host name should be included.
     */
    public void createMessageId(String hostname) {
        Header header = obtainHeader();

        header.setField(newMessageId(hostname));
    }
View Full Code Here

     * @param subject
     *            subject to set or <code>null</code> to remove the subject
     *            header field.
     */
    public void setSubject(String subject) {
        Header header = obtainHeader();

        if (subject == null) {
            header.removeFields(FieldName.SUBJECT);
        } else {
            header.setField(newSubject(subject));
        }
    }
View Full Code Here

     *            field.
     * @param zone
     *            a time zone.
     */
    public void setDate(Date date, TimeZone zone) {
        Header header = obtainHeader();

        if (date == null) {
            header.removeFields(FieldName.DATE);
        } else {
            header.setField(newDate(date, zone));
        }
    }
View Full Code Here

        return field.getMailbox();
    }

    private void setMailbox(String fieldName, Mailbox mailbox) {
        Header header = obtainHeader();

        if (mailbox == null) {
            header.removeFields(fieldName);
        } else {
            header.setField(newMailbox(fieldName, mailbox));
        }
    }
View Full Code Here

        setMailboxList(fieldName, mailboxes == null ? null : Arrays
                .asList(mailboxes));
    }

    private void setMailboxList(String fieldName, Collection<Mailbox> mailboxes) {
        Header header = obtainHeader();

        if (mailboxes == null || mailboxes.isEmpty()) {
            header.removeFields(fieldName);
        } else {
            header.setField(newMailboxList(fieldName, mailboxes));
        }
    }
View Full Code Here

        setAddressList(fieldName, addresses == null ? null : Arrays
                .asList(addresses));
    }

    private void setAddressList(String fieldName, Collection<? extends Address> addresses) {
        Header header = obtainHeader();

        if (addresses == null || addresses.isEmpty()) {
            header.removeFields(fieldName);
        } else {
            header.setField(newAddressList(fieldName, addresses));
        }
    }
View Full Code Here

    /**
     * @see org.apache.james.mime4j.parser.AbstractContentHandler#endHeader()
     */
    @Override
    public final void endHeader() {
        Header tmp = currHeader;
        currHeader = null;
        headers(tmp);
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.dom.Header

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.