private void deleteServiceShallow(String serviceId) throws IOException { Folder classesFolder = getProjectWebAppRoot().getFolder("WEB-INF/classes"); File springConfig = classesFolder.getFile(serviceId + ".spring.xml"); springConfig.delete(); File dbProperty = classesFolder.getFile(serviceId + ".properties"); if (dbProperty.exists()) { dbProperty.delete(); } Service service = getService(serviceId); if (service != null) { com.wavemaker.tools.io.Resource target; if (service.getType().equals("JavaService")) { target = classesFolder.getFile(StringUtils.classNameToClassFilePath(service.getClazz())); } else { String packageName = StringUtils.getPackage(service.getClazz()); target = classesFolder.getFolder(StringUtils.packageToSrcFilePath(packageName)); } target.delete(); } Map<String, Service> serviceDefs = getCurrentServiceDefinitions(); serviceDefs.remove(serviceId); Folder serviceHome = getServiceFolder(serviceId); Project project = this.projectManager.getCurrentProject(); project.deleteFile(serviceHome); project.deleteFile(ConfigurationCompiler.getSmdFile(project, serviceId)); }
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 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; }
/** * Unzip the specified input stream into a folder. * * @param inputStream the input stream to unzip (this must contain zip contents) * @param destination the destination folder * @see #unpack(File) */ public static void unpack(InputStream inputStream, Folder destination) { Assert.notNull(inputStream, "InputStream must not be null"); Assert.notNull(destination, "Destination must not be null"); destination.createIfMissing(); ZipInputStream zip = new ZipInputStream(new BufferedInputStream(inputStream)); try { InputStream noCloseZip = new NoCloseInputStream(zip); ZipEntry entry = zip.getNextEntry(); while (entry != null) { if (entry.isDirectory()) { destination.getFolder(entry.getName()).createIfMissing(); } else { destination.getFile(entry.getName()).getContent().write(noCloseZip); } entry = zip.getNextEntry(); } } catch (IOException e) { throw new ResourceException(e); } finally { try { zip.close(); } catch (IOException e) { } } }
/** * Uploads a file to the given path * * @param file the file contents being uploaded * @param path the path where the file should be uploaded * @return an upload response * @throws IOException * @see {@link #unzipAndMoveNewFile(String)} */ public FileUploadResponse uploadFile(@ParamName(name = "file") MultipartFile file, String path) throws IOException { FileUploadResponse response = new FileUploadResponse(); try { Folder folder = getResource(path, Folder.class); String filename = getSafeFilename(file.getOriginalFilename()); folder.getFile(filename).getContent().write(file.getInputStream()); } catch (Exception e) { response.setError(e.getMessage()); } return response; }
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 + "]}"; }
public void processService(DesignServiceManager serviceMgr, String serviceId) { Folder serviceDir = serviceMgr.getServiceRuntimeFolder(serviceId); Folder serviceFolder = serviceMgr.getServiceRuntimeFolder(serviceId); if (!serviceFolder.exists()) { throw new BuildException("Could not locate service home for " + serviceId); } ServiceClassGenerator generator = new ServiceClassGenerator(); Resources<File> files = getServiceFiles(serviceFolder); List<ServiceFile> serviceFiles = new ArrayList<ServiceFile>(); for (File file : files) { File resource = serviceDir.getFile(file.getName()); serviceFiles.add(new ServiceFile(file, resource)); } generator.addServiceFiles(serviceFiles, serviceId); if (this.destDir == null) { generator.setOutputDirectory(serviceDir); } else { generator.setOutputDirectory(this.destDir); } generator.setDesignServiceManager(serviceMgr); generator.run(); }
// cftempfix public Project(Folder projectRootFolder, String projectName) { super(); this.projectRootFolder = projectRootFolder.jail(); this.projectName = projectName; this.mavenProject = projectRootFolder.getFile(ProjectConstants.POM_XML).exists(); }