Merge "Disable syslog in heat-translator for functest integration"
[parser.git] / verigraph / src / it / polito / verigraph / deserializer / ConfigurationCustomDeserializer.java
1 /*******************************************************************************
2  * Copyright (c) 2017 Politecnico di Torino and others.
3  *
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;
10
11 import java.io.IOException;
12
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;
18
19 import it.polito.verigraph.exception.InternalServerErrorException;
20 import it.polito.verigraph.model.Configuration;
21
22 public class ConfigurationCustomDeserializer extends JsonDeserializer<Configuration> {
23
24     @Override
25     public Configuration deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
26     JsonProcessingException {
27         try {
28             JsonNode root = jp.getCodec().readTree(jp);
29             return new Configuration("", "", root);
30         }
31         catch (JsonProcessingException e) {
32             throw new InternalServerErrorException("Error parsing configuration: " + e.getMessage());
33         }
34         catch (IOException e) {
35             throw new InternalServerErrorException("I/O error parsing configuration: " + e.getMessage());
36         }
37     }
38 }