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 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; }
/** * Validates a serviceid. * * @throws ConfigurationException is the serviceid is invalid. */ public void validateServiceId(String id) { if (ObjectUtils.isNullOrEmpty(id)) { throw new InvalidServiceIdException(id, "it cannot be null or empty"); } if (RESERVED_WORDS.contains(id)) { try { deleteServiceShallow(id); } catch (IOException e) { } throw new InvalidServiceIdException(id, "it contains a reserved word"); } if (!StringUtils.isValidJavaIdentifier(id)) { try { deleteServiceShallow(id); } catch (IOException e) { } throw new InvalidServiceIdException(id, "it must be a valid java identifier"); } // last check should be for already existing service id if (getServiceIds().contains(id)) { throw new DuplicateServiceIdException(id); } }
protected void addJavadoc(JDocComment jdoc) { jdoc.add( " Operations for service \"" + this.serviceDefinition.getServiceId() + "\"\n" + StringUtils.getFormattedDate()); }
/** * Validates a fqClassName. * * @throws ConfigurationException is the Class or Package name is invalid. */ public void validateFqClassName(String fqClassName) { for (String token : fqClassName.split("\\.")) { if (!StringUtils.isValidJavaIdentifier(token)) { throw new InvalidClassNameException( token, "it can not contain reserved java keywords and must be a valid java identifier"); } } }
private boolean isDeletedSFDataObject(DataObject obj) { // salesforce Collection<String> deletedSFDataObjects = this.cfg.getDeletedSFDataObjects(); for (String name : deletedSFDataObjects) { String src = StringUtils.classNameToSrcFilePath(obj.getJavaType()); if (src.equals(name)) { return true; } } return false; }
/** * Return true if the underlying service needs to be re-generated, false otherwise. * * @param srcLastModified The last time the service src was modified, in milliseconds since the * epoch. * @return true if service is up to date, false if it needs to be re-generated. */ public boolean isUpToDate(long srcLastModified) { if (srcLastModified == 0) { return false; } com.wavemaker.tools.io.File f = this.configuration .getOutputDirectory() .getFile(StringUtils.classNameToSrcFilePath(getClassName())); if (!f.exists()) { return false; } return srcLastModified <= f.getLastModified(); }
public TypeInfo(String name, String packageName) { this.name = name; this.fqName = StringUtils.fq(packageName, name); }
public TypeInfo(String fqName) { Tuple.Two<String, String> t = StringUtils.splitPackageAndClass(fqName); this.fqName = fqName; this.name = t.v2; }
private void logStackTrace() { txLogger.debug(StringUtils.toString(new Throwable())); }