@Override public Optional<String> getQueryParam(String param) { return original.getQueryParam(param); }
@Override public Optional<String> getQueryParam(String param) { return original.getQueryParam(param); }
@Override public Optional<String> extractQueryParamStringedValueFor(EndpointParamDef parameter, RestxRequest request, RestxRequestMatch match) { return request.getQueryParam(parameter.getName()); } @Override
@Override public Optional<String> extractQueryParamStringedValueFor(EndpointParamDef parameter, RestxRequest request, RestxRequestMatch match) { return request.getQueryParam(parameter.getName()); } @Override
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { securityManager.check(req, match, permissionFactory.hasRole(AdminModule.RESTX_ADMIN_ROLE)); int id = Integer.parseInt(match.getPathParam("id")); for (RestxSpecRecorder.RecordedSpec spec : recordedSpecsRepository.getRecordedSpecs()) { if (spec.getId() == id) { Optional<String> path = req.getQueryParam("path"); Optional<String> title = req.getQueryParam("title"); RestxSpec.Storage storage = RestxSpec.Storage.with(storageSettings); File destFile = storage.store( spec.getSpec() .withTitle(title) .withPath(storage.buildPath(path, title.or(spec.getSpec().getTitle())))); resp.setContentType("text/plain"); resp.getWriter().println(destFile.getAbsolutePath()); return; } } notFound(match, resp); } }
@Override public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx) throws IOException { securityManager.check(req, match, permissionFactory.hasRole(AdminModule.RESTX_ADMIN_ROLE)); int id = Integer.parseInt(match.getPathParam("id")); for (RestxSpecRecorder.RecordedSpec spec : recordedSpecsRepository.getRecordedSpecs()) { if (spec.getId() == id) { Optional<String> path = req.getQueryParam("path"); Optional<String> title = req.getQueryParam("title"); RestxSpec.Storage storage = RestxSpec.Storage.with(storageSettings); File destFile = storage.store( spec.getSpec() .withTitle(title) .withPath(storage.buildPath(path, title.or(spec.getSpec().getTitle())))); resp.setContentType("text/plain"); resp.getWriter().println(destFile.getAbsolutePath()); return; } } notFound(match, resp); } }