Search in sources :

Example 96 with Link

use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSOAPOperation.

/**
 * Retrieves WSDL operation given the soap binding operation
 *
 * @param bindingOperation {@link BindingOperation} object
 * @return a set of {@link WSDLOperation} defined in the provided Binding
 */
private WSDLSOAPOperation getSOAPOperation(BindingOperation bindingOperation) throws APIMgtWSDLException {
    WSDLSOAPOperation wsdlOperation = null;
    for (Object boExtElement : bindingOperation.getExtensibilityElements()) {
        if (boExtElement instanceof SOAPOperation) {
            SOAPOperation soapOperation = (SOAPOperation) boExtElement;
            wsdlOperation = new WSDLSOAPOperation();
            wsdlOperation.setName(bindingOperation.getName());
            wsdlOperation.setSoapAction(soapOperation.getSoapActionURI());
            wsdlOperation.setTargetNamespace(getTargetNamespace(bindingOperation));
            wsdlOperation.setStyle(soapOperation.getStyle());
            wsdlOperation.setInputParameterModel(getSoapInputParameterModel(bindingOperation));
            wsdlOperation.setOutputParameterModel(getSoapOutputParameterModel(bindingOperation));
            wsdlOperation.setMessageType(getSoapMessageType(bindingOperation));
        } else if (boExtElement instanceof SOAP12Operation) {
            SOAP12Operation soapOperation = (SOAP12Operation) boExtElement;
            wsdlOperation = new WSDLSOAPOperation();
            wsdlOperation.setName(bindingOperation.getName());
            wsdlOperation.setSoapAction(soapOperation.getSoapActionURI());
            wsdlOperation.setTargetNamespace(getTargetNamespace(bindingOperation));
            wsdlOperation.setStyle(soapOperation.getStyle());
            wsdlOperation.setInputParameterModel(getSoapInputParameterModel(bindingOperation));
            wsdlOperation.setOutputParameterModel(getSoapOutputParameterModel(bindingOperation));
            wsdlOperation.setMessageType(getSoapMessageType(bindingOperation));
        }
    }
    return wsdlOperation;
}
Also used : WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation)

Example 97 with Link

use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSoapBindingOperations.

/**
 * Retrieves all the operations defined in the provided WSDL definition.
 *
 * @param definition WSDL Definition
 * @return a set of {@link WSDLOperation} defined in the provided WSDL definition
 */
private Set<WSDLSOAPOperation> getSoapBindingOperations(Definition definition) throws APIMgtWSDLException {
    Set<WSDLSOAPOperation> allOperations = new HashSet<>();
    for (Object bindingObj : definition.getAllBindings().values()) {
        if (bindingObj instanceof Binding) {
            Binding binding = (Binding) bindingObj;
            Set<WSDLSOAPOperation> operations = getSOAPBindingOperations(binding);
            allOperations.addAll(operations);
        }
    }
    return allOperations;
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) HashSet(java.util.HashSet)

Example 98 with Link

use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.

the class ApiMgtDAO method getApplicationPolicy.

/**
 * Retrieves {@link ApplicationPolicy} with name <code>policyName</code> and tenant Id <code>tenantNId</code>
 *
 * @param policyName name of the policy to retrieve from the database
 * @param tenantId   tenantId of the policy
 * @return {@link ApplicationPolicy}
 * @throws APIManagementException
 */
public ApplicationPolicy getApplicationPolicy(String policyName, int tenantId) throws APIManagementException {
    ApplicationPolicy policy = null;
    Connection connection = null;
    PreparedStatement selectStatement = null;
    ResultSet resultSet = null;
    String sqlQuery = SQLConstants.GET_APPLICATION_POLICY_SQL;
    if (forceCaseInsensitiveComparisons) {
        sqlQuery = SQLConstants.GET_APPLICATION_POLICY_SQL;
    }
    try {
        connection = APIMgtDBUtil.getConnection();
        selectStatement = connection.prepareStatement(sqlQuery);
        selectStatement.setString(1, policyName);
        selectStatement.setInt(2, tenantId);
        // Should return only single row
        resultSet = selectStatement.executeQuery();
        if (resultSet.next()) {
            policy = new ApplicationPolicy(resultSet.getString(ThrottlePolicyConstants.COLUMN_NAME));
            setCommonPolicyDetails(policy, resultSet);
        }
    } catch (SQLException e) {
        handleException("Failed to get application policy: " + policyName + '-' + tenantId, e);
    } finally {
        APIMgtDBUtil.closeAllConnections(selectStatement, connection, resultSet);
    }
    return policy;
}
Also used : SQLException(java.sql.SQLException) ApplicationPolicy(org.wso2.carbon.apimgt.api.model.policy.ApplicationPolicy) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 99 with Link

use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.

the class ApiMgtDAO method setQueryParameterConditions.

/**
 * Add Query parameter conditions of pipeline with pipeline Id: <code>pipelineId</code> to a
 * provided {@link Condition} array
 *
 * @param pipelineId Id of the pipeline
 * @param conditions condition array to populate
 * @throws APIManagementException
 */
private void setQueryParameterConditions(int pipelineId, ArrayList<Condition> conditions) throws APIManagementException {
    Connection connection = null;
    PreparedStatement conditionsStatement = null;
    ResultSet resultSet = null;
    try {
        connection = APIMgtDBUtil.getConnection();
        conditionsStatement = connection.prepareStatement(SQLConstants.ThrottleSQLConstants.GET_QUERY_PARAMETER_CONDITIONS_SQL);
        conditionsStatement.setInt(1, pipelineId);
        resultSet = conditionsStatement.executeQuery();
        while (resultSet.next()) {
            QueryParameterCondition queryParameterCondition = new QueryParameterCondition();
            queryParameterCondition.setParameter(resultSet.getString(ThrottlePolicyConstants.COLUMN_PARAMETER_NAME));
            queryParameterCondition.setValue(resultSet.getString(ThrottlePolicyConstants.COLUMN_PARAMETER_VALUE));
            queryParameterCondition.setInvertCondition(resultSet.getBoolean(ThrottlePolicyConstants.COLUMN_IS_PARAM_MAPPING));
            conditions.add(queryParameterCondition);
        }
    } catch (SQLException e) {
        handleException("Failed to get query parameter conditions for pipelineId: " + pipelineId, e);
    } finally {
        APIMgtDBUtil.closeAllConnections(conditionsStatement, connection, resultSet);
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) QueryParameterCondition(org.wso2.carbon.apimgt.api.model.policy.QueryParameterCondition)

Example 100 with Link

use of org.wso2.carbon.bpel.ui.bpel2svg.Link in project carbon-apimgt by wso2.

the class ApiMgtDAO method getAPIPolicyByUUID.

/**
 * Retrieves {@link APIPolicy} with name <code>uuid</code>
 * <p>This will retrieve complete details about the APIPolicy with all pipelines and conditions.</p>
 *
 * @param uuid uuid of the policy to retrieve from the database
 * @return {@link APIPolicy}
 * @throws APIManagementException
 */
public APIPolicy getAPIPolicyByUUID(String uuid) throws APIManagementException {
    APIPolicy policy = null;
    Connection connection = null;
    PreparedStatement selectStatement = null;
    ResultSet resultSet = null;
    String sqlQuery = SQLConstants.ThrottleSQLConstants.GET_API_POLICY_BY_UUID_SQL;
    if (forceCaseInsensitiveComparisons) {
        sqlQuery = SQLConstants.ThrottleSQLConstants.GET_API_POLICY_BY_UUID_SQL;
    }
    try {
        connection = APIMgtDBUtil.getConnection();
        selectStatement = connection.prepareStatement(sqlQuery);
        selectStatement.setString(1, uuid);
        // Should return only single result
        resultSet = selectStatement.executeQuery();
        if (resultSet.next()) {
            policy = new APIPolicy(resultSet.getString(ThrottlePolicyConstants.COLUMN_NAME));
            setCommonPolicyDetails(policy, resultSet);
            policy.setUserLevel(resultSet.getString(ThrottlePolicyConstants.COLUMN_APPLICABLE_LEVEL));
            policy.setPipelines(getPipelines(policy.getPolicyId()));
        }
    } catch (SQLException e) {
        handleException("Failed to get api policy: " + uuid, e);
    } finally {
        APIMgtDBUtil.closeAllConnections(selectStatement, connection, resultSet);
    }
    return policy;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) APIPolicy(org.wso2.carbon.apimgt.api.model.policy.APIPolicy)

Aggregations

PreparedStatement (java.sql.PreparedStatement)47 ArrayList (java.util.ArrayList)47 Connection (java.sql.Connection)43 SQLException (java.sql.SQLException)41 ResultSet (java.sql.ResultSet)37 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)26 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)18 HashSet (java.util.HashSet)16 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)15 IOException (java.io.IOException)14 HashMap (java.util.HashMap)14 List (java.util.List)13 Map (java.util.Map)13 Expression (org.wso2.siddhi.query.api.expression.Expression)13 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)12 TimeConstant (org.wso2.siddhi.query.api.expression.constant.TimeConstant)12 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)11 API (org.wso2.carbon.apimgt.core.models.API)11 UserStoreException (org.wso2.carbon.user.api.UserStoreException)10 SiddhiQLParser (org.wso2.siddhi.query.compiler.SiddhiQLParser)10