This repository was archived by the owner on Aug 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpossible-delivery-3.0.1.patch
2526 lines (2499 loc) · 101 KB
/
possible-delivery-3.0.1.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/core/src/main/resources/schemas/wsdl/mime-binding.xsd apache-cxf-3.0.1-src_new/core/src/main/resources/schemas/wsdl/mime-binding.xsd
--- apache-cxf-3.0.1-src_orig/core/src/main/resources/schemas/wsdl/mime-binding.xsd 2016-01-21 11:10:51.801055126 +0200
+++ apache-cxf-3.0.1-src_new/core/src/main/resources/schemas/wsdl/mime-binding.xsd 2016-01-21 11:15:10.591643173 +0200
@@ -11,7 +11,7 @@
license are distributed with them. The originals of these files can
be located at:
-http://schemas.xmlsoap.org/wsdl/mime/2002-01-29.xsd
+http://schemas.xmlsoap.org/wsdl/mime/2004-08-24.xsd
THESE SCHEMA FILES ARE PROVIDED "AS IS," AND THE AUTHORS MAKE NO REPRESENTATIONS
OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THESE FILES, INCLUDING, BUT NOT
@@ -31,14 +31,14 @@
-->
<schema targetNamespace="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema">
- <import namespace="http://schemas.xmlsoap.org/wsdl/"/>
+ <import namespace="http://schemas.xmlsoap.org/wsdl/" schemaLocation="http://schemas.xmlsoap.org/wsdl/"/>
<element name="content" type="mime:contentType"/>
<complexType name="contentType">
<complexContent>
<extension base="wsdl:tExtensibilityElement">
<sequence/>
<attribute name="type" type="string" use="optional"/>
- <attribute name="part" type="NMTOKEN" use="optional"/>
+ <attribute name="part" type="NMTOKEN" use="required"/>
</extension>
</complexContent>
</complexType>
@@ -47,16 +47,17 @@
<complexContent>
<extension base="wsdl:tExtensibilityElement">
<sequence>
- <element name="part" type="mime:tPart" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="mime:part" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</extension>
</complexContent>
</complexType>
+ <element name="part" type="mime:tPart"/>
<complexType name="tPart">
<sequence>
- <any namespace="##targetNamespace" minOccurs="0" maxOccurs="unbounded"/>
+ <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="name" type="NMTOKEN" use="required"/>
+ <attribute name="name" type="NMTOKEN" use="optional"/>
</complexType>
<element name="mimeXml" type="mime:tMimeXml"/>
<complexType name="tMimeXml">
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SOAPBindingUtil.java apache-cxf-3.0.1-src_new/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SOAPBindingUtil.java
--- apache-cxf-3.0.1-src_orig/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SOAPBindingUtil.java 2016-01-21 11:10:51.829054963 +0200
+++ apache-cxf-3.0.1-src_new/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SOAPBindingUtil.java 2016-01-21 11:15:10.615643014 +0200
@@ -365,7 +365,7 @@
|| bindingStyle.equalsIgnoreCase(previousOpStyle)
&& bindingStyle.equalsIgnoreCase(style)) {
previousOpStyle = style;
- } else if (!"".equals(bindingStyle) && "".equals(style) && "".equals(previousOpStyle)) {
+ } else if (!"".equals(bindingStyle) && "".equals(style)) {
continue;
} else {
return true;
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java apache-cxf-3.0.1-src_new/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java
--- apache-cxf-3.0.1-src_orig/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java 2016-01-21 11:10:52.049053758 +0200
+++ apache-cxf-3.0.1-src_new/tools/common/src/main/java/org/apache/cxf/tools/common/ToolConstants.java 2016-01-21 11:15:10.847641758 +0200
@@ -151,6 +151,8 @@
public static final String CXF_SCHEMA_DIR = "cxf_schema_dir";
public static final String CXF_SCHEMAS_DIR_INJAR = "schemas/wsdl/";
public static final String CFG_SUPPRESS_WARNINGS = "suppressWarnings";
+ public static final String CFG_ADDITION_WSDL_RULES_FILE = "ruleSetFile";
+ public static final String CFG_USE_STANDARD_INPUT = "useStandardInput";
// WSDL2Java Processor Constants
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/pom.xml apache-cxf-3.0.1-src_new/tools/validator/pom.xml
--- apache-cxf-3.0.1-src_orig/tools/validator/pom.xml 2016-01-21 11:10:52.005053998 +0200
+++ apache-cxf-3.0.1-src_new/tools/validator/pom.xml 2016-01-21 11:15:10.799642017 +0200
@@ -80,5 +80,10 @@
<artifactId>cxf-rt-bindings-soap</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>com.github.stefanbirkner</groupId>
+ <artifactId>system-rules</artifactId>
+ <version>1.8.0</version>
+ </dependency>
</dependencies>
</project>
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidator.java apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidator.java
--- apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidator.java 1970-01-01 03:00:00.000000000 +0300
+++ apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidator.java 2016-01-21 11:15:10.799642017 +0200
@@ -0,0 +1,222 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.validator.internal;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.tools.common.ToolException;
+import org.apache.cxf.tools.validator.internal.model.XNode;
+
+public class AdditionalRulesValidator extends AbstractDefinitionValidator {
+
+ protected PrintStream err = System.err;
+
+ protected List<XNode> vNodes = new ArrayList<XNode>();
+
+ private String[] mandatoryNodesReturningError;
+
+ private String[] mandatoryNodesReturningWarning;
+
+ private String[] notAllowedNodesReturningError;
+
+ private String[] notAllowedNodesReturningWarning;
+
+ private String[] mandatoryNodesInSpecifiedArraysReturningError;
+
+ private String[] mandatoryNodesInSpecifiedArraysReturningWarning;
+
+ private File[] configFiles;
+
+ private Document wsdlsrc;
+
+ private XPath xpath = XPathFactory.newInstance().newXPath();
+
+ public AdditionalRulesValidator(File [] configFiles, Document wsdl) {
+ this.configFiles = configFiles;
+ this.wsdlsrc = wsdl;
+ }
+ private void setPropValues(File configFile) throws Exception {
+ Properties prop = new Properties();
+
+ prop.load(new FileInputStream(configFile));
+
+ mandatoryNodesReturningError = prop.getProperty("mandatoryNodesReturningError") != null
+ ? prop.getProperty("mandatoryNodesReturningError").split(", ") : null;
+ mandatoryNodesReturningWarning = prop.getProperty("mandatoryNodesReturningWarning") != null
+ ? prop.getProperty("mandatoryNodesReturningWarning").split(", ") : null;
+
+ notAllowedNodesReturningError = prop.getProperty("notAllowedNodesReturningError") != null
+ ? prop.getProperty("notAllowedNodesReturningError").split(", ") : null;
+ notAllowedNodesReturningWarning = prop.getProperty("notAllowedNodesReturningWarning") != null
+ ? prop.getProperty("notAllowedNodesReturningWarning").split(", ") : null;
+ mandatoryNodesInSpecifiedArraysReturningError =
+ prop.getProperty("mandatoryNodesInSpecifiedArraysReturningError") != null
+ ? prop.getProperty("mandatoryNodesInSpecifiedArraysReturningError").split(", ") : null;
+ mandatoryNodesInSpecifiedArraysReturningWarning =
+ prop.getProperty("mandatoryNodesInSpecifiedArraysReturningWarning") != null
+ ? prop.getProperty("mandatoryNodesInSpecifiedArraysReturningWarning").split(", ") : null;
+ }
+
+ private boolean checkNodesReturningError(String[] rules, boolean existence) {
+ if (rules != null && rules.length > 0) {
+ for (int i = 0; i < rules.length; i++) {
+ if (rules[i] != null && !rules[i].isEmpty()) {
+ Node element = getValue(rules[i], wsdlsrc);
+ if (existence) {
+ if (element == null) {
+ addErrorMessage("Element " + rules[i] + " not found or does not match the validation rule");
+ return false;
+ }
+ } else {
+ if (element != null) {
+ addErrorMessage("Element " + rules[i] + " must not exist according to the rules");
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+ private boolean checkNodesReturningWarning(String[] rules, boolean existence) {
+ if (rules != null && rules.length > 0) {
+ for (int i = 0; i < rules.length; i++) {
+ if (!rules[i].isEmpty()) {
+ Node element = getValue(rules[i], wsdlsrc);
+ if (existence) {
+ if (element == null) {
+ err.println("WARNING: Element " + rules[i]
+ + " not found or does not match the validation rule");
+ return true;
+ }
+ } else {
+ if (element != null) {
+ err.println("WARNING: Element " + rules[i]
+ + " must not exist according to the rules");
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+ private boolean returnWarningOrError(String textError, String textWarning, boolean warning) {
+ if (!warning) {
+ addErrorMessage(textError);
+ return false;
+ } else {
+ err.println(textWarning);
+ return true;
+ }
+ }
+ private boolean checkNodeInNodeList(String nodeList, String node, boolean warning) {
+ NodeList elementsArray = getValueArray(nodeList, wsdlsrc);
+ if (elementsArray != null && elementsArray.getLength() > 0) {
+ for (int m = 0; m < elementsArray.getLength(); m++) {
+ Node parentNode = elementsArray.item(m);
+ Node childNode = getValue(node, parentNode);
+ if (parentNode == null || childNode == null) {
+ return returnWarningOrError("Element " + node + " must exist in parent " + nodeList,
+ "WARNING: Element " + node + " must exist in parent " + nodeList, warning);
+ }
+ }
+ } else {
+ addErrorMessage("Element " + nodeList + " does not exist or empty");
+ return false;
+ }
+ return true;
+ }
+
+ private boolean checkNodesInArrays(String[] rules, boolean warning) {
+ if (rules != null && rules.length > 0) {
+ for (int i = 0; i < rules.length; i++) {
+ if (rules[i] != null && !rules[i].isEmpty()) {
+ String[] parts = rules[i].split(" -> ");
+ String nodeList = parts[0];
+ String node = parts.length > 1 ? parts[1] : null;
+ if (nodeList != null && !nodeList.isEmpty() && node != null && !node.isEmpty()) {
+ if (checkNodeInNodeList(nodeList, node, warning)) {
+ continue;
+ } else {
+ return false;
+ }
+ } else {
+ addErrorMessage("Element " + rules[i] + " is incorrectly represented");
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ private Node getValue(String xpathExpression, Document document) {
+ try {
+ return (Node)xpath.evaluate(xpathExpression, document, XPathConstants.NODE);
+ } catch (Exception e) {
+ throw new ToolException(e.getMessage() + " in node " + xpathExpression);
+ }
+ }
+ private NodeList getValueArray(String xpathExpression, Document document) {
+ try {
+ return (NodeList) xpath.evaluate(xpathExpression, document, XPathConstants.NODESET);
+ } catch (Exception e) {
+ throw new ToolException(e.getMessage() + " in node " + xpathExpression);
+ }
+ }
+ private Node getValue(String xpathExpression, Node node) {
+ try {
+ return (Node)xpath.evaluate(xpathExpression, node, XPathConstants.NODE);
+ } catch (Exception e) {
+ throw new ToolException(e.getMessage() + " in node " + xpathExpression);
+ }
+ }
+ public boolean isValid() {
+ for (File file:configFiles) {
+ try {
+ setPropValues(file);
+ if (!checkNodesReturningError(mandatoryNodesReturningError, true)
+ || !checkNodesReturningWarning(mandatoryNodesReturningWarning, true)
+ || !checkNodesReturningError(notAllowedNodesReturningError, false)
+ || !checkNodesReturningWarning(notAllowedNodesReturningWarning, false)
+ || !checkNodesInArrays(mandatoryNodesInSpecifiedArraysReturningError, false)
+ || !checkNodesInArrays(mandatoryNodesInSpecifiedArraysReturningWarning, true)) {
+ return false;
+ }
+ } catch (Exception e) {
+ throw new ToolException(e);
+ }
+ }
+ return true;
+ }
+}
\ No newline at end of file
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java
--- apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java 2016-01-21 11:10:52.005053998 +0200
+++ apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/internal/WSDL11Validator.java 2016-01-21 11:15:10.799642017 +0200
@@ -22,7 +22,10 @@
import java.io.File;
import java.io.FileFilter;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.net.JarURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
@@ -37,8 +40,11 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+
import javax.wsdl.Definition;
import javax.wsdl.WSDLException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -63,6 +69,8 @@
protected static final Logger LOG = LogUtils.getL7dLogger(SchemaValidator.class);
private final List<AbstractValidator> validators = new ArrayList<AbstractValidator>();
+ private boolean useStandardInput;
+
public WSDL11Validator(final Definition definition) {
this(definition, null);
}
@@ -74,12 +82,13 @@
public WSDL11Validator(final Definition definition, final ToolContext pe, final Bus b) {
super(definition, pe, b);
}
-
+ public void setUseStandardInput(boolean s) {
+ this.useStandardInput = s;
+ }
private Document getWSDLDoc(String wsdl) {
LOG.log(Level.FINE, new Message("VALIDATE_WSDL", LOG, wsdl).toString());
try {
OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(this.getBus());
-
String nw = new OASISCatalogManagerHelper().resolve(catalogResolver,
wsdl, null);
if (nw == null) {
@@ -93,21 +102,65 @@
throw new ToolException(e);
}
}
+ private String getFileAbsolutePath(String filePath) {
+ try {
+ OASISCatalogManager catalogResolver = OASISCatalogManager.getCatalogManager(this.getBus());
+
+ String nw = new OASISCatalogManagerHelper().resolve(catalogResolver,
+ filePath, null);
+ if (nw == null) {
+ nw = filePath;
+ }
+ return URIParserUtil.getAbsoluteURI(nw);
+ } catch (FileNotFoundException fe) {
+ LOG.log(Level.WARNING, "Cannot find the ruleSet file " + filePath + "to validate");
+ return null;
+ } catch (Exception e) {
+ throw new ToolException(e);
+ }
+ }
+ private File getFile(String filePath) {
+ try {
+ URI fileUri = new URI(getFileAbsolutePath(filePath));
+ return new File(fileUri);
+ } catch (Exception e) {
+ throw new ToolException("Cannot find file: " + filePath);
+ }
+ }
+ private Document getDocument(File file) {
+ try {
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ dbFactory.setNamespaceAware(true);
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ if (file != null) {
+ return dBuilder.parse(file);
+ }
+ return dBuilder.parse(System.in);
+ } catch (Exception e) {
+ throw new ToolException(e);
+ }
+ }
public boolean isValid() throws ToolException {
//boolean isValid = true;
String schemaDir = getSchemaDir();
+ String[] ruleSetFilePaths = (String[])env.get(ToolConstants.CFG_ADDITION_WSDL_RULES_FILE);
SchemaValidator schemaValidator = null;
+ AdditionalRulesValidator additionalRulesValidator = null;
+ File stdInFile = null;
String[] schemas = (String[])env.get(ToolConstants.CFG_SCHEMA_URL);
// Tool will use the following sequence to find the schema files
// 1.ToolConstants.CFG_SCHEMA_DIR from ToolContext
// 2.ToolConstants.CXF_SCHEMA_DIR from System property
// 3.If 1 and 2 is null , then load these schema files from jar file
String wsdl = (String)env.get(ToolConstants.CFG_WSDLURL);
-
+ if (useStandardInput) {
+ stdInFile = getFileFromStdinURL();
+ wsdl = stdInFile.getPath();
+ }
Document doc = getWSDLDoc(wsdl);
if (doc == null) {
- return true;
+ throw new ToolException("Wsdl file not found");
}
if (this.def == null) {
try {
@@ -116,7 +169,14 @@
throw new ToolException(e);
}
}
-
+ if (ruleSetFilePaths != null && ruleSetFilePaths.length != 0 && doc != null) {
+ additionalRulesValidator =
+ new AdditionalRulesValidator(getRuleSetFiles(ruleSetFilePaths), doc);
+ if (!additionalRulesValidator.isValid()) {
+ this.addErrorMessage(additionalRulesValidator.getErrorMessage());
+ throw new ToolException(this.getErrorMessage());
+ }
+ }
WSDLRefValidator wsdlRefValidator = new WSDLRefValidator(this.def, doc, getBus());
wsdlRefValidator.setSuppressWarnings(env.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));
validators.add(wsdlRefValidator);
@@ -143,7 +203,6 @@
if (!env.fullValidateWSDL()) {
return true;
}
-
if (!StringUtils.isEmpty(schemaDir)) {
schemaValidator = new SchemaValidator(schemaDir, wsdl, schemas);
} else {
@@ -159,9 +218,52 @@
throw new ToolException(this.getErrorMessage());
}
-
+ if (stdInFile != null) {
+ stdInFile.delete();
+ }
return true;
}
+ public File[] getRuleSetFiles(String[] ruleFilesPaths) {
+ File[] ruleSetFiles = new File[ruleFilesPaths.length];
+ for (int i = 0; i < ruleFilesPaths.length; i++) {
+ ruleSetFiles[i] = getFile(ruleFilesPaths[i]);
+ }
+ return ruleSetFiles;
+ }
+
+ public File getFileFromStdinURL() {
+ InputStream initialStream = null;
+ OutputStream outStream = null;
+ try {
+ initialStream = System.in;
+ File targetFile = File.createTempFile("tempValid", ".wsdl");
+ outStream = new FileOutputStream(targetFile);
+ byte[] buffer = new byte[8 * 1024];
+ int bytesRead;
+ while ((bytesRead = initialStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, bytesRead);
+ }
+ targetFile.deleteOnExit();
+ return targetFile;
+ } catch (IOException e) {
+ throw new ToolException(e);
+ } finally {
+ if (initialStream != null) {
+ try {
+ initialStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ if (outStream != null) {
+ try {
+ outStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
public String getSchemaDir() {
String dir = "";
@@ -267,3 +369,4 @@
});
}
}
+
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java
--- apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java 2016-01-21 11:10:52.005053998 +0200
+++ apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/WSDLValidator.java 2016-01-21 11:15:10.799642017 +0200
@@ -46,6 +46,7 @@
private Set<String> getArrayKeys() {
Set<String> set = new HashSet<String>();
set.add(ToolConstants.CFG_SCHEMA_URL);
+ set.add(ToolConstants.CFG_ADDITION_WSDL_RULES_FILE);
return set;
}
@@ -59,8 +60,15 @@
env.put(ToolConstants.CFG_VALIDATE_WSDL, "all");
env.put(ToolConstants.CFG_CMD_ARG, getArgument());
+ String wsdlurl = (String)env.get(ToolConstants.CFG_WSDLURL);
+ boolean stInputOption = env.optionSet(ToolConstants.CFG_USE_STANDARD_INPUT);
+ if ((wsdlurl == null || wsdlurl.equals("true")) && !stInputOption) {
+ throw new ToolException("wsdlurl parameter or -st option must be used",
+ new BadUsageException(getUsage(), new ErrorVisitor()));
+ }
WSDL11Validator wsdlValidator = new WSDL11Validator(null, env, getBus());
+ wsdlValidator.setUseStandardInput(stInputOption);
return wsdlValidator.isValid();
}
@@ -76,11 +84,20 @@
env.put(ToolConstants.CFG_VALIDATE_WSDL, "all");
env.put(ToolConstants.CFG_CMD_ARG, getArgument());
+ String wsdlurl = (String)env.get(ToolConstants.CFG_WSDLURL);
+ boolean stInputOption = env.optionSet(ToolConstants.CFG_USE_STANDARD_INPUT);
+ if ((wsdlurl == null || wsdlurl.equals("true")) && !stInputOption) {
+ throw new ToolException("wsdlurl parameter or -st option must be used",
+ new BadUsageException(getUsage(), new ErrorVisitor()));
+ }
WSDL11Validator wsdlValidator = new WSDL11Validator(null, env, getBus());
+ wsdlValidator.setUseStandardInput(env.optionSet(ToolConstants.CFG_USE_STANDARD_INPUT));
if (wsdlValidator.isValid()) {
System.out.println("Passed Validation : Valid WSDL ");
+ System.exit(0);
}
+ System.exit(1);
}
} catch (ToolException ex) {
err.println("WSDLValidator Error : " + ex.getMessage());
@@ -93,6 +110,7 @@
err.println();
ex.printStackTrace(err);
}
+ System.exit(1);
} catch (Exception ex) {
err.println("WSDLValidator Error : " + ex.getMessage());
err.println();
@@ -101,6 +119,7 @@
err.println();
ex.printStackTrace(err);
}
+ System.exit(1);
}
}
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml
--- apache-cxf-3.0.1-src_orig/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml 2016-01-21 11:10:52.005053998 +0200
+++ apache-cxf-3.0.1-src_new/tools/validator/src/main/java/org/apache/cxf/tools/validator/wsdlvalidator.xml 2016-01-21 11:15:10.799642017 +0200
@@ -23,6 +23,7 @@
wsdlvalidator HelloWorld.wsdl
wsdlvalidator -s http://cxf.apache.org/schemas -s http://mycompany/schemas Greeting.wsdl
+wsdlvalidator -r rules.properties -r rules2.properties Greeting.wsdl
</annotation>
<usage>
<optionGroup id="options">
@@ -44,12 +45,27 @@
<annotation>schema-url</annotation>
</associatedArgument>
</option>
+ <option id="ruleSetFile" maxOccurs="unbounded">
+ <annotation>
+ Specify the Configuration File path with additional wsdl rules. (This option can be specified multiple times.)
+ </annotation>
+ <switch>r</switch>
+ <associatedArgument placement="afterSpace">
+ <annotation>ruleset-file</annotation>
+ </associatedArgument>
+ </option>
<option id="suppressWarnings">
<annotation>
Suppress warnings
</annotation>
<switch>w</switch>
</option>
+ <option id="useStandardInput" maxOccurs="1">
+ <annotation>
+ Use wsdl from Standard input
+ </annotation>
+ <switch>st</switch>
+ </option>
<!--option id="deep" maxOccurs="1">
<annotation>Deep level validation like wsdl imports validation and wsdl semantics check.</annotation>
<switch>deep</switch>
@@ -87,7 +103,7 @@
<switch>Q</switch>
</option>
</optionGroup>
- <argument id="wsdlurl" minOccurs="1" maxOccurs="1">
+ <argument id="wsdlurl" minOccurs="0" maxOccurs="1">
<annotation>
WSDL URL
</annotation>
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidatorTest.java apache-cxf-3.0.1-src_new/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidatorTest.java
--- apache-cxf-3.0.1-src_orig/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidatorTest.java 1970-01-01 03:00:00.000000000 +0300
+++ apache-cxf-3.0.1-src_new/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/AdditionalRulesValidatorTest.java 2016-01-21 11:15:10.803641997 +0200
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.tools.validator.internal;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AdditionalRulesValidatorTest extends Assert {
+
+ @Test
+ public void testWSDLImport() throws Exception {
+ File wsdlFile = new File(getClass().getResource(
+ "/validator_wsdl/aktorstest.wsdl").toURI());
+ File rulesFile = new File(getClass().getResource(
+ "/validator_wsdl/xroad5.properties").toURI());
+ File rulesFileAdditional = new File(getClass().getResource(
+ "/validator_wsdl/xroad5Error.properties").toURI());
+ File[] rulesFiles = new File[2];
+ rulesFiles[0] = rulesFile;
+ rulesFiles[1] = rulesFileAdditional;
+
+ DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+ dbFactory.setNamespaceAware(true);
+ DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
+ Document doc = dBuilder.parse(wsdlFile);
+
+ AdditionalRulesValidator additionalRulesValidator = new AdditionalRulesValidator(rulesFiles, doc);
+
+ assertFalse(additionalRulesValidator.isValid());
+ }
+}
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java apache-cxf-3.0.1-src_new/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
--- apache-cxf-3.0.1-src_orig/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java 2016-01-21 11:10:52.005053998 +0200
+++ apache-cxf-3.0.1-src_new/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java 2016-01-21 11:15:10.803641997 +0200
@@ -19,11 +19,17 @@
package org.apache.cxf.tools.validator.internal;
+import java.io.FileInputStream;
+import java.io.InputStream;
+/**import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.w3c.dom.Document;**/
import org.apache.cxf.tools.common.ToolConstants;
import org.apache.cxf.tools.common.ToolContext;
import org.junit.Assert;
import org.junit.Test;
+
public class WSDL11ValidatorTest extends Assert {
private ToolContext context = new ToolContext();
@@ -40,4 +46,18 @@
+ "[portType:GreeterA][operation:sayHi] not exist.") != -1);
}
}
+ @Test
+ public void testWSDLFromStdin() throws Exception {
+ try {
+ context.put(ToolConstants.CFG_USE_STANDARD_INPUT, true);
+ InputStream is = new FileInputStream("src/test/resources/validator_wsdl/aktorstest.wsdl");
+ System.setIn(is);
+
+ WSDL11Validator validator = new WSDL11Validator(null, context);
+ validator.setUseStandardInput(true);
+ assertTrue(validator.isValid());
+ } catch (Exception e) {
+ fail("Wsdl is not found or convertion to dom.Document failed " + e);
+ }
+ }
}
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java apache-cxf-3.0.1-src_new/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java
--- apache-cxf-3.0.1-src_orig/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java 2016-01-21 11:10:52.005053998 +0200
+++ apache-cxf-3.0.1-src_new/tools/validator/src/test/java/org/apache/cxf/tools/validator/WSDLValidationTest.java 2016-01-21 11:15:10.803641997 +0200
@@ -21,13 +21,18 @@
import java.io.File;
import java.net.URL;
import java.util.Enumeration;
-
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.tools.common.ToolTestBase;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.ExpectedSystemExit;
public class WSDLValidationTest extends ToolTestBase {
+ //CHECKSTYLE:OFF
+ @Rule
+ public final ExpectedSystemExit exit = ExpectedSystemExit.none();
+ //CHECKSTYLE:ON
@Before
public void setUp() {
super.setUp();
@@ -37,6 +42,7 @@
public void testValidateDefaultOpMessageNames() throws Exception {
String[] args = new String[] {"-verbose",
getLocation("/validator_wsdl/defaultOpMessageNames.wsdl")};
+ exit.expectSystemExitWithStatus(0);
WSDLValidator.main(args);
assertTrue(this.getStdOut().contains("Valid WSDL"));
}
@@ -108,6 +114,7 @@
public void testImportWsdlValidation() throws Exception {
String[] args = new String[] {"-verbose",
getLocation("/validator_wsdl/hello_world_import.wsdl")};
+ exit.expectSystemExitWithStatus(0);
WSDLValidator.main(args);
assertTrue("Is not valid wsdl!: " + getStdOut(),
@@ -118,6 +125,7 @@
public void testImportSchemaValidation() throws Exception {
String[] args = new String[] {"-verbose",
getLocation("/validator_wsdl/hello_world_schema_import.wsdl")};
+ exit.expectSystemExitWithStatus(0);
WSDLValidator.main(args);
assertTrue("Is not valid wsdl: " + getStdOut(),
@@ -127,6 +135,7 @@
public void testSOAPHeadersInMultiOperations() throws Exception {
String[] args = new String[] {"-verbose",
getLocation("/validator_wsdl/cxf1793.wsdl")};
+ exit.expectSystemExitWithStatus(0);
WSDLValidator.main(args);
assertTrue(getStdErr(), getStdOut().indexOf("Passed Validation : Valid WSDL") > -1);
}
@@ -160,6 +169,7 @@
public void testWSIBPR2203() throws Exception {
String[] args = new String[] {"-verbose",
getLocation("/validator_wsdl/header_rpc_lit.wsdl")};
+ exit.expectSystemExitWithStatus(0);
WSDLValidator.main(args);
assertTrue(getStdOut().indexOf("Passed Validation : Valid WSDL") > -1);
diff --strip-trailing-cr -wruN apache-cxf-3.0.1-src_orig/tools/validator/src/test/resources/validator_wsdl/aktorstest.wsdl apache-cxf-3.0.1-src_new/tools/validator/src/test/resources/validator_wsdl/aktorstest.wsdl
--- apache-cxf-3.0.1-src_orig/tools/validator/src/test/resources/validator_wsdl/aktorstest.wsdl 1970-01-01 03:00:00.000000000 +0300
+++ apache-cxf-3.0.1-src_new/tools/validator/src/test/resources/validator_wsdl/aktorstest.wsdl 2016-01-21 11:15:10.803641997 +0200
@@ -0,0 +1,842 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions targetNamespace="http://aktorstest.x-road.ee/producer"
+xmlns="http://schemas.xmlsoap.org/wsdl/"
+xmlns:ns1="http://www.w3.org/1999/xlink"
+xmlns:ns="http://schemas.xmlsoap.org/soap/encoding/"
+xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+xmlns:wsdl="http://www.w3.org/ns/wsdl"
+xmlns:tns="http://aktorstest.x-road.ee/producer"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
+xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+xmlns:xrd="http://x-road.ee/xsd/x-road.xsd">
+ <types>
+ <schema targetNamespace="http://aktorstest.x-road.ee/producer" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://x-road.ee/xsd/x-road.xsd" schemaLocation="http://x-road.ee/xsd/x-road.xsd"/>
+ <import namespace="http://www.w3.org/2005/05/xmlmime" schemaLocation="http://www.w3.org/2005/05/xmlmime"/>
+ <element name="isikuteList">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="eesnimi" type="string">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="en">Given name</xrd:title>
+ <xrd:title xml:lang="et">Eesnimi</xrd:title>
+ </appinfo>
+ </annotation>
+ </element>
+ <element name="perenimi" type="string">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="en">Surname</xrd:title>
+ <xrd:title xml:lang="et">Perenimi</xrd:title>
+ </appinfo>
+ </annotation>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="isikuteListResponse">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="eesnimi" nillable="true" type="string"/>
+ <element name="perenimi" nillable="true" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="response">
+ <complexType>
+ <sequence>
+ <element name="faultCode" nillable="true" type="xrd:faultCode"/>
+ <element name="faultString" nillable="true" type="xrd:faultString"/>
+ <element maxOccurs="unbounded" minOccurs="0" name="isik" nillable="true" type="tns:isik_short">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="en">Person's data</xrd:title>
+ <xrd:title xml:lang="et">Isiku andmed</xrd:title>
+ </appinfo>
+ </annotation>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="isikOtsing">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="isikukood" type="string">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="en">Perconal ID code</xrd:title>
+ <xrd:title xml:lang="et">Isikukood</xrd:title>
+ </appinfo>
+ </annotation>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="isikOtsingResponse">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="isikukood" nillable="true" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="response">
+ <complexType>
+ <sequence>
+ <element name="faultCode" nillable="true" type="xrd:faultCode"/>
+ <element name="faultString" nillable="true" type="xrd:faultString"/>
+ <element name="isiku_andmed" nillable="true" type="tns:isik"/>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="changeAddress">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="isikukood" type="string">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="et">Isikukood</xrd:title>
+ <xrd:title xml:lang="en">Personal ID code</xrd:title>
+ </appinfo>
+ </annotation>
+ </element>
+ <element name="aadress" type="tns:aadress"/>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="changeAddressResponse">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="isikukood" nillable="true" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="response">
+ <complexType>
+ <sequence>
+ <element name="faultCode" nillable="true" type="xrd:faultCode"/>
+ <element name="faultString" nillable="true" type="xrd:faultString"/>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="fileDownload">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="fileName" nillable="true" type="string">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="en">FileName</xrd:title>
+ </appinfo>
+ </annotation>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="fileDownloadResponse">
+ <complexType>
+ <sequence>
+ <element name="request">
+ <complexType>
+ <sequence>
+ <element name="fileName" nillable="true" type="string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="response">
+ <complexType>
+ <sequence>
+ <element name="faultCode" nillable="true" type="xrd:faultCode"/>
+ <element name="faultString" nillable="true" type="xrd:faultString"/>
+ <element name="file" nillable="true">
+ <annotation>
+ <appinfo>
+ <xrd:title xml:lang="en">File</xrd:title>
+ </appinfo>
+ </annotation>
+ <complexType>
+ <attribute name="href" type="string"/>
+ </complexType>
+ </element>
+ </sequence>
+ </complexType>
+ </element>