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.deserializer;
11 import java.io.IOException;
13 import com.fasterxml.jackson.core.JsonParser;
14 import com.fasterxml.jackson.core.JsonProcessingException;
15 import com.fasterxml.jackson.databind.DeserializationContext;
16 import com.fasterxml.jackson.databind.JsonDeserializer;
17 import com.fasterxml.jackson.databind.JsonNode;
19 import it.polito.verigraph.exception.InternalServerErrorException;
20 import it.polito.verigraph.model.Configuration;
22 public class ConfigurationCustomDeserializer extends JsonDeserializer<Configuration> {
25 public Configuration deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
26 JsonProcessingException {
28 JsonNode root = jp.getCodec().readTree(jp);
29 return new Configuration("", "", root);
31 catch (JsonProcessingException e) {
32 throw new InternalServerErrorException("Error parsing configuration: " + e.getMessage());
34 catch (IOException e) {
35 throw new InternalServerErrorException("I/O error parsing configuration: " + e.getMessage());