use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project solr-document-store by DBCDK.
the class SolrWorkerIT method testAddDocument.
@Test
public // @Ignore
void testAddDocument() throws Exception {
System.out.println("testAddDocument");
repository.ingestObject(FileUtils.readFileToString(new File(UNIT_FILE)));
repository.ingestObject(FileUtils.readFileToString(new File(REAL_PID_FILE)));
repository.commit();
// Put pid-message on pidQueue
MapMessage mm = session.createMapMessage();
mm.setString("pid", PID);
pidProducer.send(mm);
ArrayNode responses = fetch();
System.out.println("responses:" + JSON_OBJECT_MAPPER.writer(new DefaultPrettyPrinter()).writeValueAsString(responses));
contentTest(responses, "testAddDocument.yaml");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project spring-framework by spring-projects.
the class Jackson2JsonEncoder method initSsePrettyPrinter.
private static PrettyPrinter initSsePrettyPrinter() {
DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
printer.indentObjectsWith(new DefaultIndenter(" ", "\ndata:"));
return printer;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project flink by apache.
the class RestAPIStabilityTest method writeSnapshot.
private static void writeSnapshot(final String versionedSnapshotFileName, final RestAPISnapshot snapshot) throws IOException {
OBJECT_MAPPER.writer(new DefaultPrettyPrinter().withObjectIndenter(new DefaultIndenter().withLinefeed("\n"))).writeValue(new File("src/test/resources/" + versionedSnapshotFileName), snapshot);
System.out.println("REST API snapshot " + versionedSnapshotFileName + " was updated, please remember to commit the snapshot.");
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project rest.li by linkedin.
the class IndentedPdlBuilder method getPrettyPrinter.
private PrettyPrinter getPrettyPrinter() {
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
prettyPrinter.indentObjectsWith(new DefaultIndenter(getIndentSpaces(1), DefaultIndenter.SYS_LF + getIndentSpaces(_indentDepth)));
return prettyPrinter;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.util.DefaultPrettyPrinter in project swagger-core by swagger-api.
the class OpenApiServlet method doGet.
// TODO move to own servlet non jaxrs project and reference from there
// TODO cleanup and errors
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String ctxId = getContextIdFromServletConfig(getServletConfig());
OpenApiContext ctx = OpenApiContextLocator.getInstance().getOpenApiContext(ctxId);
OpenAPI oas = ctx.read();
if (oas != null) {
if (ctx.getOpenApiConfiguration() != null && ctx.getOpenApiConfiguration().getFilterClass() != null) {
try {
OpenAPISpecFilter filterImpl = (OpenAPISpecFilter) Class.forName(ctx.getOpenApiConfiguration().getFilterClass()).newInstance();
SpecFilter f = new SpecFilter();
oas = f.filter(oas, filterImpl, ServletUtils.getQueryParams(req.getParameterMap()), ServletUtils.getCookies(req.getCookies()), ServletUtils.getHeaders(req));
} catch (Exception e) {
LOGGER.error("failed to load filter", e);
}
}
}
String type = "json";
String acceptHeader = req.getHeader(ACCEPT_HEADER);
if (!StringUtils.isBlank(acceptHeader) && acceptHeader.toLowerCase().contains(APPLICATION_YAML)) {
type = "yaml";
} else {
// check URL:
if (req.getRequestURL().toString().toLowerCase().endsWith("yaml")) {
type = "yaml";
}
}
boolean pretty = false;
if (ctx.getOpenApiConfiguration() != null && Boolean.TRUE.equals(ctx.getOpenApiConfiguration().isPrettyPrint())) {
pretty = true;
}
resp.setStatus(200);
if (type.equalsIgnoreCase("yaml")) {
resp.setContentType(APPLICATION_YAML);
try (PrintWriter pw = resp.getWriter()) {
pw.write(pretty ? ctx.getOutputYamlMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) : ctx.getOutputYamlMapper().writeValueAsString(oas));
}
} else {
resp.setContentType(APPLICATION_JSON);
try (PrintWriter pw = resp.getWriter()) {
pw.write(pretty ? ctx.getOutputJsonMapper().writer(new DefaultPrettyPrinter()).writeValueAsString(oas) : ctx.getOutputJsonMapper().writeValueAsString(oas));
}
}
}
Aggregations