public Graph extractPersons(@FormParam("uri") String uriString) {
if (uriString == null || uriString.length() == 0)
throw new WebApplicationException(Response.status(
Response.Status.BAD_REQUEST).entity(new StringBuilder("No URI specified").toString()).build());
UIMAExecutor executor = UIMAExecutorFactory.getInstance().createUIMAExecutor();
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(OUTPUTGRAPH, uriString);
try {
URL url = URI.create(uriString).toURL();
String text = IOUtils.toString(url.openConnection().getInputStream());
executor.analyzeDocument(text, new XMLInputSource(getClass().getResource(PATH)), parameters);
} catch (Exception e) {
throw new WebApplicationException(Response.status(
Response.Status.INTERNAL_SERVER_ERROR).entity(new StringBuilder("Failed UIMA execution on URI ").
append(uriString).append(" due to \n").append(e.getLocalizedMessage()).toString()).build());
}