001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.model.dataformat;
018
019import javax.xml.bind.annotation.XmlAccessType;
020import javax.xml.bind.annotation.XmlAccessorType;
021import javax.xml.bind.annotation.XmlAttribute;
022import javax.xml.bind.annotation.XmlRootElement;
023
024import org.apache.camel.model.DataFormatDefinition;
025import org.apache.camel.spi.Metadata;
026
027/**
028 * Marshal Camel messages with attachments into MIME-Multipart messages and back.
029 */
030@Metadata(firstVersion = "2.17.0", label = "dataformat,transformation", title = "MIME Multipart")
031@XmlRootElement(name = "mime-multipart")
032@XmlAccessorType(XmlAccessType.FIELD)
033public class MimeMultipartDataFormat extends DataFormatDefinition {
034
035    @XmlAttribute
036    @Metadata(defaultValue = "mixed")
037    private String multipartSubType = "mixed";
038    @XmlAttribute
039    @Metadata(javaType = "java.lang.Boolean")
040    private String multipartWithoutAttachment;
041    @XmlAttribute
042    @Metadata(javaType = "java.lang.Boolean")
043    private String headersInline;
044    @XmlAttribute
045    private String includeHeaders;
046    @XmlAttribute
047    @Metadata(javaType = "java.lang.Boolean")
048    private String binaryContent;
049
050    public MimeMultipartDataFormat() {
051        super("mime-multipart");
052    }
053
054    public String getMultipartSubType() {
055        return multipartSubType;
056    }
057
058    /**
059     * Specify the subtype of the MIME Multipart.
060     * <p>
061     * Default is "mixed".
062     */
063    public void setMultipartSubType(String multipartSubType) {
064        this.multipartSubType = multipartSubType;
065    }
066
067    public String getMultipartWithoutAttachment() {
068        return multipartWithoutAttachment;
069    }
070
071    /**
072     * Defines whether a message without attachment is also marshaled into a
073     * MIME Multipart (with only one body part).
074     * <p>
075     * Default is "false".
076     */
077    public void setMultipartWithoutAttachment(String multipartWithoutAttachment) {
078        this.multipartWithoutAttachment = multipartWithoutAttachment;
079    }
080
081    public String getHeadersInline() {
082        return headersInline;
083    }
084
085    /**
086     * Defines whether the MIME-Multipart headers are part of the message body
087     * (true) or are set as Camel headers (false).
088     * <p>
089     * Default is "false".
090     */
091    public void setHeadersInline(String headersInline) {
092        this.headersInline = headersInline;
093    }
094
095    public String getBinaryContent() {
096        return binaryContent;
097    }
098
099    /**
100     * A regex that defines which Camel headers are also included as MIME
101     * headers into the MIME multipart. This will only work if headersInline is
102     * set to true.
103     * <p>
104     * Default is to include no headers
105     */
106    public void setIncludeHeaders(String includeHeaders) {
107        this.includeHeaders = includeHeaders;
108    }
109
110    public String getIncludeHeaders() {
111        return includeHeaders;
112    }
113
114    /**
115     * Defines whether the content of binary parts in the MIME multipart is
116     * binary (true) or Base-64 encoded (false)
117     * <p>
118     * Default is "false".
119     */
120    public void setBinaryContent(String binaryContent) {
121        this.binaryContent = binaryContent;
122    }
123}