use of org.dom4j.Attribute in project atlas by alibaba.
the class BundleInfoUtils method addComponents.
private static void addComponents(BundleInfo bundleInfo, Element root) {
List<? extends Node> serviceNodes = root.selectNodes("//service");
for (Node node : serviceNodes) {
Element element = (Element) node;
Attribute attribute = element.attribute("name");
bundleInfo.getServices().add(attribute.getValue());
}
List<? extends Node> receiverNodes = root.selectNodes("//receiver");
for (Node node : receiverNodes) {
Element element = (Element) node;
Attribute attribute = element.attribute("name");
bundleInfo.getReceivers().add(attribute.getValue());
}
List<? extends Node> providerNodes = root.selectNodes("//provider");
for (Node node : providerNodes) {
Element element = (Element) node;
Attribute attribute = element.attribute("name");
bundleInfo.getContentProviders().add(attribute.getValue());
}
List<? extends Node> activityNodes = root.selectNodes("//activity");
for (Node node : activityNodes) {
Element element = (Element) node;
Attribute attribute = element.attribute("name");
bundleInfo.getActivities().add(attribute.getValue());
}
}
use of org.dom4j.Attribute in project atlas by alibaba.
the class ManifestFileUtils method getManifestFileObject.
/**
* 获取mainifest文件的内容
*
* @param manifestFile
* @return
*/
public static ManifestFileObject getManifestFileObject(File manifestFile) throws DocumentException {
SAXReader reader = new SAXReader();
ManifestFileObject manifestFileObject = new ManifestFileObject();
manifestFileObject.setManifestFile(manifestFile);
if (manifestFile.exists()) {
// 读取XML文件
Document document = reader.read(manifestFile);
// 得到根节点
Element root = document.getRootElement();
for (Attribute attribute : root.attributes()) {
if (StringUtils.isNotBlank(attribute.getNamespacePrefix())) {
manifestFileObject.addManifestProperty(attribute.getNamespacePrefix() + ":" + attribute.getName(), attribute.getValue());
} else {
manifestFileObject.addManifestProperty(attribute.getName(), attribute.getValue());
}
}
Element useSdkElement = root.element("uses-sdk");
Element applicationElement = root.element("application");
if (null != useSdkElement) {
for (Attribute attribute : useSdkElement.attributes()) {
if (StringUtils.isNotBlank(attribute.getNamespacePrefix())) {
manifestFileObject.addUseSdkProperty(attribute.getNamespacePrefix() + ":" + attribute.getName(), attribute.getValue());
} else {
manifestFileObject.addUseSdkProperty(attribute.getName(), attribute.getValue());
}
}
}
if (null != applicationElement) {
for (Attribute attribute : applicationElement.attributes()) {
if (StringUtils.isNotBlank(attribute.getNamespacePrefix())) {
manifestFileObject.addApplicationProperty(attribute.getNamespacePrefix() + ":" + attribute.getName(), attribute.getValue());
} else {
manifestFileObject.addApplicationProperty(attribute.getName(), attribute.getValue());
}
}
}
}
return manifestFileObject;
}
use of org.dom4j.Attribute in project tdi-studio-se by Talend.
the class ChangeMappingFileMigrationTask method changeSAPHanaMappingFile.
private void changeSAPHanaMappingFile(URL url) {
File dir = new File(url.getFile());
File target = null;
if (dir.isDirectory()) {
File[] files = dir.listFiles();
for (File file : files) {
if (file.getName().equals("mapping_SAPHana.xml")) {
//$NON-NLS-1$
target = file;
break;
}
}
}
if (target != null) {
try {
SAXReader reader = new SAXReader();
Document document = reader.read(target);
Element root = document.getRootElement();
//$NON-NLS-1$
Element node = root.element("dbms");
//$NON-NLS-1$
Attribute attr = node.attribute("label");
if (attr != null && attr.getValue().equals("Mapping SAP Hana")) {
//$NON-NLS-1$
//$NON-NLS-1$
attr.setValue("Mapping SAPHana");
target.delete();
XMLWriter writer = new XMLWriter(new FileWriter(target));
writer.write(document);
writer.close();
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
use of org.dom4j.Attribute in project tdi-studio-se by Talend.
the class JobJavaScriptsWSManager method editWSDDFile.
/**
* DOC x Comment method "genWebInfoForder".
*
* @param list
*/
private void editWSDDFile(ProcessItem processItem) {
String projectName = getCorrespondingProjectName(processItem);
String selectedProcessVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
selectedProcessVersion = this.getSelectedJobVersion();
}
String jobFolderName = JavaResourcesHelper.getJobFolderName(escapeFileNameSpace(processItem), selectedProcessVersion);
String deployFileName = getTmpFolder() + PATH_SEPARATOR + projectName + PATH_SEPARATOR + jobFolderName + PATH_SEPARATOR + //$NON-NLS-1$
"deploy.wsdd";
//$NON-NLS-1$
String serverConfigFile = getTmpFolder() + PATH_SEPARATOR + "server-config.wsdd";
File deployFile = new File(deployFileName);
if (!deployFile.exists()) {
//$NON-NLS-1$
log.error(org.talend.repository.i18n.Messages.getString("JobJavaScriptsWSManager.errorMessage"));
return;
}
// edit the server-config.wsdd file
try {
File wsddFile = new File(serverConfigFile);
BufferedReader reader = new BufferedReader(new FileReader(wsddFile));
SAXReader saxReader = new SAXReader();
Document doc = saxReader.read(reader);
BufferedReader wsdlreader = new BufferedReader(new FileReader(deployFile));
SAXReader wsdlsaxReader = new SAXReader();
Document wsdldoc = wsdlsaxReader.read(wsdlreader);
Element wsdlroot = wsdldoc.getRootElement();
//$NON-NLS-1$
Element element = wsdlroot.element("service");
//$NON-NLS-1$
List<Element> elements = element.elements("arrayMapping");
for (Element item : elements) {
//$NON-NLS-1$
Attribute attribute = item.attribute("qname");
item.remove(attribute);
//$NON-NLS-1$ //$NON-NLS-2$
attribute.setValue(attribute.getValue().replaceFirst(">", ""));
item.add(attribute);
}
Element root = doc.getRootElement();
List<Node> content = root.content();
for (int i = 0; i < content.size(); i++) {
Node n = content.get(i);
if (n instanceof Element) {
if (n.getName().equals("transport")) {
//$NON-NLS-1$
content.add(i - 1, element);
break;
}
}
}
//$NON-NLS-1$
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(serverConfigFile), "UTF-8"));
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter output = new XMLWriter(writer, format);
output.write(doc);
output.flush();
output.close();
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.dom4j.Attribute in project CodeUtils by boredream.
the class TempUtils method compareStrings.
public static void compareStrings() {
List<String> hasStrName = new ArrayList<String>();
// save to
File file = new File("D:\\work\\BusinessCMT2.0\\res\\values-en\\strings.xml");
Document valuesDoc = XmlUtil.read(file);
Element rootElement = valuesDoc.getRootElement();
List<Element> elements = rootElement.elements();
for (Element element : elements) {
Attribute nameAtt = element.attribute("name");
String name = nameAtt.getValue();
hasStrName.add(name);
}
// save to
File fileChn = new File("D:\\work\\BusinessCMT2.0\\res\\values\\strings.xml");
Document valuesDocChn = XmlUtil.read(fileChn);
Element rootElementChn = valuesDocChn.getRootElement();
List<Element> elementsChn = rootElementChn.elements();
for (Element element : elementsChn) {
Attribute nameAtt = element.attribute("name");
String name = nameAtt.getValue();
if (!hasStrName.contains(name)) {
System.out.println(element.getText());
}
}
}
Aggregations