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.util;
018
019import java.util.Arrays;
020import java.util.Collections;
021import java.util.HashSet;
022import java.util.Set;
023
024public final class ImportantHeaderUtils {
025
026    private static final Set<String> IMPORTANT_HEADER_KEYS = Collections.unmodifiableSet(new HashSet<>(
027            Arrays.asList(
028                    // Generated by camel build tools - do NOT edit this list!
029                    // IMPORTANT-HEADER-KEYS: START
030                    "CamelAggregatedCorrelationKey",
031                    "CamelAggregatedSize",
032                    "CamelAsteriskEventName",
033                    "CamelExecExitValue",
034                    "CamelFileLength",
035                    "CamelFileName",
036                    "CamelFtpReplyCode",
037                    "CamelFtpReplyString",
038                    "CamelHttpResponseCode",
039                    "CamelHttpResponseText",
040                    "CamelMqttTopic",
041                    "CamelNatsDeliveryCounter",
042                    "CamelNatsSID",
043                    "CamelNatsStatusCode",
044                    "CamelNatsStatusError",
045                    "CamelNettyRemoteAddress",
046                    "CamelRockerMQKey",
047                    "CamelSplitIndex",
048                    "CamelSplitSize",
049                    "CamelSqlRowCount",
050                    "CamelSqlStoredUpdateCount",
051                    "CamelSqlUpdateCount",
052                    "CamelSshExitValue",
053                    "Content-Type",
054                    "kafka.KEY",
055                    "kafka.OFFSET",
056                    "kafka.PARTITION",
057                    "kafka.TOPIC",
058                    "websocket.eventType"
059            // IMPORTANT-HEADER-KEYS: END
060            )));
061
062    private ImportantHeaderUtils() {
063    }
064
065    /**
066     * All the important header keys (unmodifiable)
067     */
068    public static Set<String> getImportantHeaderKeys() {
069        return IMPORTANT_HEADER_KEYS;
070    }
071
072    /**
073     * Whether the given header or exchange properties is marked as important.
074     *
075     * @param  key the header key
076     * @return     true if important, false otherwise
077     */
078    public static boolean isImportantHeader(String key) {
079        return IMPORTANT_HEADER_KEYS.contains(key);
080    }
081
082}