Lines 24-33
Link Here
|
24 |
import java.io.IOException; |
24 |
import java.io.IOException; |
25 |
import java.io.InputStream; |
25 |
import java.io.InputStream; |
26 |
import java.net.ServerSocket; |
26 |
import java.net.ServerSocket; |
27 |
import java.util.Collection; |
|
|
28 |
import java.util.Hashtable; |
27 |
import java.util.Hashtable; |
29 |
import java.util.Iterator; |
28 |
import java.util.Iterator; |
|
|
29 |
import java.util.LinkedList; |
30 |
import java.util.List; |
30 |
import javax.xml.parsers.DocumentBuilderFactory; |
31 |
import javax.xml.parsers.DocumentBuilderFactory; |
|
|
32 |
import org.netbeans.modules.j2ee.jboss4.JBDeploymentManager; |
31 |
import org.openide.ErrorManager; |
33 |
import org.openide.ErrorManager; |
32 |
import org.w3c.dom.Document; |
34 |
import org.w3c.dom.Document; |
33 |
import org.w3c.dom.Element; |
35 |
import org.w3c.dom.Element; |
Lines 54-60
Link Here
|
54 |
Hashtable result = new Hashtable(); |
56 |
Hashtable result = new Hashtable(); |
55 |
// String domainListFile = File.separator+"common"+File.separator+"nodemanager"+File.separator+"nodemanager.domains"; // NOI18N |
57 |
// String domainListFile = File.separator+"common"+File.separator+"nodemanager"+File.separator+"nodemanager.domains"; // NOI18N |
56 |
|
58 |
|
57 |
if (isGoodJBServerLocation(new File(serverLocation))){ |
59 |
if (isGoodJBServerLocation4x(new File(serverLocation)) || |
|
|
60 |
isGoodJBServerLocation5x(new File(serverLocation))) |
61 |
{ |
58 |
File file = new File(serverLocation + File.separator + "server"); // NOI18N |
62 |
File file = new File(serverLocation + File.separator + "server"); // NOI18N |
59 |
|
63 |
|
60 |
String[] files = file.list(new FilenameFilter(){ |
64 |
String[] files = file.list(new FilenameFilter(){ |
Lines 67-73
Link Here
|
67 |
for(int i =0; i<files.length; i++){ |
71 |
for(int i =0; i<files.length; i++){ |
68 |
String path = file.getAbsolutePath() + File.separator + files[i]; |
72 |
String path = file.getAbsolutePath() + File.separator + files[i]; |
69 |
|
73 |
|
70 |
if (isGoodJBInstanceLocation(new File(path))){ |
74 |
if (isGoodJBInstanceLocation4x(new File(path)) || |
|
|
75 |
isGoodJBInstanceLocation5x(new File(path))) |
76 |
{ |
71 |
result.put(files[i], path); |
77 |
result.put(files[i], path); |
72 |
} |
78 |
} |
73 |
} |
79 |
} |
Lines 76-134
Link Here
|
76 |
} |
82 |
} |
77 |
|
83 |
|
78 |
|
84 |
|
79 |
//--------------- checking for possible server directory ------------- |
85 |
//--------------- checking for possible domain directory ------------- |
80 |
private static Collection serverFileColl = new java.util.ArrayList(); |
86 |
private static List<String> domainRequirements4x = new LinkedList<String>(); |
|
|
87 |
static { |
88 |
domainRequirements4x.add("conf"); // NOI18N |
89 |
domainRequirements4x.add("deploy"); // NOI18N |
90 |
domainRequirements4x.add("lib"); // NOI18N |
91 |
domainRequirements4x.add("conf/jboss-service.xml"); // NOI18N |
92 |
domainRequirements4x.add("lib/jboss-j2ee.jar"); // NOI18N |
93 |
domainRequirements4x.add("lib/jboss.jar"); // NOI18N |
94 |
domainRequirements4x.add("lib/jbosssx.jar"); // NOI18N |
95 |
domainRequirements4x.add("lib/jboss-transaction.jar"); // NOI18N |
96 |
domainRequirements4x.add("lib/jmx-adaptor-plugin.jar"); // NOI18N |
97 |
domainRequirements4x.add("lib/jnpserver.jar"); // NOI18N |
98 |
domainRequirements4x.add("lib/log4j.jar"); // NOI18N |
99 |
domainRequirements4x.add("lib/xmlentitymgr.jar"); // NOI18N |
100 |
domainRequirements4x.add("deploy/jmx-invoker-service.xml"); // NOI18N |
101 |
} |
102 |
|
103 |
private static List<String> domainRequirements5x = new LinkedList<String>(); |
104 |
|
81 |
static { |
105 |
static { |
82 |
serverFileColl.add("conf"); // NOI18N |
106 |
domainRequirements5x.add("conf"); // NOI18N |
83 |
serverFileColl.add("deploy"); // NOI18N |
107 |
domainRequirements5x.add("deploy"); // NOI18N |
84 |
serverFileColl.add("lib"); // NOI18N |
108 |
domainRequirements5x.add("lib"); // NOI18N |
85 |
serverFileColl.add("conf/jboss-service.xml"); // NOI18N |
109 |
domainRequirements5x.add("conf/jboss-service.xml"); // NOI18N |
86 |
serverFileColl.add("lib/jboss-j2ee.jar"); // NOI18N |
110 |
domainRequirements5x.add("lib/jboss-j2ee.jar"); // NOI18N |
87 |
serverFileColl.add("lib/jboss.jar"); // NOI18N |
111 |
domainRequirements5x.add("lib/jboss.jar"); // NOI18N |
88 |
serverFileColl.add("lib/jbosssx.jar"); // NOI18N |
112 |
domainRequirements5x.add("lib/jbosssx.jar"); // NOI18N |
89 |
serverFileColl.add("lib/jboss-transaction.jar"); // NOI18N |
113 |
domainRequirements5x.add("lib/jboss-transaction.jar"); // NOI18N |
90 |
serverFileColl.add("lib/jmx-adaptor-plugin.jar"); // NOI18N |
114 |
domainRequirements5x.add("lib/jmx-adaptor-plugin.jar"); // NOI18N |
91 |
serverFileColl.add("lib/jnpserver.jar"); // NOI18N |
115 |
domainRequirements5x.add("lib/jnpserver.jar"); // NOI18N |
92 |
serverFileColl.add("lib/log4j.jar"); // NOI18N |
116 |
domainRequirements5x.add("lib/log4j.jar"); // NOI18N |
93 |
serverFileColl.add("lib/xmlentitymgr.jar"); // NOI18N |
117 |
domainRequirements5x.add("deploy/jmx-invoker-service.xml"); // NOI18N |
94 |
serverFileColl.add("deploy/jmx-invoker-service.xml"); // NOI18N |
|
|
95 |
} |
118 |
} |
96 |
|
119 |
|
97 |
public static boolean isGoodJBInstanceLocation(File candidate){ |
120 |
private static boolean isGoodJBInstanceLocation(File candidate, List<String> requirements){ |
98 |
if (null == candidate || |
121 |
if (null == candidate || |
99 |
!candidate.exists() || |
122 |
!candidate.exists() || |
100 |
!candidate.canRead() || |
123 |
!candidate.canRead() || |
101 |
!candidate.isDirectory() || |
124 |
!candidate.isDirectory() || |
102 |
!hasRequiredChildren(candidate, serverFileColl)) { |
125 |
!hasRequiredChildren(candidate, requirements)) { |
103 |
return false; |
126 |
return false; |
104 |
} |
127 |
} |
105 |
return true; |
128 |
return true; |
106 |
} |
129 |
} |
107 |
|
130 |
|
|
|
131 |
public static boolean isGoodJBInstanceLocation4x(File candidate){ |
132 |
return isGoodJBInstanceLocation(candidate, domainRequirements4x); |
133 |
} |
134 |
|
135 |
public static boolean isGoodJBInstanceLocation5x(File candidate){ |
136 |
return isGoodJBInstanceLocation(candidate, domainRequirements5x); |
137 |
} |
138 |
|
108 |
//--------------- checking for possible server directory ------------- |
139 |
//--------------- checking for possible server directory ------------- |
109 |
private static Collection fileColl = new java.util.ArrayList(); |
140 |
private static List<String> serverRequirements4x = new LinkedList<String>(); |
110 |
|
141 |
|
111 |
static { |
142 |
static { |
112 |
fileColl.add("bin"); // NOI18N |
143 |
serverRequirements4x.add("bin"); // NOI18N |
113 |
fileColl.add("client"); // NOI18N |
144 |
serverRequirements4x.add("client"); // NOI18N |
114 |
fileColl.add("lib"); // NOI18N |
145 |
serverRequirements4x.add("lib"); // NOI18N |
115 |
fileColl.add("server"); // NOI18N |
146 |
serverRequirements4x.add("server"); // NOI18N |
116 |
fileColl.add("lib/jboss-common.jar"); // NOI18N |
147 |
serverRequirements4x.add("lib/jboss-common.jar"); // NOI18N |
117 |
fileColl.add("lib/endorsed/resolver.jar"); // NOI18N |
148 |
serverRequirements4x.add("lib/endorsed/resolver.jar"); // NOI18N |
118 |
} |
149 |
} |
119 |
|
150 |
|
120 |
public static boolean isGoodJBServerLocation(File candidate){ |
151 |
private static List<String> serverRequirements5x = new LinkedList<String>(); |
|
|
152 |
|
153 |
static { |
154 |
serverRequirements5x.add("bin"); // NOI18N |
155 |
serverRequirements5x.add("client"); // NOI18N |
156 |
serverRequirements5x.add("lib"); // NOI18N |
157 |
serverRequirements5x.add("server"); // NOI18N |
158 |
serverRequirements5x.add("lib/jboss-common-core.jar"); // NOI18N |
159 |
serverRequirements5x.add("lib/endorsed/resolver.jar"); // NOI18N |
160 |
} |
161 |
|
162 |
private static boolean isGoodJBServerLocation(File candidate, List<String> requirements){ |
121 |
if (null == candidate || |
163 |
if (null == candidate || |
122 |
!candidate.exists() || |
164 |
!candidate.exists() || |
123 |
!candidate.canRead() || |
165 |
!candidate.canRead() || |
124 |
!candidate.isDirectory() || |
166 |
!candidate.isDirectory() || |
125 |
!hasRequiredChildren(candidate, fileColl)) { |
167 |
!hasRequiredChildren(candidate, requirements)) { |
126 |
return false; |
168 |
return false; |
127 |
} |
169 |
} |
128 |
return true; |
170 |
return true; |
129 |
} |
171 |
} |
130 |
|
172 |
|
131 |
private static boolean hasRequiredChildren(File candidate, Collection requiredChildren) { |
173 |
public static boolean isGoodJBServerLocation4x(File candidate){ |
|
|
174 |
return isGoodJBServerLocation(candidate, serverRequirements4x); |
175 |
} |
176 |
|
177 |
public static boolean isGoodJBServerLocation4x(JBDeploymentManager dm){ |
178 |
String installDir = dm.getInstanceProperties().getProperty(JBPluginProperties.PROPERTY_ROOT_DIR); |
179 |
return isGoodJBServerLocation4x(new File(installDir)); |
180 |
} |
181 |
|
182 |
public static boolean isGoodJBServerLocation5x(File candidate){ |
183 |
return isGoodJBServerLocation(candidate, serverRequirements5x); |
184 |
} |
185 |
|
186 |
private static boolean hasRequiredChildren(File candidate, List<String> requiredChildren) { |
132 |
if (null == candidate) |
187 |
if (null == candidate) |
133 |
return false; |
188 |
return false; |
134 |
String[] children = candidate.list(); |
189 |
String[] children = candidate.list(); |
Lines 146-151
Link Here
|
146 |
return true; |
201 |
return true; |
147 |
} |
202 |
} |
148 |
|
203 |
|
|
|
204 |
//-------------------------------------------------------------------- |
149 |
|
205 |
|
150 |
/** |
206 |
/** |
151 |
* |
207 |
* |