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 *******************************************************************************/
10 package it.polito.escape.verify.serializer;
12 import java.io.IOException;
14 import com.fasterxml.jackson.core.JsonGenerator;
15 import com.fasterxml.jackson.core.JsonProcessingException;
16 import com.fasterxml.jackson.databind.JsonSerializer;
17 import com.fasterxml.jackson.databind.SerializerProvider;
19 import it.polito.escape.verify.exception.InternalServerErrorException;
20 import it.polito.escape.verify.model.Configuration;
22 public class CustomConfigurationSerializer extends JsonSerializer<Configuration> {
25 public void serialize(Configuration conf, JsonGenerator jgen, SerializerProvider provider)
26 throws IOException, JsonProcessingException {
28 jgen.writeObject(conf.getConfiguration());
29 } catch (IOException e) {
30 throw new InternalServerErrorException("I/O error serializing a configuration object: " + e.getMessage());