2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.aai.db.schema;
23 import java.io.IOException;
25 import org.codehaus.jackson.JsonGenerationException;
26 import org.codehaus.jackson.map.JsonMappingException;
27 import org.codehaus.jackson.map.ObjectMapper;
29 import org.openecomp.aai.exceptions.AAIException;
30 import org.openecomp.aai.introspection.Version;
31 import org.openecomp.aai.util.AAIConfig;
32 import com.beust.jcommander.JCommander;
33 import com.beust.jcommander.Parameter;
34 import com.thinkaurelius.titan.core.TitanFactory;
35 import com.thinkaurelius.titan.core.TitanGraph;
37 public class ScriptDriver {
43 * @param args the arguments
44 * @throws AAIException the AAI exception
45 * @throws JsonGenerationException the json generation exception
46 * @throws JsonMappingException the json mapping exception
47 * @throws IOException Signals that an I/O exception has occurred.
49 public static void main (String[] args) throws AAIException, JsonGenerationException, JsonMappingException, IOException {
50 CommandLineArgs cArgs = new CommandLineArgs();
52 new JCommander(cArgs, args);
55 System.out.println("-c [path to graph configuration] -type [what you want to audit - oxm or graph]");
57 String config = cArgs.config;
59 TitanGraph graph = TitanFactory.open(config);
60 if (!(cArgs.type.equals("oxm") || cArgs.type.equals("graph"))) {
61 System.out.println("type: " + cArgs.type + " not recognized.");
66 if (cArgs.type.equals("oxm")) {
67 a = AuditorFactory.getOXMAuditor(Version.v8);
68 } else if (cArgs.type.equals("graph")) {
69 a = AuditorFactory.getGraphAuditor(graph);
72 AuditDoc doc = a.getAuditDoc();
74 ObjectMapper mapper = new ObjectMapper();
76 String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(doc);
77 System.out.println(json);
83 class CommandLineArgs {
85 @Parameter(names = "--help", description = "Help")
86 public boolean help = false;
88 @Parameter(names = "-c", description = "Configuration", required=true)
91 @Parameter(names = "-type", description = "Type", required=true)
92 public String type = "graph";