Skip to content

Commit e4eeac6

Browse files
Merge pull request #156 from weblyzard/feature/annotation-service
add: generic class allowing to connect to any AnnotationService
2 parents 8aee5bf + f114413 commit e4eeac6

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.weblyzard.api.client;
2+
3+
import javax.ws.rs.client.Entity;
4+
import javax.ws.rs.core.MediaType;
5+
import javax.ws.rs.core.Response;
6+
import com.weblyzard.api.model.document.Document;
7+
import com.weblyzard.api.service.AnnotationService;
8+
9+
/**
10+
* Provide access to Web services implementing the AnnotationService interface.
11+
*
12+
* @see AnnotationService
13+
*
14+
* @author Philipp Kuntschik
15+
* @author Albert Weichselbraun
16+
*/
17+
public class GenericAnnotatorClient extends BasicClient implements AnnotationService {
18+
19+
20+
private static final String ANNOTATE_DOCUMENT_SERVICE_URL = "/rest/annotate_document";
21+
22+
public GenericAnnotatorClient(WebserviceClientConfig c) {
23+
super(c, "/annotator");
24+
}
25+
26+
@Override
27+
public Document annotateDocument(Document data) {
28+
29+
try (Response response = super.getTarget(ANNOTATE_DOCUMENT_SERVICE_URL)
30+
.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(data))) {
31+
32+
super.checkResponseStatus(response);
33+
Document result = response.readEntity(Document.class);
34+
return result;
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)