Added
Link Here
|
1 |
/* |
2 |
* The contents of this file are subject to the terms of the Common Development |
3 |
* and Distribution License (the License). You may not use this file except in |
4 |
* compliance with the License. |
5 |
* |
6 |
* You can obtain a copy of the License at http://www.netbeans.org/cddl.html |
7 |
* or http://www.netbeans.org/cddl.txt. |
8 |
* |
9 |
* When distributing Covered Code, include this CDDL Header Notice in each file |
10 |
* and include the License file at http://www.netbeans.org/cddl.txt. |
11 |
* If applicable, add the following below the CDDL Header, with the fields |
12 |
* enclosed by brackets [] replaced by your own identifying information: |
13 |
* "Portions Copyrighted [year] [name of copyright owner]" |
14 |
* |
15 |
* To change this template, choose Tools | Template Manager |
16 |
* and open the template in the editor. |
17 |
*/ |
18 |
|
19 |
package org.netbeans.modules.j2ee.weblogic9.util; |
20 |
|
21 |
import java.io.File; |
22 |
import java.io.FileInputStream; |
23 |
import java.io.FileNotFoundException; |
24 |
import java.io.IOException; |
25 |
import org.openide.ErrorManager; |
26 |
|
27 |
import org.openide.xml.XMLUtil; |
28 |
import org.w3c.dom.Document; |
29 |
import org.xml.sax.InputSource; |
30 |
import org.xml.sax.SAXException; |
31 |
|
32 |
/** |
33 |
* Helper class |
34 |
* |
35 |
* @author Michal Mocnak |
36 |
*/ |
37 |
public class Util { |
38 |
|
39 |
private static final String CONFIG_XML = "config/config.xml"; |
40 |
|
41 |
private Util() {} |
42 |
|
43 |
public static String getWeblogicDomainVersion(String domainRoot) { |
44 |
// Domain config file |
45 |
File config = new File(domainRoot, CONFIG_XML); |
46 |
|
47 |
// Check if the file exists |
48 |
if (!config.exists()) |
49 |
return null; |
50 |
|
51 |
try { |
52 |
InputSource source = new InputSource(new FileInputStream(config)); |
53 |
Document d = XMLUtil.parse(source, false, false, null, null); |
54 |
|
55 |
// Retrieve domain version |
56 |
return d.getElementsByTagName("domain-version").item(0).getTextContent(); |
57 |
|
58 |
} catch(FileNotFoundException e) { |
59 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); |
60 |
} catch(IOException e) { |
61 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); |
62 |
} catch(SAXException e) { |
63 |
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); |
64 |
} |
65 |
|
66 |
return null; |
67 |
} |
68 |
} |