Commit 4164c0743ecef0bbfeae9e3ed1a61837875d6d52

Authored by Nathanael Jourdane
1 parent b6b4fb3e
Exists in master

Use dedicated exceptions which extends SendQueryException and CantFillTableException.

src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java
@@ -180,9 +180,9 @@ public class EpnTapController implements MainViewListener { @@ -180,9 +180,9 @@ public class EpnTapController implements MainViewListener {
180 logger.warning("Event " + event.toString() + " detected but is not implemented."); 180 logger.warning("Event " + event.toString() + " detected but is not implemented.");
181 } 181 }
182 } catch (Exception e) { 182 } catch (Exception e) {
183 - mainView.displayError("Error", "An unexpected error occured: " + e.getMessage()  
184 - + ".\nPlease report it to the developper team along with the stacktrace.");  
185 - logger.log(Level.SEVERE, "Error occured when " + event.toString(), e); 183 + mainView.displayError("Error", e.getMessage());
  184 + logger.log(Level.WARNING,
  185 + "Exception thrown when " + event.toString() + ": " + e.getMessage());
186 } 186 }
187 } 187 }
188 } 188 }
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java
@@ -23,7 +23,6 @@ import java.io.InputStreamReader; @@ -23,7 +23,6 @@ import java.io.InputStreamReader;
23 import java.io.PrintWriter; 23 import java.io.PrintWriter;
24 import java.io.UnsupportedEncodingException; 24 import java.io.UnsupportedEncodingException;
25 import java.net.HttpURLConnection; 25 import java.net.HttpURLConnection;
26 -import java.net.MalformedURLException;  
27 import java.net.URL; 26 import java.net.URL;
28 import java.net.URLEncoder; 27 import java.net.URLEncoder;
29 import java.text.SimpleDateFormat; 28 import java.text.SimpleDateFormat;
@@ -31,7 +30,12 @@ import java.util.Date; @@ -31,7 +30,12 @@ import java.util.Date;
31 import java.util.logging.Logger; 30 import java.util.logging.Logger;
32 31
33 import eu.omp.irap.vespa.epntapclient.utils.Const; 32 import eu.omp.irap.vespa.epntapclient.utils.Const;
34 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.SendQueryException; 33 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException;
  34 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.BadResponseCodeException;
  35 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantGetErrorStream;
  36 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantGetResponseCode;
  37 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantOpenConnectionException;
  38 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException.CantPrintRequestResultException;
35 39
36 /** 40 /**
37 * This class provide HTTP connection support to send requests through POST / GET protocols. 41 * This class provide HTTP connection support to send requests through POST / GET protocols.
@@ -50,15 +54,14 @@ public final class VOTableConnection { @@ -50,15 +54,14 @@ public final class VOTableConnection {
50 } 54 }
51 55
52 /** 56 /**
53 - * @param targetURL The url of the registry to communicate (ie. "http://reg.g-vo.org"). 57 + * @param targetURL The URL of the registry to communicate (ie. "http://reg.g-vo.org").
54 * @param queryLanguage The language used for the queries (ie. "ADQL"). 58 * @param queryLanguage The language used for the queries (ie. "ADQL").
55 * @param query The query to ask to the registry. 59 * @param query The query to ask to the registry.
56 - * @throws HTTPRequestException Can not send the query.  
57 - * @throws BadRequestException The response code is not 200.  
58 * @return The path of the temporary XML file containing the http response. 60 * @return The path of the temporary XML file containing the http response.
  61 + * @throws CantSendQueryException If the query can not be sent.
59 */ 62 */
60 public static String sendQuery(String targetURL, String queryLanguage, 63 public static String sendQuery(String targetURL, String queryLanguage,
61 - String query) throws SendQueryException { 64 + String query) throws CantSendQueryException {
62 65
63 SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd_hhmmss_SSS"); 66 SimpleDateFormat ft = new SimpleDateFormat("yyyyMMdd_hhmmss_SSS");
64 String voTablePath = Const.TMP_DIR + "/votable" + ft.format(new Date()) + ".xml"; 67 String voTablePath = Const.TMP_DIR + "/votable" + ft.format(new Date()) + ".xml";
@@ -70,14 +73,14 @@ public final class VOTableConnection { @@ -70,14 +73,14 @@ public final class VOTableConnection {
70 .replace(".", "%2E").replace("-", "%2D").replace("*", "%2A") 73 .replace(".", "%2E").replace("-", "%2D").replace("*", "%2A")
71 .replace("_", "%5F"); 74 .replace("_", "%5F");
72 } catch (UnsupportedEncodingException e) { 75 } catch (UnsupportedEncodingException e) {
73 - throw new SendQueryException("Can not encode URI " + uri, e); 76 + throw new CantSendQueryException.MalformedURLException(uri, e);
74 } 77 }
75 78
76 logger.info("request: " + uri + "?" + parameters); 79 logger.info("request: " + uri + "?" + parameters);
77 try { 80 try {
78 printRequestResult(sendGet(uri, parameters), voTablePath); 81 printRequestResult(sendGet(uri, parameters), voTablePath);
79 } catch (IOException e) { 82 } catch (IOException e) {
80 - throw new SendQueryException("Can not print the result in a file.", e); 83 + throw new CantPrintRequestResultException(voTablePath, e);
81 } 84 }
82 85
83 return voTablePath; 86 return voTablePath;
@@ -86,12 +89,11 @@ public final class VOTableConnection { @@ -86,12 +89,11 @@ public final class VOTableConnection {
86 /** 89 /**
87 * @param url The target URL of the request. 90 * @param url The target URL of the request.
88 * @param urlParameters The parameters of the request. 91 * @param urlParameters The parameters of the request.
89 - * @param resultFileName The name of the file where the request response content is writed.  
90 - * @throws HTTPRequestException Can not send the request.  
91 - * @throws BadRequestException If the 92 + * @return A string builder containing the result of the query.
  93 + * @throws CantSendQueryException If the query can not be sent.
92 */ 94 */
93 public static StringBuilder sendGet(String url, String urlParameters) 95 public static StringBuilder sendGet(String url, String urlParameters)
94 - throws SendQueryException { 96 + throws CantSendQueryException {
95 String inputLine; 97 String inputLine;
96 StringBuilder response = new StringBuilder(); 98 StringBuilder response = new StringBuilder();
97 URL obj; 99 URL obj;
@@ -99,8 +101,8 @@ public final class VOTableConnection { @@ -99,8 +101,8 @@ public final class VOTableConnection {
99 101
100 try { 102 try {
101 obj = new URL(uri); 103 obj = new URL(uri);
102 - } catch (MalformedURLException e) {  
103 - throw new SendQueryException("The URI " + uri + " is not formated correctly.", e); 104 + } catch (java.net.MalformedURLException e) {
  105 + throw new CantSendQueryException.MalformedURLException(uri, e);
104 } 106 }
105 107
106 HttpURLConnection con; 108 HttpURLConnection con;
@@ -109,7 +111,7 @@ public final class VOTableConnection { @@ -109,7 +111,7 @@ public final class VOTableConnection {
109 con = (HttpURLConnection) obj.openConnection(); 111 con = (HttpURLConnection) obj.openConnection();
110 con.setRequestMethod("GET"); 112 con.setRequestMethod("GET");
111 } catch (IOException e) { 113 } catch (IOException e) {
112 - throw new SendQueryException("Can not open HTTP GET connection with uri " + uri, e); 114 + throw new CantOpenConnectionException(uri, e);
113 } 115 }
114 116
115 con.setRequestProperty("User-Agent", USER_AGENT); 117 con.setRequestProperty("User-Agent", USER_AGENT);
@@ -118,11 +120,11 @@ public final class VOTableConnection { @@ -118,11 +120,11 @@ public final class VOTableConnection {
118 try { 120 try {
119 code = con.getResponseCode(); 121 code = con.getResponseCode();
120 } catch (IOException e) { 122 } catch (IOException e) {
121 - throw new SendQueryException("Can not get the HTTP response code", e); 123 + throw new CantGetResponseCode(uri, e);
122 } 124 }
123 125
124 if (code != HttpURLConnection.HTTP_OK && code != HttpURLConnection.HTTP_BAD_REQUEST) { 126 if (code != HttpURLConnection.HTTP_OK && code != HttpURLConnection.HTTP_BAD_REQUEST) {
125 - throw new SendQueryException("The server returned a bad response code: " + code); 127 + throw new BadResponseCodeException(uri, code);
126 } 128 }
127 129
128 try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { 130 try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
@@ -130,7 +132,7 @@ public final class VOTableConnection { @@ -130,7 +132,7 @@ public final class VOTableConnection {
130 response.append(inputLine); 132 response.append(inputLine);
131 } 133 }
132 in.close(); 134 in.close();
133 - } catch (IOException e1) { 135 + } catch (@SuppressWarnings("unused") IOException e1) {
134 try (BufferedReader in = new BufferedReader( 136 try (BufferedReader in = new BufferedReader(
135 new InputStreamReader(con.getErrorStream()))) { 137 new InputStreamReader(con.getErrorStream()))) {
136 while ((inputLine = in.readLine()) != null) { 138 while ((inputLine = in.readLine()) != null) {
@@ -138,11 +140,7 @@ public final class VOTableConnection { @@ -138,11 +140,7 @@ public final class VOTableConnection {
138 } 140 }
139 in.close(); 141 in.close();
140 } catch (IOException e2) { 142 } catch (IOException e2) {
141 - throw new SendQueryException("Can not get the error stream.", e2);  
142 - }  
143 - if (code != HttpURLConnection.HTTP_BAD_REQUEST) {  
144 - throw new SendQueryException(  
145 - "The server returned a bad response code (not 200 neither 400).", e1); 143 + throw new CantGetErrorStream(uri, e2);
146 } 144 }
147 } 145 }
148 146
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java
@@ -19,11 +19,12 @@ package eu.omp.irap.vespa.epntapclient.votable.controller; @@ -19,11 +19,12 @@ package eu.omp.irap.vespa.epntapclient.votable.controller;
19 import java.io.IOException; 19 import java.io.IOException;
20 import java.util.logging.Logger; 20 import java.util.logging.Logger;
21 21
22 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.ErrorInVOTableException;  
23 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.VOTableCantFillVoTableException;  
24 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.VOTableParsingException;  
25 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.VOTableSeveralResourcesException;  
26 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.VOTableSeveralTablesException; 22 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException;
  23 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.CantModifyVOTableException;
  24 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.ErrorMessageInVOTableException;
  25 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.SeveralResourcesException;
  26 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.SeveralTablesException;
  27 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException;
27 import eu.omp.irap.vespa.epntapclient.votable.model.Table; 28 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
28 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; 29 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
29 import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; 30 import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
@@ -52,7 +53,7 @@ public class VOTableController { @@ -52,7 +53,7 @@ public class VOTableController {
52 * Method constructor 53 * Method constructor
53 * 54 *
54 * @param voTablePath The path of the VOTable XML file. 55 * @param voTablePath The path of the VOTable XML file.
55 - * @throws VOTableException 56 + * @throws VOTableException If something went wrong on the VOTable view or when filling table.
56 */ 57 */
57 public VOTableController(String voTablePath) throws VOTableException { 58 public VOTableController(String voTablePath) throws VOTableException {
58 view = new VOTableView(); 59 view = new VOTableView();
@@ -62,7 +63,7 @@ public class VOTableController { @@ -62,7 +63,7 @@ public class VOTableController {
62 /** 63 /**
63 * Method constructor 64 * Method constructor
64 * 65 *
65 - * @param targetURL The url of the registry to communicate (ie. "http://reg.g-vo.org"). 66 + * @param targetURL The URL of the registry to communicate (ie. "http://reg.g-vo.org").
66 * @param queryLanguage The language used for the queries (ie. "ADQL"). 67 * @param queryLanguage The language used for the queries (ie. "ADQL").
67 * @param query The query to ask to the registry. 68 * @param query The query to ask to the registry.
68 */ 69 */
@@ -77,46 +78,40 @@ public class VOTableController { @@ -77,46 +78,40 @@ public class VOTableController {
77 } 78 }
78 79
79 /** 80 /**
80 - * @param targetURL The url of the registry to communicate (ie. "http://reg.g-vo.org"). 81 + * @param targetURL The URL of the registry to communicate (ie. "http://reg.g-vo.org").
81 * @param queryLanguage The language used for the queries (ie. "ADQL"). 82 * @param queryLanguage The language used for the queries (ie. "ADQL").
82 * @param query The query to ask to the registry. 83 * @param query The query to ask to the registry.
83 - * @throws VOTableException Can not send the query or VOTable can not be parsed or can not fill  
84 - * the JTable. 84 + * @throws CantSendQueryException If the query can not be sent.
  85 + * @throws CantFillTableException If the table can not be filled. @see CantFillTableException
85 */ 86 */
86 public void fillTable(String targetURL, String queryLanguage, String query) 87 public void fillTable(String targetURL, String queryLanguage, String query)
87 - throws VOTableException {  
88 - fillTable(VOTableConnection.sendQuery(targetURL, queryLanguage, query)); 88 + throws CantFillTableException, CantSendQueryException {
  89 + String voTablePath = VOTableConnection.sendQuery(targetURL, queryLanguage, query);
  90 + fillTable(voTablePath);
89 } 91 }
90 92
91 /** 93 /**
92 * @param voTablePath The path of the VOTable file. 94 * @param voTablePath The path of the VOTable file.
93 - * @throws VOTableParsingException  
94 - * @throws VOTableSeveralResourcesException  
95 - * @throws ErrorInVOTableException  
96 - * @throws VOTableSeveralTablesException  
97 - * @throws VOTableCantFillVoTableException  
98 - * @throws VOTableException Can not fill the VOTable data in the JTable. 95 + * @throws CantFillTableException If the VOTable can not be filled.
99 */ 96 */
100 public void fillTable(String voTablePath) 97 public void fillTable(String voTablePath)
101 - throws VOTableParsingException, VOTableSeveralResourcesException,  
102 - ErrorInVOTableException, VOTableSeveralTablesException,  
103 - VOTableCantFillVoTableException { 98 + throws CantFillTableException {
104 99
105 voTable = VOTableParser.parseVOTable(voTablePath); 100 voTable = VOTableParser.parseVOTable(voTablePath);
106 101
107 // TODO: Handle the case when there are more than 1 resource or table. 102 // TODO: Handle the case when there are more than 1 resource or table.
108 if (voTable.getRESOURCE().size() > 1) { 103 if (voTable.getRESOURCE().size() > 1) {
109 - throw new VOTableSeveralResourcesException(voTablePath); 104 + throw new SeveralResourcesException(voTablePath);
110 } 105 }
111 106
112 // TODO: Iterate over all potential ERROR tags 107 // TODO: Iterate over all potential ERROR tags
113 if ("ERROR".equals(voTable.getRESOURCE().get(0).getINFO().get(0).getValueAttribute())) { 108 if ("ERROR".equals(voTable.getRESOURCE().get(0).getINFO().get(0).getValueAttribute())) {
114 String errorInfo = voTable.getRESOURCE().get(0).getINFO().get(0).getValue(); 109 String errorInfo = voTable.getRESOURCE().get(0).getINFO().get(0).getValue();
115 - throw new ErrorInVOTableException(errorInfo); 110 + throw new ErrorMessageInVOTableException(errorInfo);
116 } 111 }
117 112
118 if (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().size() > 1) { 113 if (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().size() > 1) {
119 - throw new VOTableSeveralTablesException(voTablePath); 114 + throw new SeveralTablesException(voTablePath);
120 } 115 }
121 116
122 Table table = (Table) (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0)); 117 Table table = (Table) (voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0));
@@ -126,7 +121,7 @@ public class VOTableController { @@ -126,7 +121,7 @@ public class VOTableController {
126 dataParser = new VOTableDataParser(table); 121 dataParser = new VOTableDataParser(table);
127 view.fillTable(dataParser.getColumnsName(), dataParser.getDataArray()); 122 view.fillTable(dataParser.getColumnsName(), dataParser.getDataArray());
128 } catch (IOException e) { 123 } catch (IOException e) {
129 - throw new VOTableCantFillVoTableException(e); 124 + throw new CantModifyVOTableException(e);
130 } 125 }
131 } 126 }
132 127
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java
@@ -19,60 +19,254 @@ package eu.omp.irap.vespa.epntapclient.votable.controller; @@ -19,60 +19,254 @@ package eu.omp.irap.vespa.epntapclient.votable.controller;
19 import java.io.IOException; 19 import java.io.IOException;
20 20
21 /** 21 /**
22 - * VOTable Exception class. 22 + * VOTableException is the global exception for all the VOTable application. All other exceptions
  23 + * should extend it.
23 * 24 *
24 * @author N. Jourdane 25 * @author N. Jourdane
25 */ 26 */
26 -@SuppressWarnings({ "javadoc", "serial" }) 27 +@SuppressWarnings("serial")
27 public abstract class VOTableException extends Exception { 28 public abstract class VOTableException extends Exception {
  29 + /** The serial version UID (affected with a random number). */
  30 + private static final long serialVersionUID = -5707662871529583209L;
  31 +
  32 + /**
  33 + * Method constructor
  34 + *
  35 + * @param message The message describing the exception displayed in the error dialog.
  36 + */
28 public VOTableException(String message) { 37 public VOTableException(String message) {
29 super(message); 38 super(message);
30 } 39 }
31 40
  41 + /**
  42 + * Method constructor
  43 + *
  44 + * @param message The message describing the exception displayed in the error dialog.
  45 + * @param e The exception thrown.
  46 + */
32 public VOTableException(String message, Exception e) { 47 public VOTableException(String message, Exception e) {
33 super(message, e); 48 super(message, e);
34 } 49 }
35 50
36 - public static class SendQueryException extends VOTableException {  
37 - public SendQueryException(String message) {  
38 - super("Can not send the query: " + message); 51 + /**
  52 + * Abstract exception for when the application can not send the query.
  53 + *
  54 + * @author N. Jourdane
  55 + */
  56 + public abstract static class CantSendQueryException extends VOTableException {
  57 +
  58 + /**
  59 + * Method constructor with a message.
  60 + *
  61 + * @param message The message describing the exception displayed in the error dialog.
  62 + */
  63 + public CantSendQueryException(String message) {
  64 + super(message);
39 } 65 }
40 66
41 - public SendQueryException(String message, Exception e) {  
42 - super("Can not send the query: " + message + " because " + e.getMessage(), e); 67 + /**
  68 + * Method constructor with a message and and exception.
  69 + *
  70 + * @param message The message describing the exception displayed in the error dialog.
  71 + * @param e The exception thrown.
  72 + */
  73 + public CantSendQueryException(String message, Exception e) {
  74 + super(message, e);
43 } 75 }
44 - }  
45 76
46 - public static class VOTableParsingException extends VOTableException {  
47 - public VOTableParsingException(String message, Exception e) {  
48 - super("Can not parse the VOTable: " + message + " because " + e.getMessage(), e); 77 + /**
  78 + * @author N. Jourdane
  79 + */
  80 + public static class MalformedURLException extends CantSendQueryException {
  81 + /**
  82 + * Method constructor
  83 + *
  84 + * @param uri The URI sent to the server.
  85 + * @param e The exception thrown.
  86 + */
  87 + public MalformedURLException(String uri, Exception e) {
  88 + super("The URL " + uri + " is not correctly formated.", e);
  89 + }
49 } 90 }
50 - }  
51 91
52 - public static class VOTableSeveralResourcesException extends VOTableException {  
53 - public VOTableSeveralResourcesException(String voTablePath) {  
54 - super("VOTable with more than one resource are not yet supported. \n"  
55 - + "See VOTable file for more informations: " + voTablePath); 92 + /**
  93 + * @author N. Jourdane
  94 + */
  95 + public static class CantPrintRequestResultException extends CantSendQueryException {
  96 + /**
  97 + * Method constructor
  98 + *
  99 + * @param resultFilePath The path of the file where the query results should be stored.
  100 + * @param e The exception thrown.
  101 + */
  102 + public CantPrintRequestResultException(String resultFilePath, IOException e) {
  103 + super("Can not print the result in the file " + resultFilePath, e);
  104 + }
56 } 105 }
57 - }  
58 106
59 - public static class VOTableSeveralTablesException extends VOTableException {  
60 - public VOTableSeveralTablesException(String voTablePath) {  
61 - super("VOTable with more than one resource are not yet supported. \n"  
62 - + "See VOTable file for more informations: " + voTablePath); 107 + /**
  108 + * @author N. Jourdane
  109 + */
  110 + public static class CantOpenConnectionException extends CantSendQueryException {
  111 + /**
  112 + * Method constructor
  113 + *
  114 + * @param uri The URI sent to the server.
  115 + * @param e The exception thrown.
  116 + */
  117 + public CantOpenConnectionException(String uri, IOException e) {
  118 + super("Can not open an HTTP connection to " + uri, e);
  119 + }
  120 + }
  121 +
  122 + /**
  123 + * @author N. Jourdane
  124 + */
  125 + public static class CantGetResponseCode extends CantSendQueryException {
  126 + /**
  127 + * Method constructor
  128 + *
  129 + * @param uri The URI sent to the server.
  130 + * @param e The exception thrown.
  131 + */
  132 + public CantGetResponseCode(String uri, IOException e) {
  133 + super("Can not get the server response code for the request " + uri, e);
  134 + }
  135 + }
  136 +
  137 + /**
  138 + * @author N. Jourdane
  139 + */
  140 + public static class BadResponseCodeException extends CantSendQueryException {
  141 + /**
  142 + * Method constructor
  143 + *
  144 + * @param uri The URI sent to the server.
  145 + * @param responseCode The HTTP GET response code, which is bad.
  146 + */
  147 + public BadResponseCodeException(String uri, int responseCode) {
  148 + super("The server returned the bad response code `" + responseCode
  149 + + "` for the request " + uri);
  150 + }
63 } 151 }
64 - }  
65 152
66 - public static class VOTableCantFillVoTableException extends VOTableException {  
67 - public VOTableCantFillVoTableException(IOException e) {  
68 - super("Can not fill the VOTable data in the JTable: " + e.getMessage(), e); 153 + /**
  154 + * @author N. Jourdane
  155 + */
  156 + public static class CantGetErrorStream extends CantSendQueryException {
  157 + /**
  158 + * Method constructor
  159 + *
  160 + * @param uri The URI sent to the server.
  161 + * @param e The exception thrown.
  162 + */
  163 + public CantGetErrorStream(String uri, IOException e) {
  164 + super("Can not get the input stream of the result, neither the error stream "
  165 + + "for the request " + uri);
  166 + }
69 } 167 }
  168 +
70 } 169 }
71 170
72 - public static class ErrorInVOTableException extends VOTableException {  
73 - public ErrorInVOTableException(String errorInfo) {  
74 - super("There is an error in the VOTable:\n" + errorInfo  
75 - + "\nPlease check your ADQL query."); 171 + /**
  172 + * @author N. Jourdane
  173 + */
  174 + public abstract static class CantDisplayVOTableException extends VOTableException {
  175 +
  176 + /**
  177 + * Method constructor
  178 + *
  179 + * @param message The message describing the exception displayed in the error dialog.
  180 + * @param e The exception thrown.
  181 + */
  182 + public CantDisplayVOTableException(String message, Exception e) {
  183 + super(message, e);
  184 + }
  185 +
  186 + /**
  187 + * Method constructor
  188 + *
  189 + * @param message The message describing the exception displayed in the error dialog.
  190 + */
  191 + public CantDisplayVOTableException(String message) {
  192 + super(message);
  193 + }
  194 +
  195 + /**
  196 + * @author N. Jourdane
  197 + */
  198 + public static class VOTableIsNotValidException extends CantDisplayVOTableException {
  199 +
  200 + /**
  201 + * Method constructor
  202 + *
  203 + * @param e The exception thrown.
  204 + */
  205 + public VOTableIsNotValidException(String voTablePath, Exception e) {
  206 + super("Can not parse the VOTable because it doesn't match with the VOTable schema."
  207 + + "\n See the VOTable file for more details: " + voTablePath, e);
  208 + }
  209 + }
  210 +
  211 + /**
  212 + * @author N. Jourdane
  213 + */
  214 + public static class SeveralResourcesException extends CantDisplayVOTableException {
  215 +
  216 + /**
  217 + * Method constructor
  218 + *
  219 + * @param voTablePath
  220 + */
  221 + public SeveralResourcesException(String voTablePath) {
  222 + super("VOTable with more than one resource are not yet supported. \n"
  223 + + "See VOTable file for more informations: " + voTablePath);
  224 + }
  225 + }
  226 +
  227 + /**
  228 + * @author N. Jourdane
  229 + */
  230 + public static class SeveralTablesException extends CantDisplayVOTableException {
  231 +
  232 + /**
  233 + * Method constructor
  234 + *
  235 + * @param voTablePath
  236 + */
  237 + public SeveralTablesException(String voTablePath) {
  238 + super("VOTable with more than one resource are not yet supported. \n"
  239 + + "See VOTable file for more informations: " + voTablePath);
  240 + }
  241 + }
  242 +
  243 + /**
  244 + * @author N. Jourdane
  245 + */
  246 + public static class CantModifyVOTableException extends CantDisplayVOTableException {
  247 + /**
  248 + * Method constructor
  249 + *
  250 + * @param e The exception thrown.
  251 + */
  252 + public CantModifyVOTableException(String voTablePath, Exception e) {
  253 + super("Can not change schema location on the VOTable file: " + voTablePath, e);
  254 + }
  255 + }
  256 +
  257 + /**
  258 + * @author N. Jourdane
  259 + */
  260 + public static class ErrorMessageInVOTableException extends CantDisplayVOTableException {
  261 + /**
  262 + * Method constructor
  263 + *
  264 + * @param errorInfo
  265 + */
  266 + public ErrorMessageInVOTableException(String errorInfo) {
  267 + super("There is an error in the VOTable:\n" + errorInfo
  268 + + "\nPlease check your ADQL query.");
  269 + }
76 } 270 }
77 } 271 }
78 272
src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableParser.java
@@ -36,7 +36,7 @@ import org.w3c.dom.Document; @@ -36,7 +36,7 @@ import org.w3c.dom.Document;
36 import org.w3c.dom.NamedNodeMap; 36 import org.w3c.dom.NamedNodeMap;
37 import org.xml.sax.SAXException; 37 import org.xml.sax.SAXException;
38 38
39 -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.VOTableParsingException; 39 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantFillTableException.VOTableParsingException;
40 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; 40 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
41 41
42 /** 42 /**