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 * The MIME Multipart data format can marshal a Camel message with attachments
029 * into a Camel message having a MIME-Multipart message as message body (and no
030 * attachments), and vise-versa when unmarshalling.
031 */
032@Metadata(firstVersion = "2.17.0", label = "dataformat,transformation", title = "MIME Multipart")
033@XmlRootElement(name = "mime-multipart")
034@XmlAccessorType(XmlAccessType.FIELD)
035public class MimeMultipartDataFormat extends DataFormatDefinition {
036
037    @XmlAttribute
038    @Metadata(defaultValue = "mixed")
039    private String multipartSubType = "mixed";
040    @XmlAttribute
041    private Boolean multipartWithoutAttachment;
042    @XmlAttribute
043    private Boolean headersInline;
044    @XmlAttribute
045    private String includeHeaders;
046    @XmlAttribute
047    private Boolean binaryContent;
048
049    public MimeMultipartDataFormat() {
050        super("mime-multipart");
051    }
052
053    public String getMultipartSubType() {
054        return multipartSubType;
055    }
056
057    /**
058     * Specify the subtype of the MIME Multipart.
059     * <p>
060     * Default is "mixed".
061     */
062    public void setMultipartSubType(String multipartSubType) {
063        this.multipartSubType = multipartSubType;
064    }
065
066    public Boolean getMultipartWithoutAttachment() {
067        return multipartWithoutAttachment;
068    }
069
070    /**
071     * Defines whether a message without attachment is also marshaled into a
072     * MIME Multipart (with only one body part).
073     * <p>
074     * Default is "false".
075     */
076    public void setMultipartWithoutAttachment(Boolean multipartWithoutAttachment) {
077        this.multipartWithoutAttachment = multipartWithoutAttachment;
078    }
079
080    public Boolean getHeadersInline() {
081        return headersInline;
082    }
083
084    /**
085     * Defines whether the MIME-Multipart headers are part of the message body
086     * (true) or are set as Camel headers (false).
087     * <p>
088     * Default is "false".
089     */
090    public void setHeadersInline(Boolean headersInline) {
091        this.headersInline = headersInline;
092    }
093
094    public Boolean getBinaryContent() {
095        return binaryContent;
096    }
097
098    /**
099     * A regex that defines which Camel headers are also included as MIME
100     * headers into the MIME multipart. This will only work if headersInline is
101     * set to true.
102     * <p>
103     * Default is to include no headers
104     */
105    public void setIncludeHeaders(String includeHeaders) {
106        this.includeHeaders = includeHeaders;
107    }
108
109    public String getIncludeHeaders() {
110        return includeHeaders;
111    }
112
113    /**
114     * Defines whether the content of binary parts in the MIME multipart is
115     * binary (true) or Base-64 encoded (false)
116     * <p>
117     * Default is "false".
118     */
119    public void setBinaryContent(Boolean binaryContent) {
120        this.binaryContent = binaryContent;
121    }
122}