Commit e669c5d39fadbbc38773a6d289339874d336c53a

Authored by Nathanael Jourdane
1 parent 8ac245d4
Exists in master

Improve Javadoc.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java
... ... @@ -29,8 +29,9 @@ import eu.omp.irap.vespa.epntapclient.voresource.VOResourceCtrl;
29 29 import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException;
30 30 import eu.omp.irap.vespa.epntapclient.voresource.model.Resource;
31 31 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
32   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
33 32 import eu.omp.irap.vespa.votable.controller.VOTableController;
  33 +import eu.omp.irap.vespa.votable.controller.VOTableException;
  34 +import eu.omp.irap.vespa.votable.controller.VOTableException.CantReadVOTableException;
34 35 import eu.omp.irap.vespa.votable.utils.StringJoiner;
35 36 import eu.omp.irap.vespa.votable.votabledata.VOTableData;
36 37  
... ... @@ -50,7 +51,7 @@ public class EpnTapConnection implements EpnTapInterface {
50 51  
51 52 @Override
52 53 public List<Resource> getEPNVOResources() throws VOResourceException {
53   - List<String> ivoids = VOResourceCtrl.getVOResources(ServiceCore.EPNCORE);
  54 + List<String> ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE);
54 55 return VOResourceCtrl.getVOResources(ivoids);
55 56 }
56 57  
... ... @@ -64,14 +65,14 @@ public class EpnTapConnection implements EpnTapInterface {
64 65 // *** Service ***
65 66  
66 67 @Override
67   - public VOTABLE getEPNService(String ivoid) throws CantGetVOTableException {
  68 + public VOTABLE getEPNService(String ivoid) throws VOTableException {
68 69 String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_IVOID, ivoid);
69 70 return ServiceCtrl.getVoTable(query);
70 71 }
71 72  
72 73 @Override
73 74 public VOTABLE getEPNService(String ivoid, List<String> attributes)
74   - throws CantGetVOTableException {
  75 + throws VOTableException {
75 76 String select = StringJoiner.join(attributes);
76 77 String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, select, ivoid);
77 78 return ServiceCtrl.getVoTable(query);
... ... @@ -80,14 +81,14 @@ public class EpnTapConnection implements EpnTapInterface {
80 81 // *** Services ***
81 82  
82 83 @Override
83   - public VOTABLE getEPNServices() throws CantGetVOTableException {
  84 + public VOTABLE getEPNServices() throws VOTableException {
84 85 String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE,
85 86 ServiceCore.EPNCORE);
86 87 return ServiceCtrl.getVoTable(query);
87 88 }
88 89  
89 90 @Override
90   - public VOTABLE getEPNServices(List<String> attributes) throws CantGetVOTableException {
  91 + public VOTABLE getEPNServices(List<String> attributes) throws VOTableException {
91 92 String select = StringJoiner.join(attributes);
92 93 String query = String.format(Queries.SELECT_TAP_SERVICES, select);
93 94 return ServiceCtrl.getVoTable(query);
... ... @@ -95,7 +96,7 @@ public class EpnTapConnection implements EpnTapInterface {
95 96  
96 97 @Override
97 98 public VOTABLE getEPNServices(List<String> keywords, List<String> attributes)
98   - throws CantGetVOTableException {
  99 + throws VOTableException {
99 100 attributes.add("res_subject");
100 101 String select = StringJoiner.join(attributes);
101 102 List<String> whereList = new ArrayList<>();
... ... @@ -110,12 +111,12 @@ public class EpnTapConnection implements EpnTapInterface {
110 111 // *** Getters ***
111 112  
112 113 @Override
113   - public String getEPNCoreTableName(String ivoid) throws CantGetVOTableException {
  114 + public String getEPNCoreTableName(String ivoid) throws VOTableException {
114 115 return (String) ServiceCtrl.getParameter(ivoid, "table_name");
115 116 }
116 117  
117 118 @Override
118   - public String getTAPURL(String ivoid) throws CantGetVOTableException {
  119 + public String getTAPURL(String ivoid) throws VOTableException {
119 120 return (String) ServiceCtrl.getParameter(ivoid, "access_url");
120 121 }
121 122  
... ... @@ -123,7 +124,7 @@ public class EpnTapConnection implements EpnTapInterface {
123 124  
124 125 @Override
125 126 public List<Granule> sendADQLQuery(String tapURL, String adqlQuery)
126   - throws CantGetVOTableException {
  127 + throws VOTableException {
127 128 VOTableController voTableCtrl = new VOTableController(tapURL, adqlQuery);
128 129 voTableCtrl.readTable();
129 130 VOTableData data = voTableCtrl.getVOTableData();
... ... @@ -133,14 +134,14 @@ public class EpnTapConnection implements EpnTapInterface {
133 134 GranuleCtrl gc = new GranuleCtrl(data);
134 135 granules = gc.getGranules();
135 136 } catch (ParseException e) {
136   - throw new CantGetVOTableException("Parsing error on a granule.", e);
  137 + throw new CantReadVOTableException("Parsing error on a granule.", e);
137 138 }
138 139 return granules;
139 140 }
140 141  
141 142 @Override
142 143 public List<Granule> sendQuery(String tapURL, String schemaName, Query enumeratedQuery)
143   - throws CantGetVOTableException {
  144 + throws VOTableException {
144 145 String query = String.format(enumeratedQuery.toString(), schemaName);
145 146 VOTableController voTableCtrl = new VOTableController(tapURL, query);
146 147 voTableCtrl.readTable();
... ... @@ -151,7 +152,7 @@ public class EpnTapConnection implements EpnTapInterface {
151 152 GranuleCtrl gc = new GranuleCtrl(data);
152 153 granules = gc.getGranules();
153 154 } catch (ParseException e) {
154   - throw new CantGetVOTableException("Parsing error on a granule.", e);
  155 + throw new CantReadVOTableException("Parsing error on a granule.", e);
155 156 }
156 157 return granules;
157 158 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java
... ... @@ -22,7 +22,7 @@ import java.util.logging.Logger;
22 22 import eu.omp.irap.vespa.epntapclient.service.Queries;
23 23 import eu.omp.irap.vespa.epntapclient.service.ServiceCore;
24 24 import eu.omp.irap.vespa.votable.Consts;
25   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  25 +import eu.omp.irap.vespa.votable.controller.VOTableException;
26 26 import eu.omp.irap.vespa.votable.controller.VOTableController;
27 27  
28 28 /**
... ... @@ -66,7 +66,7 @@ public class EpnTapController {
66 66 public void readServices() {
67 67 try {
68 68 servicesCtrl.readTable();
69   - } catch (CantGetVOTableException e) {
  69 + } catch (VOTableException e) {
70 70 displayError("Can not get services.", e);
71 71 }
72 72 }
... ... @@ -87,10 +87,10 @@ public class EpnTapController {
87 87 *
88 88 * @param query An ADQL query to send.
89 89 * @param tableServiceURL the URL of the service.
90   - * @throws CantGetVOTableException Can not get the VOTable.
  90 + * @throws VOTableException Can not get the VOTable.
91 91 */
92 92 public void sendQuery(String query, String tableServiceURL)
93   - throws CantGetVOTableException {
  93 + throws VOTableException {
94 94 resultsCtrl = new VOTableController(tableServiceURL, query);
95 95 resultsCtrl.readTable();
96 96 voTablePath = resultsCtrl.getVOTablePath();
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java
... ... @@ -23,7 +23,7 @@ import eu.omp.irap.vespa.epntapclient.granule.GranuleEnum;
23 23 import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException;
24 24 import eu.omp.irap.vespa.epntapclient.voresource.model.Resource;
25 25 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
26   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  26 +import eu.omp.irap.vespa.votable.controller.VOTableException;
27 27  
28 28 /**
29 29 * @author N. Jourdane
... ... @@ -74,9 +74,9 @@ public interface EpnTapInterface {
74 74 *
75 75 * @param ivoid The ivoid of the service to get.
76 76 * @return A VOTable containing the service.
77   - * @throws CantGetVOTableException Can not get the VOTable.
  77 + * @throws VOTableException Can not get the VOTable.
78 78 */
79   - public VOTABLE getEPNService(String ivoid) throws CantGetVOTableException;
  79 + public VOTABLE getEPNService(String ivoid) throws VOTableException;
80 80  
81 81 /**
82 82 * Returns a VOTable containing the attributes of the corresponding service (from the list of
... ... @@ -86,10 +86,10 @@ public interface EpnTapInterface {
86 86 * @param attributes A list of attributes, which are the column names to get.
87 87 * @return A VOTable containing the service.
88 88 * @see GranuleEnum The EpnTapv2 column names.
89   - * @throws CantGetVOTableException Can not get the VOTable.
  89 + * @throws VOTableException Can not get the VOTable.
90 90 */
91 91 public VOTABLE getEPNService(String ivoid, List<String> attributes)
92   - throws CantGetVOTableException;
  92 + throws VOTableException;
93 93  
94 94 // *** Services ***
95 95  
... ... @@ -98,9 +98,9 @@ public interface EpnTapInterface {
98 98 * predefined list).
99 99 *
100 100 * @return A VOTable containing the services.
101   - * @throws CantGetVOTableException Can not get the VOTable.
  101 + * @throws VOTableException Can not get the VOTable.
102 102 */
103   - public VOTABLE getEPNServices() throws CantGetVOTableException;
  103 + public VOTABLE getEPNServices() throws VOTableException;
104 104  
105 105 /**
106 106 * Returns a VOTable containing the list of EPN-TAP services and their attributes (from the list
... ... @@ -108,9 +108,9 @@ public interface EpnTapInterface {
108 108 *
109 109 * @param attributes A list of attributes, which are the column names to get.
110 110 * @return A VOTable containing the services.
111   - * @throws CantGetVOTableException Can not get the VOTable.
  111 + * @throws VOTableException Can not get the VOTable.
112 112 */
113   - public VOTABLE getEPNServices(List<String> attributes) throws CantGetVOTableException;
  113 + public VOTABLE getEPNServices(List<String> attributes) throws VOTableException;
114 114  
115 115 /**
116 116 * Returns a VOTable containing the list of EPN-TAP services corresponding to the keywords and
... ... @@ -120,10 +120,10 @@ public interface EpnTapInterface {
120 120 * rr.res_subject of a registry.
121 121 * @param attributes A list of attributes, which are the column names to get.
122 122 * @return A VOTable containing the services.
123   - * @throws CantGetVOTableException Can not get the VOTable.
  123 + * @throws VOTableException Can not get the VOTable.
124 124 */
125 125 public VOTABLE getEPNServices(List<String> keywords, List<String> attributes)
126   - throws CantGetVOTableException;
  126 + throws VOTableException;
127 127  
128 128 // *** Getters ***
129 129  
... ... @@ -132,18 +132,18 @@ public interface EpnTapInterface {
132 132 *
133 133 * @param ivoid The ivoid of the service.
134 134 * @return The table name of the service, used usually in the 'FROM' keyword in a ADQL query.
135   - * @throws CantGetVOTableException Can not get the VOTable.
  135 + * @throws VOTableException Can not get the VOTable.
136 136 */
137   - public String getEPNCoreTableName(String ivoid) throws CantGetVOTableException;
  137 + public String getEPNCoreTableName(String ivoid) throws VOTableException;
138 138  
139 139 /**
140 140 * Returns the Access URL of an EPN-TAP Service.
141 141 *
142 142 * @param ivoid the ivoid of the service.
143 143 * @return The target URL of the service, used usually to process requests on it.
144   - * @throws CantGetVOTableException Can not get the VOTable.
  144 + * @throws VOTableException Can not get the VOTable.
145 145 */
146   - public String getTAPURL(String ivoid) throws CantGetVOTableException;
  146 + public String getTAPURL(String ivoid) throws VOTableException;
147 147  
148 148 // *** Queries ***
149 149  
... ... @@ -155,10 +155,10 @@ public interface EpnTapInterface {
155 155 * @param tapURL The URL of the service.
156 156 * @param adqlQuery The ADQL query.
157 157 * @return A list of Granules resulting the query.
158   - * @throws CantGetVOTableException Can not get the VOTable.
  158 + * @throws VOTableException Can not get the VOTable.
159 159 */
160 160 public List<Granule> sendADQLQuery(String tapURL, String adqlQuery)
161   - throws CantGetVOTableException;
  161 + throws VOTableException;
162 162  
163 163 /**
164 164 * Returns the list of granules which are compliant with the Query, in VOTable format. "Query"
... ... @@ -169,8 +169,8 @@ public interface EpnTapInterface {
169 169 * @param schemaName The name of the service schema.
170 170 * @param query The query, from a list a predefined queries.
171 171 * @return A list of granules resulting the query.
172   - * @throws CantGetVOTableException Can not get the VOTable.
  172 + * @throws VOTableException Can not get the VOTable.
173 173 */
174 174 public List<Granule> sendQuery(String tapURL, String schemaName, Query query)
175   - throws CantGetVOTableException;
  175 + throws VOTableException;
176 176 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java
... ... @@ -25,7 +25,7 @@ import eu.omp.irap.vespa.epntapclient.EpnTapController;
25 25 import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl;
26 26 import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelCtrl;
27 27 import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelCtrl;
28   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  28 +import eu.omp.irap.vespa.votable.controller.VOTableException;
29 29  
30 30 /**
31 31 * @author N. Jourdane
... ... @@ -62,7 +62,7 @@ public class MainPanelCtrl extends EpnTapController {
62 62 public void readServices() {
63 63 try {
64 64 servicesPanelCtrl.readTable();
65   - } catch (CantGetVOTableException e) {
  65 + } catch (VOTableException e) {
66 66 displayError("Can not get services.", e);
67 67 }
68 68 view.getServicesPanel().fillTable(servicesPanelCtrl.getVOTableData());
... ... @@ -79,7 +79,7 @@ public class MainPanelCtrl extends EpnTapController {
79 79 try {
80 80 resultPanelCtrl.updateVOTable(serviceURL, query);
81 81 view.getResultsPanel().fillTable(resultPanelCtrl.getVOTableData());
82   - } catch (CantGetVOTableException e) {
  82 + } catch (VOTableException e) {
83 83 displayError("Can not send the query.", e);
84 84 LOGGER.log(Level.WARNING, "Can not send query.", e);
85 85 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java
... ... @@ -49,8 +49,7 @@ public class ResultPanelView extends VOTableView {
49 49 * Method constructor which customize the result panel, but don't build it from scratch since
50 50 * VOTableView is already created by ResultController.
51 51 *
52   - * @param mainView The main view of the application.
53   - * @param voTableView The generic view of the VOTable panel.
  52 + * @param listener The listener of the result view.
54 53 */
55 54 public ResultPanelView(ResultPanelListener listener) {
56 55 super();
... ... @@ -58,6 +57,9 @@ public class ResultPanelView extends VOTableView {
58 57 buildResultPanel();
59 58 }
60 59  
  60 + /**
  61 + * Build the panel and add graphical elements to it.
  62 + */
61 63 public void buildResultPanel() {
62 64 JPanel statusBar = new JPanel();
63 65 statusBar.setLayout(new BorderLayout());
... ... @@ -67,6 +69,11 @@ public class ResultPanelView extends VOTableView {
67 69 add(statusBar, BorderLayout.SOUTH);
68 70 }
69 71  
  72 + /**
  73 + * Returns the info label, create it if doesn't exist.
  74 + *
  75 + * @return The info label.
  76 + */
70 77 public JLabel getInfoLabel() {
71 78 return infoLabel == null ? new JLabel() : infoLabel;
72 79 }
... ... @@ -78,6 +85,11 @@ public class ResultPanelView extends VOTableView {
78 85 infoLabel.setText(infoText);
79 86 }
80 87  
  88 + /**
  89 + * Returns the button to save the VOTable, create it if doesn't exist.
  90 + *
  91 + * @return The button to save the VOTable.
  92 + */
81 93 public JButton getFileButton() {
82 94 if (fileButton == null) {
83 95 fileButton = new JButton("Get File");
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java
... ... @@ -32,8 +32,10 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane
32 32 /** The logger for the class ServicesPanelCtrl. */
33 33 private static final Logger LOGGER = Logger.getLogger(ServicesPanelCtrl.class.getName());
34 34  
  35 + /** The controller of the main panel. */
35 36 private MainPanelCtrl mainPanelCtrl;
36 37  
  38 + /** The view of the services panel. */
37 39 private ServicesPanelView view;
38 40  
39 41 /** The name of the table selected by the user on the table list panel. */
... ... @@ -43,6 +45,11 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane
43 45 private String selectedServiceURL;
44 46  
45 47  
  48 + /**
  49 + * Constructor of ServicesPanelCtrl
  50 + *
  51 + * @param mainPanelCtrl The controller of the main panel.
  52 + */
46 53 public ServicesPanelCtrl(MainPanelCtrl mainPanelCtrl) {
47 54 this.mainPanelCtrl = mainPanelCtrl;
48 55 targetURL = Consts.DEFAULT_REGISTRY_URL;
... ... @@ -50,14 +57,23 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane
50 57 view = new ServicesPanelView(this);
51 58 }
52 59  
  60 + /**
  61 + * @return The view of the services panel.
  62 + */
53 63 public ServicesPanelView getView() {
54 64 return view;
55 65 }
56 66  
  67 + /**
  68 + * @return The table name of the service selected by the user on the services table list.
  69 + */
57 70 public String getSelectedTableName() {
58 71 return selectedTableName;
59 72 }
60 73  
  74 + /**
  75 + * @return The access URL of the service selected by the user on the services table list.
  76 + */
61 77 public String getSelectedServiceURL() {
62 78 return selectedServiceURL;
63 79 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/service/Queries.java
... ... @@ -23,10 +23,17 @@ package eu.omp.irap.vespa.epntapclient.service;
23 23 */
24 24 public final class Queries {
25 25  
26   - private static final String SELECT = "SELECT DISTINCT ivoid, access_url, res_title, "
  26 + /**
  27 + * The default SELECT keyword content of the query, which select standard service column names.
  28 + */
  29 + private static final String SELECT_SERVICE = "SELECT DISTINCT ivoid, access_url, res_title, "
27 30 + "short_name, table_name, content_type, res_description, creator_seq, content_level, "
28 31 + "reference_url, created, updated ";
29 32  
  33 + /** The default SELECT keyword */
  34 + private static final String SELECT = "SELECT DISTINCT ";
  35 +
  36 + /** The default FROM keyword content of the query, which links all required tables. */
30 37 private static final String FROM = "FROM rr.resource "
31 38 + "NATURAL JOIN rr.res_schema "
32 39 + "NATURAL JOIN rr.res_table "
... ... @@ -34,8 +41,10 @@ public final class Queries {
34 41 + "NATURAL JOIN rr.res_detail "
35 42 + "NATURAL JOIN rr.capability ";
36 43  
  44 + /** The default ORDER BY keyword content of the query. */
37 45 private static final String ORDER_BY = "ORDER BY short_name, table_name";
38 46  
  47 + /** The default WHERE keyword content of the query, in order to get only TAP services. */
39 48 private static final String WHERE_TAP = "WHERE "
40 49 + "standard_id='ivo://ivoa.net/std/tap' AND "
41 50 + "intf_type='vs:paramhttp' AND "
... ... @@ -45,29 +54,34 @@ public final class Queries {
45 54  
46 55 /** Query to get all TAP services. */
47 56 public static final String SELECT_ALL_TAP_SERVICES =
48   - SELECT + FROM + WHERE_TAP + ORDER_BY;
  57 + SELECT_SERVICE + FROM + WHERE_TAP + ORDER_BY;
  58 +
  59 + /** Query to get the specified columns (%s #1) of all TAP services. */
  60 + public static final String SELECT_TAP_SERVICES =
  61 + SELECT + "%s " + FROM + WHERE_TAP;
49 62  
50   - /** Query to get TAP services which implement the specified core. */
  63 + /** Query to get TAP services which implement the specified core (%s #1). */
51 64 public static final String SELECT_ALL_TAP_SERVICES_WHERE_CORE =
52   - SELECT + FROM + WHERE_TAP
  65 + SELECT_SERVICE + FROM + WHERE_TAP
53 66 + "AND 1=ivo_nocasematch(detail_value, 'ivo://vopdc.obspm/std/%s%%') " + ORDER_BY;
54 67  
55   - /** Query to get the TAP service with the specified ivoid. */
  68 + /** Query to get the TAP service with the specified ivoid (%s #1). */
56 69 public static final String SELECT_ALL_TAP_SERVICES_WHERE_IVOID =
57   - SELECT + FROM + WHERE_TAP + "AND ivoid = '%s'";
  70 + SELECT_SERVICE + FROM + WHERE_TAP + "AND ivoid = '%s'";
58 71  
  72 + /** Query to get the specified column names (%s #1) of TAP service with the specified ivoid (%s #2). */
59 73 public static final String SELECT_TAP_SERVICES_WHERE_IVOID =
60   - "SELECT DISTINCT %s " + FROM + WHERE_TAP + "AND ivoid = '%s'";
61   -
62   - public static final String SELECT_TAP_SERVICES =
63   - "SELECT DISTINCT %s " + FROM + WHERE_TAP;
  74 + SELECT + "%s " + FROM + WHERE_TAP + "AND ivoid = '%s'";
64 75  
  76 + /** Query to get the specified column names (%s #1) of TAP service with the specified subject (%s #2). */
65 77 public static final String SELECT_TAP_SERVICES_WHERE_SUBJECT =
66   - "SELECT DISTINCT %s " + FROM + "NATURAL JOIN rr.res_subject " + WHERE_TAP + "AND (%s)";
  78 + SELECT + "%s " + FROM + "NATURAL JOIN rr.res_subject " + WHERE_TAP + "AND (%s)";
67 79  
  80 + /** Query to get the specified column names (%s #1) of any table. */
68 81 public static final String SELECT_FROM =
69   - "SELECT DISTINCT %s FROM %s";
  82 + SELECT + "%s FROM %s";
70 83  
  84 + /** Query to select all columns of any table. */
71 85 public static final String SELECT_ALL =
72 86 "SELECT DISTINCT * FROM %s";
73 87 //@format
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java
... ... @@ -30,7 +30,7 @@ import eu.omp.irap.vespa.epntapclient.voresource.model.Type;
30 30 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
31 31 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
32 32 import eu.omp.irap.vespa.votable.Consts;
33   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  33 +import eu.omp.irap.vespa.votable.controller.VOTableException;
34 34 import eu.omp.irap.vespa.votable.controller.VOTableController;
35 35 import eu.omp.irap.vespa.votable.utils.StringJoiner;
36 36 import eu.omp.irap.vespa.votable.votabledata.VOTableData;
... ... @@ -111,9 +111,9 @@ public class ServiceCtrl {
111 111 /**
112 112 * @param query The query to get the service.
113 113 * @return The VOTableData
114   - * @throws CantGetVOTableException Can not get the VOTable.
  114 + * @throws VOTableException Can not get the VOTable.
115 115 */
116   - public static VOTableData getVoTableData(String query) throws CantGetVOTableException {
  116 + public static VOTableData getVoTableData(String query) throws VOTableException {
117 117 return getVoTableData(getVoTable(query));
118 118 }
119 119  
... ... @@ -122,9 +122,9 @@ public class ServiceCtrl {
122 122 *
123 123 * @param voTable The VOTable parsed.
124 124 * @return The corresponding VOTableData.
125   - * @throws CantGetVOTableException Can not get the VOTable.
  125 + * @throws VOTableException Can not get the VOTable.
126 126 */
127   - public static VOTableData getVoTableData(VOTABLE voTable) throws CantGetVOTableException {
  127 + public static VOTableData getVoTableData(VOTABLE voTable) throws VOTableException {
128 128 VOTableController.checkVOTable(voTable);
129 129  
130 130 Table table = (Table) voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0);
... ... @@ -133,29 +133,58 @@ public class ServiceCtrl {
133 133 return dataParser.getData();
134 134 }
135 135  
136   - public static VOTABLE getVoTable(String query) throws CantGetVOTableException {
  136 + /**
  137 + * @param query The query.
  138 + * @return The VOTable resulting the query.
  139 + * @throws VOTableException Can not get the VOTable.
  140 + */
  141 + public static VOTABLE getVoTable(String query) throws VOTableException {
137 142 VOTableController voTableCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query);
138 143 voTableCtrl.readTable();
139 144 return voTableCtrl.getVOTable();
140 145 }
141 146  
  147 + /**
  148 + * @param ivoid The ivoid of the service.
  149 + * @param parameters The parameters to get, separated by commas.
  150 + * @return A map of <parameter name, value> resulting the request.
  151 + * @throws VOTableException Can not get the VOTable.
  152 + */
142 153 public static Map<String, Object> getParameters(String ivoid, String parameters)
143   - throws CantGetVOTableException {
  154 + throws VOTableException {
144 155 String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameters, ivoid);
145 156 return getVoTableData(query).getRowMap(0);
146 157 }
147 158  
  159 + /**
  160 + * @param ivoid The ivoid of the service.
  161 + * @param parameters A list of parameters to get.
  162 + * @return A map of <parameter name, value> resulting the request.
  163 + * @throws VOTableException Can not get the VOTable.
  164 + */
148 165 public static Map<String, Object> getParameters(String ivoid, List<String> parameters)
149   - throws CantGetVOTableException {
  166 + throws VOTableException {
150 167 return getParameters(ivoid, StringJoiner.join(parameters));
151 168 }
152 169  
153   - public static Object getParameter(String ivoid, String parameters)
154   - throws CantGetVOTableException {
155   - String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameters, ivoid);
  170 + /**
  171 + * @param ivoid The ivoid of the service.
  172 + * @param parameter The unique parameter to get.
  173 + * @return The value of the parameter.
  174 + * @throws VOTableException Can not get the VOTable.
  175 + */
  176 + public static Object getParameter(String ivoid, String parameter)
  177 + throws VOTableException {
  178 + String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameter, ivoid);
156 179 return getVoTableData(query).getCell(0, 0);
157 180 }
158 181  
  182 + /**
  183 + * Convert a date from XMLGregorianCalendar to a string literal.
  184 + *
  185 + * @param date The date to convert
  186 + * @return The serialized date.
  187 + */
159 188 private static String xmlDateToString(XMLGregorianCalendar date) {
160 189 SimpleDateFormat sdf = new SimpleDateFormat(ServiceCtrl.DATE_FORMAT);
161 190 return sdf.format(date.toGregorianCalendar().getTime());
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java
... ... @@ -36,6 +36,7 @@ import com.google.gson.JsonObject;
36 36  
37 37 import eu.omp.irap.vespa.epntapclient.service.ServiceCore;
38 38 import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException.CantGetVOResourceException;
  39 +import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException.CantReadVOResourceException;
39 40 import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException.VOResourceIsNotValidException;
40 41 import eu.omp.irap.vespa.epntapclient.voresource.model.Resource;
41 42 import eu.omp.irap.vespa.votable.utils.CantSendQueryException;
... ... @@ -51,30 +52,44 @@ public class VOResourceCtrl {
51 52 /** The logger for the class VOResourceController. */
52 53 private static final Logger LOGGER = Logger.getLogger(VOResourceCtrl.class.getName());
53 54  
  55 + /** The URL used to get the resources in VOResource (XML) format. */
54 56 private static final String GET_VORESOURCE_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources.xml";
55 57  
  58 + /** The URL used to get the resources in JSON format. */
56 59 private static final String GET_JSONRESOURCES_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search";
57 60  
  61 + /** The maximum number of resulting resources. */
58 62 private static final int MAX_VORESOURCES = 100;
59 63  
  64 + /** The new schema location, since one in the dowloaded VOResource is not compliant. */
60 65 private static final String SCHEMA_LOCATION = "http://www.ivoa.net/xml/RegistryInterface/v1.0 "
61 66 + "http://www.ivoa.net/xml/RegistryInterface/v1.0 "
62 67 + "http://www.ivoa.net/xml/VODataService/v1.1 "
63 68 + "http://www.ivoa.net/xml/TAPRegExt/v1.0";
64 69  
  70 + /** The URL of the VS namespace, since it is not present in the dowloaded VOResource. */
65 71 private static final String NAMESPACE_VS = "http://www.ivoa.net/xml/TAPRegExt/v1.0";
66 72  
  73 + /** The URL of the TR namespace, since it is not present in the dowloaded VOResource. */
67 74 private static final String NAMESPACE_TR = "http://www.ivoa.net/xml/VODataService/v1.1";
68 75  
69 76  
  77 + /** Private constructor to hide the default public one. */
70 78 private VOResourceCtrl() {
71 79 }
72 80  
73   - public static List<String> getVOResources(ServiceCore type) throws VOResourceException {
  81 + /**
  82 + * Get the list of ivoIDs of all resources which implements the specified core.
  83 + *
  84 + * @param core The service core (ie. ObsCore, EpnCore, etc.)
  85 + * @return A list of ivoIDs
  86 + * @throws VOResourceException Can not get the VOResource.
  87 + */
  88 + public static List<String> getIvoidResources(ServiceCore core) throws VOResourceException {
74 89 List<String> ivoidResources;
75 90 Map<String, String> parameters = new HashMap<>();
76 91  
77   - parameters.put("keywords", "datamodel:\"" + type.toString() + "\"");
  92 + parameters.put("keywords", "datamodel:\"" + core.toString() + "\"");
78 93 parameters.put("max", String.valueOf(MAX_VORESOURCES));
79 94 String query = Network.buildQuery(GET_JSONRESOURCES_URL, parameters);
80 95 try {
... ... @@ -86,13 +101,23 @@ public class VOResourceCtrl {
86 101 return ivoidResources;
87 102 }
88 103  
89   - public static List<String> getVOResources(ServiceCore type, List<String> keywords)
  104 + /**
  105 + * Get the list of ivoIDs of all resources which implements the specified core and match with
  106 + * the keywords.
  107 + *
  108 + * @param core The service core (ie. ObsCore, EpnCore, etc.)
  109 + * @param keywords A list of keywords to filter the result. The keywords are the subjects of the
  110 + * resources, for example, 'Space plasmas'.
  111 + * @return A list of ivoIDs
  112 + * @throws CantGetVOResourceException Can not get the VOResource.
  113 + */
  114 + public static List<String> getVOResources(ServiceCore core, List<String> keywords)
90 115 throws CantGetVOResourceException {
91 116 List<String> ivoidResources;
92 117 Map<String, String> parameters = new HashMap<>();
93 118 String subjects = StringJoiner.join(keywords);
94 119 parameters.put("keywords",
95   - "datamodel:\"" + type.toString() + "\" subjects:\"" + subjects + "\"");
  120 + "datamodel:\"" + core.toString() + "\" subjects:\"" + subjects + "\"");
96 121 parameters.put("max", String.valueOf(MAX_VORESOURCES));
97 122  
98 123 String query = Network.buildQuery(GET_JSONRESOURCES_URL, parameters);
... ... @@ -105,6 +130,13 @@ public class VOResourceCtrl {
105 130 return ivoidResources;
106 131 }
107 132  
  133 + /**
  134 + * Get a resource from its identifier.
  135 + *
  136 + * @param identifier The resource identifier.
  137 + * @return The returned resource.
  138 + * @throws VOResourceException Can not get the VOResource.
  139 + */
108 140 public static Resource getVOresource(String identifier) throws VOResourceException {
109 141 Map<String, String> parameters = new HashMap<>();
110 142 parameters.put("identifier", identifier);
... ... @@ -122,7 +154,7 @@ public class VOResourceCtrl {
122 154 try {
123 155 changeNamespaces(voResourcePath);
124 156 } catch (IOException e) {
125   - throw new VOResourceException("The VOResource file can not be modified.", e);
  157 + throw new CantReadVOResourceException("The VOResource file can not be modified.", e);
126 158 }
127 159  
128 160 Resource voResource;
... ... @@ -140,14 +172,13 @@ public class VOResourceCtrl {
140 172 return voResource;
141 173 }
142 174  
143   - private static void changeNamespaces(String voResourcePath) throws IOException {
144   - Map<String, String> attributes = new HashMap<>();
145   - attributes.put("xsi:schemaLocation", SCHEMA_LOCATION);
146   - attributes.put("xmlns:vs", NAMESPACE_VS);
147   - attributes.put("xmlns:tr", NAMESPACE_TR);
148   - XMLUtils.changeRootAttributes(voResourcePath, attributes);
149   - }
150   -
  175 + /**
  176 + * Get a list of Resources from a list of ivoid.
  177 + *
  178 + * @param ivoidResources A list of ivoIds
  179 + * @return A list of Resources corresponding to the ivoIDs.
  180 + * @throws VOResourceException Can not get the VOResource.
  181 + */
151 182 public static List<Resource> getVOResources(List<String> ivoidResources)
152 183 throws VOResourceException {
153 184 List<Resource> resources = new ArrayList<>();
... ... @@ -157,6 +188,26 @@ public class VOResourceCtrl {
157 188 return resources;
158 189 }
159 190  
  191 + /**
  192 + * Change the namespaces of the VOResource to make the XML file valid against its XSD.
  193 + *
  194 + * @param voResourcePath The file path of the VOResource.
  195 + * @throws IOException Can not read or write on the VOResource file.
  196 + */
  197 + private static void changeNamespaces(String voResourcePath) throws IOException {
  198 + Map<String, String> attributes = new HashMap<>();
  199 + attributes.put("xsi:schemaLocation", SCHEMA_LOCATION);
  200 + attributes.put("xmlns:vs", NAMESPACE_VS);
  201 + attributes.put("xmlns:tr", NAMESPACE_TR);
  202 + XMLUtils.changeRootAttributes(voResourcePath, attributes);
  203 + }
  204 +
  205 + /**
  206 + * Parse a JSON query result and returns a list of ivoid.
  207 + *
  208 + * @param getIvoidsResult The JSON object result a query. See {@link #GET_JSONRESOURCES_URL}.
  209 + * @return A list of ivoIDs.
  210 + */
160 211 private static List<String> parseIvoidResources(JsonObject getIvoidsResult) {
161 212 JsonArray resources = getIvoidsResult.get("resources").getAsJsonArray();
162 213 List<String> ivoidResources = new ArrayList<>();
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceException.java
... ... @@ -17,11 +17,13 @@
17 17 package eu.omp.irap.vespa.epntapclient.voresource;
18 18  
19 19 /**
  20 + * The general abstract class for all exceptions concerning the VOResources.
  21 + *
20 22 * @author N. Jourdane
21 23 */
22   -public class VOResourceException extends Exception {
  24 +public abstract class VOResourceException extends Exception {
23 25  
24   - /** */
  26 + /** The serial version UID. */
25 27 private static final long serialVersionUID = 1L;
26 28  
27 29  
... ... @@ -41,6 +43,7 @@ public class VOResourceException extends Exception {
41 43 }
42 44  
43 45  
  46 + /** An exception thrown when we can not read the VOResource. */
44 47 public static class CantReadVOResourceException extends VOResourceException {
45 48  
46 49 /** The serial version UID. */
... ... @@ -48,7 +51,7 @@ public class VOResourceException extends Exception {
48 51  
49 52  
50 53 /**
51   - * @param voTablePath The path of the VOTable.
  54 + * @param voResourcePath The path of the VOResource.
52 55 * @param e The exception thrown.
53 56 */
54 57 public CantReadVOResourceException(String voResourcePath, Exception e) {
... ... @@ -56,6 +59,7 @@ public class VOResourceException extends Exception {
56 59 }
57 60 }
58 61  
  62 + /** An exception thrown when we can not get the VOResource, ie. an error in the query. */
59 63 public static class CantGetVOResourceException extends VOResourceException {
60 64  
61 65 /** The serial version UID. */
... ... @@ -63,7 +67,7 @@ public class VOResourceException extends Exception {
63 67  
64 68  
65 69 /**
66   - * @param voTablePath The path of the VOTable.
  70 + * @param voResourceRequest The path of the VOResource.
67 71 * @param e The exception thrown.
68 72 */
69 73 public CantGetVOResourceException(String voResourceRequest, Exception e) {
... ... @@ -71,6 +75,9 @@ public class VOResourceException extends Exception {
71 75 }
72 76 }
73 77  
  78 + /**
  79 + * An exception thrown when the VOResource is not valid, ie. it don't have the expected body.
  80 + */
74 81 public static class VOResourceIsNotValidException extends VOResourceException {
75 82  
76 83 /** The serial version UID. */
... ... @@ -78,7 +85,7 @@ public class VOResourceException extends Exception {
78 85  
79 86  
80 87 /**
81   - * @param voTablePath The path of the VOTable.
  88 + * @param voResourcePath The path of the VOResource.
82 89 * @param e The exception thrown.
83 90 */
84 91 public VOResourceIsNotValidException(String voResourcePath, Exception e) {
... ...
src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java
... ... @@ -33,7 +33,7 @@ import eu.omp.irap.vespa.epntapclient.service.ServiceCtrl;
33 33 import eu.omp.irap.vespa.epntapclient.voresource.VOResourceException;
34 34 import eu.omp.irap.vespa.epntapclient.voresource.model.Resource;
35 35 import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
36   -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
  36 +import eu.omp.irap.vespa.votable.controller.VOTableException;
37 37 import eu.omp.irap.vespa.votable.votabledata.VOTableData;
38 38  
39 39 /**
... ... @@ -153,10 +153,10 @@ public class EpnTapConnectionTest {
153 153 /**
154 154 * Unit test for the class {@link EpnTapConnection#getEPNService(String)}.
155 155 *
156   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  156 + * @throws VOTableException Can not get the VOTable corresponding to the service.
157 157 */
158 158 @Test
159   - public void getEPNServiceTest() throws CantGetVOTableException {
  159 + public void getEPNServiceTest() throws VOTableException {
160 160 LOGGER.info("getEPNServiceTest");
161 161 EpnTapConnection facade = new EpnTapConnection();
162 162  
... ... @@ -175,10 +175,10 @@ public class EpnTapConnectionTest {
175 175 /**
176 176 * Unit test for the class {@link EpnTapConnection#getEPNService(String, List)}.
177 177 *
178   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  178 + * @throws VOTableException Can not get the VOTable corresponding to the service.
179 179 */
180 180 @Test
181   - public void getEPNServiceWithAttributesTest() throws CantGetVOTableException {
  181 + public void getEPNServiceWithAttributesTest() throws VOTableException {
182 182 LOGGER.info("getEPNServiceWithAttributesTest");
183 183 EpnTapConnection facade = new EpnTapConnection();
184 184  
... ... @@ -200,10 +200,10 @@ public class EpnTapConnectionTest {
200 200 /**
201 201 * Unit test for the class {@link EpnTapConnection#getEPNServices()}.
202 202 *
203   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  203 + * @throws VOTableException Can not get the VOTable corresponding to the service.
204 204 */
205 205 @Test
206   - public void getEPNServicesTest() throws CantGetVOTableException {
  206 + public void getEPNServicesTest() throws VOTableException {
207 207 LOGGER.info("getEPNServicesTest");
208 208  
209 209 EpnTapConnection facade = new EpnTapConnection();
... ... @@ -234,11 +234,11 @@ public class EpnTapConnectionTest {
234 234 /**
235 235 * Unit test for the class {@link EpnTapConnection#getEPNServices(List)}.
236 236 *
237   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  237 + * @throws VOTableException Can not get the VOTable corresponding to the service.
238 238 */
239 239 @Test
240 240 public void getEPNServicesWithAttributesTest()
241   - throws CantGetVOTableException {
  241 + throws VOTableException {
242 242 LOGGER.info("getEPNServicesWithAttributesTest");
243 243 EpnTapConnection facade = new EpnTapConnection();
244 244  
... ... @@ -265,12 +265,12 @@ public class EpnTapConnectionTest {
265 265 /**
266 266 * Unit test for the class {@link EpnTapConnection#getEPNServices(List, List)}.
267 267 *
268   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  268 + * @throws VOTableException Can not get the VOTable corresponding to the service.
269 269 * @throws VOResourceException Can not get the VOresource.
270 270 */
271 271 @Test
272 272 public void getEPNServicesWithKeywordsAndAttributesTest()
273   - throws CantGetVOTableException, VOResourceException {
  273 + throws VOTableException, VOResourceException {
274 274 LOGGER.info("getEPNServicesWithKeywordsAndAttributesTest");
275 275 EpnTapConnection facade = new EpnTapConnection();
276 276  
... ... @@ -302,10 +302,10 @@ public class EpnTapConnectionTest {
302 302 /**
303 303 * Unit test for the class {@link EpnTapConnection#getEPNCoreTableName(String)}.
304 304 *
305   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  305 + * @throws VOTableException Can not get the VOTable corresponding to the service.
306 306 */
307 307 @Test
308   - public void getEPNCoreTableNameTest() throws CantGetVOTableException {
  308 + public void getEPNCoreTableNameTest() throws VOTableException {
309 309 LOGGER.info("getEPNCoreTableNameTest");
310 310 EpnTapConnection facade = new EpnTapConnection();
311 311  
... ... @@ -317,10 +317,10 @@ public class EpnTapConnectionTest {
317 317 /**
318 318 * Unit test for the class {@link EpnTapConnection#getTAPURL(String)}.
319 319 *
320   - * @throws CantGetVOTableException Can not get the VOTable corresponding to the service.
  320 + * @throws VOTableException Can not get the VOTable corresponding to the service.
321 321 */
322 322 @Test
323   - public void getTAPURLTest() throws CantGetVOTableException {
  323 + public void getTAPURLTest() throws VOTableException {
324 324 LOGGER.info("getTAPURLTest");
325 325 EpnTapConnection facade = new EpnTapConnection();
326 326  
... ... @@ -334,10 +334,10 @@ public class EpnTapConnectionTest {
334 334 /**
335 335 * Unit test for the class {@link EpnTapConnection#sendADQLQuery(String, String)}.
336 336 *
337   - * @throws CantGetVOTableException Can not get the VOTable resulting the query.
  337 + * @throws VOTableException Can not get the VOTable resulting the query.
338 338 */
339 339 @Test
340   - public void sendADQLQueryTest() throws CantGetVOTableException {
  340 + public void sendADQLQueryTest() throws VOTableException {
341 341 LOGGER.info("sendADQLQueryTest");
342 342 EpnTapConnection facade = new EpnTapConnection();
343 343  
... ... @@ -360,10 +360,10 @@ public class EpnTapConnectionTest {
360 360 /**
361 361 * Unit test for the class {@link EpnTapConnection#sendQuery(String, String, Query)}.
362 362 *
363   - * @throws CantGetVOTableException Can not get the VOTable resulting the query.
  363 + * @throws VOTableException Can not get the VOTable resulting the query.
364 364 */
365 365 @Test
366   - public void sendADQLQueryWithSchemaNameTest() throws CantGetVOTableException {
  366 + public void sendADQLQueryWithSchemaNameTest() throws VOTableException {
367 367 LOGGER.info("sendADQLQueryWithSchemaNameTest");
368 368 EpnTapConnection facade = new EpnTapConnection();
369 369 List<Granule> granules = facade.sendQuery(SERVICE_EPNCOREV2_ACCESS_URL,
... ...