Search in sources :

Example 1 with PackageFile

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);
            }
        }
    }
}
Also used : QName(javax.xml.namespace.QName) DeploymentUnitDir(org.apache.ode.store.DeploymentUnitDir) IOException(java.io.IOException) CarbonException(org.wso2.carbon.CarbonException) TDeployment(org.apache.ode.bpel.dd.TDeployment) TInvoke(org.apache.ode.bpel.dd.TInvoke) DeployDocument(org.apache.ode.bpel.dd.DeployDocument) TProvide(org.apache.ode.bpel.dd.TProvide) File(java.io.File)

Example 2 with PackageFile

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;
}
Also used : PackageFile(org.wso2.ballerinalang.programfile.CompiledBinaryFile.PackageFile)

Example 3 with 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);
}
Also used : CompiledBinaryFile(org.wso2.ballerinalang.programfile.CompiledBinaryFile) ByteArrayInputStream(java.io.ByteArrayInputStream) BLangCompilerException(org.ballerinalang.compiler.BLangCompilerException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 QName (javax.xml.namespace.QName)1 DeployDocument (org.apache.ode.bpel.dd.DeployDocument)1 TDeployment (org.apache.ode.bpel.dd.TDeployment)1 TInvoke (org.apache.ode.bpel.dd.TInvoke)1 TProvide (org.apache.ode.bpel.dd.TProvide)1 DeploymentUnitDir (org.apache.ode.store.DeploymentUnitDir)1 BLangCompilerException (org.ballerinalang.compiler.BLangCompilerException)1 CompiledBinaryFile (org.wso2.ballerinalang.programfile.CompiledBinaryFile)1 PackageFile (org.wso2.ballerinalang.programfile.CompiledBinaryFile.PackageFile)1 CarbonException (org.wso2.carbon.CarbonException)1