Exemplo n.º 1
0
  @Override
  public List<Resource<?>> setup(ScaffoldSetupContext setupContext) {
    setProject(setupContext.getProject());
    String targetDir = setupContext.getTargetDirectory();
    Resource<?> template = null;
    List<Resource<?>> resources = generateIndex(targetDir, template);
    setupWebXML();

    return resources;
  }
Exemplo n.º 2
0
 @SuppressWarnings("rawtypes")
 @Override
 public boolean isSetup(ScaffoldSetupContext setupContext) {
   Project project = setupContext.getProject();
   setProject(project);
   String targetDir = setupContext.getTargetDirectory();
   targetDir = targetDir == null ? "" : targetDir;
   if (project.hasAllFacets(
       Arrays.asList(
           WebResourcesFacet.class,
           DependencyFacet.class,
           JPAFacet.class,
           EJBFacet.class,
           CDIFacet.class,
           ServletFacet.class,
           FacesFacet.class))) {
     WebResourcesFacet web = project.getFacet(WebResourcesFacet.class);
     boolean areResourcesInstalled =
         web.getWebResource(targetDir + INDEX_HTML).exists()
             && web.getWebResource(targetDir + INDEX_XHTML).exists()
             && web.getWebResource(ERROR_XHTML).exists()
             && web.getWebResource(ADD_PNG).exists()
             && web.getWebResource(BOOTSTRAP_CSS).exists()
             && web.getWebResource(FALSE_PNG).exists()
             && web.getWebResource(FAVICON_ICO).exists()
             && web.getWebResource(FORGE_LOGO_PNG).exists()
             && web.getWebResource(FORGE_STYLE_CSS).exists()
             && web.getWebResource(REMOVE_PNG).exists()
             && web.getWebResource(SEARCH_PNG).exists()
             && web.getWebResource(TRUE_PNG).exists()
             && web.getWebResource(JBOSS_COMMUNITY_PNG).exists()
             && web.getWebResource(PAGINATOR).exists()
             && getTemplateStrategy().getDefaultTemplate().exists();
     ServletFacet servlet = project.getFacet(ServletFacet.class);
     boolean isWelcomeFileListed = false;
     if (servlet instanceof ServletFacet_3_0) {
       WebAppDescriptor servletConfig = (WebAppDescriptor) servlet.getConfig();
       for (WelcomeFileListType<WebAppDescriptor> welcomeFileList :
           servletConfig.getAllWelcomeFileList()) {
         for (String welcomeFile : welcomeFileList.getAllWelcomeFile()) {
           if (welcomeFile.equals(INDEX_HTML)) {
             isWelcomeFileListed = true;
             break;
           }
         }
       }
     } else if (servlet instanceof ServletFacet_3_1) {
       org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor servletConfig =
           (org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor) servlet.getConfig();
       for (org.jboss.shrinkwrap.descriptor.api.webcommon31.WelcomeFileListType<
               org.jboss.shrinkwrap.descriptor.api.webapp31.WebAppDescriptor>
           welcomeFileList : servletConfig.getAllWelcomeFileList()) {
         for (String welcomeFile : welcomeFileList.getAllWelcomeFile()) {
           if (welcomeFile.equals(INDEX_HTML)) {
             isWelcomeFileListed = true;
             break;
           }
         }
       }
     }
     return areResourcesInstalled && isWelcomeFileListed;
   }
   return false;
 }