Commit b1c5c3ccf56b1eefaff78c4aede32e55b1c4ae5e
1 parent
81f20aff
Exists in
master
remove test to request the registry with keywords
Showing
4 changed files
with
2 additions
and
207 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java
... | ... | @@ -94,26 +94,7 @@ public class EpnTapConnection implements EpnTapInterface { |
94 | 94 | return ServiceCtrl.getVoTable(query); |
95 | 95 | } |
96 | 96 | |
97 | - @Override | |
98 | - public Resource getEPNVOresource(String ivoid) throws VOResourceException { | |
99 | - return VOResourceCtrl.getVOresource(ivoid); | |
100 | - } | |
101 | - | |
102 | - @Override | |
103 | - public List<Resource> getEPNVOResources() throws VOResourceException { | |
104 | - List<String> ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE); | |
105 | - return VOResourceCtrl.getVOResources(ivoids); | |
106 | - } | |
107 | - | |
108 | 97 | // *** Getters *** |
109 | - | |
110 | - @Override | |
111 | - public List<Resource> getEPNVOResources(List<String> keywords) | |
112 | - throws VOResourceException { | |
113 | - List<String> ivoids = VOResourceCtrl.getVOResources(ServiceCore.EPNCORE, keywords); | |
114 | - return VOResourceCtrl.getVOResources(ivoids); | |
115 | - } | |
116 | - | |
117 | 98 | @Override |
118 | 99 | public String getTAPURL(String ivoid) throws VOTableException { |
119 | 100 | return (String) ServiceCtrl.getParameter(ivoid, "access_url"); | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapInterface.java
... | ... | @@ -103,38 +103,6 @@ public interface EpnTapInterface { |
103 | 103 | VOTABLE getEPNServices(List<String> keywords, List<String> attributes) |
104 | 104 | throws VOTableException; |
105 | 105 | |
106 | - /** | |
107 | - * Returns the VOResource element of the service identified by the ivoID. | |
108 | - * | |
109 | - * @param ivoid the ivoid of the service. | |
110 | - * @return The Resource of a service corresponding to the ivoid | |
111 | - * @throws VOResourceException Can not get the VOResource. | |
112 | - */ | |
113 | - Resource getEPNVOresource(String ivoid) throws VOResourceException; | |
114 | - | |
115 | - /** | |
116 | - * Returns a set of VOResource elements (one per EPN-TAP service). | |
117 | - * | |
118 | - * @return A list containing the VOResources of all EpnTap services. | |
119 | - * @throws VOResourceException Can not get the VOResource. | |
120 | - */ | |
121 | - List<Resource> getEPNVOResources() throws VOResourceException; | |
122 | - | |
123 | - // *** Getters *** | |
124 | - | |
125 | - /** | |
126 | - * Returns a set of VOREsource elements (one per EPN-TAP service corresponding to the keywords). | |
127 | - * The way keywords are defined is still to be defined. | |
128 | - * | |
129 | - * @param keywords A list of keywords, which are the content of the *subject* JSON node in the | |
130 | - * query. | |
131 | - * @see <a href= | |
132 | - * "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search?keywords=standardid:%22ivo://ivoa.net/std/TAP%22%20subjects:%22Spectroscopy%22&max=100"> | |
133 | - * this example request</a> | |
134 | - * @return A list containing the selected VOResources. | |
135 | - * @throws VOResourceException Can not get the VOResource. | |
136 | - */ | |
137 | - List<Resource> getEPNVOResources(List<String> keywords) throws VOResourceException; | |
138 | 106 | |
139 | 107 | /** |
140 | 108 | * Returns the Access URL of an EPN-TAP Service. | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java
... | ... | @@ -52,9 +52,6 @@ public class VOResourceCtrl { |
52 | 52 | /** The URL used to get the resources in JSON format. */ |
53 | 53 | private static final String GET_JSONRESOURCES_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search"; |
54 | 54 | |
55 | - /** The URL used to get the resources in VOResource (XML) format. */ | |
56 | - private static final String GET_VORESOURCE_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources.xml"; | |
57 | - | |
58 | 55 | /** The logger for the class VOResourceController. */ |
59 | 56 | private static final Logger LOGGER = Logger.getLogger(VOResourceCtrl.class.getName()); |
60 | 57 | |
... | ... | @@ -95,71 +92,13 @@ public class VOResourceCtrl { |
95 | 92 | try { |
96 | 93 | ivoidResources = parseIvoidResources(JsonUtils.readJsonFromNetwork(query)); |
97 | 94 | } catch (CantSendQueryException e) { |
98 | - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); | |
95 | + throw new CantGetVOResourceException(query, e); | |
99 | 96 | } |
100 | 97 | LOGGER.info("Got resources: " + StringJoiner.join(ivoidResources)); |
101 | 98 | return ivoidResources; |
102 | 99 | } |
103 | 100 | |
104 | 101 | /** |
105 | - * Get a resource from its identifier. | |
106 | - * | |
107 | - * @param identifier The resource identifier. | |
108 | - * @return The returned resource. | |
109 | - * @throws VOResourceException Can not get the VOResource. | |
110 | - */ | |
111 | - public static Resource getVOresource(String identifier) throws VOResourceException { | |
112 | - Map<String, String> parameters = new HashMap<>(); | |
113 | - parameters.put("identifier", identifier); | |
114 | - String voResourcePath; | |
115 | - | |
116 | - try { | |
117 | - LOGGER.fine("Trying to get VOResource '" + identifier + "'..."); | |
118 | - String query = Network.buildGetRequest(GET_VORESOURCE_URL, parameters); | |
119 | - voResourcePath = Network.saveQuery(query); | |
120 | - } catch (CantSendQueryException e) { | |
121 | - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); | |
122 | - } | |
123 | - LOGGER.fine("VOResource downloaded in " + voResourcePath); | |
124 | - | |
125 | - try { | |
126 | - changeNamespaces(voResourcePath); | |
127 | - } catch (IOException e) { | |
128 | - throw new CantReadVOResourceException("The VOResource file can not be modified.", e); | |
129 | - } | |
130 | - | |
131 | - Resource voResource; | |
132 | - try { | |
133 | - File inputStream = new File(voResourcePath); | |
134 | - | |
135 | - Source source = new StreamSource(inputStream); | |
136 | - JAXBContext jc = JAXBContext.newInstance(Resource.class); | |
137 | - Unmarshaller unmarshaller = jc.createUnmarshaller(); | |
138 | - voResource = unmarshaller.unmarshal(source, Resource.class).getValue(); | |
139 | - | |
140 | - } catch (JAXBException e) { | |
141 | - throw new VOResourceIsNotValidException(voResourcePath, e); | |
142 | - } | |
143 | - return voResource; | |
144 | - } | |
145 | - | |
146 | - /** | |
147 | - * Get a list of Resources from a list of ivoid. | |
148 | - * | |
149 | - * @param ivoidResources A list of ivoIds | |
150 | - * @return A list of Resources corresponding to the ivoIDs. | |
151 | - * @throws VOResourceException Can not get the VOResource. | |
152 | - */ | |
153 | - public static List<Resource> getVOResources(List<String> ivoidResources) | |
154 | - throws VOResourceException { | |
155 | - List<Resource> resources = new ArrayList<>(); | |
156 | - for (String ivoid : ivoidResources) { | |
157 | - resources.add(getVOresource(ivoid)); | |
158 | - } | |
159 | - return resources; | |
160 | - } | |
161 | - | |
162 | - /** | |
163 | 102 | * Get the list of ivoIDs of all resources which implements the specified core and match with |
164 | 103 | * the keywords. |
165 | 104 | * |
... | ... | @@ -182,7 +121,7 @@ public class VOResourceCtrl { |
182 | 121 | try { |
183 | 122 | ivoidResources = parseIvoidResources(JsonUtils.readJsonFromNetwork(query)); |
184 | 123 | } catch (CantSendQueryException e) { |
185 | - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); | |
124 | + throw new CantGetVOResourceException(query, e); | |
186 | 125 | } |
187 | 126 | LOGGER.info("Got resources: " + StringJoiner.join(ivoidResources)); |
188 | 127 | return ivoidResources; | ... | ... |
src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java
... | ... | @@ -233,99 +233,6 @@ public class EpnTapConnectionTest { |
233 | 233 | assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name")); |
234 | 234 | } |
235 | 235 | |
236 | - /** | |
237 | - * Unit test for the class {@link EpnTapConnection#getEPNVOResources()}. | |
238 | - * | |
239 | - * @throws VOResourceException Can not get the VOresource. | |
240 | - */ | |
241 | - @Test | |
242 | - public void getEPNVOResourcesTest() throws VOResourceException { | |
243 | - LOGGER.info("getEPNVOResourcesTest"); | |
244 | - EpnTapConnection facade = new EpnTapConnection(); | |
245 | - | |
246 | - List<Resource> resources = facade.getEPNVOResources(); | |
247 | - | |
248 | - int nbResources = resources.size(); | |
249 | - assertTrue(nbResources + " < 10", nbResources >= 10); | |
250 | - | |
251 | - Resource amda = null; | |
252 | - Resource apis = null; | |
253 | - for (Resource resource : resources) { | |
254 | - if (AMDA_IVOID.equals(resource.getIdentifier())) { | |
255 | - amda = resource; | |
256 | - } | |
257 | - if (APIS_IVOID.equals(resource.getIdentifier())) { | |
258 | - apis = resource; | |
259 | - } | |
260 | - } | |
261 | - assertNotNull("AMDA resource should be present.", amda); | |
262 | - assertNotNull("APIS resource should be present.", apis); | |
263 | - assertEquals(AMDA_SHORT_NAME, amda.getShortName()); | |
264 | - assertEquals(APIS_SHORT_NAME, apis.getShortName()); | |
265 | - } | |
266 | - | |
267 | - /** | |
268 | - * Unit test for the class {@link EpnTapConnection#getEPNVOResources(List)}. | |
269 | - * | |
270 | - * @throws VOResourceException Can not get the VOresource. | |
271 | - */ | |
272 | - @Test | |
273 | - public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException { | |
274 | - LOGGER.info("getEPNVOResourcesWithKeywordsTest"); | |
275 | - EpnTapConnection facade = new EpnTapConnection(); | |
276 | - | |
277 | - final List<String> keywords = new ArrayList<>(); | |
278 | - keywords.add("Virtual Observatory"); | |
279 | - keywords.add("Plasma Physics"); | |
280 | - keywords.add("Planetary Systems"); | |
281 | - List<Resource> resources = facade.getEPNVOResources(keywords); | |
282 | - | |
283 | - assertEquals(resources.size(), 1); | |
284 | - | |
285 | - Resource amda = null; | |
286 | - for (Resource resource : resources) { | |
287 | - if (AMDA_IVOID.equals(resource.getIdentifier())) { | |
288 | - amda = resource; | |
289 | - } | |
290 | - } | |
291 | - assertNotNull("AMDA resource should be present.", amda); | |
292 | - } | |
293 | - | |
294 | - // *** Getters *** | |
295 | - | |
296 | - /** | |
297 | - * Unit test for the class {@link EpnTapConnection#getTAPURL(String)}. | |
298 | - * | |
299 | - * @throws VOTableException Can not get the VOTable corresponding to the service. | |
300 | - */ | |
301 | - @Test | |
302 | - public void getTAPURLTest() throws VOTableException { | |
303 | - LOGGER.info("getTAPURLTest"); | |
304 | - EpnTapConnection facade = new EpnTapConnection(); | |
305 | - | |
306 | - String tapURL = facade.getTAPURL(AMDA_IVOID); | |
307 | - | |
308 | - assertEquals(AMDA_ACCESS_URL, tapURL); | |
309 | - } | |
310 | - | |
311 | - /** | |
312 | - * Unit test for the class {@link EpnTapConnection#getEPNVOresource(String)}. | |
313 | - * | |
314 | - * @throws VOResourceException Can not get the VOresource. | |
315 | - */ | |
316 | - @Test | |
317 | - public void getVOResourceTest() throws VOResourceException { | |
318 | - LOGGER.info("getVOResourceTest"); | |
319 | - EpnTapConnection facade = new EpnTapConnection(); | |
320 | - | |
321 | - Resource resource = facade.getEPNVOresource(AMDA_IVOID); | |
322 | - | |
323 | - assertEquals("AMDA", resource.getShortName()); | |
324 | - assertEquals("Planetary and heliophysics plasma data at CDPP/AMDA", resource.getTitle()); | |
325 | - assertEquals("M. Gangloff", | |
326 | - resource.getCuration().getCreator().get(0).getName().getValue()); | |
327 | - } | |
328 | - | |
329 | 236 | // *** Queries *** |
330 | 237 | |
331 | 238 | /** | ... | ... |