diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2022-09-17 20:42:06 +0200 |
---|---|---|
committer | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2022-09-17 20:42:06 +0200 |
commit | e0ad4f2890f9f933199bc6f1b3f0e988da471aa9 (patch) | |
tree | 0c42f25d258aeb0327cdafab0012ddbba13e040d /aai-schema-gen/src/main/java/org/onap | |
parent | 1b2c97dbc18bc0db5610fc18e9ae690b7a40d06d (diff) |
Replace all tab characters in java files with two spaces to remove linter warning
Issue-ID: AAI-3525
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: I36cf7b83dd33c3b69de51e56e00bbd93a79c5ec4
Diffstat (limited to 'aai-schema-gen/src/main/java/org/onap')
9 files changed, 357 insertions, 357 deletions
diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java index a85ecac..9d3f258 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/GenerateXsd.java @@ -42,101 +42,101 @@ import java.util.*; public class GenerateXsd { - private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class"); - protected static String apiVersion = null; - public static AnnotationConfigApplicationContext ctx = null; - static String apiVersionFmt = null; - static boolean useAnnotationsInXsd = false; - static String responsesUrl = null; - static String responsesLabel = null; - static String jsonEdges = null; - static Map<String, String> generatedJavaType; - static Map<String, String> appliedPaths; - static String RELEASE = System.getProperty("aai.release", "onap"); - - - static NodeList javaTypeNodes; - static Map<String,String> javaTypeDefinitions = createJavaTypeDefinitions(); + private static final Logger logger = LoggerFactory.getLogger("GenerateXsd.class"); + protected static String apiVersion = null; + public static AnnotationConfigApplicationContext ctx = null; + static String apiVersionFmt = null; + static boolean useAnnotationsInXsd = false; + static String responsesUrl = null; + static String responsesLabel = null; + static String jsonEdges = null; + static Map<String, String> generatedJavaType; + static Map<String, String> appliedPaths; + static String RELEASE = System.getProperty("aai.release", "onap"); + + + static NodeList javaTypeNodes; + static Map<String,String> javaTypeDefinitions = createJavaTypeDefinitions(); private static Map<String, String> createJavaTypeDefinitions() { StringBuilder aaiInternal = new StringBuilder(); - Map<String,String> javaTypeDefinitions = new HashMap<String, String>(); - aaiInternal.append(" aai-internal:\n"); - aaiInternal.append(" properties:\n"); - aaiInternal.append(" property-name:\n"); - aaiInternal.append(" type: string\n"); - aaiInternal.append(" property-value:\n"); - aaiInternal.append(" type: string\n"); -// javaTypeDefinitions.put("aai-internal", aaiInternal.toString()); - return javaTypeDefinitions; + Map<String,String> javaTypeDefinitions = new HashMap<String, String>(); + aaiInternal.append(" aai-internal:\n"); + aaiInternal.append(" properties:\n"); + aaiInternal.append(" property-name:\n"); + aaiInternal.append(" type: string\n"); + aaiInternal.append(" property-value:\n"); + aaiInternal.append(" type: string\n"); +// javaTypeDefinitions.put("aai-internal", aaiInternal.toString()); + return javaTypeDefinitions; } - public static final int VALUE_NONE = 0; - public static final int VALUE_DESCRIPTION = 1; - public static final int VALUE_INDEXED_PROPS = 2; - public static final int VALUE_CONTAINER = 3; + public static final int VALUE_NONE = 0; + public static final int VALUE_DESCRIPTION = 1; + public static final int VALUE_INDEXED_PROPS = 2; + public static final int VALUE_CONTAINER = 3; - private static final String GENERATE_TYPE_XSD = "xsd"; - private static final String GENERATE_TYPE_YAML = "yaml"; + private static final String GENERATE_TYPE_XSD = "xsd"; + private static final String GENERATE_TYPE_YAML = "yaml"; - private final static String NODE_DIR = System.getProperty("nodes.configuration.location"); - private final static String EDGE_DIR = System.getProperty("edges.configuration.location"); - private static final String BASE_ROOT = "aai-schema/"; - private static final String BASE_AUTO_GEN_ROOT = "aai-schema/"; + private final static String NODE_DIR = System.getProperty("nodes.configuration.location"); + private final static String EDGE_DIR = System.getProperty("edges.configuration.location"); + private static final String BASE_ROOT = "aai-schema/"; + private static final String BASE_AUTO_GEN_ROOT = "aai-schema/"; - private static final String ROOT = BASE_ROOT + "src/main/resources"; - private static final String AUTO_GEN_ROOT = BASE_AUTO_GEN_ROOT + "src/main/resources"; + private static final String ROOT = BASE_ROOT + "src/main/resources"; + private static final String AUTO_GEN_ROOT = BASE_AUTO_GEN_ROOT + "src/main/resources"; - private static final String NORMAL_START_DIR = "aai-schema-gen"; - private static final String XSD_DIR = ROOT + "/" + RELEASE +"/aai_schema"; + private static final String NORMAL_START_DIR = "aai-schema-gen"; + private static final String XSD_DIR = ROOT + "/" + RELEASE +"/aai_schema"; - private static final String + private static final String YAML_DIR = (((System.getProperty("user.dir") != null) && (!System.getProperty("user.dir").contains( NORMAL_START_DIR))) ? AUTO_GEN_ROOT : ROOT) + "/" + RELEASE + "/aai_swagger_yaml"; - /* These three strings are for yaml auto-generation from aai-common class*/ + /* These three strings are for yaml auto-generation from aai-common class*/ - private static final int SWAGGER_SUPPORT_STARTS_VERSION = 1; // minimum version to support swagger documentation + private static final int SWAGGER_SUPPORT_STARTS_VERSION = 1; // minimum version to support swagger documentation - private static boolean validVersion(String versionToGen) { + private static boolean validVersion(String versionToGen) { - if ("ALL".equalsIgnoreCase(versionToGen)) { - return true; - } + if ("ALL".equalsIgnoreCase(versionToGen)) { + return true; + } - SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class); - if (schemaVersions == null) { - return false; + SchemaVersions schemaVersions = SpringContextAware.getBean(SchemaVersions.class); + if (schemaVersions == null) { + return false; } - for (SchemaVersion v : schemaVersions.getVersions()) { - if (v.toString().equals(versionToGen)) { - return true; - } - } + for (SchemaVersion v : schemaVersions.getVersions()) { + if (v.toString().equals(versionToGen)) { + return true; + } + } - return false; - } + return false; + } - private static boolean versionSupportsSwagger(String version) { + private static boolean versionSupportsSwagger(String version) { return Integer.parseInt(version.substring(1)) >= SWAGGER_SUPPORT_STARTS_VERSION; } - public static String getAPIVersion() { - return apiVersion; - } + public static String getAPIVersion() { + return apiVersion; + } - public static String getYamlDir() { - return YAML_DIR; - } + public static String getYamlDir() { + return YAML_DIR; + } - public static String getResponsesUrl() { - return responsesUrl; - } - public static void main(String[] args) throws IOException { - String versionToGen = System.getProperty("gen_version"); + public static String getResponsesUrl() { + return responsesUrl; + } + public static void main(String[] args) throws IOException { + String versionToGen = System.getProperty("gen_version"); if (versionToGen == null) { System.err.println("Version is required, ie v<n> or ALL."); System.exit(1); @@ -152,175 +152,175 @@ public class GenerateXsd { } AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( - "org.onap.aai.setup", + "org.onap.aai.setup", "org.onap.aai.schemagen" - ); - - SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class); - - if ( !fileTypeToGen.equals(GENERATE_TYPE_XSD) && !fileTypeToGen.equals(GENERATE_TYPE_YAML)) { - System.err.println("Invalid gen_type passed. " + fileTypeToGen); - System.exit(1); - } - - String responsesLabel = System.getProperty("yamlresponses_url"); - responsesUrl = responsesLabel; - - List<SchemaVersion> versionsToGen = new ArrayList<>(); - if (!"ALL".equalsIgnoreCase(versionToGen) && !versionToGen.matches("v\\d+") && !validVersion(versionToGen)) { - System.err.println("Invalid version passed. " + versionToGen); - System.exit(1); - } - else if ("ALL".equalsIgnoreCase(versionToGen)) { - versionsToGen = schemaVersions.getVersions(); - Collections.sort(versionsToGen); - Collections.reverse(versionsToGen); - } else { - versionsToGen.add(new SchemaVersion(versionToGen)); - } - - //process file type System property - if ( fileTypeToGen.equals(GENERATE_TYPE_YAML) ) { - if ( responsesUrl == null || responsesUrl.length() < 1 - || responsesLabel == null || responsesLabel.length() < 1 ) { - System.err.println("generating swagger yaml file requires yamlresponses_url and yamlresponses_label properties" ); - System.exit(1); - } else { - responsesUrl = "description: "+ "Response codes found in [response codes]("+responsesLabel+ ").\n"; - } - } - /* - * TODO: Oxm Path is config driveb - */ - String oxmPath; - if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains( + ); + + SchemaVersions schemaVersions = ctx.getBean(SchemaVersions.class); + + if ( !fileTypeToGen.equals(GENERATE_TYPE_XSD) && !fileTypeToGen.equals(GENERATE_TYPE_YAML)) { + System.err.println("Invalid gen_type passed. " + fileTypeToGen); + System.exit(1); + } + + String responsesLabel = System.getProperty("yamlresponses_url"); + responsesUrl = responsesLabel; + + List<SchemaVersion> versionsToGen = new ArrayList<>(); + if (!"ALL".equalsIgnoreCase(versionToGen) && !versionToGen.matches("v\\d+") && !validVersion(versionToGen)) { + System.err.println("Invalid version passed. " + versionToGen); + System.exit(1); + } + else if ("ALL".equalsIgnoreCase(versionToGen)) { + versionsToGen = schemaVersions.getVersions(); + Collections.sort(versionsToGen); + Collections.reverse(versionsToGen); + } else { + versionsToGen.add(new SchemaVersion(versionToGen)); + } + + //process file type System property + if ( fileTypeToGen.equals(GENERATE_TYPE_YAML) ) { + if ( responsesUrl == null || responsesUrl.length() < 1 + || responsesLabel == null || responsesLabel.length() < 1 ) { + System.err.println("generating swagger yaml file requires yamlresponses_url and yamlresponses_label properties" ); + System.exit(1); + } else { + responsesUrl = "description: "+ "Response codes found in [response codes]("+responsesLabel+ ").\n"; + } + } + /* + * TODO: Oxm Path is config driveb + */ + String oxmPath; + if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains( NORMAL_START_DIR)) { - oxmPath = BASE_AUTO_GEN_ROOT + NODE_DIR; - } - else { - oxmPath = BASE_ROOT + NODE_DIR; - } - - String outfileName = null; - File outfile; - String nodesfileName = null; - File nodesfile; - String fileContent = null; - String nodesContent = null; - - - for (SchemaVersion v : versionsToGen) { - apiVersion = v.toString(); - logger.debug("YAMLdir = "+ YAML_DIR); - logger.debug("Generating " + apiVersion + " " + fileTypeToGen); - apiVersionFmt = "." + apiVersion + "."; - generatedJavaType = new HashMap<String, String>(); - appliedPaths = new HashMap<String, String>(); - File edgeRuleFile = null; - String fileName = EDGE_DIR + "DbEdgeRules_" + apiVersion + ".json"; - logger.debug("user.dir = "+System.getProperty("user.dir")); - if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains( + oxmPath = BASE_AUTO_GEN_ROOT + NODE_DIR; + } + else { + oxmPath = BASE_ROOT + NODE_DIR; + } + + String outfileName = null; + File outfile; + String nodesfileName = null; + File nodesfile; + String fileContent = null; + String nodesContent = null; + + + for (SchemaVersion v : versionsToGen) { + apiVersion = v.toString(); + logger.debug("YAMLdir = "+ YAML_DIR); + logger.debug("Generating " + apiVersion + " " + fileTypeToGen); + apiVersionFmt = "." + apiVersion + "."; + generatedJavaType = new HashMap<String, String>(); + appliedPaths = new HashMap<String, String>(); + File edgeRuleFile = null; + String fileName = EDGE_DIR + "DbEdgeRules_" + apiVersion + ".json"; + logger.debug("user.dir = "+System.getProperty("user.dir")); + if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains( NORMAL_START_DIR)) { - fileName = BASE_AUTO_GEN_ROOT + fileName; - - } - else { - fileName = BASE_ROOT + fileName; - - } - edgeRuleFile = new File( fileName); -// Document doc = ni.getSchema(translateVersion(v)); - - if ( fileTypeToGen.equals(GENERATE_TYPE_XSD) ) { - outfileName = XSD_DIR + "/aai_schema_" + apiVersion + "." + GENERATE_TYPE_XSD; - try { - HTMLfromOXM swagger = ctx.getBean(HTMLfromOXM.class); - swagger.setVersion(v); - fileContent = swagger.process(); - if ( fileContent.startsWith("Schema format issue")) { - throw new Exception(fileContent); - } - } catch(Exception e) { - logger.error( "Exception creating output file " + outfileName); - logger.error( e.getMessage()); - System.exit(-1); - } - } else if ( versionSupportsSwagger(apiVersion )) { - outfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + GENERATE_TYPE_YAML; - nodesfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + "nodes"+"."+ + fileName = BASE_AUTO_GEN_ROOT + fileName; + + } + else { + fileName = BASE_ROOT + fileName; + + } + edgeRuleFile = new File( fileName); +// Document doc = ni.getSchema(translateVersion(v)); + + if ( fileTypeToGen.equals(GENERATE_TYPE_XSD) ) { + outfileName = XSD_DIR + "/aai_schema_" + apiVersion + "." + GENERATE_TYPE_XSD; + try { + HTMLfromOXM swagger = ctx.getBean(HTMLfromOXM.class); + swagger.setVersion(v); + fileContent = swagger.process(); + if ( fileContent.startsWith("Schema format issue")) { + throw new Exception(fileContent); + } + } catch(Exception e) { + logger.error( "Exception creating output file " + outfileName); + logger.error( e.getMessage()); + System.exit(-1); + } + } else if ( versionSupportsSwagger(apiVersion )) { + outfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + GENERATE_TYPE_YAML; + nodesfileName = YAML_DIR + "/aai_swagger_" + apiVersion + "." + "nodes"+"."+ GENERATE_TYPE_YAML; - try { - YAMLfromOXM swagger = (YAMLfromOXM) ctx.getBean(YAMLfromOXM.class); - swagger.setVersion(v); - fileContent = swagger.process(); - Map combinedJavaTypes = swagger.getCombinedJavaTypes(); - NodesYAMLfromOXM nodesSwagger = ctx.getBean(NodesYAMLfromOXM.class); - nodesSwagger.setVersion(v); - nodesSwagger.setCombinedJavaTypes(combinedJavaTypes); - nodesContent = nodesSwagger.process(); - } catch(Exception e) { - logger.error("Exception creating output file " + outfileName, e); - } - } else { - continue; - } - outfile = new File(outfileName); - File parentDir = outfile.getParentFile(); - if(!parentDir.exists()) { + try { + YAMLfromOXM swagger = (YAMLfromOXM) ctx.getBean(YAMLfromOXM.class); + swagger.setVersion(v); + fileContent = swagger.process(); + Map combinedJavaTypes = swagger.getCombinedJavaTypes(); + NodesYAMLfromOXM nodesSwagger = ctx.getBean(NodesYAMLfromOXM.class); + nodesSwagger.setVersion(v); + nodesSwagger.setCombinedJavaTypes(combinedJavaTypes); + nodesContent = nodesSwagger.process(); + } catch(Exception e) { + logger.error("Exception creating output file " + outfileName, e); + } + } else { + continue; + } + outfile = new File(outfileName); + File parentDir = outfile.getParentFile(); + if(!parentDir.exists()) { parentDir.mkdirs(); } - if(nodesfileName != null) { - BufferedWriter nodesBW = null; - nodesfile = new File(nodesfileName); - parentDir = nodesfile.getParentFile(); - if(!parentDir.exists()){ + if(nodesfileName != null) { + BufferedWriter nodesBW = null; + nodesfile = new File(nodesfileName); + parentDir = nodesfile.getParentFile(); + if(!parentDir.exists()){ parentDir.mkdirs(); } - try { - if(!nodesfile.createNewFile()) { + try { + if(!nodesfile.createNewFile()) { logger.error( "File {} already exist", nodesfileName); } - } catch (IOException e) { - logger.error( "Exception creating output file " + nodesfileName, e); - } - try { - Charset charset = StandardCharsets.UTF_8; - Path path = Paths.get(nodesfileName); - nodesBW = Files.newBufferedWriter(path, charset); - nodesBW.write(nodesContent); - } catch ( IOException e) { - logger.error( "Exception writing output file " + outfileName, e); - } finally { - if ( nodesBW != null ) { - nodesBW.close(); - } - } - } - - try { - if(!outfile.createNewFile()) { + } catch (IOException e) { + logger.error( "Exception creating output file " + nodesfileName, e); + } + try { + Charset charset = StandardCharsets.UTF_8; + Path path = Paths.get(nodesfileName); + nodesBW = Files.newBufferedWriter(path, charset); + nodesBW.write(nodesContent); + } catch ( IOException e) { + logger.error( "Exception writing output file " + outfileName, e); + } finally { + if ( nodesBW != null ) { + nodesBW.close(); + } + } + } + + try { + if(!outfile.createNewFile()) { logger.error( "File {} already exist", outfileName); } - } catch (IOException e) { - logger.error( "Exception creating output file " + outfileName, e); - } - BufferedWriter bw = null; - try { - Charset charset = StandardCharsets.UTF_8; - Path path = Paths.get(outfileName); - bw = Files.newBufferedWriter(path, charset); - bw.write(fileContent); - } catch ( IOException e) { - logger.error( "Exception writing output file " + outfileName, e); - } finally { - if ( bw != null ) { - bw.close(); - } - } - logger.debug( "GeneratedXSD successful, saved in " + outfileName); - } - - } + } catch (IOException e) { + logger.error( "Exception creating output file " + outfileName, e); + } + BufferedWriter bw = null; + try { + Charset charset = StandardCharsets.UTF_8; + Path path = Paths.get(outfileName); + bw = Files.newBufferedWriter(path, charset); + bw.write(fileContent); + } catch ( IOException e) { + logger.error( "Exception writing output file " + outfileName, e); + } finally { + if ( bw != null ) { + bw.close(); + } + } + logger.debug( "GeneratedXSD successful, saved in " + outfileName); + } + + } } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java index 48cd46d..d91cf81 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/SpringContextAware.java @@ -31,23 +31,23 @@ public class SpringContextAware implements ApplicationContextAware { private static ApplicationContext context = null; public static ApplicationContext getApplicationContext() { - return context; + return context; } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - context = applicationContext; + context = applicationContext; } - public static <T> T getBean(String beanName, Class<T> requiredType) { - if(context != null){ - return context.getBean(beanName, requiredType); - } + public static <T> T getBean(String beanName, Class<T> requiredType) { + if(context != null){ + return context.getBean(beanName, requiredType); + } return null; - } + } - public static <T> T getBean(Class<T> clazz){ + public static <T> T getBean(Class<T> clazz){ if(context != null){ return context.getBean(clazz); } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java index 217aa4e..c4db6f9 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/ConfigTranslatorForDocs.java @@ -31,51 +31,51 @@ import java.util.*; public class ConfigTranslatorForDocs extends ConfigTranslator { - public ConfigTranslatorForDocs(SchemaLocationsBean bean, SchemaVersions schemaVersions) { - super(bean, schemaVersions); - } + public ConfigTranslatorForDocs(SchemaLocationsBean bean, SchemaVersions schemaVersions) { + super(bean, schemaVersions); + } - @Override - public Map<SchemaVersion, List<String>> getNodeFiles() { - List<SchemaVersion> versionsToGen = new ArrayList<>(); - versionsToGen = schemaVersions.getVersions(); - Collections.sort(versionsToGen); - Collections.reverse(versionsToGen); - Map<SchemaVersion, List<String>> mp = new TreeMap<>(); - for (SchemaVersion v : versionsToGen) { - File dir = new File(bean.getNodeDirectory() + File.separator + v.toString().toLowerCase()); - File [] fileSet = dir.listFiles(); - List<String> files = new ArrayList<>(); - for(File f: fileSet ) { - files.add(f.getAbsolutePath()); - } + @Override + public Map<SchemaVersion, List<String>> getNodeFiles() { + List<SchemaVersion> versionsToGen = new ArrayList<>(); + versionsToGen = schemaVersions.getVersions(); + Collections.sort(versionsToGen); + Collections.reverse(versionsToGen); + Map<SchemaVersion, List<String>> mp = new TreeMap<>(); + for (SchemaVersion v : versionsToGen) { + File dir = new File(bean.getNodeDirectory() + File.separator + v.toString().toLowerCase()); + File [] fileSet = dir.listFiles(); + List<String> files = new ArrayList<>(); + for(File f: fileSet ) { + files.add(f.getAbsolutePath()); + } - mp.put(v, files); - } - return mp; - } + mp.put(v, files); + } + return mp; + } - @Override - public Map<SchemaVersion, List<String>> getEdgeFiles() { - List<SchemaVersion> versionsToGen = new ArrayList<>(); - versionsToGen = schemaVersions.getVersions(); - Collections.sort(versionsToGen); - Collections.reverse(versionsToGen); - Map<SchemaVersion, List<String>> mp = new TreeMap<>(); - for (SchemaVersion v : versionsToGen) { - File dir = new File(bean.getEdgeDirectory()); - File [] fileSet = dir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.contains("_"+v.toString().toLowerCase()); - } - }); - List<String> files = new ArrayList<>(); - for(File f: fileSet ) { - files.add(f.getAbsolutePath()); - } - mp.put(v, files); - } - return mp; - } + @Override + public Map<SchemaVersion, List<String>> getEdgeFiles() { + List<SchemaVersion> versionsToGen = new ArrayList<>(); + versionsToGen = schemaVersions.getVersions(); + Collections.sort(versionsToGen); + Collections.reverse(versionsToGen); + Map<SchemaVersion, List<String>> mp = new TreeMap<>(); + for (SchemaVersion v : versionsToGen) { + File dir = new File(bean.getEdgeDirectory()); + File [] fileSet = dir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.contains("_"+v.toString().toLowerCase()); + } + }); + List<String> files = new ArrayList<>(); + for(File f: fileSet ) { + files.add(f.getAbsolutePath()); + } + mp.put(v, files); + } + return mp; + } } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java index 7efaed9..a570d6f 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/DeleteFootnoteSet.java @@ -23,35 +23,35 @@ import java.util.Set; import java.util.TreeSet; public class DeleteFootnoteSet { - protected Set<String> footnotes = new TreeSet<>(); - protected String targetNode = "<NodeType>"; - public DeleteFootnoteSet(String targetNode) { - super(); - this.targetNode = targetNode == null ? "" : targetNode; - } + protected Set<String> footnotes = new TreeSet<>(); + protected String targetNode = "<NodeType>"; + public DeleteFootnoteSet(String targetNode) { + super(); + this.targetNode = targetNode == null ? "" : targetNode; + } - public void add(String s ) { - String fullnote=null; - if("(1)".equals(s)) { - fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this FROM node is DELETED also"; - } else if("(2)".equals(s)) { - fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this TO node is DELETED also"; - } else if("(3)".equals(s)) { - fullnote = s+" IF this FROM node is deleted, this "+targetNode.toUpperCase()+" is DELETED also"; - } else if("(4)".equals(s)) { - fullnote = s+" IF this TO node is deleted, this "+targetNode.toUpperCase()+" is DELETED also"; - } else if(s.contains(targetNode.toUpperCase())) { - fullnote = s; - } else { - return; - } - footnotes.add(fullnote); - } + public void add(String s ) { + String fullnote=null; + if("(1)".equals(s)) { + fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this FROM node is DELETED also"; + } else if("(2)".equals(s)) { + fullnote = s+" IF this "+targetNode.toUpperCase()+" node is deleted, this TO node is DELETED also"; + } else if("(3)".equals(s)) { + fullnote = s+" IF this FROM node is deleted, this "+targetNode.toUpperCase()+" is DELETED also"; + } else if("(4)".equals(s)) { + fullnote = s+" IF this TO node is deleted, this "+targetNode.toUpperCase()+" is DELETED also"; + } else if(s.contains(targetNode.toUpperCase())) { + fullnote = s; + } else { + return; + } + footnotes.add(fullnote); + } - public String toString() { - StringBuilder sb = new StringBuilder(); - if(footnotes.size() > 0) sb.append("\n -"); - sb.append(String.join("\n -", footnotes)+"\n"); - return sb.toString(); - } + public String toString() { + StringBuilder sb = new StringBuilder(); + if(footnotes.size() > 0) sb.append("\n -"); + sb.append(String.join("\n -", footnotes)+"\n"); + return sb.toString(); + } } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java index a22dfd5..f9d1799 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/GetOperation.java @@ -50,16 +50,16 @@ public class GetOperation { this.tag = tag; this.path = path; this.pathParams = pathParams; -// StringBuilder p = new StringBuilder(); +// StringBuilder p = new StringBuilder(); if (containers.get(xmlRootElementName) == null) { this.queryParams = ""; } else { this.queryParams = String.join("", containers.get(xmlRootElementName)); -// for(String param : containers.get(xmlRootElementName)) { -// p.append(param); -// } -// this.queryParams = p.toString(); +// for(String param : containers.get(xmlRootElementName)) { +// p.append(param); +// } +// this.queryParams = p.toString(); } } @@ -68,11 +68,11 @@ public class GetOperation { StringTokenizer st; st = new StringTokenizer(path, "/"); //Path has to be longer than one element - /* - if ( st.countTokens() <= 1) { - return ""; - } - */ + /* + if ( st.countTokens() <= 1) { + return ""; + } + */ //a valid tag is necessary if (StringUtils.isEmpty(tag)) { return ""; @@ -116,9 +116,9 @@ public class GetOperation { if (StringUtils.isNotEmpty(pathParams)) { pathSb.append(pathParams); } -// if ( StringUtils.isNotEmpty(pathParams) && StringUtils.isNotEmpty(queryParams)) { -// pathSb.append("\n"); -// } +// if ( StringUtils.isNotEmpty(pathParams) && StringUtils.isNotEmpty(queryParams)) { +// pathSb.append("\n"); +// } if (StringUtils.isNotEmpty(queryParams)) { pathSb.append(queryParams); } diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java index ce45236..01598a0 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/HTMLfromOXM.java @@ -203,7 +203,7 @@ public class HTMLfromOXM extends OxmFileProcessor { XSDElement xmlElementElement = new XSDElement((Element) xmlElementNodes.item(i), maxOccurs); -// String elementName = xmlElementElement.getAttribute("name"); +// String elementName = xmlElementElement.getAttribute("name"); String elementType = xmlElementElement.getAttribute("type"); //No simple types; only AAI custom types String addType = elementType.contains("." + v.toString() + ".") ? diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java index 2561593..bdfdfd6 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/NodeGetOperation.java @@ -90,11 +90,11 @@ public class NodeGetOperation { StringTokenizer st; st = new StringTokenizer(CRUDpath, "/"); //Path has to be longer than one element - /* - if ( st.countTokens() <= 1) { - return ""; - } - */ + /* + if ( st.countTokens() <= 1) { + return ""; + } + */ //a valid tag is necessary if (StringUtils.isEmpty(tag)) { return ""; diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java index 5fe3564..bbdcd70 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/genxsd/XSDElement.java @@ -131,9 +131,9 @@ public class XSDElement implements Element { .equals(this.xmlElementElement.getAttribute("name"))) { continue; } -// This stopped working, replaced with above - should figure out why... -// if ( !xmlPropElement.getParentNode().isSameNode(this.xmlElementElement)) -// continue; +// This stopped working, replaced with above - should figure out why... +// if ( !xmlPropElement.getParentNode().isSameNode(this.xmlElementElement)) +// continue; NodeList childNodes = xmlPropElement.getElementsByTagName("xml-property"); for (int j = 0; j < childNodes.getLength(); ++j) { @@ -370,7 +370,7 @@ public class XSDElement implements Element { sbElement.append("/>").append(OxmFileProcessor.LINE_SEPARATOR); } return this.getHTMLElementWrapper(sbElement.toString(), v, useAnnotation); -// return sbElement.toString(); +// return sbElement.toString(); } public String getHTMLElementWrapper(String unwrappedElement, SchemaVersion v, diff --git a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java index ded5f52..6663dc4 100644 --- a/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java +++ b/aai-schema-gen/src/main/java/org/onap/aai/schemagen/swagger/GenerateSwagger.java @@ -44,12 +44,12 @@ public class GenerateSwagger { public static SchemaVersions schemaVersions; public SchemaVersions getSchemaVersions() { - return schemaVersions; - } + return schemaVersions; + } - public static void main(String[] args) throws IOException, TemplateException { + public static void main(String[] args) throws IOException, TemplateException { @@ -63,13 +63,13 @@ public class GenerateSwagger { if(schemaDir == null){ if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) { - System.out.println("Warning: Schema directory is not set so using default schema dir: " + ALT_SCHEMA_DIR); - schemaDir = ALT_SCHEMA_DIR; - } - else { - System.out.println("Warning: Schema directory is not set so using default schema dir: " + DEFAULT_SCHEMA_DIR); - schemaDir = DEFAULT_SCHEMA_DIR; - } + System.out.println("Warning: Schema directory is not set so using default schema dir: " + ALT_SCHEMA_DIR); + schemaDir = ALT_SCHEMA_DIR; + } + else { + System.out.println("Warning: Schema directory is not set so using default schema dir: " + DEFAULT_SCHEMA_DIR); + schemaDir = DEFAULT_SCHEMA_DIR; + } } if(versionToGenerate == null){ @@ -141,7 +141,7 @@ public class GenerateSwagger { line = line.trim(); String hyperLink = ""; if(line.trim().contains("Differences versus")) { - return ""; + return ""; } if(line.trim().contains("https://")){ int startIndex = line.indexOf("https://"); @@ -161,10 +161,10 @@ public class GenerateSwagger { configuration.setClassForTemplateLoading(Api.class, "/"); String resourcePath = "src/main/resources"; if(System.getProperty("user.dir") != null && !System.getProperty("user.dir").contains(DEFAULT_RUN_DIR)) { - configuration.setDirectoryForTemplateLoading(new File(DEFAULT_RUN_DIR + "/" + resourcePath)); + configuration.setDirectoryForTemplateLoading(new File(DEFAULT_RUN_DIR + "/" + resourcePath)); } else { - configuration.setDirectoryForTemplateLoading(new File(resourcePath)); + configuration.setDirectoryForTemplateLoading(new File(resourcePath)); } Template template = configuration.getTemplate("swagger.html.ftl"); @@ -255,23 +255,23 @@ public class GenerateSwagger { requestBody = requestBodyList.get(0); for(String key : requestBody.keySet()) { //Filter out all the relationship links that appear in the YAML - if(key.equals("description")) { - String reqBody=(String)requestBody.get(key); - if(!reqBody.replaceAll("\\[.*.json\\)", "").equals(reqBody)) { - requestBody.put(key, reqBody.replaceAll("\\[.*.json\\)", "")); - } - } + if(key.equals("description")) { + String reqBody=(String)requestBody.get(key); + if(!reqBody.replaceAll("\\[.*.json\\)", "").equals(reqBody)) { + requestBody.put(key, reqBody.replaceAll("\\[.*.json\\)", "")); + } + } //Filter out all the patchDefinition links that appear in the YAML - if(key.equals("schema")) { - LinkedHashMap<String,String> reqBody = (LinkedHashMap<String,String>)requestBody.get(key); - String schema=reqBody.get("$ref"); - String schemaNopatch = schema.replace("patchDefinitions", "definitions"); - - if(! schema.equals(schemaNopatch)) { - reqBody.put("$ref", schemaNopatch); - requestBody.put(key, reqBody); - } - } + if(key.equals("schema")) { + LinkedHashMap<String,String> reqBody = (LinkedHashMap<String,String>)requestBody.get(key); + String schema=reqBody.get("$ref"); + String schemaNopatch = schema.replace("patchDefinitions", "definitions"); + + if(! schema.equals(schemaNopatch)) { + reqBody.put("$ref", schemaNopatch); + requestBody.put(key, reqBody); + } + } } httpVerb.setBodyParametersEnabled(true); httpVerb.setBodyParameters(requestBody); |