Esempio n. 1
0
 @Override
 public Result execute() {
   Folder cur;
   try {
     cur = currentResource();
   } catch (NotAuthorizedException | BadRequestException ex) {
     return result("can't lookup current resource", ex);
   }
   if (cur == null) {
     return result("current dir not found: " + currentDir);
   }
   String cmd = args.get(0);
   args.remove(0);
   switch (cmd) {
     case "add":
       return doAdd(cur.getHost());
     case "remove":
       return doRemove(cur.getHost());
     default:
       return result("Unknown command: " + cmd);
   }
 }
Esempio n. 2
0
  private Result deploySimple(String deployUrl, Folder currentFolder)
      throws MalformedURLException, IOException, Exception {
    URL url = new URL(deployUrl);

    try (InputStream in = url.openStream();
        BufferedInputStream bufIn = new BufferedInputStream(in)) {
      VfsTransactionManager.setRollbackOnly(true);
      Path path = Path.path(url.getPath());
      File deployWar = File.createTempFile("ettrema-deploy", path.getName());
      try (FileOutputStream fout = new FileOutputStream(deployWar);
          BufferedOutputStream bufOut = new BufferedOutputStream(fout)) {
        StreamUtils.readTo(bufIn, bufOut);
        bufOut.flush();
        fout.flush();
      }
      String deployName = findDeployName(path);
      deploymentService.deploy(deployWar, deployName, currentFolder.getWeb());
      VfsTransactionManager.setRollbackOnly(false);
      commit();
      return result("Deployed ok: " + deployName);
    } finally {
      VfsTransactionManager.setRollbackOnly(false);
    }
  }
Esempio n. 3
0
  @Override
  public Result execute() {
    Folder cur;
    try {
      cur = currentResource();
    } catch (NotAuthorizedException | BadRequestException ex) {
      return result("can't lookup current resource", ex);
    }
    if (cur == null) {
      return result("current dir not found: " + currentDir);
    }
    String deployUrl = "";
    if (cur instanceof Folder) {
      Folder col = cur;
      try {

        if (args.size() == 1) {
          deployUrl = args.get(0);

          return deploySimple(deployUrl, col);
        } else if (args.size() >= 3) {
          String s = args.get(0);
          boolean isUnderlay = false;
          if (s.equals("-underlay")) {
            isUnderlay = true;
            args.remove(0);
          }

          if (mavenRoot == null || mavenRoot.length() == 0) {
            return result("Cant deploy maven spec, no maven root has been configred");
          }
          String group = args.get(0);
          String artifact = args.get(1);
          String version = args.get(2);
          deployUrl =
              mavenRoot
                  + "/"
                  + group.replace(".", "/")
                  + "/"
                  + artifact
                  + "/"
                  + version
                  + "/"
                  + artifact
                  + "-"
                  + version
                  + ".war";
          log.info("Built maven URL: " + deployUrl);
          if (isUnderlay) {
            UnderlayVector v = new UnderlayVector();
            v.setArtifcatId(artifact);
            v.setGroupId(group);
            v.setVersion(version);
            return deployUnderlay(deployUrl, v);
          } else {
            return deploySimple(deployUrl, col);
          }
        } else {
          return result(
              "Invalid number of arguments. Either give single URL or 3 arguments for a maven vector group artifact id");
        }
      } catch (MalformedURLException ex) {
        return result("Bad url: " + deployUrl);
      } catch (Exception ex) {
        return result("Exception deploying: " + deployUrl, ex);
      }
    } else {
      return result("not a collection: " + cur.getHref());
    }
  }