Mentions légales du service

Skip to content
Snippets Groups Projects
Commit bbec0227 authored by RAVERDY Pierre-Guillaume's avatar RAVERDY Pierre-Guillaume
Browse files

Merge branch 'index-manifest-after' into 'master'

Manifest indexed during check not extract

Closes #17

See merge request !10
parents 330380cd 241f73c0
No related branches found
No related tags found
1 merge request!10Manifest indexed during check not extract
...@@ -357,6 +357,9 @@ public class Check extends HttpServlet { ...@@ -357,6 +357,9 @@ public class Check extends HttpServlet {
_store.addAnnotationList(tAnnotationListJSON); _store.addAnnotationList(tAnnotationListJSON);
_logger.debug("Imported annotation list:"); _logger.debug("Imported annotation list:");
indexManifest(key);
_logger.debug("Indexed manifest:");
annotationStatus = "Automatic annotations uploaded (" + tAnnotationListJSON.size() + ")"; annotationStatus = "Automatic annotations uploaded (" + tAnnotationListJSON.size() + ")";
} catch (Exception tException) { } catch (Exception tException) {
...@@ -368,6 +371,34 @@ public class Check extends HttpServlet { ...@@ -368,6 +371,34 @@ public class Check extends HttpServlet {
return resp_part1 + resp_part2 + getExtractResultOk(jobId, status, annotationStatus) + resp_part3; return resp_part1 + resp_part2 + getExtractResultOk(jobId, status, annotationStatus) + resp_part3;
} }
private void indexManifest(String manifestUrl) throws IOException {
ServletContext context = getServletContext();
try {
// use direct localhost as https/ssl cannot be validated without creating keystore
// TODO : use constants or build using servelt configuration
String url = "http://127.0.0.1:8080/manifests";
String result = "";
HttpPost post = new HttpPost(url);
// add request parameters or form parameters
String TEXT_STRING="uri=" + manifestUrl ;
HttpEntity stringEntity = new StringEntity(TEXT_STRING, ContentType.APPLICATION_FORM_URLENCODED);
post.setEntity(stringEntity);
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(post)) {
result = EntityUtils.toString(response.getEntity());
}
return;
} catch (Exception error) {
error.printStackTrace();
}
}
String buildResponseError(String errorCpde) { String buildResponseError(String errorCpde) {
return resp_part1 + resp_part2 + getExtractResultError(errorCpde) + resp_part3; return resp_part1 + resp_part2 + getExtractResultError(errorCpde) + resp_part3;
} }
......
...@@ -57,7 +57,8 @@ public class Extract extends HttpServlet { ...@@ -57,7 +57,8 @@ public class Extract extends HttpServlet {
String result = ""; String result = "";
HttpPost post = new HttpPost(url); HttpPost post = new HttpPost(url);
indexManifest(pReq.getParameter("uri")); // XXX this is now done in Check
// indexManifest(pReq.getParameter("uri"));
// add request parameters or form parameters // add request parameters or form parameters
String JSON_STRING="{\"manifestUrls\":[\"" + pReq.getParameter("uri") + "\"]}"; String JSON_STRING="{\"manifestUrls\":[\"" + pReq.getParameter("uri") + "\"]}";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment