throw new ServletException(e1);
}
- String jsonResponse = null;
-
long startTimeInMs = System.currentTimeMillis();
visContext.processSelfLinks(searchtargetEntity, queryParams);
GraphMeta graphMeta = new GraphMeta();
- D3VisualizationOutput output = null;
- try {
- output = transformer
- .generateVisualizationOutput((System.currentTimeMillis() - opStartTimeInMs), graphMeta);
- } catch (JsonProcessingException exc) {
- throw new ServletException("Caught an exception while generation visualization output", exc);
- } catch (IOException exc) {
- LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, exc.getLocalizedMessage());
- }
+ D3VisualizationOutput output = getD3VisualizationOutput(opStartTimeInMs, transformer, graphMeta);
- output.setInlineMessage(visContext.getInlineMessage());
- output.getGraphMeta().setNumLinkResolveFailed(visContext.getNumFailedLinkResolve());
- output.getGraphMeta().setNumLinksResolvedSuccessfullyFromCache(
- visContext.getNumSuccessfulLinkResolveFromCache());
- output.getGraphMeta().setNumLinksResolvedSuccessfullyFromServer(
- visContext.getNumSuccessfulLinkResolveFromFromServer());
+ String jsonResponse = null;
- try {
- jsonResponse = transformer.convertVisualizationOutputToJson(output);
- } catch (JsonProcessingException jpe) {
- throw new ServletException(
- "Caught an exception while converting visualization output to json", jpe);
+ if (output != null) {
+ output.setInlineMessage(visContext.getInlineMessage());
+ output.getGraphMeta().setNumLinkResolveFailed(visContext.getNumFailedLinkResolve());
+ output.getGraphMeta().setNumLinksResolvedSuccessfullyFromCache(
+ visContext.getNumSuccessfulLinkResolveFromCache());
+ output.getGraphMeta().setNumLinksResolvedSuccessfullyFromServer(
+ visContext.getNumSuccessfulLinkResolveFromFromServer());
+
+ try {
+ jsonResponse = transformer.convertVisualizationOutputToJson(output);
+ } catch (JsonProcessingException jpe) {
+ throw new ServletException(
+ "Caught an exception while converting visualization output to json", jpe);
+ }
}
logOptime("[build flat node array, add relationship data, search target,"
return jsonResponse;
}
-
+
+ private D3VisualizationOutput getD3VisualizationOutput(long opStartTimeInMs, VisualizationTransformer transformer, GraphMeta graphMeta) throws ServletException {
+ D3VisualizationOutput output = null;
+ try {
+ output = transformer
+ .generateVisualizationOutput((System.currentTimeMillis() - opStartTimeInMs), graphMeta);
+ } catch (JsonProcessingException exc) {
+ throw new ServletException("Caught an exception while generation visualization output", exc);
+ } catch (IOException exc) {
+ LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, exc.getLocalizedMessage());
+ }
+ return output;
+ }
+
public void shutdown() {
aaiExecutorService.shutdown();
}