1 /*******************************************************************************
2 * Copyright (c) 2017 Politecnico di Torino and others.
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Apache License, Version 2.0
6 * which accompanies this distribution, and is available at
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *******************************************************************************/
9 package it.polito.verigraph.serializer;
11 import java.io.IOException;
12 import com.fasterxml.jackson.core.JsonGenerator;
13 import com.fasterxml.jackson.core.JsonProcessingException;
14 import com.fasterxml.jackson.databind.JsonSerializer;
15 import com.fasterxml.jackson.databind.SerializerProvider;
16 import it.polito.verigraph.exception.InternalServerErrorException;
17 import it.polito.verigraph.model.Configuration;
19 public class CustomConfigurationSerializer extends JsonSerializer<Configuration> {
22 public void serialize(Configuration conf, JsonGenerator jgen, SerializerProvider provider)
23 throws IOException, JsonProcessingException {
25 jgen.writeObject(conf.getConfiguration());
26 } catch (IOException e) {
27 throw new InternalServerErrorException("I/O error serializing a configuration object: " + e.getMessage());