com.fasterxml.jackson.core.JsonEncoding Java Examples

The following examples show how to use com.fasterxml.jackson.core.JsonEncoding. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UCartographer.java    From ure with MIT License 6 votes vote down vote up
/**
 * Persist an object to disk.  This will most likely be an area or region, but in theory you could
 * write anything that serializes properly.
 * @param object
 * @param filename
 */
public void persist(Object object, String filename) {
    String path = commander.savePath();
    if (commander.config.isPersistentAreas()) {
        File dir = new File(path);
        dir.mkdirs();
        log.info("saving file " + path + filename);
        File file = new File(path + filename);
        try (
                FileOutputStream stream = new FileOutputStream(file);
                GZIPOutputStream gzip = new GZIPOutputStream(stream)
        ) {
            JsonFactory jfactory = new JsonFactory();
            JsonGenerator jGenerator = jfactory
                    .createGenerator(gzip, JsonEncoding.UTF8);
            jGenerator.setCodec(objectMapper);
            jGenerator.writeObject(object);
            jGenerator.close();
        } catch (IOException e) {
            throw new RuntimeException("Couldn't persist object " + object.toString(), e);
        }
    }
}
 
Example #2
Source File: CustomAccessDeniedHandler.java    From oauth2-resource with MIT License 6 votes vote down vote up
@Override
public void handle(HttpServletRequest request,
                   HttpServletResponse response, AccessDeniedException e) throws IOException {

    String toUrl = ClientIpUtils.getFullRequestUrl(request);
    log.info("【" + request.getRequestURI() + "】权限不足 FORBIDDEN");
    response.setHeader("Content-Type", "application/json;charset=UTF-8");
    Map<String, Object> responseMessage = new HashMap<>(16);
    responseMessage.put("status", HttpStatus.FORBIDDEN.value());
    responseMessage.put("message", "权限不足!");
    responseMessage.put("path", toUrl);
    ObjectMapper objectMapper = new ObjectMapper();
    response.setStatus(HttpStatus.FORBIDDEN.value());
    JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(response.getOutputStream(),
        JsonEncoding.UTF8);
    objectMapper.writeValue(jsonGenerator, responseMessage);
}
 
Example #3
Source File: ResultMapperExt.java    From roncoo-education with MIT License 6 votes vote down vote up
private String buildJSONFromFields(Collection<SearchHitField> values) {
	JsonFactory nodeFactory = new JsonFactory();
	try {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		JsonGenerator generator = nodeFactory.createGenerator(stream, JsonEncoding.UTF8);
		generator.writeStartObject();
		for (SearchHitField value : values) {
			if (value.getValues().size() > 1) {
				generator.writeArrayFieldStart(value.getName());
				for (Object val : value.getValues()) {
					generator.writeObject(val);
				}
				generator.writeEndArray();
			} else {
				generator.writeObjectField(value.getName(), value.getValue());
			}
		}
		generator.writeEndObject();
		generator.flush();
		return new String(stream.toByteArray(), Charset.forName("UTF-8"));
	} catch (IOException e) {
		return null;
	}
}
 
Example #4
Source File: MockQueryHandler.java    From vespa with Apache License 2.0 6 votes vote down vote up
private String getResponse(String query) throws IOException {
    List<MockQueryHit> hits = hitMap.get(query);
    if (hits == null) {
        return null;
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    JsonGenerator g = new JsonFactory().createGenerator(out, JsonEncoding.UTF8);

    writeResultStart(g, hits.size());
    for (MockQueryHit hit : hits) {
        writeHit(g, hit);
    }
    writeResultsEnd(g);
    g.close();

    return out.toString();
}
 
Example #5
Source File: PingResponseSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws IOException
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);

    logger.info("serialize: exit");
}
 
Example #6
Source File: ListTablesRequestSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws IOException
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);

    logger.info("serialize: exit");
}
 
Example #7
Source File: GetTableRequestSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws IOException
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);

    logger.info("serialize: exit");
}
 
Example #8
Source File: MetricStore.java    From incubator-nemo with Apache License 2.0 6 votes vote down vote up
/**
 * Dumps JSON-serialized string of all stored metric.
 *
 * @return dumped JSON string of all metric.
 * @throws IOException when failed to write file.
 */
public synchronized String dumpAllMetricToJson() throws IOException {
  final ObjectMapper objectMapper = new ObjectMapper();
  final JsonFactory jsonFactory = new JsonFactory();
  final ByteArrayOutputStream stream = new ByteArrayOutputStream();

  try (JsonGenerator jsonGenerator = jsonFactory.createGenerator(stream, JsonEncoding.UTF8)) {
    jsonGenerator.setCodec(objectMapper);

    jsonGenerator.writeStartObject();
    for (final Map.Entry<Class<? extends Metric>, Map<String, Object>> metricMapEntry : metricMap.entrySet()) {
      jsonGenerator.writeFieldName(metricMapEntry.getKey().getSimpleName());
      jsonGenerator.writeStartObject();
      for (final Map.Entry<String, Object> idToMetricEntry : metricMapEntry.getValue().entrySet()) {
        generatePreprocessedJsonFromMetricEntry(idToMetricEntry, jsonGenerator, objectMapper);
      }
      jsonGenerator.writeEndObject();
    }
    jsonGenerator.writeEndObject();
  }

  return stream.toString();
}
 
Example #9
Source File: GetTableLayoutResponseSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws IOException
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);

    logger.info("serialize: exit");
}
 
Example #10
Source File: GetSplitsRequestSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws Exception
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);
    expected.close();

    logger.info("serialize: exit");
}
 
Example #11
Source File: MetricStore.java    From incubator-nemo with Apache License 2.0 6 votes vote down vote up
/**
 * Send changed metric data to {@link MetricBroadcaster}, which will broadcast it to
 * all active WebSocket sessions. This method should be called manually if you want to
 * send changed metric data to the frontend client. Also this method is synchronized.
 *
 * @param metricClass class of the metric.
 * @param id          id of the metric.
 * @param <T>         type of the metric to broadcast
 */
public synchronized <T extends Metric> void triggerBroadcast(final Class<T> metricClass, final String id) {
  final MetricBroadcaster metricBroadcaster = MetricBroadcaster.getInstance();
  final ObjectMapper objectMapper = new ObjectMapper();
  final T metric = getMetricWithId(metricClass, id);
  final JsonFactory jsonFactory = new JsonFactory();
  final ByteArrayOutputStream stream = new ByteArrayOutputStream();
  try (JsonGenerator jsonGenerator = jsonFactory.createGenerator(stream, JsonEncoding.UTF8)) {
    jsonGenerator.setCodec(objectMapper);

    jsonGenerator.writeStartObject();
    jsonGenerator.writeFieldName("metricType");
    jsonGenerator.writeString(metricClass.getSimpleName());

    jsonGenerator.writeFieldName("data");
    jsonGenerator.writeObject(metric);
    jsonGenerator.writeEndObject();

    metricBroadcaster.broadcast(stream.toString());
  } catch (final IOException e) {
    throw new MetricException(e);
  }
}
 
Example #12
Source File: JSONIO.java    From pom-manipulation-ext with Apache License 2.0 6 votes vote down vote up
public static JsonEncoding detectEncoding(File jsonFile) throws ManipulationException
{
    try ( FileInputStream in = new FileInputStream( jsonFile ) )
    {
        byte[] inputBuffer = new byte[4];
        in.read( inputBuffer );
        IOContext ctxt = new IOContext( new BufferRecycler(), null, false );
        ByteSourceJsonBootstrapper strapper = new ByteSourceJsonBootstrapper( ctxt, inputBuffer, 0,
                4 );
        JsonEncoding encoding = strapper.detectEncoding();
        logger.debug( "Detected JSON encoding {} for file {}", encoding, jsonFile );
        return encoding;
    }
    catch ( IOException e )
    {
        logger.error( "Unable to detect charset for file: {}", jsonFile, e );
        throw new ManipulationException( "Unable to detect charset for file {}", jsonFile, e );
    }
}
 
Example #13
Source File: DumpReportTask.java    From extract with MIT License 6 votes vote down vote up
/**
 * Dump the report as JSON to the given output stream.
 *
 * @param reportMap the report to dump
 * @param output the stream to dump to
 * @param match only dump matching results
 */
private void dump(final ReportMap reportMap, final OutputStream output, final ExtractionStatus match) throws
		IOException {
	final ObjectMapper mapper = new ObjectMapper();
	final SimpleModule module = new SimpleModule();

	module.addSerializer(ReportMap.class, new ReportSerializer(monitor, match));
	mapper.registerModule(module);

	try (final JsonGenerator jsonGenerator = new JsonFactory().setCodec(mapper).createGenerator(output,
			JsonEncoding.UTF8)) {
		jsonGenerator.useDefaultPrettyPrinter();
		jsonGenerator.writeObject(reportMap);
		jsonGenerator.writeRaw('\n');
	}
}
 
Example #14
Source File: UVaultSet.java    From ure with MIT License 6 votes vote down vote up
public void persist(String absoluteFilepath) {
    File file = new File(absoluteFilepath);
    try (
            FileOutputStream stream = new FileOutputStream(file);
            //GZIPOutputStream gzip = new GZIPOutputStream(stream)
    ) {
        JsonFactory jfactory = new JsonFactory();
        JsonGenerator jGenerator = jfactory
                .createGenerator(stream, JsonEncoding.UTF8);
        jGenerator.setCodec(new ObjectMapper());
        jGenerator.writeObject(this);
        jGenerator.close();
    } catch (IOException e) {
        throw new RuntimeException("Couldn't persist object " + toString(), e);
    }
}
 
Example #15
Source File: UserDefinedFunctionResponseSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws IOException
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);

    logger.info("serialize: exit");
}
 
Example #16
Source File: JsonContentHandlerJacksonWrapper.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
private static JsonGenerator createGenerator(JsonFactory f, Object o) throws SAXException {
  try {
    if (o instanceof Writer) {
      return f.createGenerator((Writer)o);
    }
    if (o instanceof OutputStream) {
      return f.createGenerator((OutputStream)o);
    }
    if (o instanceof File) {
      return f.createGenerator((File)o, JsonEncoding.UTF8);
    }
    throw new RuntimeException(new OperationNotSupportedException(String.format("Object must be a Writer, OutputStream, or File, but was of class %s",
        o.getClass().getName())));
  } catch (IOException e) {
    throw new SAXException(e);
  }
}
 
Example #17
Source File: LandedModal.java    From ure with MIT License 6 votes vote down vote up
void saveScaper(ULandscaper scaper, String filename) {
    String path = commander.savePath();
    File file = new File(path + filename);
    try (
            FileOutputStream stream = new FileOutputStream(file);
    ) {
        JsonFactory jfactory = new JsonFactory();
        JsonGenerator jGenerator = jfactory
                .createGenerator(stream, JsonEncoding.UTF8);
        jGenerator.setCodec(objectMapper);
        jGenerator.writeObject(scaper);
        jGenerator.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example #18
Source File: Sensor.java    From act with GNU General Public License v3.0 6 votes vote down vote up
private void setupFiles(String sensorReadingPath) {
  String logFilename = deviceName.concat(LOG_EXTENSION);
  Path sensorReadingDirectory = Paths.get(sensorReadingPath, sensorData.getDeviceType());
  this.sensorReadingFilePath = Paths.get(
      sensorReadingDirectory.toString(), deviceName);
  this.sensorReadingLogFilePath = Paths.get(
      sensorReadingDirectory.toString(), logFilename);
  if (!Files.exists(sensorReadingDirectory)) {
    Boolean madeDir = sensorReadingDirectory.toFile().mkdirs();
    if (!madeDir) {
      LOGGER.error("The following directory could not be accessed or created: %s", sensorReadingDirectory);
    }
  }
  try {
    this.jsonGenerator = objectMapper.getFactory().createGenerator(
        new File(sensorReadingLogFilePath.toString()), JsonEncoding.UTF8);
    this.sensorReadingTmp = File.createTempFile(sensorReadingFilePath.toString(), ".tmp");
  } catch (IOException e) {
    LOGGER.error("Error during reading/log files creation: %s", e);
    System.exit(1);
  }
}
 
Example #19
Source File: GetTableResponseSerDeTest.java    From aws-athena-query-federation with Apache License 2.0 6 votes vote down vote up
@Test
public void serialize()
        throws IOException
{
    logger.info("serialize: enter");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    mapper.writeValue(outputStream, expected);

    String actual = new String(outputStream.toByteArray(), JsonEncoding.UTF8.getJavaName());
    logger.info("serialize: serialized text[{}]", actual);

    assertEquals(expectedSerDeText, actual);

    logger.info("serialize: exit");
}
 
Example #20
Source File: AbstractJackson2Encoder.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Determine the JSON encoding to use for the given mime type.
 * @param mimeType the mime type as requested by the caller
 * @return the JSON encoding to use (never {@code null})
 * @since 5.0.5
 */
protected JsonEncoding getJsonEncoding(@Nullable MimeType mimeType) {
	if (mimeType != null && mimeType.getCharset() != null) {
		Charset charset = mimeType.getCharset();
		for (JsonEncoding encoding : JsonEncoding.values()) {
			if (charset.name().equals(encoding.getJavaName())) {
				return encoding;
			}
		}
	}
	return JsonEncoding.UTF8;
}
 
Example #21
Source File: CustomAccessDeniedHandler.java    From oauth2-server with MIT License 5 votes vote down vote up
@Override
    public void handle(HttpServletRequest request,
                       HttpServletResponse response, AccessDeniedException e) throws IOException {
        //服务器地址
        String toUrl = ClientIpUtil.getFullRequestUrl(request);
        boolean isAjax = "XMLHttpRequest".equals(request
            .getHeader("X-Requested-With")) || "apiLogin".equals(request
            .getHeader("api-login"));
        if (isAjax) {
            response.setHeader("Content-Type", "application/json;charset=UTF-8");
            try {
                ResponseResult<Object> responseMessage = new ResponseResult<>();
                responseMessage.setStatus(GlobalConstant.ERROR_DENIED);
                responseMessage.setMessage(toUrl);
                ObjectMapper objectMapper = new ObjectMapper();
                JsonGenerator jsonGenerator = objectMapper.getFactory().createGenerator(response.getOutputStream(),
                    JsonEncoding.UTF8);
                objectMapper.writeValue(jsonGenerator, responseMessage);
            } catch (Exception ex) {
                throw new HttpMessageNotWritableException("Could not write JSON: " + ex.getMessage(), ex);
            }
        } else {
///            response.sendRedirect(accessDeniedUrl + "?toUrl=" + toUrl);
            response.sendRedirect(accessDeniedUrl);
        }
    }
 
Example #22
Source File: HoconFactory.java    From jackson-dataformat-hocon with Apache License 2.0 5 votes vote down vote up
protected Reader _createReader(InputStream in, JsonEncoding enc, IOContext ctxt) throws IOException
{
    if (enc == null) {
        enc = JsonEncoding.UTF8;
    }
    // default to UTF-8 if encoding missing
    if (enc == JsonEncoding.UTF8) {
        boolean autoClose = ctxt.isResourceManaged() || isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE);
        return new UTF8Reader(in, autoClose);
    }
    return new InputStreamReader(in, enc.getJavaName());
}
 
Example #23
Source File: FilterObjectWriterITest.java    From jfilter with Apache License 2.0 5 votes vote down vote up
@Before
public void init() throws IOException {
    FilterObjectMapper objectMapper = new FilterObjectMapper(filterConfiguration);
    writer = (FilterObjectWriter) objectMapper.writer();
    user = new MockUser();

    out = new ByteArrayOutputStream();
    generator = objectMapper.getFactory().createGenerator(out, JsonEncoding.UTF8);
}
 
Example #24
Source File: KriptonXmlContext.java    From kripton with Apache License 2.0 5 votes vote down vote up
public XmlWrapperSerializer createSerializer(OutputStream out, JsonEncoding encoding) {
       try {
		return new XmlWrapperSerializer(new XMLSerializer(new OutputStreamWriter(out, encoding.getJavaName())));
	} catch (Exception e) {
		e.printStackTrace();
		throw new KriptonRuntimeException(e);
	}
}
 
Example #25
Source File: MappingJacksonRPC2HttpMessageConverter.java    From jsonrpc4j with MIT License 5 votes vote down vote up
/**
 * Determine the JSON encoding to use for the given content type.
 *
 * @param contentType the media type as requested by the caller
 * @return the JSON encoding to use (never <code>null</code>)
 */
private JsonEncoding getJsonEncoding(MediaType contentType) {
	if (contentType != null && contentType.getCharset() != null) {
		Charset charset = contentType.getCharset();
		for (JsonEncoding encoding : JsonEncoding.values()) {
			if (charset.name().equals(encoding.getJavaName())) {
				return encoding;
			}
		}
	}
	return JsonEncoding.UTF8;
}
 
Example #26
Source File: TranslationServlet.java    From apiman with Apache License 2.0 5 votes vote down vote up
/**
 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
        IOException {
    Messages.setLocale(request.getLocale());
    try {
        Map<String, String> strings = Messages.i18n.all();

        response.getOutputStream().write("window.APIMAN_TRANSLATION_DATA = ".getBytes("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
        JsonFactory f = new JsonFactory();
        JsonGenerator g = f.createGenerator(response.getOutputStream(), JsonEncoding.UTF8);
        g.useDefaultPrettyPrinter();

        // Write string data here.
        g.writeStartObject();
        for (Entry<String, String> entry : strings.entrySet()) {
            g.writeStringField(entry.getKey(), entry.getValue());
        }
        g.writeEndObject();

        g.flush();
        response.getOutputStream().write(";".getBytes("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
        g.close();
    } catch (Exception e) {
        throw new ServletException(e);
    } finally {
        Messages.clearLocale();
    }
}
 
Example #27
Source File: FilteringJacksonJsonProvider.java    From ameba with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected JsonGenerator _createGenerator(ObjectWriter writer, OutputStream rawStream, JsonEncoding enc) throws IOException {
    JsonGenerator generator = super._createGenerator(writer, rawStream, enc);
    JacksonUtils.configureGenerator(uriInfo, generator, mode.isDev());
    return generator;
}
 
Example #28
Source File: JsonServiceDocumentWriter.java    From odata with Apache License 2.0 5 votes vote down vote up
/**
 * The main method for Writer.
 * It builds the service root document according to spec.
 *
 * @return output in json
 * @throws ODataRenderException If unable to render the json service document
 */
public String buildJson() throws ODataRenderException {
    LOG.debug("Start building Json service root document");
    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
        JsonGenerator jsonGenerator = JSON_FACTORY.createGenerator(stream, JsonEncoding.UTF8);
        jsonGenerator.writeStartObject();
        jsonGenerator.writeStringField(CONTEXT, getContextURL(uri, entityDataModel));
        jsonGenerator.writeArrayFieldStart(VALUE);


        List<EntitySet> entities = entityDataModel.getEntityContainer().getEntitySets();
        for (EntitySet entity : entities) {
            if (entity.isIncludedInServiceDocument()) {
                writeObject(jsonGenerator, entity);
            }
        }

        List<Singleton> singletons = entityDataModel.getEntityContainer().getSingletons();
        for (Singleton singleton : singletons) {
            writeObject(jsonGenerator, singleton);
        }

        jsonGenerator.writeEndArray();
        jsonGenerator.writeEndObject();
        jsonGenerator.close();
        return stream.toString(StandardCharsets.UTF_8.name());
    } catch (IOException e) {
        throw new ODataRenderException("It is unable to render service document", e);
    }
}
 
Example #29
Source File: JsonSteamTest.java    From java-master with Apache License 2.0 5 votes vote down vote up
@Test
public void test2() throws Exception {
    JsonFactory factory = new JsonFactory();
    JsonGenerator generator = factory.createGenerator(
            new File("D:\\output.json"), JsonEncoding.UTF8);
    generator.writeStartObject();
    generator.writeStringField("brand", "Mercedes");
    generator.writeNumberField("doors", 5);
    generator.writeEndObject();
    generator.close();
}
 
Example #30
Source File: ConfigJsServlet.java    From apicurio-registry with Apache License 2.0 5 votes vote down vote up
/**
 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String ct = "application/javascript; charset=" + StandardCharsets.UTF_8;
    response.setContentType(ct);
    JsonFactory f = new JsonFactory();
    try (JsonGenerator g = f.createGenerator(response.getOutputStream(), JsonEncoding.UTF8)) {
        response.getOutputStream().write("var ApicurioRegistryConfig = ".getBytes("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
        ObjectMapper mapper = new ObjectMapper();
        mapper.setSerializationInclusion(Include.NON_NULL);
        g.setCodec(mapper);
        g.useDefaultPrettyPrinter();

        ConfigJs config = new ConfigJs();
        config.mode = "prod";

        config.artifacts.url = this.generateApiUrl(request);
        
        config.ui.url = this.generateUiUrl(request);
        config.ui.contextPath = "/ui";
        
        config.features.readOnly = this.isFeatureReadOnly();
        
        g.writeObject(config);

        g.flush();
        response.getOutputStream().write(";".getBytes("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
    } catch (Exception e) {
        throw new ServletException(e);
    }
}