use of org.wso2.carbon.identity.workflow.mgt.bean.Parameter in project carbon-apimgt by wso2.
the class JMSTaskManagerFactory method getTransactionality.
/**
* @param svcMap JNDI context properties and other general property map
* @param cfMap properties defined on the JMS CF
* @return value for the specific transactionality type
*/
private static int getTransactionality(Map<String, String> svcMap, Map<String, String> cfMap) {
String key = BaseConstants.PARAM_TRANSACTIONALITY;
String val = svcMap.get(key);
if (val == null) {
val = cfMap.get(key);
}
if (val == null) {
return BaseConstants.TRANSACTION_NONE;
} else {
if (BaseConstants.STR_TRANSACTION_JTA.equalsIgnoreCase(val)) {
return BaseConstants.TRANSACTION_JTA;
} else if (BaseConstants.STR_TRANSACTION_LOCAL.equalsIgnoreCase(val)) {
return BaseConstants.TRANSACTION_LOCAL;
} else {
throw new JmsRunTimeException("Invalid option : " + val + " for parameter : " + BaseConstants.STR_TRANSACTION_JTA);
// TODO fix it
// return 0;
}
}
}
use of org.wso2.carbon.identity.workflow.mgt.bean.Parameter 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);
}
}
use of org.wso2.carbon.identity.workflow.mgt.bean.Parameter in project carbon-apimgt by wso2.
the class CertificateMgtDAO method getCertificate.
/**
* Method to retrieve certificate metadata from db for specific tenant which matches alias or endpoint.
* From alias and endpoint, only one parameter is required.
*
* @param tenantId : The id of the tenant which the certificate belongs to.
* @param alias : Alias for the certificate. (Optional)
* @param endpoint : The endpoint/ server url which the certificate is mapped to. (Optional)
* @return : A CertificateMetadataDTO object if the certificate is retrieved successfully, null otherwise.
*/
public CertificateMetadataDTO getCertificate(String alias, String endpoint, int tenantId) throws CertificateManagementException {
String getCertQuery;
getCertQuery = SQLConstants.CertificateConstants.GET_CERTIFICATE_TENANT_ALIAS_ENDPOINT;
try (Connection connection = APIMgtDBUtil.getConnection()) {
try (PreparedStatement preparedStatement = connection.prepareStatement(getCertQuery)) {
preparedStatement.setInt(1, tenantId);
preparedStatement.setString(2, alias);
preparedStatement.setString(3, endpoint);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (resultSet.next()) {
CertificateMetadataDTO certificateMetadataDTO = new CertificateMetadataDTO();
certificateMetadataDTO.setAlias(resultSet.getString("ALIAS"));
certificateMetadataDTO.setEndpoint(resultSet.getString("END_POINT"));
try (InputStream certificate = resultSet.getBinaryStream("CERTIFICATE")) {
certificateMetadataDTO.setCertificate(APIMgtDBUtil.getStringFromInputStream(certificate));
}
return certificateMetadataDTO;
}
}
}
} catch (SQLException | IOException e) {
handleException("Error while retrieving certificate metadata.", e);
}
throw new CertificateManagementException("Certificate didn't exist with alias" + alias);
}
use of org.wso2.carbon.identity.workflow.mgt.bean.Parameter in project carbon-apimgt by wso2.
the class SystemApplicationDAO method getApplications.
/**
* Method to retrieve all the system Applications for the given tenant
*
* @param tenantDomain required parameter
* @return SystemApplicationDTO which hold the retrieved client credentials
* @throws APIMgtDAOException
*/
public SystemApplicationDTO[] getApplications(String tenantDomain) throws APIMgtDAOException {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
SystemApplicationDTO systemApplicationDTO = null;
List<SystemApplicationDTO> systemApplicationDTOS = new ArrayList<>();
String getCredentialsQuery = SQLConstants.SystemApplicationConstants.GET_APPLICATIONS;
try {
connection = APIMgtDBUtil.getConnection();
connection.setAutoCommit(false);
connection.commit();
preparedStatement = connection.prepareStatement(getCredentialsQuery);
preparedStatement.setString(1, tenantDomain);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
systemApplicationDTO = new SystemApplicationDTO();
systemApplicationDTO.setName(resultSet.getString("NAME"));
systemApplicationDTO.setConsumerKey(resultSet.getString("CONSUMER_KEY"));
systemApplicationDTO.setConsumerSecret(resultSet.getString("CONSUMER_SECRET"));
systemApplicationDTOS.add(systemApplicationDTO);
}
} catch (SQLException e) {
if (log.isDebugEnabled()) {
log.debug("Error while retrieving system applications for tenant: " + tenantDomain);
}
handleException("Error while retrieving system applications for tenant: " + tenantDomain, e);
} finally {
APIMgtDBUtil.closeAllConnections(preparedStatement, connection, resultSet);
}
return systemApplicationDTOS.toArray(new SystemApplicationDTO[systemApplicationDTOS.size()]);
}
use of org.wso2.carbon.identity.workflow.mgt.bean.Parameter in project carbon-apimgt by wso2.
the class CertificateMgtDAO method getCertificates.
/**
* Method to retrieve certificate metadata from db for specific tenant which matches alias or endpoint.
* From alias and endpoint, only one parameter is required.
*
* @param tenantId : The id of the tenant which the certificate belongs to.
* @param alias : Alias for the certificate. (Optional)
* @param endpoint : The endpoint/ server url which the certificate is mapped to. (Optional)
* @return : A CertificateMetadataDTO object if the certificate is retrieved successfully, null otherwise.
*/
public List<CertificateMetadataDTO> getCertificates(String alias, String endpoint, int tenantId) throws CertificateManagementException {
String getCertQuery;
CertificateMetadataDTO certificateMetadataDTO;
List<CertificateMetadataDTO> certificateMetadataList = new ArrayList<>();
if (StringUtils.isNotEmpty(alias) || StringUtils.isNotEmpty(endpoint)) {
if (log.isDebugEnabled()) {
log.debug("The alias and endpoint are not empty. Invoking the search query with parameters " + "alias = " + alias + " endpoint = " + endpoint);
}
getCertQuery = SQLConstants.CertificateConstants.GET_CERTIFICATE_TENANT;
} else {
if (log.isDebugEnabled()) {
log.debug("The alias and endpoint are empty. Invoking the get all certificates for tenant " + tenantId);
}
getCertQuery = SQLConstants.CertificateConstants.GET_CERTIFICATES;
}
try (Connection connection = APIMgtDBUtil.getConnection()) {
try (PreparedStatement preparedStatement = connection.prepareStatement(getCertQuery)) {
preparedStatement.setInt(1, tenantId);
if (StringUtils.isNotEmpty(alias) || StringUtils.isNotEmpty(endpoint)) {
preparedStatement.setString(2, alias);
preparedStatement.setString(3, endpoint);
}
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
certificateMetadataDTO = new CertificateMetadataDTO();
certificateMetadataDTO.setAlias(resultSet.getString("ALIAS"));
certificateMetadataDTO.setEndpoint(resultSet.getString("END_POINT"));
try (InputStream certificate = resultSet.getBinaryStream("CERTIFICATE")) {
certificateMetadataDTO.setCertificate(APIMgtDBUtil.getStringFromInputStream(certificate));
}
certificateMetadataList.add(certificateMetadataDTO);
}
}
}
} catch (SQLException | IOException e) {
handleException("Error while retrieving certificate metadata.", e);
}
return certificateMetadataList;
}
Aggregations