Changeset 1924 for trunk/autoquest-plugin-http/src/main/java/de/ugoe
- Timestamp:
- 03/18/15 09:58:50 (10 years ago)
- Location:
- trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/HTTPUtils.java
r1923 r1924 15 15 package de.ugoe.cs.autoquest.plugin.http; 16 16 17 import java.util.Iterator;18 import java.util.LinkedList;19 import java.util.List;20 21 import de.ugoe.cs.autoquest.eventcore.Event;22 import de.ugoe.cs.autoquest.plugin.http.eventcore.SOAPEventType;23 import de.ugoe.cs.autoquest.plugin.http.eventcore.SimpleSOAPEventType;24 17 import de.ugoe.cs.autoquest.plugin.http.logdata.Address; 25 18 … … 128 121 /** 129 122 * <p> 130 * Replaces events with a {@link SOAPEventType} with new events of {@link SimpleSOAPEventType}131 * and no target.132 * </p>133 *134 * @param sequence135 * sequence where the events are replaced136 * @param keepOnlySOAPEvents137 * if true, all events that are not of SOAPEventType or SimpleSOAPEventType are138 * removed139 * @return sequence with {@link SimpleSOAPEventType}s instead of {@link SOAPEventType}s140 */141 public static List<Event> convertToSimpleSOAPEvent(List<Event> sequence,142 boolean keepOnlySOAPEvents)143 {144 List<Event> newSequence = null;145 if (sequence != null) {146 newSequence = new LinkedList<>();147 for (Event event : sequence) {148 if (event.getType() instanceof SOAPEventType) {149 SOAPEventType eventType = (SOAPEventType) event.getType();150 newSequence.add(new Event(new SimpleSOAPEventType(eventType.getCalledMethod(),151 eventType.getServiceName(),152 eventType.getClientName())));153 }154 else {155 if (!keepOnlySOAPEvents || event.getType() instanceof SimpleSOAPEventType) {156 newSequence.add(event);157 }158 }159 }160 }161 return newSequence;162 }163 164 /**165 * <p>166 * Removes all non SOAP events from a sequence. Warning: this change is performed in-place!167 * </p>168 *169 * @param sequence170 * sequence where the events are replaced171 */172 public static void removeNonSOAPEvents(List<Event> sequence)173 {174 for (Iterator<Event> eventIter = sequence.iterator(); eventIter.hasNext();) {175 Event event = eventIter.next();176 if (!(event.getType() instanceof SOAPEventType)) {177 eventIter.remove();178 }179 }180 }181 182 /**183 * <p>184 123 * prevent instantiation 185 124 * </p> -
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SOAPEventType.java
r1912 r1924 23 23 import javax.xml.soap.SOAPMessage; 24 24 25 import org.w3c.dom.Element; 26 25 27 import de.ugoe.cs.autoquest.plugin.http.HTTPUtils; 26 28 import de.ugoe.cs.autoquest.plugin.http.logdata.Header; … … 256 258 return soapResponse; 257 259 } 260 261 /** 262 * @return the body of the soapRequest 263 */ 264 public Element getSoapRequestBody() { 265 try { 266 return soapRequest.getSOAPBody(); 267 } 268 catch (SOAPException e) { 269 return null; 270 } 271 } 258 272 259 273 /* (non-Javadoc) -
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java
r1913 r1924 15 15 package de.ugoe.cs.autoquest.plugin.http.eventcore; 16 16 17 import java.io.ByteArrayInputStream; 18 import java.io.IOException; 19 20 import javax.xml.parsers.DocumentBuilderFactory; 21 import javax.xml.parsers.ParserConfigurationException; 22 23 import org.w3c.dom.Element; 24 import org.xml.sax.SAXException; 25 17 26 import de.ugoe.cs.autoquest.eventcore.IEventType; 18 27 import de.ugoe.cs.autoquest.plugin.http.HTTPUtils; 28 import de.ugoe.cs.autoquest.plugin.http.SOAPUtils; 19 29 20 30 /** … … 44 54 */ 45 55 private final String serviceName; 46 56 47 57 /** 48 58 * <p> 49 * the name of the client; this is either the host/ip and port of the sender or, if a path 50 * mapis available, a human readable name that may be based also on the receiver59 * the name of the client; this is either the host/ip and port of the sender or, if a path map 60 * is available, a human readable name that may be based also on the receiver 51 61 * </p> 52 62 */ 53 63 private final String clientName; 64 65 /** 66 * <p> 67 * the body of the SOAP request; storage as serialized XML string to allow object serialization 68 * </p> 69 */ 70 private final String soapRequestBody; 54 71 55 72 /** … … 59 76 * 60 77 */ 61 public SimpleSOAPEventType(String calledMethod, String serviceName, String clientName) { 78 public SimpleSOAPEventType(String calledMethod, 79 String serviceName, 80 String clientName, 81 Element soapRequestBody) 82 { 62 83 if (calledMethod == null) { 63 84 throw new IllegalArgumentException("called method must not be null"); … … 69 90 throw new IllegalArgumentException("clientName must not be null"); 70 91 } 92 if (soapRequestBody == null) { 93 throw new IllegalArgumentException("soapRequestBody must not be null"); 94 } 71 95 this.calledMethod = calledMethod; 72 96 this.serviceName = serviceName; 73 97 this.clientName = clientName; 98 this.soapRequestBody = SOAPUtils.getSerialization(soapRequestBody); 74 99 } 75 100 … … 95 120 return serviceName; 96 121 } 97 122 98 123 /** 99 124 * <p> 100 125 * the name of the client calling in this request 101 126 * </p> 102 * 127 * 103 128 * @return the name of the client calling in this request 104 129 */ 105 130 public String getClientName() { 106 131 return clientName; 132 } 133 134 public Element getSoapRequestBody() { 135 try { 136 return DocumentBuilderFactory.newInstance().newDocumentBuilder() 137 .parse(new ByteArrayInputStream(soapRequestBody.getBytes())).getDocumentElement(); 138 } 139 catch (SAXException | IOException | ParserConfigurationException e) { 140 return null; 141 } 107 142 } 108 143 … … 129 164 else if (obj instanceof SimpleSOAPEventType) { 130 165 return HTTPUtils.equals(calledMethod, ((SimpleSOAPEventType) obj).calledMethod) && 131 HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName); 166 HTTPUtils.equals(serviceName, ((SimpleSOAPEventType) obj).serviceName) && 167 HTTPUtils.equals(clientName, ((SimpleSOAPEventType) obj).clientName); 132 168 } 133 169 else { … … 143 179 @Override 144 180 public int hashCode() { 145 int hashCode = calledMethod.hashCode() + serviceName.hashCode() ;181 int hashCode = calledMethod.hashCode() + serviceName.hashCode() + clientName.hashCode(); 146 182 return hashCode; 147 183 } 148 149 /* (non-Javadoc) 184 185 /* 186 * (non-Javadoc) 187 * 150 188 * @see java.lang.Object#toString() 151 189 */
Note: See TracChangeset
for help on using the changeset viewer.