mawiesne commented on code in PR #97:
URL: https://github.com/apache/opennlp-sandbox/pull/97#discussion_r1167954561


##########
corpus-server/corpus-server-connector/src/main/java/org/apache/opennlp/corpus_server/connector/CSQueueCollectionReader.java:
##########
@@ -79,62 +81,57 @@ public void initialize() throws 
ResourceInitializationException {
     corpusName = (String) getConfigParameterValue(CORPUS_NAME);
     
     String queueName = (String) getConfigParameterValue(QUEUE_NAME);
-    
     String searchQuery = (String) getConfigParameterValue(SEARCH_QUERY);
     
-    Client client = Client.create();
-    
+    Client c = ClientBuilder.newClient();
+
     // Create a queue if the search query is specified
     if (searchQuery != null) {
-      WebResource r = client.resource(serverAddress + "/queues/");
+      WebTarget r = c.target(serverAddress + "/queues/");
 
-      ClientResponse response = r.path("_createTaskQueue")
+      try (Response response = r.path("_createTaskQueue")
           .queryParam("corpusId", corpusName)
           .queryParam("queueId", queueName)
           .queryParam("q", searchQuery)
-          .accept(MediaType.TEXT_XML)
-          // TODO: How to fix this? Shouldn't accept do it?
-          .header("Content-Type", MediaType.TEXT_XML)
-          .post(ClientResponse.class);
-      
-      if (response.getStatus() != 204) {
-         throw new ResourceInitializationException(
-                         new Exception("Failed to create queue: " + 
response.getStatus()));
-      }
-      
-      if (logger.isLoggable(Level.INFO)) {
-        logger.log(Level.INFO, "Successfully created queue: " + queueName + " 
for corpus: " + corpusName);
+          .request(MediaType.TEXT_XML)
+          // as this is an query-param driven POST request,
+          // we just set an empty string to the body.
+          .post(Entity.entity("", MediaType.TEXT_PLAIN_TYPE))) {
+
+        if (response.getStatus() != 204) {
+          throw new ResourceInitializationException(
+                  new Exception("Failed to create queue: " + 
response.getStatus()));

Review Comment:
   It's because of `ResourceInitializationException extends UIMAException` and 
those only provide 1 constructor to pass in a simple cause via a 
(Runtime)Exception. All other constructors of `ResourceInitializationException` 
require the name of a resource bundle (`ResourceBundle`) and one or more keys 
as argument... 
   
   Long story short: I will re-write the lines 102 and 103 to create a 
_RuntimeException_ as this is what's happening. Won't change other things here, 
see explanation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@opennlp.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to