public Result manageGlobal(String inputId) { if (!Permissions.isPermitted(RestPermissions.INPUTS_EDIT, inputId)) { return redirect(routes.StartpageController.redirect()); } try { Node node = nodeService.loadMasterNode(); Input input = node.getInput(inputId); return ok( views.html.system.inputs.extractors.manage.render( currentUser(), standardBreadcrumbs(node, input), node, input, extractorService.all(node, input))); } catch (IOException e) { return status(500, views.html.errors.error.render(ApiClient.ERROR_MSG_IO, e, request())); } catch (APIException e) { String message = "Could not fetch system information. We expected HTTP 200, but got a HTTP " + e.getHttpCode() + "."; return status(500, views.html.errors.error.render(message, e, request())); } }
public Result exportExtractors(String nodeId, String inputId) { if (!Permissions.isPermitted(RestPermissions.INPUTS_READ, inputId)) { return redirect(routes.StartpageController.redirect()); } try { Node node = nodeService.loadNode(nodeId); Input input = node.getInput(inputId); BreadcrumbList bc = standardBreadcrumbs(node, input); bc.addCrumb( "Export", controllers.routes.ExtractorsController.exportExtractors(nodeId, inputId)); Map<String, Object> result = Maps.newHashMap(); List<Map<String, Object>> extractors = Lists.newArrayList(); for (Extractor extractor : extractorService.all(node, input)) { extractors.add(extractor.export()); } result.put("extractors", extractors); result.put("version", Version.VERSION.toString()); String extractorExport = Json.toJsonString(result); return ok( views.html.system.inputs.extractors.export.render( currentUser(), bc, node, input, extractorExport)); } catch (IOException e) { return status(500, views.html.errors.error.render(ApiClient.ERROR_MSG_IO, e, request())); } catch (APIException e) { String message = "Could not fetch system information. We expected HTTP 200, but got a HTTP " + e.getHttpCode() + "."; return status(500, views.html.errors.error.render(message, e, request())); } catch (NodeService.NodeNotFoundException e) { return status( 404, views.html.errors.error.render(ApiClient.ERROR_MSG_NODE_NOT_FOUND, e, request())); } }