@Test void exportConfiguration() throws Exception { String json = "{\"config\": {\"lang\": \"ru\"}}"; String response = (String)resource.exportConfiguration(new JSONObject(json)).getEntity(); assertTrue(response.contains("redpen-conf lang=\"ru\"")); }
@Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") public Response exportConfiguration(JSONObject requestJSON) throws RedPenException { LOG.info("Exporting configuration using JSON request"); RedPen redPen = new RedPenService(context).getRedPenFromJSON(requestJSON); String result = null; try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) { new ConfigurationExporter().export(redPen.getConfiguration(), baos); result = new String(baos.toByteArray()); } catch (IOException e) { LOG.error("Exception when exporting configuration", e); } return Response.ok(result, RedPenResource.MIME_TYPE_XML).build(); }
RedPenConfigurationResource { @Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") public Response exportConfiguration(JSONObject requestJSON) throws RedPenException { LOG.info("Exporting configuration using JSON request"); RedPen redPen = new RedPenService(context).getRedPenFromJSON(requestJSON); String result = null; try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) { new ConfigurationExporter().export(redPen.getConfiguration(), baos); result = new String(baos.toByteArray()); } catch (IOException e) { LOG.error("Exception when exporting configuration", e); } return Response.ok(result, RedPenResource.MIME_TYPE_XML).build(); } }
RedPenConfigurationResource { @Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") public Response exportConfiguration(JSONObject requestJSON) throws RedPenException { LOG.info("Exporting configuration using JSON request"); RedPen redPen = new RedPenService(context).getRedPenFromJSON(requestJSON); String result = null; try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) { new ConfigurationExporter().export(redPen.getConfiguration(), baos); result = new String(baos.toByteArray()); } catch (IOException e) { LOG.error("Exception when exporting configuration", e); } return Response.ok(result, RedPenResource.MIME_TYPE_XML).build(); }  }
RedPenConfigurationResource { @Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") public Response exportConfiguration(JSONObject requestJSON) throws RedPenException { LOG.info("Exporting configuration using JSON request"); RedPen redPen = new RedPenService(context).getRedPenFromJSON(requestJSON); String result = null; try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) { new ConfigurationExporter().export(redPen.getConfiguration(), baos); result = new String(baos.toByteArray()); } catch (IOException e) { LOG.error("Exception when exporting configuration", e); } return Response.ok(result, RedPenResource.MIME_TYPE_XML).build(); }  @Path("/redpens") @GET @Produces(MediaType.APPLICATION_JSON) @WinkAPIDescriber.Description("Return the configuration for available redpens matching the supplied language (default is any language)") Response getRedPens(@QueryParam("lang") @DefaultValue("") String lang); @Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") Response exportConfiguration(JSONObject requestJSON); }
RedPenConfigurationResource { @Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") public Response exportConfiguration(JSONObject requestJSON) throws RedPenException { LOG.info("Exporting configuration using JSON request"); RedPen redPen = new RedPenService(context).getRedPenFromJSON(requestJSON); String result = null; try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) { new ConfigurationExporter().export(redPen.getConfiguration(), baos); result = new String(baos.toByteArray()); } catch (IOException e) { LOG.error("Exception when exporting configuration", e); } return Response.ok(result, RedPenResource.MIME_TYPE_XML).build(); }  @Path("/redpens") @GET @Produces(MediaType.APPLICATION_JSON) @WinkAPIDescriber.Description("Return the configuration for available redpens matching the supplied language (default is any language)") Response getRedPens(@QueryParam("lang") @DefaultValue("") String lang); @Path("/export") @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_XML) @WinkAPIDescriber.Description("Returns the configuration XML corresponds to the UI") Response exportConfiguration(JSONObject requestJSON);  }