Merge the supplied web fragments into this main web.xml. @param fragments The fragments to merge in @return true if merge is successful, else false
(Set<WebXml> fragments)
| 2080 | * @return <code>true</code> if merge is successful, else <code>false</code> |
| 2081 | */ |
| 2082 | public boolean merge(Set<WebXml> fragments) { |
| 2083 | // As far as possible, process in alphabetical order so it is easy to |
| 2084 | // check everything is present |
| 2085 | |
| 2086 | // Merge rules vary from element to element. See SRV.8.2.3 |
| 2087 | |
| 2088 | WebXml temp = new WebXml(); |
| 2089 | |
| 2090 | for (WebXml fragment : fragments) { |
| 2091 | if (!mergeMap(fragment.getContextParams(), contextParams, temp.getContextParams(), fragment, |
| 2092 | "Context Parameter")) { |
| 2093 | return false; |
| 2094 | } |
| 2095 | } |
| 2096 | contextParams.putAll(temp.getContextParams()); |
| 2097 | |
| 2098 | if (displayName == null) { |
| 2099 | for (WebXml fragment : fragments) { |
| 2100 | String value = fragment.getDisplayName(); |
| 2101 | if (value != null) { |
| 2102 | if (temp.getDisplayName() == null) { |
| 2103 | temp.setDisplayName(value); |
| 2104 | } else { |
| 2105 | log.error( |
| 2106 | sm.getString("webXml.mergeConflictDisplayName", fragment.getName(), fragment.getURL())); |
| 2107 | return false; |
| 2108 | } |
| 2109 | } |
| 2110 | } |
| 2111 | displayName = temp.getDisplayName(); |
| 2112 | } |
| 2113 | |
| 2114 | // Note: Not permitted in fragments, but we also use fragments for |
| 2115 | // per-Host and global defaults so they may appear there |
| 2116 | if (!denyUncoveredHttpMethods) { |
| 2117 | for (WebXml fragment : fragments) { |
| 2118 | if (fragment.getDenyUncoveredHttpMethods()) { |
| 2119 | denyUncoveredHttpMethods = true; |
| 2120 | break; |
| 2121 | } |
| 2122 | } |
| 2123 | } |
| 2124 | if (requestCharacterEncoding == null) { |
| 2125 | for (WebXml fragment : fragments) { |
| 2126 | if (fragment.getRequestCharacterEncoding() != null) { |
| 2127 | requestCharacterEncoding = fragment.getRequestCharacterEncoding(); |
| 2128 | } |
| 2129 | } |
| 2130 | } |
| 2131 | if (responseCharacterEncoding == null) { |
| 2132 | for (WebXml fragment : fragments) { |
| 2133 | if (fragment.getResponseCharacterEncoding() != null) { |
| 2134 | responseCharacterEncoding = fragment.getResponseCharacterEncoding(); |
| 2135 | } |
| 2136 | } |
| 2137 | } |
| 2138 | |
| 2139 | if (distributable) { |