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