Lines 80-85
Link Here
|
80 |
mavenproject = project.getLookup().lookup(NbMavenProject.class); |
80 |
mavenproject = project.getLookup().lookup(NbMavenProject.class); |
81 |
} |
81 |
} |
82 |
|
82 |
|
|
|
83 |
private void copySrcToDest( FileObject srcFile, FileObject destFile) throws IOException { |
84 |
if (destFile != null && !srcFile.isFolder()) { |
85 |
InputStream is = null; |
86 |
OutputStream os = null; |
87 |
FileLock fl = null; |
88 |
try { |
89 |
is = srcFile.getInputStream(); |
90 |
fl = destFile.lock(); |
91 |
os = destFile.getOutputStream(fl); |
92 |
FileUtil.copy(is, os); |
93 |
} finally { |
94 |
if (is != null) { |
95 |
is.close(); |
96 |
} |
97 |
if (os != null) { |
98 |
os.close(); |
99 |
} |
100 |
if (fl != null) { |
101 |
fl.releaseLock(); |
102 |
} |
103 |
} |
104 |
System.out.println("copied + " + srcFile.getPath() + " to " + destFile); |
105 |
} |
106 |
} |
107 |
|
83 |
private WebModule getWebModule() { |
108 |
private WebModule getWebModule() { |
84 |
return provider.findWebModule(project.getProjectDirectory()); |
109 |
return provider.findWebModule(project.getProjectDirectory()); |
85 |
} |
110 |
} |
Lines 223-231
Link Here
|
223 |
|
248 |
|
224 |
private void handleDeleteFileInDestDir(String resourcePath) throws IOException { |
249 |
private void handleDeleteFileInDestDir(String resourcePath) throws IOException { |
225 |
FileObject webBuildBase = getJ2eeModule().getContentDirectory(); |
250 |
FileObject webBuildBase = getJ2eeModule().getContentDirectory(); |
|
|
251 |
FileObject webInfClasses = webBuildBase.getFileObject("WEB-INF/classes"); |
226 |
if (webBuildBase != null) { |
252 |
if (webBuildBase != null) { |
227 |
// project was built |
253 |
// project was built |
228 |
FileObject toDelete = webBuildBase.getFileObject(resourcePath); |
254 |
FileObject toDelete = webInfClasses.getFileObject(resourcePath); |
229 |
if (toDelete != null) { |
255 |
if (toDelete != null) { |
230 |
toDelete.delete(); |
256 |
toDelete.delete(); |
231 |
} |
257 |
} |
Lines 245-279
Link Here
|
245 |
return; |
271 |
return; |
246 |
} |
272 |
} |
247 |
FileObject webBuildBase = getJ2eeModule().getContentDirectory(); |
273 |
FileObject webBuildBase = getJ2eeModule().getContentDirectory(); |
|
|
274 |
|
248 |
if (webBuildBase != null) { |
275 |
if (webBuildBase != null) { |
249 |
// project was built |
276 |
// project was built |
250 |
if (FileUtil.isParentOf(documentBase, webBuildBase) || FileUtil.isParentOf(webBuildBase, documentBase)) { |
277 |
if (FileUtil.isParentOf(documentBase, webBuildBase) || FileUtil.isParentOf(webBuildBase, documentBase)) { |
251 |
//cannot copy into self |
278 |
//cannot copy into self |
252 |
return; |
279 |
return; |
253 |
} |
280 |
} |
254 |
FileObject destFile = ensureDestinationFileExists(webBuildBase, path, fo.isFolder()); |
281 |
FileObject webAppClassesDir = webBuildBase.getFileObject("WEB-INF/classes"); |
255 |
if (destFile != null && !fo.isFolder()) { |
282 |
FileObject destFile = ensureDestinationFileExists(webAppClassesDir, path, fo.isFolder()); |
256 |
InputStream is = null; |
283 |
copySrcToDest(fo, destFile); |
257 |
OutputStream os = null; |
284 |
|
258 |
FileLock fl = null; |
285 |
String projClassesPath = mavenproject.getMavenProject().getBuild().getOutputDirectory(); |
259 |
try { |
286 |
FileObject targetClasses = FileUtil.toFileObject(new File(projClassesPath)); |
260 |
is = fo.getInputStream(); |
287 |
destFile = ensureDestinationFileExists(targetClasses, path, fo.isFolder()); |
261 |
fl = destFile.lock(); |
288 |
copySrcToDest(fo, destFile); |
262 |
os = destFile.getOutputStream(fl); |
289 |
|
263 |
FileUtil.copy(is, os); |
|
|
264 |
} finally { |
265 |
if (is != null) { |
266 |
is.close(); |
267 |
} |
268 |
if (os != null) { |
269 |
os.close(); |
270 |
} |
271 |
if (fl != null) { |
272 |
fl.releaseLock(); |
273 |
} |
274 |
} |
275 |
//System.out.println("copied + " + FileUtil.copy(fo.getInputStream(), destDir, fo.getName(), fo.getExt())); |
276 |
} |
277 |
} |
290 |
} |
278 |
} |
291 |
} |
279 |
} |
292 |
} |