aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-06-16 13:36:25 -0400
committerVenkata Harish K Kajur <vk250x@att.com>2017-06-16 13:41:34 -0400
commiteff9232ffe36022d63e6a70df7a3f0165015bbc8 (patch)
treee014ef33e3e950955c770b07410c2867ca09b9e9 /aai-core
parent0a85ae513893b48c82e8024188a6ab7070d797c9 (diff)
[AAI-ONAP] Take latest develop code from internal
Change-Id: I9ce0ecd6adcfb3678a7e94567bd7a3814ec3440d Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/pom.xml10
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java2
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java13
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java41
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/util/AAIConstants.java7
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java261
6 files changed, 216 insertions, 118 deletions
diff --git a/aai-core/pom.xml b/aai-core/pom.xml
index b1a0226f..22d6daf8 100644
--- a/aai-core/pom.xml
+++ b/aai-core/pom.xml
@@ -322,7 +322,7 @@
<scope>test</scope>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
@@ -423,7 +423,7 @@
<phase>none</phase>
</execution>
</executions>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
@@ -437,7 +437,7 @@
</plugin>
</plugins>
</build>
-
+
<distributionManagement>
<repository>
<id>ecomp-releases</id>
@@ -467,7 +467,7 @@
<url>http://www.evosuite.org/m2</url>
</pluginRepository>
</pluginRepositories>
-
+
<repositories>
<repository>
<id>AJSC</id>
@@ -479,7 +479,7 @@
<name>maven reslet</name>
<url>https://maven.restlet.com/</url>
</repository>
-
+
<repository>
<id>central</id>
<name>Maven 2 repository 2</name>
diff --git a/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java b/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java
index b5a80033..78f59844 100644
--- a/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java
+++ b/aai-core/src/main/java/org/openecomp/aai/introspection/Introspector.java
@@ -302,7 +302,7 @@ public abstract class Introspector implements Cloneable {
public Set<String> getDependentOn() {
String dependentOn = this.getMetadata(ObjectMetadata.DEPENDENT_ON);
if (dependentOn == null) {
- dependentOn = "";
+ return new LinkedHashSet<>();
}
return new LinkedHashSet<>(Arrays.asList(dependentOn.split(",")));
}
diff --git a/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java b/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java
index 43af40ae..919029a0 100644
--- a/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java
+++ b/aai-core/src/main/java/org/openecomp/aai/logging/ErrorLogHelper.java
@@ -41,8 +41,10 @@ import org.slf4j.MDC;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.logging.LoggingContext.StatusCode;
+import org.openecomp.aai.util.AAIConfig;
import org.openecomp.aai.util.AAIConstants;
import org.openecomp.aai.util.MapperUtil;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -560,10 +562,13 @@ public class ErrorLogHelper {
// MDC.put("severity", errorObject.getSeverity()); //TODO Use LoggingContext.severity(int severity)
String severityCode = errorObject.getSeverityCode(errorObject.getSeverity());
- int sevCode = Integer.parseInt(severityCode);
- if (sevCode > 0 && sevCode <= 3 )
- {
- LoggingContext.severity(sevCode);
+
+ if (!AAIConfig.isEmpty(severityCode)) {
+ int sevCode = Integer.parseInt(severityCode);
+ if (sevCode > 0 && sevCode <= 3 )
+ {
+ LoggingContext.severity(sevCode);
+ }
}
final String errorMessage = new StringBuilder()
diff --git a/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java b/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java
index 5f59a931..4e261060 100644
--- a/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java
+++ b/aai-core/src/main/java/org/openecomp/aai/serialization/db/DBSerializer.java
@@ -33,6 +33,7 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
@@ -51,7 +52,6 @@ import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.javatuples.Pair;
-
import org.openecomp.aai.db.props.AAIProperties;
import org.openecomp.aai.exceptions.AAIException;
import org.openecomp.aai.introspection.Introspector;
@@ -80,6 +80,7 @@ import org.openecomp.aai.util.AAIApiServerURLBase;
import org.openecomp.aai.util.AAIConfig;
import org.openecomp.aai.util.AAIConstants;
import org.openecomp.aai.workarounds.NamingExceptions;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.google.common.base.CaseFormat;
@@ -295,10 +296,12 @@ public class DBSerializer {
continue;
}
if (value != null) {
- if (propertyType.toLowerCase().contains(".long")) {
- v.property(dbProperty, new Integer(((Long)value).toString()));
- } else {
- v.property(dbProperty, value);
+ if (!value.equals(v.property(dbProperty).orElse(null))) {
+ if (propertyType.toLowerCase().contains(".long")) {
+ v.property(dbProperty, new Integer(((Long)value).toString()));
+ } else {
+ v.property(dbProperty, value);
+ }
}
} else {
v.property(dbProperty).remove();
@@ -920,12 +923,12 @@ public class DBSerializer {
//we must look up all parents in this case because we need to compute name-properties
//we cannot used the cached aaiUri to perform this action currently
- Pair<Vertex, List<Introspector>> tuple = this.getParents(relationshipObj.getLoader(), cousin, "true".equals(cleanUp));
+ Optional<Pair<Vertex, List<Introspector>>> tuple = this.getParents(relationshipObj.getLoader(), cousin, "true".equals(cleanUp));
//damaged vertex found, ignore
- if (tuple == null) {
+ if (!tuple.isPresent()) {
return null;
}
- List<Introspector> list = tuple.getValue1();
+ List<Introspector> list = tuple.get().getValue1();
URI uri = this.getURIFromList(list);
URIToRelationshipObject uriParser = null;
@@ -934,9 +937,9 @@ public class DBSerializer {
uriParser = new URIToRelationshipObject(relationshipObj.getLoader(), uri, this.baseURL);
result = uriParser.getResult();
} catch (AAIException | URISyntaxException e) {
- LOGGER.error("Error while processing edge relationship in version " + relationshipObj.getVersion() + " (bad vertex ID=" + tuple.getValue0().id().toString() + ": " + e.getMessage(), e);
+ LOGGER.error("Error while processing edge relationship in version " + relationshipObj.getVersion() + " (bad vertex ID=" + tuple.get().getValue0().id().toString() + ": " + e.getMessage(), e);
if ("true".equals(cleanUp)) {
- this.deleteWithTraversal(tuple.getValue0());
+ this.deleteWithTraversal(tuple.get().getValue0());
}
return null;
}
@@ -968,18 +971,20 @@ public class DBSerializer {
}
public URI getURIForVertex(Vertex v, boolean overwrite) throws UnsupportedEncodingException {
- URI uri = null;
+ URI uri = UriBuilder.fromPath("/unknown-uri").build();
String aaiUri = v.<String>property(AAIProperties.AAI_URI).orElse(null);
if (aaiUri != null && !overwrite) {
uri = UriBuilder.fromPath(aaiUri).build();
} else {
- Pair<Vertex, List<Introspector>> tuple = this.getParents(this.loader, v, false);
- List<Introspector> list = tuple.getValue1();
- uri = this.getURIFromList(list);
+ Optional<Pair<Vertex, List<Introspector>>> tuple = this.getParents(this.loader, v, false);
+ if (tuple.isPresent()) {
+ List<Introspector> list = tuple.get().getValue1();
+ uri = this.getURIFromList(list);
+ }
}
- return uri;
+ return uri;
}
/**
* Gets the URI from list.
@@ -1014,7 +1019,7 @@ public class DBSerializer {
* @throws SecurityException the security exception
* @throws AAIUnknownObjectException
*/
- private Pair<Vertex, List<Introspector>> getParents(Loader loader, Vertex start, boolean removeDamaged) {
+ private Optional<Pair<Vertex, List<Introspector>>> getParents(Loader loader, Vertex start, boolean removeDamaged) {
List<Vertex> results = this.engine.getQueryEngine().findParents(start);
List<Introspector> objs = new ArrayList<>();
@@ -1050,10 +1055,10 @@ public class DBSerializer {
//stop processing and don't return anything for this bad vertex
if (shortCircuit) {
- return null;
+ return Optional.empty();
}
- return new Pair<>(results.get(results.size()-1), objs);
+ return Optional.of(new Pair<>(results.get(results.size()-1), objs));
}
/**
* Takes a list of vertices and a list of objs and assumes they are in
diff --git a/aai-core/src/main/java/org/openecomp/aai/util/AAIConstants.java b/aai-core/src/main/java/org/openecomp/aai/util/AAIConstants.java
index 382825d0..7d9bcccd 100644
--- a/aai-core/src/main/java/org/openecomp/aai/util/AAIConstants.java
+++ b/aai-core/src/main/java/org/openecomp/aai/util/AAIConstants.java
@@ -20,6 +20,8 @@
package org.openecomp.aai.util;
+import org.openecomp.aai.db.props.AAIProperties;
+
public final class AAIConstants {
//
@@ -78,7 +80,12 @@ public final class AAIConstants {
public static final String AAI_SERVER_URL = "aai.server.url";
public static final String AAI_OLDSERVER_URL = "aai.oldserver.url";
public static final String AAI_GLOBAL_CALLBACK_URL = "aai.global.callback.url";
+ public static final String AAI_LOCAL_REST = "https://localhost:%d/aai/" + AAIProperties.LATEST + "/";
+ public static final int AAI_RESOURCES_PORT = 8447;
+ public static final int AAI_QUERY_PORT = 8446;
+ public static final int AAI_LEGACY_PORT = 8443;
+
public static final String AAI_DEFAULT_API_VERSION = "v7";
public static final String AAI_DEFAULT_API_VERSION_PROP = "aai.default.api.version";
public static final String AAI_NOTIFICATION_CURRENT_VERSION = "aai.notification.current.version";
diff --git a/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java b/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java
index ed3b8f07..7cc6bcf0 100644
--- a/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java
+++ b/aai-core/src/main/java/org/openecomp/aai/util/GenerateXsd.java
@@ -26,9 +26,11 @@ import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@@ -55,6 +57,8 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import org.openecomp.aai.dbmodel.DbEdgeRules;
+import org.openecomp.aai.db.props.AAIProperties;
+import org.openecomp.aai.introspection.Version;
import com.google.common.base.Joiner;
import com.google.common.collect.Multimap;
@@ -62,10 +66,13 @@ import com.google.common.collect.Multimap;
public class GenerateXsd {
static String apiVersion = null;
static String apiVersionFmt = null;
+ static boolean useAnnotationsInXsd = false;
static String responsesUrl = null;
static String responsesLabel = null;
- static Map<String, String> generatedJavaType = new HashMap<String, String>();
- static Map<String, String> appliedPaths = new HashMap<String, String>();
+ //static Map<String, String> generatedJavaType = new HashMap<String, String>();
+ //static Map<String, String> appliedPaths = new HashMap<String, String>();
+ static Map<String, String> generatedJavaType;
+ static Map<String, String> appliedPaths;
static NodeList javaTypeNodes;
static Class<?> versionedClass;
@@ -74,6 +81,16 @@ public class GenerateXsd {
public static final int VALUE_DESCRIPTION = 1;
public static final int VALUE_INDEXED_PROPS = 2;
+ private static final String generateTypeXSD = "xsd";
+ private static final String generateTypeYAML = "yaml";
+
+ private static final String root = "../aai-schema/src/main/resources";
+ private static final String xsd_dir = root + "/aai_schema";
+ private static final String yaml_dir = root + "/aai_swagger_yaml";
+
+ private static int annotationsStartVersion = 9; // minimum version to support annotations in xsd
+ private static int swaggerSupportStartsVersion = 7; // minimum version to support swagger documentation
+
private static XPath xpath = XPathFactory.newInstance().newXPath();
@@ -211,62 +228,107 @@ public class GenerateXsd {
// }
}
+ private static boolean validVersion(String versionToGen) {
+
+ if ("ALL".equalsIgnoreCase(versionToGen)) {
+ return true;
+ }
+
+ for (Version v : Version.values()) {
+ if (v.name().equals(versionToGen)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private static boolean versionUsesAnnotations( String version) {
+ if (new Integer(version.substring(1)).intValue() >= annotationsStartVersion ) {
+ return true;
+ }
+ return false;
+ }
+
+ private static boolean versionSupportsSwagger( String version) {
+ if (new Integer(version.substring(1)).intValue() >= swaggerSupportStartsVersion ) {
+ return true;
+ }
+ return false;
+ }
+
public static void main(String[] args) throws IOException {
-
- if (args.length > 0) {
- if (args[0] != null) {
- apiVersion = args[0];
- }
+ String versionToGen = System.getProperty("gen_version").toLowerCase();
+ String fileTypeToGen = System.getProperty("gen_type").toLowerCase();
+ if ( fileTypeToGen == null ) {
+ fileTypeToGen = generateTypeXSD;
}
- boolean genDoc = false;
- if ( args.length > 1 ) {
- genDoc = true;
- int index = args[1].indexOf("|");
- if ( index > 0 ) {
- responsesUrl = args[1].substring(0, index);
- responsesLabel = args[1].substring(index+1);
- //System.out.println( "response URL " + responsesUrl);
- //System.out.println( "response label " + responsesLabel);
- responsesUrl = "description: "+ responsesLabel + "(" +
- responsesUrl + ").\n";
- //System.out.println( "operation described with " + responsesUrl);
- } else { // default
- responsesUrl = "";
- }
+
+ if ( !fileTypeToGen.equals( generateTypeXSD ) && !fileTypeToGen.equals( generateTypeYAML )) {
+ System.err.println("Invalid gen_type passed. " + fileTypeToGen);
+ System.exit(1);
}
- String oxmPath = null;
- if ( apiVersion == null ) {
- // to run from eclipse, set these env, e.g. v7, \sources\aai\aaimastergit\bundleconfig-local\etc\oxm\
- String envRev= System.getenv("OXM_REV");
- if ( envRev != null )
- apiVersion = envRev;
-
+
+
+ if ( versionToGen == null ) {
+ System.err.println("Version is required, ie v<n> or ALL.");
+ System.exit(1);
}
- oxmPath = System.getenv("OXM_PATH");
- String outfileName;
- if ( genDoc ) {
- outfileName = "c:\\temp\\aai.yaml";
- } else
- outfileName = "c:\\temp\\aai_schema.xsd";
- if ( apiVersion != null ) { // generate from oxm
- apiVersionFmt = "." + apiVersion + ".";
- if ( oxmPath == null ) {
- oxmPath = AAIConstants.AAI_HOME_ETC_OXM + AAIConstants.AAI_FILESEP;
- //oxmPath = "\\sources\\aai\\aaimastergit\\bundleconfig-local\\etc\\oxm\\";
+
+ responsesUrl = System.getProperty("yamlresponses_url");
+ String responsesLabel = System.getProperty("yamlresponses_label");
+ List<Version> versionsToGen = new ArrayList<>();
+
+
+ if (!"ALL".equalsIgnoreCase(versionToGen) && !versionToGen.matches("v\\d+") && !validVersion(versionToGen)) {
+ System.err.println("Invalid version passed. " + versionToGen);
+ System.exit(1);
+ }
+
+ if ("ALL".equalsIgnoreCase(versionToGen)) {
+ versionsToGen = Arrays.asList(Version.values());
+ Collections.sort(versionsToGen);
+ Collections.reverse(versionsToGen);
+ } else {
+ versionsToGen.add(Version.valueOf(versionToGen));
+ }
+
+ if ( fileTypeToGen.equals(generateTypeYAML) ) {
+ 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);
}
-
+ responsesUrl = "description: "+ responsesLabel+ "(" + responsesUrl + ").\n";
+ }
+ String oxmPath = root + "/oxm/";
+
+ String outfileName;
+ File outfile;
+ String fileContent;
+
+ for (Version v : versionsToGen) {
+ apiVersion = v.toString();
+ System.out.println("Generating " + apiVersion + " " + fileTypeToGen);
File oxm_file = new File(oxmPath + "aai_oxm_" + apiVersion + ".xml");
- String xsd;
- File outfile;
- if ( genDoc ) {
- xsd = generateSwaggerFromOxmFile( oxm_file);
- outfile =new File(outfileName);
+ apiVersionFmt = "." + apiVersion + ".";
+ generatedJavaType = new HashMap<String, String>();
+ appliedPaths = new HashMap<String, String>();
+ if ( fileTypeToGen.equals(generateTypeXSD) ) {
+ useAnnotationsInXsd = versionUsesAnnotations(apiVersion);
+ outfileName = xsd_dir + "/aai_schema_" + apiVersion + "." + generateTypeXSD;
+ fileContent = processOxmFile( oxm_file);
+ } else if ( versionSupportsSwagger(apiVersion )) {
+ outfileName = yaml_dir + "/aai_swagger_" + apiVersion + "." + generateTypeYAML;
+ fileContent = generateSwaggerFromOxmFile( oxm_file);
} else {
- xsd = processOxmFile( oxm_file);
- outfile =new File(outfileName);
+ continue;
}
-
-
+ outfile = new File(outfileName);
+ File parentDir = outfile.getParentFile();
+ if(! parentDir.exists())
+ parentDir.mkdirs();
+
try {
outfile.createNewFile();
} catch (IOException e) {
@@ -276,7 +338,7 @@ public class GenerateXsd {
try {
FileWriter fw = new FileWriter(outfile.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
- bw.write(xsd);
+ bw.write(fileContent);
bw.close();
} catch ( IOException e) {
@@ -284,32 +346,11 @@ public class GenerateXsd {
e.printStackTrace();
}
System.out.println( "GeneratedXSD successful, saved in " + outfileName);
- return;
}
-
- JAXBContext jaxbContext = null;
- try {
- jaxbContext = JAXBContext.newInstance(org.openecomp.aai.domain.yang.Vce.class);
- } catch (JAXBException e) {
- e.printStackTrace();
- }
- SchemaOutputResolver sor = new MySchemaOutputResolver();
- jaxbContext.generateSchema(sor);
-
}
- public static class MySchemaOutputResolver extends SchemaOutputResolver {
- public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
- File file = new File("c:\\temp\\aai_schema.xsd");
- StreamResult result = new StreamResult(file);
- result.setSystemId(file.toURI().toURL().toString());
- return result;
- }
-
- }
-
public static String processJavaTypeElement( String javaTypeName, Element javaTypeElement) {
String xmlRootElementName = null;
@@ -317,7 +358,7 @@ public class GenerateXsd {
NodeList parentNodes = javaTypeElement.getElementsByTagName("java-attributes");
StringBuffer sb = new StringBuffer();
if ( parentNodes.getLength() == 0 ) {
- System.out.println( "no java-attributes for java-type " + javaTypeName);
+ //System.out.println( "no java-attributes for java-type " + javaTypeName);
return "";
}
@@ -358,15 +399,15 @@ public class GenerateXsd {
sb1.append(" <xs:element name=\"" + xmlRootElementName + "\">\n");
sb1.append(" <xs:complexType>\n");
NodeList properties = GenerateXsd.locateXmlProperties(javaTypeElement);
- if (properties != null) {
- System.out.println("properties found for: " + xmlRootElementName);
+ if (properties != null && useAnnotationsInXsd) {
+ //System.out.println("properties found for: " + xmlRootElementName);
sb1.append(" <xs:annotation>\r\n");
insertAnnotation(properties, false, "class", sb1, " ");
sb1.append(" </xs:annotation>\r\n");
- } else {
+ } /*else {
System.out.println("no properties found for: " + xmlRootElementName);
- }
+ }*/
sb1.append(" <xs:sequence>\n");
for ( int i = 0; i < xmlElementNodes.getLength(); ++i ) {
@@ -434,18 +475,18 @@ public class GenerateXsd {
sb1.append(">\n");
sb1.append(" <xs:complexType>\n");
properties = GenerateXsd.locateXmlProperties(javaTypeElement);
- if (properties != null) {
+ if (properties != null && useAnnotationsInXsd) {
sb1.append(" <xs:annotation>\r\n");
insertAnnotation(properties, false, "class", sb1, " ");
sb1.append(" </xs:annotation>\r\n");
- } else {
+ } /*else {
System.out.println("no properties found for: " + xmlElementWrapper);
- }
+ }*/
sb1.append(" <xs:sequence>\n");
sb1.append(" ");
}
if ("Nodes".equals(addType)) {
- System.out.println ("Skipping nodes, temporary testing");
+ //System.out.println ("Skipping nodes, temporary testing");
continue;
}
if ( addType != null ) {
@@ -474,10 +515,11 @@ public class GenerateXsd {
properties = GenerateXsd.locateXmlProperties(xmlElementElement);
if (properties != null || elementIsKey != null) {
sb1.append(">\n");
- sb1.append(" <xs:annotation>\r\n");
- insertAnnotation(properties, elementIsKey != null, "field", sb1, " ");
- sb1.append(" </xs:annotation>\r\n");
-
+ if ( useAnnotationsInXsd ) {
+ sb1.append(" <xs:annotation>\r\n");
+ insertAnnotation(properties, elementIsKey != null, "field", sb1, " ");
+ sb1.append(" </xs:annotation>\r\n");
+ }
if (xmlElementWrapper== null) {
sb1.append(" </xs:element>\n");
}
@@ -553,7 +595,7 @@ public class GenerateXsd {
name = "extendsFrom";
}
metadata.add(name + "=\"" + value.replaceAll("&", "&amp;") + "\"");
- System.out.println("property name: " + name);
+ //System.out.println("property name: " + name);
}
}
@@ -645,13 +687,18 @@ public class GenerateXsd {
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
String namespace = "org.openecomp";
- sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/"
+ if ( useAnnotationsInXsd ) {
+ sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/"
+ apiVersion + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + apiVersion + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\""
+ "\n"
+ "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"\r\n" +
" jaxb:version=\"2.1\" \r\n" +
" xmlns:annox=\"http://annox.dev.java.net\" \r\n" +
" jaxb:extensionBindingPrefixes=\"annox\">\n\n");
+ } else {
+ sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/"
+ + apiVersion + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + apiVersion + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n\n");
+ }
try {
@@ -705,7 +752,7 @@ public class GenerateXsd {
return null;
}
if ("Nodes".equals(javaTypeName)) {
- System.out.println("skipping Nodes entry (temporary feature)");
+ //System.out.println("skipping Nodes entry (temporary feature)");
continue;
}
if ( !generatedJavaType.containsKey(javaTypeName) ) {
@@ -886,7 +933,33 @@ public class GenerateXsd {
return null;
}
}
+ /*
+ if ( path == null )
+ System.out.println( "processJavaTypeElementSwagger called with null path for javaTypeName " + javaTypeName);
+ */
+ /*
+ if ( path == null || !(path.contains("cloud-infrastructure")))
+ switch ( javaTypeName) {
+ case "Inventory":
+ useTag = null;
+ break;
+
+ case "CloudInfrastructure":
+ case "Search":
+ case "Actions":
+ case "ServiceDesignAndCreation":
+ case "LicenseManagement":
+ case "Network":
+ if ( tag == null )
+ useTag = javaTypeName;
+ break;
+ default:
+ return null;
+
+ }
+ */
+
if ( !javaTypeName.equals("Inventory") ) {
if ( javaTypeName.equals("AaiInternal"))
return null;
@@ -898,10 +971,18 @@ public class GenerateXsd {
useTag = javaTypeName;
}
+ /*
+ if ( javaTypeName.equals("GenericVnf"))
+ System.out.println( "Processing " + javaTypeName);
+ else if ( javaTypeName.equals("Service"))
+ System.out.println( "Processing " + javaTypeName);
+ else if ( javaTypeName.equals("SitePair"))
+ System.out.println( "Processing " + javaTypeName);
+ */
NodeList parentNodes = javaTypeElement.getElementsByTagName("java-attributes");
if ( parentNodes.getLength() == 0 ) {
- System.out.println( "no java-attributes for java-type " + javaTypeName);
+ //System.out.println( "no java-attributes for java-type " + javaTypeName);
return "";
}
@@ -1555,7 +1636,7 @@ public class GenerateXsd {
{
StringBuffer sb = new StringBuffer();
- sb.append("swagger: \"2.0\"\ninfo:\n description:\n A&AI REST API\n version: \"" + apiVersion +"\"\n");
+ sb.append("swagger: \"2.0\"\ninfo:\n description: |\n Copyright &copy; 2017 AT&amp;T Intellectual Property. All rights reserved.\n\n Licensed under the Creative Commons License, Attribution 4.0 Intl. (the &quot;License&quot;); you may not use this documentation except in compliance with the License.\n\n You may obtain a copy of the License at\n\n (https://creativecommons.org/licenses/by/4.0/)\n\n Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n\n ECOMP and OpenECOMP are trademarks and service marks of AT&amp;T Intellectual Property.\n\n This document is best viewed with Firefox or Chrome. Nodes can be found by appending /#/definitions/node-type-to-find to the path to this document. Edge definitions can be found with the node definitions.\n version: \"" + apiVersion +"\"\n");
sb.append(" title: Active and Available Inventory REST API\n");
sb.append(" license:\n name: Apache 2.0\n url: http://www.apache.org/licenses/LICENSE-2.0.html\n");
sb.append("schemes:\n - https\npaths:\n");