protected void copyOrRemoveSnapshot( String packageName, String snapshotName, boolean delete, String newSnapshotName) throws SerializationException { if (delete) { log.info( "USER:"******" REMOVING SNAPSHOT for package: [" + packageName + "] snapshot: [" + snapshotName + "]"); rulesRepository.removePackageSnapshot(packageName, snapshotName); } else { if (newSnapshotName.equals("")) { throw new SerializationException("Need to have a new snapshot name."); } log.info( "USER:"******" COPYING SNAPSHOT for package: [" + packageName + "] snapshot: [" + snapshotName + "] to [" + newSnapshotName + "]"); rulesRepository.copyPackageSnapshot(packageName, snapshotName, newSnapshotName); } }
private void listFiles() { if (listFiles) { for (File srcFile : compileList) { log.info(srcFile.getAbsolutePath()); } } }
public void savePackage(PackageConfigData data) throws SerializationException { log.info("USER:"******" SAVING package [" + data.getName() + "]"); PackageItem item = rulesRepository.loadPackage(data.getName()); // If package is being unarchived. boolean unarchived = (!data.isArchived() && item.isArchived()); Calendar packageLastModified = item.getLastModified(); DroolsHeader.updateDroolsHeader(data.getHeader(), item); updateCategoryRules(data, item); item.updateExternalURI(data.getExternalURI()); item.updateDescription(data.getDescription()); item.archiveItem(data.isArchived()); item.updateBinaryUpToDate(false); if (!data.getFormat().equals("")) { item.updateFormat(data.getFormat()); } RuleBaseCache.getInstance().remove(data.getUuid()); item.checkin(data.getDescription()); // If package is archived, archive all the assets under it if (data.isArchived()) { handleArchivedForSavePackage(data, item); } else if (unarchived) { handleUnarchivedForSavePackage(data, item, packageLastModified); } }
protected String createPackage(String name, String description, String format, String[] workspace) throws RulesRepositoryException { log.info("USER: "******" CREATING package [" + name + "]"); PackageItem item = rulesRepository.createPackage(name, description, format, workspace); return item.getUUID(); }
protected String renamePackage(String uuid, String newName) { log.info( "USER:"******" RENAMING package [UUID: " + uuid + "] to package [" + newName + "]"); return rulesRepository.renamePackage(uuid, newName); }
protected void removePackage(String uuid) { try { PackageItem item = rulesRepository.loadPackageByUUID(uuid); log.info("USER:"******" REMOVEING package [" + item.getName() + "]"); item.remove(); rulesRepository.save(); } catch (RulesRepositoryException e) { log.error("Unable to remove package.", e); throw e; } }
protected String createSubPackage(String name, String description, String parentNode) throws SerializationException { log.info( "USER: "******" CREATING subPackage [" + name + "], parent [" + parentNode + "]"); PackageItem item = rulesRepository.createSubPackage(name, description, parentNode); return item.getUUID(); }
protected byte[] exportPackages(String packageName) { log.info("USER:"******" export package [name: " + packageName + "] "); try { return rulesRepository.dumpPackageFromRepositoryXml(packageName); } catch (PathNotFoundException e) { throw new RulesRepositoryException(e); } catch (IOException e) { throw new RulesRepositoryException(e); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
public ValidatedResponse validatePackageConfiguration(PackageConfigData data) throws SerializationException { log.info( "USER:"******" validatePackageConfiguration package [" + data.getName() + "]"); RuleBaseCache.getInstance().remove(data.getUuid()); BRMSSuggestionCompletionLoader loader = createBRMSSuggestionCompletionLoader(); loader.getSuggestionEngine(rulesRepository.loadPackage(data.getName()), data.getHeader()); return validateBRMSSuggestionCompletionLoaderResponse(loader); }
private void runCompiler(String[] commandLine) { // hand crank it so we can add our own compiler configuration try { Options options = FileSystemCompiler.createCompilationOptions(); CommandLineParser cliParser = new GroovyPosixParser(); CommandLine cli; cli = cliParser.parse(options, commandLine); configuration = FileSystemCompiler.generateCompilerConfigurationFromOptions(cli); configuration.setScriptExtensions(getScriptExtensions()); String tmpExtension = getScriptExtension(); if (tmpExtension.startsWith("*.")) tmpExtension = tmpExtension.substring(1); configuration.setDefaultScriptExtension(tmpExtension); // Load the file name list String[] filenames = FileSystemCompiler.generateFileNamesFromOptions(cli); boolean fileNameErrors = filenames == null; fileNameErrors = fileNameErrors && !FileSystemCompiler.validateFiles(filenames); if (targetBytecode != null) { configuration.setTargetBytecode(targetBytecode); } if (!fileNameErrors) { FileSystemCompiler.doCompilation(configuration, makeCompileUnit(), filenames, false); } } catch (Exception re) { Throwable t = re; if ((re.getClass() == RuntimeException.class) && (re.getCause() != null)) { // unwrap to the real exception t = re.getCause(); } StringWriter writer = new StringWriter(); new ErrorReporter(t, false).write(new PrintWriter(writer)); String message = writer.toString(); if (failOnError) { log.info(message); throw new BuildException("Compilation Failed", t, getLocation()); } else { log.error(message); } } }
protected String copyPackage(String sourcePackageName, String destPackageName) throws SerializationException { try { log.info( "USER:"******" COPYING package [" + sourcePackageName + "] to package [" + destPackageName + "]"); return rulesRepository.copyPackage(sourcePackageName, destPackageName); } catch (RulesRepositoryException e) { log.error("Unable to copy package.", e); throw e; } }
protected void createPackageSnapshot( String packageName, String snapshotName, boolean replaceExisting, String comment) { log.info( "USER:"******" CREATING PACKAGE SNAPSHOT for package: [" + packageName + "] snapshot name: [" + snapshotName); if (replaceExisting) { rulesRepository.removePackageSnapshot(packageName, snapshotName); } rulesRepository.createPackageSnapshot(packageName, snapshotName); PackageItem item = rulesRepository.loadPackageSnapshot(packageName, snapshotName); item.updateCheckinComment(comment); rulesRepository.save(); }
protected void compile() { if (compileList.length == 0) return; try { log.info( "Compiling " + compileList.length + " source file" + (compileList.length == 1 ? "" : "s") + (destDir != null ? " to " + destDir : "")); listFiles(); Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject()); List<String> jointOptions = extractJointOptions(classpath); String separator = System.getProperty("file.separator"); List<String> commandLineList = new ArrayList<String>(); doForkCommandLineList(commandLineList, classpath, separator); doNormalCommandLineList(commandLineList, jointOptions, classpath); addSourceFiles(commandLineList); String[] commandLine = makeCommandLine(commandLineList); if (fork) { runForked(commandLine); } else { runCompiler(commandLine); } } finally { for (File temporaryFile : temporaryFiles) { try { FileSystemCompiler.deleteRecursive(temporaryFile); } catch (Throwable t) { System.err.println("error: could not delete temp files - " + temporaryFile.getPath()); } } } }