use of org.wso2.ballerinalang.util.Flags in project carbon-business-process by wso2.
the class TransformerUtils method transformTaskAuthorization.
/**
* Creates the TTaskAuthorisationParams object based on the authorisations the caller has on the
* given task
*
* @param task : The TaskDAO object for the authorisations to be checked.
* @param callerName : The caller user name.
* @return : The TTaskAuthorisationParams object containing the authorisation parameters as
* boolean flags.
*/
public static TTaskAuthorisationParams transformTaskAuthorization(TaskDAO task, String callerName) {
PeopleQueryEvaluator pqe = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getPeopleQueryEvaluator();
OrganizationalEntityDAO caller = pqe.createUserOrgEntityForName(callerName);
TTaskAuthorisationParams authParams = new TTaskAuthorisationParams();
if (TaskType.TASK.equals(task.getType())) {
authParams.setAuthorisedToActivate(OperationAuthorizationUtil.authorisedToActivate(task, caller, pqe));
authParams.setAuthorisedToClaim(OperationAuthorizationUtil.authorisedToClaim(task, caller, pqe));
authParams.setAuthorisedToComment(OperationAuthorizationUtil.authorisedToComment(task, caller, pqe));
authParams.setAuthorisedToComplete(OperationAuthorizationUtil.authorisedToComplete(task, caller, pqe));
authParams.setAuthorisedToDelegate(OperationAuthorizationUtil.authorisedToDelegate(task, caller, pqe));
authParams.setAuthorisedToDeleteFault(OperationAuthorizationUtil.authorisedToDeleteFault(task, caller, pqe));
authParams.setAuthorisedToDeleteComment(OperationAuthorizationUtil.authorisedToDeleteComment(task, caller, pqe));
authParams.setAuthorisedToDeleteOutput(OperationAuthorizationUtil.authorisedToDeleteOutput(task, caller, pqe));
authParams.setAuthorisedToExit(OperationAuthorizationUtil.authorisedToExit(task, caller, pqe));
authParams.setAuthorisedToFail(OperationAuthorizationUtil.authorisedToFail(task, caller, pqe));
authParams.setAuthorisedToForward(OperationAuthorizationUtil.authorisedToForward(task, caller, pqe));
authParams.setAuthorisedToGetComments(OperationAuthorizationUtil.authorisedToGetComments(task, caller, pqe));
authParams.setAuthorisedToGetDescription(OperationAuthorizationUtil.authorisedToGetDescription(task, caller, pqe));
authParams.setAuthorisedToGetInput(OperationAuthorizationUtil.authorisedToGetInput(task, caller, pqe));
authParams.setAuthorisedToNominate(OperationAuthorizationUtil.authorisedToNominate(task, caller, pqe));
authParams.setAuthorisedToRelease(OperationAuthorizationUtil.authorisedToRelease(task, caller, pqe));
authParams.setAuthorisedToResume(OperationAuthorizationUtil.authorisedToResume(task, caller, pqe));
authParams.setAuthorisedToRemove(OperationAuthorizationUtil.authorisedToRemove(task, caller, pqe));
authParams.setAuthorisedToSetFault(OperationAuthorizationUtil.authorisedToSetFault(task, caller, pqe));
authParams.setAuthorisedToSetOutput(OperationAuthorizationUtil.authorisedToSetOutput(task, caller, pqe));
authParams.setAuthorisedToSetPriority(OperationAuthorizationUtil.authorisedToSetPriority(task, caller, pqe));
authParams.setAuthorisedToSkip(OperationAuthorizationUtil.authorisedToSkip(task, caller, pqe));
authParams.setAuthorisedToStart(OperationAuthorizationUtil.authorisedToStart(task, caller, pqe));
authParams.setAuthorisedToStop(OperationAuthorizationUtil.authorisedToStop(task, caller, pqe));
authParams.setAuthorisedToSuspend(OperationAuthorizationUtil.authorisedToSuspend(task, caller, pqe));
authParams.setAuthorisedToUpdateComment(OperationAuthorizationUtil.authorisedToUpdateComment(task, caller, pqe));
} else if (TaskType.NOTIFICATION.equals(task.getType())) {
authParams.setAuthorisedToGetDescription(OperationAuthorizationUtil.authorisedToGetDescription(task, caller, pqe));
authParams.setAuthorisedToRemove(OperationAuthorizationUtil.authorisedToRemove(task, caller, pqe));
}
return authParams;
}
use of org.wso2.ballerinalang.util.Flags in project ballerina by ballerina-lang.
the class Symbols method createTransformerSymbol.
public static BTransformerSymbol createTransformerSymbol(int flags, Name name, PackageID pkgID, BType type, boolean safe, BSymbol owner) {
BTransformerSymbol symbol = new BTransformerSymbol(name, pkgID, type, owner, safe);
symbol.kind = SymbolKind.TRANSFORMER;
symbol.scope = new Scope(symbol);
return symbol;
}
use of org.wso2.ballerinalang.util.Flags in project ballerina by ballerina-lang.
the class CodeGenerator method getFuncOperands.
private Operand[] getFuncOperands(BLangInvocation iExpr, int funcRefCPIndex) {
// call funcRefCPIndex, nArgRegs, argRegs[nArgRegs], nRetRegs, retRegs[nRetRegs]
int i = 0;
int nArgRegs = iExpr.requiredArgs.size() + iExpr.namedArgs.size() + iExpr.restArgs.size();
int nRetRegs = iExpr.types.size();
int flags = FunctionFlags.NOTHING;
Operand[] operands = new Operand[nArgRegs + nRetRegs + 4];
operands[i++] = getOperand(funcRefCPIndex);
if (iExpr.async) {
flags = FunctionFlags.markAsync(flags);
}
if (iExpr.actionInvocation) {
flags = FunctionFlags.markObserved(flags);
}
operands[i++] = getOperand(flags);
operands[i++] = getOperand(nArgRegs);
// Write required arguments
for (BLangExpression argExpr : iExpr.requiredArgs) {
operands[i++] = genNode(argExpr, this.env).regIndex;
}
// Write named arguments
i = generateNamedArgs(iExpr, operands, i);
// Write rest arguments
for (BLangExpression argExpr : iExpr.restArgs) {
operands[i++] = genNode(argExpr, this.env).regIndex;
}
// Calculate registers to store return values
operands[i++] = getOperand(nRetRegs);
RegIndex[] iExprRegIndexes;
if (iExpr.regIndex != null) {
iExprRegIndexes = new RegIndex[nRetRegs];
iExprRegIndexes[0] = iExpr.regIndex;
} else {
iExprRegIndexes = new RegIndex[nRetRegs];
}
for (int j = 0; j < nRetRegs; j++) {
RegIndex regIndex = calcAndGetExprRegIndex(iExprRegIndexes[j], iExpr.getTypes().get(j).tag);
iExprRegIndexes[j] = regIndex;
operands[i++] = regIndex;
}
iExpr.setRegIndexes(iExprRegIndexes);
return operands;
}
use of org.wso2.ballerinalang.util.Flags in project ballerina by ballerina-lang.
the class CodeGenerator method createStructInfoEntry.
private void createStructInfoEntry(BLangStruct structNode) {
BStructSymbol structSymbol = (BStructSymbol) structNode.symbol;
// Add Struct name as an UTFCPEntry to the constant pool
int structNameCPIndex = addUTF8CPEntry(currentPkgInfo, structSymbol.name.value);
StructInfo structInfo = new StructInfo(currentPackageRefCPIndex, structNameCPIndex, structSymbol.flags);
currentPkgInfo.addStructInfo(structSymbol.name.value, structInfo);
structInfo.structType = (BStructType) structSymbol.type;
List<BLangVariable> structFields = structNode.fields;
for (BLangVariable structField : structFields) {
// Create StructFieldInfo Entry
int fieldNameCPIndex = addUTF8CPEntry(currentPkgInfo, structField.name.value);
int sigCPIndex = addUTF8CPEntry(currentPkgInfo, structField.type.getDesc());
StructFieldInfo structFieldInfo = new StructFieldInfo(fieldNameCPIndex, sigCPIndex, structField.symbol.flags);
structFieldInfo.fieldType = structField.type;
// Populate default values
if (structField.expr != null && structField.expr.getKind() == NodeKind.LITERAL) {
DefaultValueAttributeInfo defaultVal = getDefaultValueAttributeInfo((BLangLiteral) structField.expr);
structFieldInfo.addAttributeInfo(AttributeInfo.Kind.DEFAULT_VALUE_ATTRIBUTE, defaultVal);
}
structInfo.fieldInfoEntries.add(structFieldInfo);
structField.symbol.varIndex = getFieldIndex(structField.symbol.type.tag);
}
// Create variable count attribute info
prepareIndexes(fieldIndexes);
int[] fieldCount = new int[] { fieldIndexes.tInt, fieldIndexes.tFloat, fieldIndexes.tString, fieldIndexes.tBoolean, fieldIndexes.tBlob, fieldIndexes.tRef };
addVariableCountAttributeInfo(currentPkgInfo, structInfo, fieldCount);
fieldIndexes = new VariableIndex(FIELD);
// Create attached function info entries
for (BAttachedFunction attachedFunc : structSymbol.attachedFuncs) {
int funcNameCPIndex = addUTF8CPEntry(currentPkgInfo, attachedFunc.funcName.value);
// Remove the first type. The first type is always the type to which the function is attached to
BType[] paramTypes = attachedFunc.type.paramTypes.toArray(new BType[0]);
if (paramTypes.length == 1) {
paramTypes = new BType[0];
} else {
paramTypes = attachedFunc.type.paramTypes.toArray(new BType[0]);
paramTypes = Arrays.copyOfRange(paramTypes, 1, paramTypes.length);
}
int sigCPIndex = addUTF8CPEntry(currentPkgInfo, generateFunctionSig(paramTypes, attachedFunc.type.retTypes.toArray(new BType[0])));
int flags = attachedFunc.symbol.flags;
structInfo.attachedFuncInfoEntries.add(new AttachedFunctionInfo(funcNameCPIndex, sigCPIndex, flags));
}
}
use of org.wso2.ballerinalang.util.Flags in project ballerina by ballerina-lang.
the class TestCmd method execute.
public void execute() {
if (helpFlag) {
printCommandUsageInfo(parentCmdParser, "test");
return;
}
if (sourceFileList == null || sourceFileList.isEmpty()) {
Path userDir = Paths.get(System.getProperty("user.dir"));
SourceDirectory srcDirectory = new FileSystemProjectDirectory(userDir);
sourceFileList = srcDirectory.getSourcePackageNames();
}
if (groupList != null && disableGroupList != null) {
throw LauncherUtils.createUsageException("Cannot specify both --groups and --disable-groups flags at the same time");
}
Path sourceRootPath = LauncherUtils.getSourceRootPath(sourceRoot);
Path ballerinaConfPath = sourceRootPath.resolve("ballerina.conf");
try {
ConfigRegistry.getInstance().initRegistry(configRuntimeParams, null, ballerinaConfPath);
((BLogManager) LogManager.getLogManager()).loadUserProvidedLogConfiguration();
} catch (IOException e) {
throw new RuntimeException("failed to read the specified configuration file: " + ballerinaConfPath.toString(), e);
}
Path[] paths = sourceFileList.stream().map(Paths::get).toArray(Path[]::new);
BTestRunner testRunner = new BTestRunner();
if (disableGroupList != null) {
testRunner.runTest(sourceRoot, paths, disableGroupList, false);
} else {
testRunner.runTest(sourceRoot, paths, groupList, true);
}
if (testRunner.getTesterinaReport().isFailure()) {
Runtime.getRuntime().exit(1);
}
Runtime.getRuntime().exit(0);
}
Aggregations