summaryrefslogtreecommitdiffstats
path: root/aai-core/src/main
diff options
context:
space:
mode:
authorKajur, Harish (vk250x) <vk250x@att.com>2018-11-01 15:44:03 -0400
committerKajur, Harish (vk250x) <vk250x@att.com>2018-11-01 15:44:09 -0400
commit9bae143d3310eb57bfbb0674f62f278f740db0f4 (patch)
treecf1e08c39254d408f0a5726439288f8053f89ca3 /aai-core/src/main
parent653948302e921dbcee24ed6746c73557c0b54c92 (diff)
Replace platform specific line seperators System
Issue-ID: AAI-1463 Change-Id: Ibdd3803dd825342d54dfa1b008f1a8c2d78d6198 Signed-off-by: Kajur, Harish (vk250x) <vk250x@att.com>
Diffstat (limited to 'aai-core/src/main')
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java64
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java4
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java31
3 files changed, 52 insertions, 47 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java
index b1a4d919..7d3b37d1 100644
--- a/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java
+++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/HTMLfromOXM.java
@@ -28,7 +28,7 @@ import java.util.List;
import javax.xml.parsers.ParserConfigurationException;
-import org.apache.commons.lang.StringUtils;
+
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
@@ -42,16 +42,12 @@ import org.slf4j.LoggerFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import com.google.common.base.CaseFormat;
-
public class HTMLfromOXM extends OxmFileProcessor {
private static final Logger logger = LoggerFactory.getLogger("HTMLfromOXM.class");
- public static final String LINE_SEPARATOR = System.getProperty("line.separator");
private String maxOccurs;
@@ -77,7 +73,7 @@ public class HTMLfromOXM extends OxmFileProcessor {
public String getDocumentHeader() {
StringBuffer sb = new StringBuffer();
logger.trace("processing starts");
- sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + LINE_SEPARATOR);
String namespace = "org.onap";
if (v.compareTo(getSchemaVersions().getNamespaceChangeVersion()) < 0 ) {
namespace = "org.openecomp";
@@ -85,22 +81,22 @@ public class HTMLfromOXM extends OxmFileProcessor {
if ( versionUsesAnnotations(v.toString()) ) {
sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/"
+ v.toString() + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" 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");
+ + LINE_SEPARATOR
+ + "xmlns:jaxb=\"http://java.sun.com/xml/ns/jaxb\"" + LINE_SEPARATOR +
+ " jaxb:version=\"2.1\"" + LINE_SEPARATOR +
+ " xmlns:annox=\"http://annox.dev.java.net\"" + LINE_SEPARATOR +
+ " jaxb:extensionBindingPrefixes=\"annox\">" + DOUBLE_LINE_SEPARATOR);
} else {
sb.append("<xs:schema elementFormDefault=\"qualified\" version=\"1.0\" targetNamespace=\"http://" + namespace + ".aai.inventory/"
- + v.toString() + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n\n");
+ + v.toString() + "\" xmlns:tns=\"http://" + namespace + ".aai.inventory/" + v.toString() + "\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" + DOUBLE_LINE_SEPARATOR);
}
return sb.toString();
}
-
@Override
public String process() throws ParserConfigurationException, SAXException, IOException, AAIException, FileNotFoundException, EdgeRuleNotFoundException {
StringBuilder sb = new StringBuilder();
+
try {
init();
} catch(Exception e) {
@@ -141,11 +137,10 @@ public class HTMLfromOXM extends OxmFileProcessor {
sb.append(processJavaTypeElement( javaTypeName, javaTypeElement, sbInventory ));
}
sb.append(sbInventory);
- sb.append(" </xs:sequence>\n");
- sb.append(" </xs:complexType>\n");
- sb.append(" </xs:element>\n");
- sb.append("</xs:schema>\n");
- StringBuilder invalidSb = new StringBuilder();
+ sb.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
+ sb.append("</xs:schema>" + LINE_SEPARATOR);
return sb.toString();
}
@@ -156,6 +151,14 @@ public class HTMLfromOXM extends OxmFileProcessor {
String pattern = "^[a-z0-9-]*$";
return name.matches(pattern);
}
+
+ protected boolean skipCheck( String javaAttribute ) {
+ if ( javaAttribute.equals("model")
+ || javaAttribute.equals("eventHeader") ) {
+ return true;
+ }
+ return false;
+ }
public String processJavaTypeElement( String javaTypeName, Element javaType_Element, StringBuilder sbInventory) {
String xmlRootElementName = getXMLRootElementName(javaType_Element);
@@ -183,15 +186,15 @@ public class HTMLfromOXM extends OxmFileProcessor {
if ( xmlElementNodes.getLength() > 0 ) {
if ( !processingInventory || !hasPreviousInventory ) {
- sb1.append(" <xs:element name=\"" + xmlRootElementName + "\">\n");
- sb1.append(" <xs:complexType>\n");
+ sb1.append(" <xs:element name=\"" + xmlRootElementName + "\">" + LINE_SEPARATOR);
+ sb1.append(" <xs:complexType>" + LINE_SEPARATOR);
XSDElement javaTypeElement = new XSDElement(javaType_Element, maxOccurs);
logger.debug("XSDElement name: "+javaTypeElement.name());
if(versionUsesAnnotations(v.toString())) {
sb1.append(javaTypeElement.getHTMLAnnotation("class", " "));
}
- sb1.append(" <xs:sequence>\n");
+ sb1.append(" <xs:sequence>" + LINE_SEPARATOR);
}
Element javatypeElement;
for ( int i = 0; i < xmlElementNodes.getLength(); ++i ) {
@@ -205,7 +208,6 @@ public class HTMLfromOXM extends OxmFileProcessor {
if ( elementType.contains("." + v.toString() + ".") && !generatedJavaType.containsKey(addType) ) {
generatedJavaType.put(addType, elementType);
javatypeElement = getJavaTypeElement(addType, processingInventory);
-
sb.append(processJavaTypeElement( addType, javatypeElement, null ));
}
if ("Nodes".equals(addType)) {
@@ -216,18 +218,18 @@ public class HTMLfromOXM extends OxmFileProcessor {
sb1.append(xmlElementElement.getHTMLElement(v, versionUsesAnnotations(v.toString()), this));
}
if ( !processingInventory ) {
- sb1.append(" </xs:sequence>\n");
- sb1.append(" </xs:complexType>\n");
- sb1.append(" </xs:element>\n");
+ sb1.append(" </xs:sequence>" + LINE_SEPARATOR);
+ sb1.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb1.append(" </xs:element>" + LINE_SEPARATOR);
}
}
if ( xmlElementNodes.getLength() < 1 ) {
- sb.append(" <xs:element name=\"" + xmlRootElementName + "\">\n");
- sb.append(" <xs:complexType>\n");
- sb.append(" <xs:sequence/>\n");
- sb.append(" </xs:complexType>\n");
- sb.append(" </xs:element>\n");
+ sb.append(" <xs:element name=\"" + xmlRootElementName + "\">" + LINE_SEPARATOR);
+ sb.append(" <xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" <xs:sequence/>" + LINE_SEPARATOR);
+ sb.append(" </xs:complexType>" + LINE_SEPARATOR);
+ sb.append(" </xs:element>" + LINE_SEPARATOR);
generatedJavaType.put(javaTypeName, null);
return sb.toString();
}
@@ -283,4 +285,4 @@ public class HTMLfromOXM extends OxmFileProcessor {
}
return false;
}
-} \ No newline at end of file
+}
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java
index 44e5a9f8..a758be50 100644
--- a/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java
+++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/OxmFileProcessor.java
@@ -62,6 +62,10 @@ import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
public abstract class OxmFileProcessor {
+
+ public static final String LINE_SEPARATOR = System.getProperty("line.separator");
+ public static final String DOUBLE_LINE_SEPARATOR = System.getProperty("line.separator") + System.getProperty("line.separator");
+
EdgeIngestor ei;
NodeIngestor ni;
protected Set<String> namespaceFilter;
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java
index 1494b8f6..9de7967e 100644
--- a/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java
+++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java
@@ -314,11 +314,11 @@ public class XSDElement implements Element {
}
if(useAnnotation) {
String annotation = new XSDElement(xmlElementElement, maxOccurs).getHTMLAnnotation("field", " ");
- sbElement.append(StringUtils.isNotEmpty(annotation) ? ">\n" : "");
+ sbElement.append(StringUtils.isNotEmpty(annotation) ? ">" + OxmFileProcessor.LINE_SEPARATOR : "");
sbElement.append(annotation);
- sbElement.append(StringUtils.isNotEmpty(annotation) ? " </xs:element>\n" : "/>\n" );
+ sbElement.append(StringUtils.isNotEmpty(annotation) ? " </xs:element>" + OxmFileProcessor.LINE_SEPARATOR : "/>" + OxmFileProcessor.LINE_SEPARATOR );
} else {
- sbElement.append("/>\n");
+ sbElement.append("/>" + OxmFileProcessor.LINE_SEPARATOR);
}
return this.getHTMLElementWrapper(sbElement.toString(), v, useAnnotation);
// return sbElement.toString();
@@ -346,18 +346,18 @@ public class XSDElement implements Element {
if ( elementIsRequired == null || !elementIsRequired.equals("true")||addType != null) {
sbElement.append(" minOccurs=\"0\"");
}
- sbElement.append(">\n");
- sbElement.append(" <xs:complexType>\n");
+ sbElement.append(">" + OxmFileProcessor.LINE_SEPARATOR);
+ sbElement.append(" <xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
if(useAnnotation) {
XSDElement javaTypeElement = new XSDElement((Element)this.getParentNode(), maxOccurs);
sbElement.append(javaTypeElement.getHTMLAnnotation("class", " "));
}
- sbElement.append(" <xs:sequence>\n");
+ sbElement.append(" <xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
sbElement.append(" ");
sbElement.append(unwrappedElement);
- sbElement.append(" </xs:sequence>\n");
- sbElement.append(" </xs:complexType>\n");
- sbElement.append(" </xs:element>\n");
+ sbElement.append(" </xs:sequence>" + OxmFileProcessor.LINE_SEPARATOR);
+ sbElement.append(" </xs:complexType>" + OxmFileProcessor.LINE_SEPARATOR);
+ sbElement.append(" </xs:element>" + OxmFileProcessor.LINE_SEPARATOR);
return sbElement.toString();
}
@@ -394,12 +394,12 @@ public class XSDElement implements Element {
if(metadata.size() == 0) {
return "";
}
- sb.append(indentation +"<xs:annotation>\r\n");
+ sb.append(indentation +"<xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
sb.append(
- indentation + " <xs:appinfo>\r\n" +
- indentation + " <annox:annotate target=\""+target+"\">@org.onap.aai.annotations.Metadata(" + Joiner.on(",").join(metadata) + ")</annox:annotate>\r\n" +
- indentation + " </xs:appinfo>\r\n");
- sb.append(indentation +"</xs:annotation>\r\n");
+ indentation + " <xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR +
+ indentation + " <annox:annotate target=\""+target+"\">@org.onap.aai.annotations.Metadata(" + Joiner.on(",").join(metadata) + ")</annox:annotate>" + OxmFileProcessor.LINE_SEPARATOR +
+ indentation + " </xs:appinfo>" + OxmFileProcessor.LINE_SEPARATOR);
+ sb.append(indentation +"</xs:annotation>" + OxmFileProcessor.LINE_SEPARATOR);
return sb.toString();
}
@@ -731,5 +731,4 @@ public class XSDElement implements Element {
}
-}
-
+} \ No newline at end of file