Lines 470-482
Link Here
|
470 |
// |
470 |
// |
471 |
Vector warnings = new Vector(); |
471 |
Vector warnings = new Vector(); |
472 |
|
472 |
|
|
|
473 |
boolean shouldPutIn = false; |
474 |
boolean alreadyAsked = false; |
475 |
|
473 |
// create WEB-INF |
476 |
// create WEB-INF |
474 |
FileObject webInf = fs.find(FOLDER_WEB_INF, null, null); |
477 |
FileObject webInf = fs.find(FOLDER_WEB_INF, null, null); |
475 |
if (webInf == null) { |
478 |
if (webInf == null) { |
|
|
479 |
if (!alreadyAsked) { |
480 |
alreadyAsked = true; |
481 |
shouldPutIn = shouldPutIntoClearCase(fs); |
482 |
} |
476 |
// this should not happen, as if WEB-INF does not exist, then we shouldn't be called |
483 |
// this should not happen, as if WEB-INF does not exist, then we shouldn't be called |
477 |
// but anyway |
484 |
// but anyway |
478 |
try { |
485 |
try { |
479 |
webInf = FileUtil.createFolder(fs.getRoot(), FOLDER_WEB_INF); |
486 |
webInf = createFolderClearCaseHack(fs.getRoot(), FOLDER_WEB_INF, shouldPutIn); |
480 |
} catch (IOException fx1) { |
487 |
} catch (IOException fx1) { |
481 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINF")); // NOI18N |
488 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINF")); // NOI18N |
482 |
} |
489 |
} |
Lines 484-491
Link Here
|
484 |
// create WEB-INF/classes |
491 |
// create WEB-INF/classes |
485 |
FileObject classesDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_CLASSES, null, null);//NOI18N |
492 |
FileObject classesDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_CLASSES, null, null);//NOI18N |
486 |
if (classesDir == null) { |
493 |
if (classesDir == null) { |
|
|
494 |
if (!alreadyAsked) { |
495 |
alreadyAsked = true; |
496 |
shouldPutIn = shouldPutIntoClearCase(fs); |
497 |
} |
487 |
try { |
498 |
try { |
488 |
classesDir = FileUtil.createFolder(webInf, FOLDER_CLASSES); |
499 |
classesDir = createFolderClearCaseHack(webInf, FOLDER_CLASSES, shouldPutIn); |
489 |
} catch (IOException fx1) { |
500 |
} catch (IOException fx1) { |
490 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFclasses")); // NOI18N |
501 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFclasses")); // NOI18N |
491 |
} |
502 |
} |
Lines 493-500
Link Here
|
493 |
// create WEB-INF/lib |
504 |
// create WEB-INF/lib |
494 |
FileObject libDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_LIB, null, null);//NOI18N |
505 |
FileObject libDir = fs.find(FOLDER_WEB_INF + "." + FOLDER_LIB, null, null);//NOI18N |
495 |
if (libDir == null) { |
506 |
if (libDir == null) { |
|
|
507 |
if (!alreadyAsked) { |
508 |
alreadyAsked = true; |
509 |
shouldPutIn = shouldPutIntoClearCase(fs); |
510 |
} |
496 |
try { |
511 |
try { |
497 |
libDir = FileUtil.createFolder(webInf, FOLDER_LIB); |
512 |
libDir = createFolderClearCaseHack(webInf, FOLDER_LIB, shouldPutIn); |
498 |
} catch (IOException fx1) { |
513 |
} catch (IOException fx1) { |
499 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFlib")); // NOI18N |
514 |
warnings.addElement(NbBundle.getMessage (WebContextObject.class, "MSG_WARNING_CannotCreateWEBINFlib")); // NOI18N |
500 |
} |
515 |
} |
Lines 533-538
Link Here
|
533 |
NotifyDescriptor.INFORMATION_MESSAGE)); |
548 |
NotifyDescriptor.INFORMATION_MESSAGE)); |
534 |
|
549 |
|
535 |
} |
550 |
} |
|
|
551 |
} |
552 |
|
553 |
/** |
554 |
* Creates a folder on given filesystem. The name of the new folder can be |
555 |
* specified as a multi-component pathname whose components are separated |
556 |
* by File.separatorChar or "/" (forward slash). |
557 |
* Has the following ClearCase-related behavior: if the folder is on clearcase FS, |
558 |
* and the putToVCS argument is set to true, then puts the file into VCS |
559 |
* |
560 |
* @param folder where the new folder will be placed in |
561 |
* @param name name of the new folder |
562 |
* @return the new folder |
563 |
* @exception IOException if the creation fails |
564 |
*/ |
565 |
public static FileObject createFolderClearCaseHack(FileObject folder, String name, boolean putToVCS) throws IOException { |
566 |
FileObject result = null; |
567 |
if (putToVCS) { |
568 |
String folderName = folder.getPath(); |
569 |
if ((folderName.length() > 0) && !folderName.endsWith("/")) { |
570 |
folderName = folderName + "/"; |
571 |
} |
572 |
folderName = folderName + name; |
573 |
folder.getFileSystem().getRoot().setAttribute("VCS_MKDIR_ACTION", folderName); |
574 |
result = folder.getFileObject(name); |
575 |
} |
576 |
if (result == null) { |
577 |
result = FileUtil.createFolder(folder, name); |
578 |
} |
579 |
return result; |
580 |
} |
581 |
|
582 |
/** Hack - we may be putting some directories into clearcase. |
583 |
*/ |
584 |
public static boolean shouldPutIntoClearCase(FileSystem fs) { |
585 |
FileObject root = fs.getRoot(); |
586 |
if ("ClearCase".equals(root.getAttribute("FS_DISPLAY_NAME"))) { |
587 |
// ask the user |
588 |
NotifyDescriptor nd = new NotifyDescriptor.Confirmation( |
589 |
NbBundle.getMessage(WebContextObject.class, "MSG_PutIntoClearCase"), NotifyDescriptor.OK_CANCEL_OPTION); |
590 |
DialogDisplayer.getDefault().notify(nd); |
591 |
|
592 |
if (nd.getValue() != NotifyDescriptor.OK_OPTION) return false; |
593 |
return true; |
594 |
} |
595 |
else { |
596 |
return false; |
597 |
} |
536 |
} |
598 |
} |
537 |
|
599 |
|
538 |
// Necessary because of bug - filesystems are added incorrectly if one is |
600 |
// Necessary because of bug - filesystems are added incorrectly if one is |