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, 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 try (TitanGraph graph = TitanFactory.open(config)) {
60 if (!("oxm".equals(cArgs.type) || "graph".equals(cArgs.type))) {
61 System.out.println("type: " + cArgs.type + " not recognized.");
66 if ("oxm".equals(cArgs.type)) {
67 doc = AuditorFactory.getOXMAuditor(Version.v8).getAuditDoc();
68 } else if ("graph".equals(cArgs.type)) {
69 doc = AuditorFactory.getGraphAuditor(graph).getAuditDoc();
72 ObjectMapper mapper = new ObjectMapper();
74 String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(doc);
75 System.out.println(json);
81 class CommandLineArgs {
83 @Parameter(names = "--help", description = "Help")
84 public boolean help = false;
86 @Parameter(names = "-c", description = "Configuration", required=true)
89 @Parameter(names = "-type", description = "Type", required=true)
90 public String type = "graph";