@Test
  public void testZIPFolder() {

    String pathToFolder = "C:\\PROJECTS\\ArtifactoryDeployTool\\ArtifactoryDeployTool";

    String pathToZIP = "C:\\PROJECTS\\ArtifactoryDeployTool\\ArtifactoryDeployTool.zip";

    ZipUtil.pack(new File(pathToFolder), new File(pathToZIP));
  }
Ejemplo n.º 2
0
 public static void decodeResources(File input, File output) {
   try {
     Path temporaryDirectory = Files.createTempDirectory("apkresources");
     File directory = temporaryDirectory.toFile();
     Files.delete(temporaryDirectory);
     cmdDecode(input, directory);
     File original = new File(directory, "original");
     FileUtils.deleteDirectory(original);
     File apktool = new File(directory, "apktool.yml");
     apktool.delete();
     ZipUtil.pack(directory, output);
     FileUtils.deleteDirectory(directory);
   } catch (Exception e) {
     ExceptionHandler.handle(e);
   }
 }
  public void generator(ProxyObject proxyObject) throws IOException, JAXBException {

    String apiDir = "/" + proxyObject.getApiBundleName() + "/" + "apiproxy";
    String apiProxyZip = proxyObject.getApiBundleLocation() + "/" + "apiproxy.zip";
    String proxyDir = apiDir + "/" + "proxies";
    String targetDir = apiDir + "/" + "targets";
    String policiesDir = apiDir + "/" + "policies";

    boolean success =
        (new File(proxyObject.getApiBundleLocation() + "/" + proxyObject.getApiBundleName()))
            .mkdir();
    (new File(proxyObject.getApiBundleLocation() + apiDir)).mkdir();
    (new File(proxyObject.getApiBundleLocation() + proxyDir)).mkdir();
    (new File(proxyObject.getApiBundleLocation() + targetDir)).mkdir();

    try {

      if (proxyObject.getSwaggerType().equalsIgnoreCase("n")) {
        GeneralProxyGenerator genProxy = new GeneralProxyGenerator(proxyObject);
        genProxy.createProxy();

      } else if (proxyObject.getSwaggerType().equalsIgnoreCase("y")) {
        ProxyGenerator proxy = new ProxyGenerator(proxyObject);
        proxy.createProxy();
      }

    } catch (IOException e) {
      e.printStackTrace();
    } catch (JAXBException e) {
      e.printStackTrace();
    }

    TargetGenerator target = new TargetGenerator(proxyObject);
    try {
      target.createTarget();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (JAXBException e) {
      e.printStackTrace();
    }

    ApplicationGenerator application = new ApplicationGenerator(proxyObject);
    try {
      application.createProxy();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (JAXBException e) {
      e.printStackTrace();
    }

    if (proxyObject.isApplyProlicies()) {
      (new File(proxyObject.getApiBundleLocation() + policiesDir)).mkdir();

      PolicyGenerator policies = new PolicyGenerator(proxyObject);
      try {
        policies.createPolicies();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (JAXBException e) {
        e.printStackTrace();
      }
    }

    String proxyDefault = proxyObject.getApiBundleLocation() + proxyDir + "/default.xml";
    String targetDefault = proxyObject.getApiBundleLocation() + targetDir + "/default.xml";

    String appfile =
        proxyObject.getApiBundleLocation()
            + "/"
            + apiDir
            + "/"
            + proxyObject.getApiBundleName()
            + ".xml";

    // Create a apiproxy.zip
    ZipUtil.pack(
        new File(proxyObject.getApiBundleLocation() + "/" + proxyObject.getApiBundleName() + "/"),
        new File(
            proxyObject.getApiBundleLocation()
                + "/"
                + proxyObject.getApiBundleName()
                + "/"
                + "apiproxy.zip"));
  }