Search in sources :

Example 96 with Store

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);
    }
}
Also used : HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) ArrayList(java.util.ArrayList) HumanTaskIllegalArgumentException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalArgumentException) HumanTaskIllegalAccessException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskIllegalAccessException) HumanTaskRuntimeException(org.wso2.carbon.humantask.core.engine.runtime.api.HumanTaskRuntimeException)

Example 97 with Store

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.");
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) OAuthAdminServiceException(org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) TrustStoreManager(org.apache.airavata.security.util.TrustStoreManager) RemoteException(java.rmi.RemoteException) AiravataSecurityException(org.apache.airavata.security.AiravataSecurityException)

Example 98 with Store

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;
}
Also used : Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) RegIndex(org.wso2.ballerinalang.programfile.Instruction.RegIndex)

Example 99 with Store

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

Example 100 with Store

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);
}
Also used : BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint) BLangFunction(org.wso2.ballerinalang.compiler.tree.BLangFunction) BLangService(org.wso2.ballerinalang.compiler.tree.BLangService) BLangResource(org.wso2.ballerinalang.compiler.tree.BLangResource) BLangStruct(org.wso2.ballerinalang.compiler.tree.BLangStruct) BLangConnector(org.wso2.ballerinalang.compiler.tree.BLangConnector) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction)

Aggregations

HashMap (java.util.HashMap)25 Test (org.testng.annotations.Test)21 ArrayList (java.util.ArrayList)18 CharonException (org.wso2.charon3.core.exceptions.CharonException)18 SCIMResponse (org.wso2.charon3.core.protocol.SCIMResponse)18 UserManager (org.wso2.charon3.core.extensions.UserManager)15 Produces (javax.ws.rs.Produces)14 ApiOperation (io.swagger.annotations.ApiOperation)12 ApiResponses (io.swagger.annotations.ApiResponses)12 Path (javax.ws.rs.Path)10 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)10 Map (java.util.Map)9 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)8 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)8 UserStoreException (org.wso2.carbon.user.api.UserStoreException)8 Consumes (javax.ws.rs.Consumes)7 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)7 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)7 Response (feign.Response)6 IOException (java.io.IOException)6