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 "CamelNatsSID", 042 "CamelNatsStatusCode", 043 "CamelNatsStatusError", 044 "CamelNettyRemoteAddress", 045 "CamelRockerMQKey", 046 "CamelSplitIndex", 047 "CamelSplitSize", 048 "CamelSqlRowCount", 049 "CamelSqlStoredUpdateCount", 050 "CamelSqlUpdateCount", 051 "CamelSshExitValue", 052 "Content-Type", 053 "kafka.KEY", 054 "kafka.OFFSET", 055 "kafka.PARTITION", 056 "kafka.TOPIC", 057 "websocket.eventType" 058 // IMPORTANT-HEADER-KEYS: END 059 ))); 060 061 private ImportantHeaderUtils() { 062 } 063 064 /** 065 * All the important header keys (unmodifiable) 066 */ 067 public static Set<String> getImportantHeaderKeys() { 068 return IMPORTANT_HEADER_KEYS; 069 } 070 071 /** 072 * Whether the given header or exchange properties is marked as important. 073 * 074 * @param key the header key 075 * @return true if important, false otherwise 076 */ 077 public static boolean isImportantHeader(String key) { 078 return IMPORTANT_HEADER_KEYS.contains(key); 079 } 080 081}