Commit 3ba8e2a7a32f087412c5e54c5e2652af2fd9e14e

Authored by Nathanael Jourdane
1 parent 081ec67a
Exists in master and in 1 other branch b6.0.X

Improve VOTable verification.

src/main/java/eu/omp/irap/vespa/votable/controller/VOTableController.java
... ... @@ -20,6 +20,7 @@ import java.util.SortedMap;
20 20 import java.util.TreeMap;
21 21 import java.util.logging.Logger;
22 22  
  23 +import eu.omp.irap.vespa.epntapclient.votable.model.Info;
23 24 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
24 25 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
25 26 import eu.omp.irap.vespa.votable.Consts;
... ... @@ -81,7 +82,7 @@ public class VOTableController implements VOTableViewListener {
81 82 voTablePath = VOTableController.downloadVOTable(targetURL, query);
82 83 }
83 84 voTable = VOTableParser.parseVOTable(voTablePath);
84   - checkVOTable();
  85 + checkVOTable(voTable);
85 86  
86 87 Table table = (Table) voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0);
87 88  
... ... @@ -91,10 +92,10 @@ public class VOTableController implements VOTableViewListener {
91 92 voTableData = dataCtrl.getData();
92 93 }
93 94  
94   - private void checkVOTable() throws CantGetVOTableException {
  95 + public static void checkVOTable(VOTABLE voTable) throws CantGetVOTableException {
95 96 if (voTable.getRESOURCE().isEmpty()) {
96 97 throw new CantGetVOTableException("The VOTable do not have any resource. "
97   - + "See the local file for more informations: " + voTablePath);
  98 + + "See the local file for more informations.");
98 99 }
99 100  
100 101 if (voTable.getRESOURCE().size() > 1) {
... ... @@ -102,16 +103,17 @@ public class VOTableController implements VOTableViewListener {
102 103 "VOTable with more than one resource are not yet supported.");
103 104 }
104 105  
105   - if ("ERROR".equals(voTable.getRESOURCE().get(0).getINFO().get(0).getValueAttribute())) {
106   - String errorInfo = voTable.getRESOURCE().get(0).getINFO().get(0).getValue();
107   - throw new CantGetVOTableException("There is an error in the VOTable:\n" + errorInfo
108   - + "\nPlease check your ADQL query. ");
  106 + for (Info info : voTable.getRESOURCE().get(0).getINFO()) {
  107 + if ("ERROR".equals(info.getValueAttribute())) {
  108 + throw new CantGetVOTableException("There is an error in the VOTable:\n"
  109 + + info.getValue() + "\nPlease check your ADQL query. ");
  110 + }
109 111 }
110 112  
111 113 if (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().size() > 1) {
112 114 throw new CantGetVOTableException(
113 115 "VOTable with more than one table are not yet supported. "
114   - + "See the local file for more informations: " + voTablePath);
  116 + + "See the local file for more informations.");
115 117 }
116 118  
117 119 }
... ...