Skip to content

Commit

Permalink
Merge pull request #156 from weblyzard/feature/annotation-service
Browse files Browse the repository at this point in the history
add: generic class allowing to connect to any AnnotationService
  • Loading branch information
AlbertWeichselbraun authored Nov 22, 2018
2 parents 8aee5bf + f114413 commit e4eeac6
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/java/main/com/weblyzard/api/client/GenericAnnotatorClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.weblyzard.api.client;

import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.weblyzard.api.model.document.Document;
import com.weblyzard.api.service.AnnotationService;

/**
* Provide access to Web services implementing the AnnotationService interface.
*
* @see AnnotationService
*
* @author Philipp Kuntschik
* @author Albert Weichselbraun
*/
public class GenericAnnotatorClient extends BasicClient implements AnnotationService {


private static final String ANNOTATE_DOCUMENT_SERVICE_URL = "/rest/annotate_document";

public GenericAnnotatorClient(WebserviceClientConfig c) {
super(c, "/annotator");
}

@Override
public Document annotateDocument(Document data) {

try (Response response = super.getTarget(ANNOTATE_DOCUMENT_SERVICE_URL)
.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(data))) {

super.checkResponseStatus(response);
Document result = response.readEntity(Document.class);
return result;
}
}
}

0 comments on commit e4eeac6

Please sign in to comment.