Search in sources :

Example 6 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-apimgt by wso2.

the class OAuth2Authenticator method getRestAPIResource.

/*
    * This methos is used to get the rest api resource based on the api context
    * @param Request
    * @return String : api resource object
    * @throws APIMgtSecurityException if resource could not be found.
    * */
private String getRestAPIResource(Request request) throws APIMgtSecurityException {
    // todo improve to get appname as a property in the Request
    String path = (String) request.getProperty(APIConstants.REQUEST_URL);
    String restAPIResource = null;
    // this is publisher API so pick that API
    try {
        if (path.contains(RestApiConstants.REST_API_PUBLISHER_CONTEXT)) {
            restAPIResource = RestApiUtil.getPublisherRestAPIResource();
        } else if (path.contains(RestApiConstants.REST_API_STORE_CONTEXT)) {
            restAPIResource = RestApiUtil.getStoreRestAPIResource();
        } else if (path.contains(RestApiConstants.REST_API_ADMIN_CONTEXT)) {
            restAPIResource = RestApiUtil.getAdminRestAPIResource();
        } else if (path.contains(RestApiConstants.REST_API_ANALYTICS_CONTEXT)) {
            restAPIResource = RestApiUtil.getAnalyticsRestAPIResource();
        } else {
            throw new APIMgtSecurityException("No matching Rest Api definition found for path:" + path);
        }
    } catch (APIManagementException e) {
        throw new APIMgtSecurityException(e.getMessage(), ExceptionCodes.AUTH_GENERAL_ERROR);
    }
    return restAPIResource;
}
Also used : APIMgtSecurityException(org.wso2.carbon.apimgt.rest.api.common.exception.APIMgtSecurityException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException)

Example 7 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project ballerina by ballerina-lang.

the class TestAnnotationProcessor method process.

@Override
public void process(FunctionNode functionNode, List<AnnotationAttachmentNode> annotations) {
    // to avoid processing those, we have to have below check.
    if (!suite.getSuiteName().equals(functionNode.getPosition().getSource().getPackageName())) {
        return;
    }
    // traverse through the annotations of this function
    for (AnnotationAttachmentNode attachmentNode : annotations) {
        String annotationName = attachmentNode.getAnnotationName().getValue();
        String functionName = functionNode.getName().getValue();
        if (BEFORE_SUITE_ANNOTATION_NAME.equals(annotationName)) {
            suite.addBeforeSuiteFunction(functionName);
        } else if (AFTER_SUITE_ANNOTATION_NAME.equals(annotationName)) {
            suite.addAfterSuiteFunction(functionName);
        } else if (BEFORE_EACH_ANNOTATION_NAME.equals(annotationName)) {
            suite.addBeforeEachFunction(functionName);
        } else if (AFTER_EACH_ANNOTATION_NAME.equals(annotationName)) {
            suite.addAfterEachFunction(functionName);
        } else if (MOCK_ANNOTATION_NAME.equals(annotationName)) {
            String[] vals = new String[2];
            // If package property not present the package is .
            // TODO: when default values are supported in annotation struct we can remove this
            vals[0] = ".";
            if (attachmentNode.getExpression() instanceof BLangRecordLiteral) {
                List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) attachmentNode.getExpression()).getKeyValuePairs();
                attributes.forEach(attributeNode -> {
                    String name = attributeNode.getKey().toString();
                    String value = attributeNode.getValue().toString();
                    if (PACKAGE.equals(name)) {
                        vals[0] = value;
                    } else if (FUNCTION.equals(name)) {
                        vals[1] = value;
                    }
                });
                suite.addMockFunction(vals[0] + MOCK_ANNOTATION_DELIMITER + vals[1], functionName);
            }
        } else if (TEST_ANNOTATION_NAME.equals(annotationName)) {
            Test test = new Test();
            test.setTestName(functionName);
            AtomicBoolean shouldSkip = new AtomicBoolean();
            AtomicBoolean groupsFound = new AtomicBoolean();
            List<String> groups = registry.getGroups();
            boolean shouldIncludeGroups = registry.shouldIncludeGroups();
            if (attachmentNode.getExpression() instanceof BLangRecordLiteral) {
                List<BLangRecordLiteral.BLangRecordKeyValue> attributes = ((BLangRecordLiteral) attachmentNode.getExpression()).getKeyValuePairs();
                attributes.forEach(attributeNode -> {
                    String name = attributeNode.getKey().toString();
                    // Check if enable property is present in the annotation
                    if (TEST_ENABLE_ANNOTATION_NAME.equals(name) && "false".equals(attributeNode.getValue().toString())) {
                        // If enable is false, disable the test, no further processing is needed
                        shouldSkip.set(true);
                        return;
                    }
                    // Check whether user has provided a group list
                    if (groups != null && !groups.isEmpty()) {
                        // check if groups attribute is present in the annotation
                        if (GROUP_ANNOTATION_NAME.equals(name)) {
                            if (attributeNode.getValue() instanceof BLangArrayLiteral) {
                                BLangArrayLiteral values = (BLangArrayLiteral) attributeNode.getValue();
                                boolean isGroupPresent = isGroupAvailable(groups, values.exprs.stream().map(node -> node.toString()).collect(Collectors.toList()));
                                if (shouldIncludeGroups) {
                                    // include only if the test belong to one of these groups
                                    if (!isGroupPresent) {
                                        // skip the test if this group is not defined in this test
                                        shouldSkip.set(true);
                                        return;
                                    }
                                } else {
                                    // exclude only if the test belong to one of these groups
                                    if (isGroupPresent) {
                                        // skip if this test belongs to one of the excluded groups
                                        shouldSkip.set(true);
                                        return;
                                    }
                                }
                                groupsFound.set(true);
                            }
                        }
                    }
                    if (VALUE_SET_ANNOTATION_NAME.equals(name)) {
                        test.setDataProvider(attributeNode.getValue().toString());
                    }
                    if (BEFORE_FUNCTION.equals(name)) {
                        test.setBeforeTestFunction(attributeNode.getValue().toString());
                    }
                    if (AFTER_FUNCTION.equals(name)) {
                        test.setAfterTestFunction(attributeNode.getValue().toString());
                    }
                    if (DEPENDS_ON_FUNCTIONS.equals(name)) {
                        if (attributeNode.getValue() instanceof BLangArrayLiteral) {
                            BLangArrayLiteral values = (BLangArrayLiteral) attributeNode.getValue();
                            values.exprs.stream().map(node -> node.toString()).forEach(test::addDependsOnTestFunction);
                        }
                    }
                });
            }
            if (groups != null && !groups.isEmpty() && !groupsFound.get() && shouldIncludeGroups) {
                // if the user has asked to run only a specific list of groups and this test doesn't have
                // that group, we should skip the test
                shouldSkip.set(true);
            }
            if (!shouldSkip.get()) {
                suite.addTests(test);
            }
        } else {
        // disregard this annotation
        }
    }
}
Also used : Arrays(java.util.Arrays) PackageNode(org.ballerinalang.model.tree.PackageNode) BType(org.ballerinalang.model.types.BType) ProgramFile(org.ballerinalang.util.codegen.ProgramFile) TestSuite(org.ballerinalang.testerina.core.entity.TestSuite) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BallerinaException(org.ballerinalang.util.exceptions.BallerinaException) BLangRecordLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral) DiagnosticLog(org.ballerinalang.util.diagnostic.DiagnosticLog) PackageInfo(org.ballerinalang.util.codegen.PackageInfo) ArrayList(java.util.ArrayList) SupportedAnnotationPackages(org.ballerinalang.compiler.plugins.SupportedAnnotationPackages) AbstractCompilerPlugin(org.ballerinalang.compiler.plugins.AbstractCompilerPlugin) Vector(java.util.Vector) Map(java.util.Map) TesterinaFunction(org.ballerinalang.testerina.core.entity.TesterinaFunction) BLangArrayLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral) LinkedList(java.util.LinkedList) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) FunctionNode(org.ballerinalang.model.tree.FunctionNode) TypeTags(org.ballerinalang.model.types.TypeTags) Collectors(java.util.stream.Collectors) AnnotationAttachmentNode(org.ballerinalang.model.tree.AnnotationAttachmentNode) BArrayType(org.ballerinalang.model.types.BArrayType) List(java.util.List) Instruction(org.ballerinalang.util.codegen.Instruction) Test(org.ballerinalang.testerina.core.entity.Test) Queue(java.util.Queue) FunctionInfo(org.ballerinalang.util.codegen.FunctionInfo) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Test(org.ballerinalang.testerina.core.entity.Test) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BLangArrayLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangArrayLiteral) BLangRecordLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral) AnnotationAttachmentNode(org.ballerinalang.model.tree.AnnotationAttachmentNode)

Example 8 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class AxisServiceUtils method createAxisService.

/**
 * Build the underlying Axis Service from Service QName and Port Name of interest using given WSDL
 * for BPEL document.
 * In the current implementation we are extracting service name from the soap:address' location property.
 * But specified port may not contain soap:adress instead it may contains http:address. We need to handle that
 * situation.
 *
 * @param axisConfiguration AxisConfiguration to which we should publish the service
 * @param processProxy      BPELProcessProxy
 * @return Axis Service build using WSDL, Service and Port
 * @throws org.apache.axis2.AxisFault on error
 */
public static AxisService createAxisService(AxisConfiguration axisConfiguration, BPELProcessProxy processProxy) throws AxisFault {
    QName serviceName = processProxy.getServiceName();
    String portName = processProxy.getPort();
    Definition wsdlDefinition = processProxy.getWsdlDefinition();
    ProcessConf processConfiguration = processProxy.getProcessConfiguration();
    if (log.isDebugEnabled()) {
        log.debug("Creating AxisService: Service=" + serviceName + " port=" + portName + " WSDL=" + wsdlDefinition.getDocumentBaseURI() + " BPEL=" + processConfiguration.getBpelDocument());
    }
    WSDL11ToAxisServiceBuilder serviceBuilder = createAxisServiceBuilder(processProxy);
    /**
     * Need to figure out a way to handle service name extractoin. According to my perspective extracting
     * the service name from the EPR is not a good decision. But we need to handle JMS case properly.
     * I am keeping JMS handling untouched until we figureout best solution.
     */
    /* String axisServiceName = extractServiceName(processConf, wsdlServiceName, portName);*/
    AxisService axisService = populateAxisService(processProxy, axisConfiguration, serviceBuilder);
    Iterator operations = axisService.getOperations();
    BPELMessageReceiver messageRec = new BPELMessageReceiver();
    /**
     * Set the corresponding BPELService to message receivers
     */
    messageRec.setProcessProxy(processProxy);
    while (operations.hasNext()) {
        AxisOperation operation = (AxisOperation) operations.next();
        // Setting WSDLAwareMessage Receiver even if operation has a message receiver specified.
        // This is to fix the issue when build service configuration using services.xml(Always RPCMessageReceiver
        // is set to operations).
        operation.setMessageReceiver(messageRec);
        axisConfiguration.getPhasesInfo().setOperationPhases(operation);
    }
    /**
     * TODO: JMS Destination handling.
     */
    return axisService;
}
Also used : AxisOperation(org.apache.axis2.description.AxisOperation) QName(javax.xml.namespace.QName) ProcessConf(org.apache.ode.bpel.iapi.ProcessConf) AxisService(org.apache.axis2.description.AxisService) Definition(javax.wsdl.Definition) Iterator(java.util.Iterator) WSDL11ToAxisServiceBuilder(org.apache.axis2.description.WSDL11ToAxisServiceBuilder) BPELMessageReceiver(org.wso2.carbon.bpel.core.ode.integration.axis2.receivers.BPELMessageReceiver)

Example 9 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class InstanceManagementServiceSkeleton method getCorrelationPropertires.

private CorrelationSets_type0 getCorrelationPropertires(ScopeDAO scope) {
    CorrelationSets_type0 correlationSets = new CorrelationSets_type0();
    for (CorrelationSetDAO correlationSetDAO : scope.getCorrelationDTOs()) {
        CorrelationSet_type0 correlationset = new CorrelationSet_type0();
        correlationset.setCsetid(correlationSetDAO.getCorrelationSetId().toString());
        correlationset.setName(correlationSetDAO.getName());
        for (Map.Entry<QName, String> property : correlationSetDAO.getProperties().entrySet()) {
            CorrelationPropertyType prop = new CorrelationPropertyType();
            prop.setCsetid(correlationSetDAO.getCorrelationSetId().toString());
            prop.setPropertyName(property.getKey());
            prop.setString(property.getValue());
            correlationset.addCorrelationProperty(prop);
        }
        correlationSets.addCorrelationSet(correlationset);
    }
    return correlationSets;
}
Also used : CorrelationSet_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CorrelationSet_type0) QName(javax.xml.namespace.QName) CorrelationPropertyType(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CorrelationPropertyType) CorrelationSets_type0(org.wso2.carbon.bpel.skeleton.ode.integration.mgt.services.types.CorrelationSets_type0) CorrelationSetDAO(org.apache.ode.bpel.dao.CorrelationSetDAO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 10 with Property

use of org.wso2.carbon.identity.application.common.model.Property in project carbon-business-process by wso2.

the class TenantProcessStoreImpl method undeploy.

/**
 * Undeploying BPEL package.
 *
 * @param bpelPackageName Name of the BPEL package which going to be undeployed
 */
public void undeploy(String bpelPackageName) throws RegistryException, BPELUIException {
    if (log.isDebugEnabled()) {
        log.debug("Un-deploying BPEL package " + bpelPackageName + " ....");
    }
    if (!repository.isExistingBPELPackage(bpelPackageName)) {
        // This can be a situation where we un-deploy the archive through management console,
        // so that, the archive is deleted from the repo. As a result this method get invoked.
        // to handle this case we just log the message but does not throw an exception.
        final String warningMsg = "Cannot find BPEL package with name " + bpelPackageName + " in the repository. If the bpel package is un-deployed through the management" + " console or if this node is a member of a cluster, please ignore this warning.";
        if (isConfigRegistryReadOnly()) {
            // This is for the deployment synchronizer scenarios where package un-deployment on a worker node
            // has to remove the deployed bpel package from the memory and remove associated services
            handleUndeployOnSlaveNode(bpelPackageName);
        } else {
            log.warn(warningMsg);
        }
        return;
    }
    if (repository.isExistingBPELPackage(bpelPackageName) && isConfigRegistryReadOnly()) {
        log.warn("This node seems to be a slave, since the configuration registry is in read-only mode, hence " + "processes cannot be directly undeployed from this node. Please undeploy the process in Master " + "node first.");
        return;
    }
    List<String> versionsOfThePackage;
    try {
        versionsOfThePackage = repository.getAllVersionsForPackage(bpelPackageName);
    } catch (RegistryException re) {
        String errMessage = "Cannot get all versions of the package " + bpelPackageName + " from registry.";
        log.error(errMessage);
        throw re;
    }
    // check the instance count to be deleted
    long instanceCount = getInstanceCountForPackage(versionsOfThePackage);
    if (instanceCount > BPELServerImpl.getInstance().getBpelServerConfiguration().getBpelInstanceDeletionLimit()) {
        throw new BPELUIException("Instance deletion limit reached.");
    }
    for (String nameWithVersion : versionsOfThePackage) {
        parentProcessStore.deleteDeploymentUnitDataFromDB(nameWithVersion);
        Utils.deleteInstances(getProcessesInPackage(nameWithVersion));
        // location for extracted BPEL package
        String bpelPackageLocation = parentProcessStore.getLocalDeploymentUnitRepo().getAbsolutePath() + File.separator + tenantId + File.separator + nameWithVersion;
        File bpelPackage = new File(bpelPackageLocation);
        // removing extracted bpel package at repository/bpel/0/
        deleteBpelPackageFromRepo(bpelPackage);
        for (QName pid : getProcessesInPackage(nameWithVersion)) {
            ProcessConfigurationImpl processConf = (ProcessConfigurationImpl) getProcessConfiguration(pid);
            // This property is read when we removing the axis service for this process.
            // So that we can decide whether we should persist service QOS configs
            processConf.setUndeploying(true);
        }
    }
    try {
        repository.handleBPELPackageUndeploy(bpelPackageName);
    } catch (RegistryException re) {
        String errMessage = "Cannot update the BPEL package repository for undeployment of" + "package " + bpelPackageName + ".";
        log.error(errMessage);
        throw re;
    }
    updateLocalInstanceWithUndeployment(bpelPackageName, versionsOfThePackage);
// We should use the deployment synchronizer, instead of the code below.
// parentProcessStore.sendProcessDeploymentNotificationsToCluster(
// new BPELPackageUndeployedCommand(versionsOfThePackage, bpelPackageName, tenantId),
// configurationContext);
}
Also used : QName(javax.xml.namespace.QName) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) File(java.io.File)

Aggregations

HashMap (java.util.HashMap)17 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)17 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 ArrayList (java.util.ArrayList)7 GET (javax.ws.rs.GET)7 POST (javax.ws.rs.POST)7 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)7 Map (java.util.Map)6 QName (javax.xml.namespace.QName)6 File (java.io.File)5 List (java.util.List)5 IOException (java.io.IOException)4 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)4 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)3 RepositoryService (org.activiti.engine.RepositoryService)3 Iterator (java.util.Iterator)2 Set (java.util.Set)2 Consumes (javax.ws.rs.Consumes)2 FormService (org.activiti.engine.FormService)2