Changed to unmaintained
[appc.git] / appc-config / appc-config-audit / provider / src / main / java / org / onap / sdnc / config / audit / node / CompareJsonData.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.sdnc.config.audit.node;
25
26 import java.io.IOException;
27 import java.util.Map;
28
29
30 import com.att.eelf.configuration.EELFLogger;
31 import com.att.eelf.configuration.EELFManager;
32 import com.fasterxml.jackson.core.JsonParseException;
33 import com.fasterxml.jackson.databind.JsonMappingException;
34 import com.fasterxml.jackson.databind.ObjectMapper;
35
36
37 public class CompareJsonData implements CompareDataInterface {
38
39     private static final EELFLogger log = EELFManager.getInstance().getLogger(CompareJsonData.class);
40
41     String payloadX;
42     String payloadY;
43
44     public CompareJsonData(String payloadX, String payloadY)
45     {
46         this.payloadX = payloadX;
47         this.payloadY = payloadY;
48     }
49
50     @Override
51     public boolean compare() throws Exception
52     {
53
54         ObjectMapper dataMapper = new ObjectMapper();
55         boolean match = false;
56         try
57         {
58             Map<String, Object> controlData = (Map<String, Object>)(dataMapper.readValue(payloadX, Map.class));
59             Map<String, Object>  testData = (Map<String, Object>)(dataMapper.readValue(payloadY, Map.class));
60
61             log.debug("Control Data :" + controlData);
62             log.debug("testData Data :" + testData);
63
64            if(controlData.equals(testData))
65                match=true;
66         }
67         catch(JsonParseException e)
68         {
69             throw new Exception(e.getMessage());
70         }
71         catch(JsonMappingException e)
72         {
73             throw new Exception(e.getMessage());
74         }
75         catch(IOException ioe)
76         {
77             throw new Exception(ioe.getMessage());
78         }
79
80         return match;
81     }
82 }