use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project carbon-business-process by wso2.
the class Delegate method checkPreConditions.
/**
* Checks the Pre-conditions before executing the task operation.
*/
@Override
protected void checkPreConditions() {
checkForValidTask();
OrganizationalEntityDAO caller = getOperationInvoker();
TaskDAO task = getTask();
// if the delegatee is not an existing user
if (!getEngine().getPeopleQueryEvaluator().isExistingUser(delegatee.getName())) {
String errMsg = String.format("The user[%s] cannot delegate task[id:%d] to the given" + " delegatee[name:%s] as he/she does not exist in the user store", caller.getName(), task.getId(), delegatee.getName());
log.error(errMsg);
throw new HumanTaskIllegalArgumentException(errMsg);
}
if (isExcludedOwner(delegatee.getName())) {
String errMsg = String.format("The user[%s] cannot delegate task[id:%d] to the given" + " delegatee[name:%s] as he/she is an exclude owner for this task.", caller.getName(), task.getId(), delegatee.getName());
log.error(errMsg);
throw new HumanTaskIllegalArgumentException(errMsg);
}
// if the task is in reserved or in-progress we have to release it first.
if (TaskStatus.RESERVED.equals(task.getStatus()) || TaskStatus.IN_PROGRESS.equals(task.getStatus())) {
// task releasing can be done only by bus admins and the actual owner.
List<GenericHumanRoleDAO.GenericHumanRoleType> allowedRoles = new ArrayList<GenericHumanRoleDAO.GenericHumanRoleType>();
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.BUSINESS_ADMINISTRATORS);
allowedRoles.add(GenericHumanRoleDAO.GenericHumanRoleType.ACTUAL_OWNER);
try {
authoriseRoles(allowedRoles);
} catch (Exception ex) {
String err = String.format("The task[id:%d] can be only delegated after it's released. " + "But for the task to be released you need to be a business " + "administrator or the actual owner of the task. " + "Given user[%s] is not in those roles!", task.getId(), caller.getName());
log.error(err);
throw new HumanTaskIllegalAccessException(err, ex);
}
task.release();
}
// Add delegatee as a potential owner.
GenericHumanRoleDAO potentialOwnersRole = task.getGenericHumanRole(GenericHumanRoleDAO.GenericHumanRoleType.POTENTIAL_OWNERS);
if (getEngine().getPeopleQueryEvaluator().isOrgEntityInRole(delegatee, potentialOwnersRole)) {
task.persistToPotentialOwners(delegatee);
}
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project airavata by apache.
the class OAuthAppRegisteringClient method registerApplication.
public OAuthConsumerAppDTO registerApplication(String appName, String consumerId, String consumerSecret) throws AiravataSecurityException {
try {
OAuthConsumerAppDTO consumerAppDTO = new OAuthConsumerAppDTO();
consumerAppDTO.setApplicationName(appName);
// consumer key and secret is set by the application.
consumerAppDTO.setOauthConsumerKey(consumerId);
consumerAppDTO.setOauthConsumerSecret(consumerSecret);
// consumerAppDTO.setUsername(adminUserName);
// initialize trust store for SSL handshake
TrustStoreManager trustStoreManager = new TrustStoreManager();
trustStoreManager.initializeTrustStoreManager(Properties.TRUST_STORE_PATH, Properties.TRUST_STORE_PASSWORD);
stub.registerOAuthApplicationData(consumerAppDTO);
// After registration application is retrieve
return stub.getOAuthApplicationDataByAppName(appName);
} catch (AxisFault axisFault) {
axisFault.printStackTrace();
throw new AiravataSecurityException("Error in registering the OAuth application.");
} catch (RemoteException e) {
e.printStackTrace();
throw new AiravataSecurityException("Error in registering the OAuth application.");
} catch (OAuthAdminServiceException e) {
e.printStackTrace();
throw new AiravataSecurityException("Error in registering the OAuth application.");
}
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store 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.siddhi.query.api.execution.query.input.store.Store in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangTernaryExpr ternaryExpr) {
// Determine the reg index of the ternary expression and this reg index will be used by both then and else
// expressions to store their result
RegIndex ternaryExprRegIndex = calcAndGetExprRegIndex(ternaryExpr);
// Generate code for the condition
this.genNode(ternaryExpr.expr, this.env);
Operand ifFalseJumpAddr = getOperand(-1);
this.emit(InstructionCodes.BR_FALSE, ternaryExpr.expr.regIndex, ifFalseJumpAddr);
// Generate code for the then expression
ternaryExpr.thenExpr.regIndex = createLHSRegIndex(ternaryExprRegIndex);
this.genNode(ternaryExpr.thenExpr, this.env);
Operand endJumpAddr = getOperand(-1);
this.emit(InstructionCodes.GOTO, endJumpAddr);
ifFalseJumpAddr.value = nextIP();
// Generate code for the then expression
ternaryExpr.elseExpr.regIndex = createLHSRegIndex(ternaryExprRegIndex);
this.genNode(ternaryExpr.elseExpr, this.env);
endJumpAddr.value = nextIP();
}
use of org.wso2.siddhi.query.api.execution.query.input.store.Store in project ballerina by ballerina-lang.
the class AnnotationDesugar method rewritePackageAnnotations.
protected void rewritePackageAnnotations(BLangPackage pkgNode) {
BLangFunction initFunction = pkgNode.initFunction;
// Remove last return statement. we will add it later. TODO : Fix this properly.
initFunction.body.stmts.remove(initFunction.body.stmts.size() - 1);
// This is the variable which store all package level annotations.
BLangVariable annotationMap = createGlobalAnnotationMapVar(pkgNode);
// handle Service Annotations.
for (BLangService service : pkgNode.services) {
generateAnnotations(service, service.name.value, initFunction, annotationMap);
for (BLangResource resource : service.resources) {
String key = service.name.value + DOT + resource.name.value;
generateAnnotations(resource, key, initFunction, annotationMap);
}
}
// Handle Function Annotations.
for (BLangFunction function : pkgNode.functions) {
generateAnnotations(function, function.symbol.name.value, initFunction, annotationMap);
}
// Handle Connector Annotations.
for (BLangConnector connector : pkgNode.connectors) {
generateAnnotations(connector, connector.name.value, initFunction, annotationMap);
for (BLangAction action : connector.actions) {
String key = connector.name.value + DOT + action.name.value;
generateAnnotations(connector, key, initFunction, annotationMap);
}
}
// Handle Struct Annotations.
for (BLangStruct struct : pkgNode.structs) {
generateAnnotations(struct, struct.name.value, initFunction, annotationMap);
for (BLangVariable field : struct.fields) {
String key = struct.name.value + DOT + field.name.value;
generateAnnotations(field, key, initFunction, annotationMap);
}
}
for (BLangEndpoint globalEndpoint : pkgNode.globalEndpoints) {
generateAnnotations(globalEndpoint, globalEndpoint.name.value, initFunction, annotationMap);
}
ASTBuilderUtil.createReturnStmt(pkgNode.pos, initFunction.body);
}
Aggregations