01: /*
02: * Copyright 2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.ws.soap.saaj;
18:
19: import java.util.ArrayList;
20: import java.util.Iterator;
21: import java.util.List;
22: import javax.xml.soap.SOAPConstants;
23: import javax.xml.soap.SOAPHeader;
24: import javax.xml.soap.SOAPHeaderElement;
25:
26: import org.springframework.util.ObjectUtils;
27: import org.springframework.util.StringUtils;
28: import org.springframework.ws.soap.soap11.Soap11Header;
29:
30: /**
31: * SAAJ-specific implementation of the <code>Soap11Header</code> interface. Wraps a {@link javax.xml.soap.SOAPHeader}.
32: *
33: * @author Arjen Poutsma
34: * @since 1.0.0
35: */
36: class SaajSoap11Header extends SaajSoapHeader implements Soap11Header {
37:
38: SaajSoap11Header(SOAPHeader header) {
39: super (header);
40: }
41:
42: public Iterator examineHeaderElementsToProcess(String[] actors) {
43: List result = new ArrayList();
44: Iterator iterator = getImplementation()
45: .examineAllHeaderElements(getSaajHeader());
46: while (iterator.hasNext()) {
47: SOAPHeaderElement saajHeaderElement = (SOAPHeaderElement) iterator
48: .next();
49: String headerActor = saajHeaderElement.getActor();
50: if (shouldProcess(headerActor, actors)) {
51: result.add(saajHeaderElement);
52: }
53: }
54: return new SaajSoapHeaderElementIterator(result.iterator());
55: }
56:
57: private boolean shouldProcess(String headerActor, String[] actors) {
58: if (!StringUtils.hasLength(headerActor)) {
59: return true;
60: }
61: if (SOAPConstants.URI_SOAP_ACTOR_NEXT.equals(headerActor)) {
62: return true;
63: }
64: if (!ObjectUtils.isEmpty(actors)) {
65: for (int i = 0; i < actors.length; i++) {
66: if (actors[i].equals(headerActor)) {
67: return true;
68: }
69: }
70: }
71: return false;
72: }
73: }
|