コード例 #1
0
  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;
  }
コード例 #2
0
  /**
   * Generates service stubs.
   *
   * @throws GenerationException
   */
  @SuppressWarnings("deprecation")
  public void generate() throws GenerationException {

    preGeneration();

    JDefinedClass serviceCls = generateClass();

    preGenerateClassBody(serviceCls);

    generateClassJavadoc(serviceCls.javadoc());

    if (hasDefaultConstructor()) {
      JMethod defaultConst = generateDefaultConstructor(serviceCls);
      JBlock defaultConstBody = defaultConst.body();
      generateDefaultConstructorBody(defaultConstBody);
    }

    List<String> operationNames = this.serviceDefinition.getOperationNames();

    if (this.logger.isDebugEnabled()) {
      this.logger.debug("Generating service class with operations: " + operationNames);
    }

    for (int i = 0; i < operationNames.size(); i++) {
      String operationName = operationNames.get(i);
      List<ElementType> inputTypes = getInputTypes(operationName);
      generateOperationMethod(serviceCls, operationName, inputTypes, null);

      // add overloaded versions for this method
      int j = 0;
      List<List<ElementType>> overloadedVersions = getOverloadedVersions(operationName);
      for (List<ElementType> overloadedInputTypes : overloadedVersions) {
        generateOperationMethod(serviceCls, operationName, overloadedInputTypes, j++);
      }
    }

    postGenerateClassBody(serviceCls);

    try {
      Folder dir = this.configuration.getOutputDirectory();
      if (dir instanceof LocalFolder) {
        File dest = ((LocalFolder) dir).getLocalFile();
        this.codeModel.build(dest, dest, null);
      } else {
        File f = IOUtils.createTempDirectory("dataService_directory", null);
        this.codeModel.build(f, f, null);
        Folder folder = new LocalFolder(f);
        folder.copyContentsTo(this.configuration.getOutputDirectory());
        IOUtils.deleteRecursive(f);
      }
    } catch (IOException e) {
      throw new GenerationException("Unable to write service stub", e);
    }

    postGeneration();
  }
コード例 #3
0
 public void copyFolder(@ParamName(name = "from") String from, @ParamName(name = "to") String to)
     throws IOException {
   Folder source;
   if (from.startsWith("app/templates")) {
     source = this.fileSystem.getStudioWebAppRootFolder().getFolder(from);
   } else {
     source = getResource(from, Folder.class);
   }
   Folder dest = getResource(to, Folder.class);
   if (dest.exists()) throw new IOException("Already Exists");
   dest.createIfMissing();
   source.copyContentsTo(dest);
 }
コード例 #4
0
  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 + "]}";
  }