public FileUploadResponse uploadClientComponent(MultipartFile file) throws IOException {
    String fileName = file.getOriginalFilename();
    String className = fileName.substring(0, fileName.lastIndexOf(".zip"));
    FileUploadResponse ret = new FileUploadResponse();
    Folder componentStage =
        this.fileSystem
            .getWaveMakerHomeFolder()
            .getFolder("common/packages")
            .getFolder(CLIENT_COMPONENTS_STAGE);
    ZipArchive.unpack(file.getInputStream(), componentStage);
    com.wavemaker.tools.io.File jsFile =
        componentStage.getFile(className + "/" + className + ".js");
    if (!jsFile.exists()) {
      componentStage.delete();
      throw new IOException(jsFile.toString() + " not found");
    }
    String str = getClientComponentPackageString(jsFile);
    String packageStr = str.substring(0, str.lastIndexOf("." + className));

    Folder componentFolder =
        this.fileSystem
            .getWaveMakerHomeFolder()
            .getFolder(StringUtils.packageToSrcFilePath(packageStr));
    componentFolder.createIfMissing();
    componentFolder.list().delete(); // delete older version of the composite
    Folder zipFolder = componentStage.getFolder(className);
    zipFolder.copyContentsTo(componentFolder);
    this.deploymentManager.writeModuleToLibJs(packageStr + "." + className);
    componentStage.delete();
    ret.setPath(packageStr + "." + className);

    return ret;
  }
Ejemplo n.º 2
0
 private List<Hashtable<String, Object>> listChildren(Folder folder) {
   Resources<Resource> list = folder.list().include(FilterOn.nonHidden());
   List<Hashtable<String, Object>> children = new ArrayList<Hashtable<String, Object>>();
   for (Resource child : list) {
     children.add(asHashTable(child));
   }
   return children;
 }
  public void deployClientComponent(
      String className,
      String folder,
      String data,
      String[] services,
      String[] images,
      String[] html)
      throws IOException {
    deployClientComponent(className, folder, data);

    /* Take care of the services */
    Folder componentFolder = this.fileSystem.getWaveMakerHomeFolder().getFolder("common/packages");
    if (folder != null && folder.length() > 0) {

      String[] folderList = folder.split("\\.");
      for (String f : folderList) {
        componentFolder = componentFolder.getFolder(f);
      }
    }

    Folder componentServiceFolder = componentFolder.getFolder("services");
    componentServiceFolder.createIfMissing();
    componentServiceFolder.list().delete(); // delete any old services
    com.wavemaker.tools.io.Folder projectServicesFolder =
        this.serviceDeploymentManager
            .getProjectManager()
            .getCurrentProject()
            .getRootFolder()
            .getFolder("services");

    int i;
    for (i = 0; i < services.length; i++) {
      Folder destFolder = componentServiceFolder.getFolder(services[i]);
      destFolder.createIfMissing();
      projectServicesFolder.getFolder(services[i]).copyContentsTo(destFolder);
    }

    com.wavemaker.tools.io.Folder webappFolder =
        this.serviceDeploymentManager
            .getProjectManager()
            .getCurrentProject()
            .getRootFolder()
            .getFolder("webapproot");
    Folder compositeImagesFolder = componentFolder.getFolder("images");
    compositeImagesFolder.createIfMissing();
    for (i = 0; i < images.length; i++) {
      com.wavemaker.tools.io.File sourceFile = webappFolder.getFile(images[i]);
      sourceFile.copyTo(compositeImagesFolder);
    }

    Folder compositeHtmlFolder = componentFolder.getFolder("html");
    compositeHtmlFolder.createIfMissing();
    for (i = 0; i < html.length; i++) {
      com.wavemaker.tools.io.File sourceFile = webappFolder.getFile(html[i]);
      sourceFile.copyTo(compositeHtmlFolder);
    }
  }
  public String copyComponentServices(String path) {
    Folder componentFolder =
        this.fileSystem.getWaveMakerHomeFolder().getFolder("common/packages").getFolder(path);
    com.wavemaker.tools.io.Folder componentServicesFolder = componentFolder.getFolder("services");
    com.wavemaker.tools.io.Folder projectServicesFolder =
        this.serviceDeploymentManager
            .getProjectManager()
            .getCurrentProject()
            .getRootFolder()
            .getFolder("services");
    String responseInclude = "";
    String responseExclude = "";
    if (componentServicesFolder.exists()) {
      com.wavemaker.tools.io.Resources<com.wavemaker.tools.io.Folder> componentServiceFolders =
          componentServicesFolder.list().folders();
      for (com.wavemaker.tools.io.Folder f : componentServiceFolders) {
        String name = f.getName();
        com.wavemaker.tools.io.Folder projectServiceFolder = projectServicesFolder.getFolder(name);
        if (!projectServiceFolder.exists()) {
          projectServiceFolder.createIfMissing();
          f.copyContentsTo(projectServiceFolder);
          if (responseInclude.equals("") == false) responseInclude += ", ";
          responseInclude += "'" + name + "'";
        } else {
          if (responseExclude.equals("") == false) responseExclude += ", ";
          responseExclude += "'" + name + "'";
        }
      }
    }

    com.wavemaker.tools.io.Resources<com.wavemaker.tools.io.File> jarfiles =
        componentFolder.list().files().include(FilterOn.names().ending(".jar"));
    com.wavemaker.tools.io.Folder projectFolder =
        this.serviceDeploymentManager.getProjectManager().getCurrentProject().getRootFolder();
    com.wavemaker.tools.io.Folder libFolder = projectFolder.getFolder("lib");
    for (com.wavemaker.tools.io.File f : jarfiles) {
      com.wavemaker.tools.io.File destfile = libFolder.getFile(f.getName());
      if (!destfile.exists()) {
        f.copyTo(libFolder);
      }
    }

    return "{servicesAdded: [" + responseInclude + "], servicesSkipped: [" + responseExclude + "]}";
  }
Ejemplo n.º 5
0
 private Resources<com.wavemaker.tools.io.File> getServiceFiles(Folder folder) {
   return folder.list().files().include(FilterOn.names().notEnding(".properties"));
 }