예제 #1
0
  public static void modulesTestScript(String uuid) {
    renderArgs.put("format", "sh");
    List<Module> modules = Module.findAll();

    render("Application/modulesTestScript.sh", modules);
  }
예제 #2
0
  public static void publish(Long id) throws IOException {
    models.Upload upload = getUpload(id);
    File uploadsDir = Util.getUploadDir(id);
    User user = getUser();
    UploadInfo uploadInfo = getUploadInfo(upload, uploadsDir, user);

    if (!uploadInfo.isPublishable()) {
      Validation.addError(null, "Upload is not valid, cannot publish. Fix errors first.");
      prepareForErrorRedirect();
      view(id);
    }

    List<models.ModuleVersion> versions = new LinkedList<models.ModuleVersion>();
    for (Module module : uploadInfo.modules) {
      models.Module mod = models.Module.find("name = ?", module.name).first();
      if (mod == null) {
        mod = new models.Module();
        mod.name = module.name;
        mod.owner = user;
        mod.create();
      }

      models.ModuleVersion modVersion = new models.ModuleVersion();
      modVersion.module = mod;
      modVersion.version = module.version;
      modVersion.isCarPresent = module.car.exists;
      modVersion.isJarPresent = module.jar.exists;
      modVersion.isJsPresent = module.js.exists;
      modVersion.isSourcePresent = module.source.exists;
      modVersion.isScriptsPresent = module.scripts.exists;
      modVersion.isAPIPresent = module.docs.hasUnzipped;
      modVersion.isDocPresent = module.docs.exists;
      modVersion.isResourcesPresent = module.docs.exists;
      modVersion.isRunnable = module.isRunnable;
      modVersion.jvmBinMajor = module.jvmBinMajor;
      modVersion.jvmBinMinor = module.jvmBinMinor;
      modVersion.jsBinMajor = module.jsBinMajor;
      modVersion.jsBinMinor = module.jsBinMinor;
      modVersion.isNativeJvm = module.isNativeJvm();
      modVersion.isNativeJs = module.isNativeJs();
      modVersion.published = Util.currentTimeInUTC();
      modVersion.doc = module.doc;
      modVersion.license = module.license;
      if (module.authors != null) {
        for (String author : module.authors) {
          modVersion.authors.add(Author.findOrCreate(author));
        }
      }
      modVersion.create();

      for (Import imp : module.getAllDependencies())
        modVersion.addDependency(
            imp.name,
            imp.version,
            imp.optional,
            imp.export,
            imp.mavenDependency != null,
            imp.herdDependency != null,
            imp.isNativeJvm(),
            imp.isNativeJs());

      for (ModuleChecker.Member member : module.members)
        modVersion.addMember(member.packageName, member.name, member.type, member.shared);

      for (ModuleChecker.Script script : module.scriptDescriptions)
        modVersion.addScript(
            script.name, script.description, script.unix, script.plugin, script.module);

      versions.add(modVersion);
    }

    FileUtils.copyDirectory(uploadsDir, Util.getRepoDir(), NonEmptyDirectoryFilter);
    FileUtils.deleteDirectory(uploadsDir);
    upload.delete();

    MyCache.evictUploadsForOwner(user);
    MyCache.evictModulesForOwner(user);

    if (versions.size() == 1) {
      flash("message", "Your module has been published");
      models.ModuleVersion moduleVersion = versions.get(0);
      Repo.view(moduleVersion.module.name, moduleVersion.version);
    } else {
      flash("message", "Your modules have been published");
      render(versions);
    }
  }
예제 #3
0
  public static void index() {

    List<Module> modules = Module.findAll();

    render(modules);
  }