Exemplo n.º 1
0
 /*
  * Facet Methods
  */
 @Override
 public boolean isInstalled() {
   DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
   return webRoot.exists()
       && getConfigFile().exists()
       && project.getFacet(DependencyFacet.class).hasDependency(dep);
 }
Exemplo n.º 2
0
  @Override
  public List<String> getWebPaths(Resource<?> r) {
    List<String> results = new ArrayList<String>();

    if (r != null) {
      WebResourceFacet web = project.getFacet(WebResourceFacet.class);
      List<DirectoryResource> webRootDirectories = web.getWebRootDirectories();
      for (DirectoryResource d : webRootDirectories) {
        if (r.getFullyQualifiedName().startsWith(d.getFullyQualifiedName())) {
          String path = r.getFullyQualifiedName().substring(d.getFullyQualifiedName().length());

          for (String p : getWebPaths(path)) {
            if (!results.contains(p)) results.add(p);
          }
          break;
        }
      }
    }
    return results;
  }
Exemplo n.º 3
0
 private List<Resource<?>> listChildrenRecursively(
     final DirectoryResource current, ResourceFilter filter) {
   List<Resource<?>> result = new ArrayList<Resource<?>>();
   List<Resource<?>> list = current.listResources();
   if (list != null) {
     for (Resource<?> file : list) {
       if (file instanceof DirectoryResource) {
         result.addAll(listChildrenRecursively((DirectoryResource) file, filter));
       }
       if (filter.accept(file)) result.add(file);
     }
   }
   return result;
 }
Exemplo n.º 4
0
  @Override
  public boolean install() {
    if (!isInstalled()) {
      String projectName = project.getFacet(MetadataFacet.class).getProjectName();

      project.getFacet(DependencyFacet.class).addDependency(dep);

      DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
      if (!webRoot.exists()) {
        webRoot.mkdirs();
      }

      FileResource<?> descriptor = getConfigFile();
      if (!descriptor.exists()) {
        WebAppDescriptor unit =
            Descriptors.create(WebAppDescriptor.class)
                .displayName(projectName)
                .sessionTimeout(30)
                .welcomeFile("/index.html");

        descriptor.setContents(unit.exportAsString());
      }

      FileResource<?> welcomePage = (FileResource<?>) webRoot.getChild("index.html");
      welcomePage.setContents(
          "<html><head><title>Welcome to Seam Forge</title></head>"
              + "<body>"
              + "<h1> ["
              + projectName
              + "] is Online</h1>"
              + "Powered by <a href=\"http://bit.ly/seamforge\">Seam Forge</a>"
              + "</body>"
              + "</html>");
    }
    return true;
  }
Exemplo n.º 5
0
 @Override
 public FileResource<?> getConfigFile() {
   DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
   return (FileResource<?>) webRoot.getChild("WEB-INF" + File.separator + "faces-config.xml");
 }