Improved: Replaces ModelInduceFromDb with widgets (OFBIZ-6510)
This is a manual backport of the related two commits in trunk with minor changes to fit the r18.12 codebase.
This commit is contained in:
@@ -27,6 +27,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
@@ -38,6 +39,7 @@ import java.util.regex.Pattern;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
@@ -55,6 +57,7 @@ import org.apache.xerces.xni.XMLLocator;
|
||||
import org.apache.xerces.xni.XMLResourceIdentifier;
|
||||
import org.apache.xerces.xni.XMLString;
|
||||
import org.apache.xerces.xni.XNIException;
|
||||
import org.w3c.dom.Comment;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentFragment;
|
||||
@@ -1237,8 +1240,10 @@ public final class UtilXml {
|
||||
|
||||
/**
|
||||
* get attribute value ignoring prefix in attribute name
|
||||
*
|
||||
* @param element
|
||||
* @return The value of the node, depending on its type; see the table Node class
|
||||
* @return The value of the node, depending on its type; see the table Node
|
||||
* class
|
||||
*/
|
||||
public static String getAttributeValueIgnorePrefix(Element element, String attributeName){
|
||||
if (element==null) {
|
||||
@@ -1261,4 +1266,66 @@ public final class UtilXml {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String convertDocumentToXmlString(Document document) {
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer transformer;
|
||||
try {
|
||||
transformer = tf.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
|
||||
StringWriter writer = new StringWriter();
|
||||
transformer.transform(new DOMSource(document), new StreamResult(writer));
|
||||
String output = writer.getBuffer().toString();
|
||||
return output;
|
||||
} catch (TransformerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ASF Licence Header as a Comment Element
|
||||
*
|
||||
* @param document
|
||||
* @return
|
||||
*/
|
||||
public static Comment createApacheLicenceComment(Document document) {
|
||||
String lb = "\n";
|
||||
|
||||
StringBuilder disclaimer = new StringBuilder();
|
||||
disclaimer.append("Licensed to the Apache Software Foundation (ASF) under one");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("or more contributor license agreements. See the NOTICE file");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("distributed with this work for additional information");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("regarding copyright ownership. The ASF licenses this file");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("to you under the Apache License, Version 2.0 (the");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("\"License\"); you may not use this file except in compliance");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("with the License. You may obtain a copy of the License at");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("http://www.apache.org/licenses/LICENSE-2.0");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("Unless required by applicable law or agreed to in writing,");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("software distributed under the License is distributed on an");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("KIND, either express or implied. See the License for the");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("specific language governing permissions and limitations");
|
||||
disclaimer.append(lb);
|
||||
disclaimer.append("under the License.");
|
||||
disclaimer.append(lb);
|
||||
|
||||
return document.createComment(disclaimer.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user