use of org.wso2.ballerinalang.programfile.CompiledBinaryFile.PackageFile in project carbon-business-process by wso2.
the class BPELUploadExecutor method validateBPELPackage.
public void validateBPELPackage(String directoryPath) throws Exception {
DeploymentUnitDir du;
try {
du = new DeploymentUnitDir(new File(directoryPath));
} catch (IllegalArgumentException iae) {
log.error("BPEL Package Validation Failure.", iae);
throw new Exception("BPEL Package Validation Failure.", iae);
}
// check package for illegal charactors which registry does not support. (~!@#$;%^*()+={}[]|\<>)
List<File> packageFiles = du.allFiles();
for (File packageFile : packageFiles) {
if (!packageFile.getName().matches("[^\\~\\!\\@\\#\\$\\;\\%\\^\\*\\(\\)\\+ " + "/\\=\\{\\}\\[\\]\\\\|\\<\\>\"\\'\\`]+")) {
log.error("BPEL Package Validation Failure: one or many of the following illegal characters are in " + "the package.\n ~!@#$;%^*()+={}[]| \\<>\"'`");
throw new Exception("BPEL Package Validation Failure: one or many of the following illegal characters" + " " + "are in the package. ~!@#$;%^*()+={}[]| \\<>\"'`");
}
}
try {
du.compile();
} catch (RuntimeException ce) {
log.error("BPEL Process Compilation Failure.", ce);
throw new Exception("BPEL Compilation Failure!", ce);
} catch (Exception e) {
log.error("BPEL Process Compilation Failure.", e);
throw new Exception("BPEL Compilation Failure!", e);
}
du.scan();
DeployDocument dd = du.getDeploymentDescriptor();
for (TDeployment.Process processDD : dd.getDeploy().getProcessList()) {
QName processType = processDD.getType() != null ? processDD.getType() : processDD.getName();
DeploymentUnitDir.CBPInfo cbpInfo = du.getCBPInfo(processType);
if (cbpInfo == null) {
// removeDeploymentArtifacts(deploymentContext, du);
String logMessage = "Aborting deployment. Cannot find Process definition for type " + processType + ".";
log.error(logMessage);
throw new Exception(logMessage);
}
for (TProvide tProvide : processDD.getProvideList()) {
if (tProvide.getService() == null) {
String errMsg = "Service element missing for the provide element in deploy.xml";
log.error(errMsg);
throw new Exception(errMsg);
}
}
for (TInvoke tInvoke : processDD.getInvokeList()) {
if (tInvoke.getService() == null) {
String errMsg = "Service element missing for the invoke element in deploy.xml";
log.error(errMsg);
throw new Exception(errMsg);
}
}
}
}
use of org.wso2.ballerinalang.programfile.CompiledBinaryFile.PackageFile in project ballerina by ballerina-lang.
the class CodeGenerator method generateBALO.
public PackageFile generateBALO(BLangPackage pkgNode) {
this.buildCompiledPackage = true;
this.packageFile = new PackageFile();
genPackage(pkgNode.symbol);
// Add global variable indexes to the ProgramFile
prepareIndexes(pvIndexes);
// Create Global variable attribute info
addVarCountAttrInfo(this.packageFile, this.packageFile, pvIndexes);
return this.packageFile;
}
use of org.wso2.ballerinalang.programfile.CompiledBinaryFile.PackageFile in project ballerina by ballerina-lang.
the class BinaryFileWriter method writeLibraryPackage.
public void writeLibraryPackage(BLangPackage packageNode) {
String fileName = getOutputFileName(packageNode, BLANG_COMPILED_PACKAGE_FILE_SUFFIX);
CompiledBinaryFile.PackageFile packageFile = this.codeGenerator.generateBALO(packageNode);
ByteArrayOutputStream byteArrayOS = new ByteArrayOutputStream();
try {
PackageFileWriter.writePackage(packageFile, byteArrayOS);
} catch (IOException e) {
throw new BLangCompilerException("error writing package file '" + fileName + "'", e);
}
this.sourceDirectory.saveCompiledPackage(new ByteArrayInputStream(byteArrayOS.toByteArray()), fileName);
}
Aggregations