Search in sources :

Example 6 with APILogInfoDTO

use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.

the class LoggingMgtDAO method retrieveAPILoggerByAPIID.

public List<APILogInfoDTO> retrieveAPILoggerByAPIID(String tenant, String apiId) throws APIManagementException {
    String query = SQLConstants.RETRIEVE_PER_API_LOGGING_BY_UUID_SQL;
    List<APILogInfoDTO> apiLogInfoDTOList = new ArrayList<>();
    try (Connection connection = APIMgtDBUtil.getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement(query)) {
        preparedStatement.setString(1, apiId);
        preparedStatement.setString(2, tenant);
        try (ResultSet resultSet = preparedStatement.executeQuery()) {
            while (resultSet.next()) {
                String logLevel = APIConstants.LOG_LEVEL_OFF;
                if (resultSet.getString(APIConstants.LOG_LEVEL) != null) {
                    logLevel = resultSet.getString(APIConstants.LOG_LEVEL);
                }
                APILogInfoDTO apiLogInfoDTO = new APILogInfoDTO(resultSet.getString(API_UUID), resultSet.getString(CONTEXT), logLevel);
                apiLogInfoDTOList.add(apiLogInfoDTO);
            }
        }
    } catch (SQLException e) {
        handleException("Failed to retrieve organization", e);
    }
    return apiLogInfoDTOList;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) APILogInfoDTO(org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO) PreparedStatement(java.sql.PreparedStatement)

Example 7 with APILogInfoDTO

use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.

the class TenantLogsApiServiceImpl method tenantLogsTenantIdApisGet.

public Response tenantLogsTenantIdApisGet(String tenantId, String logLevel, MessageContext messageContext) throws APIManagementException {
    APILoggingImpl apiLoggingImpl = new APILoggingImpl();
    List<APILogInfoDTO> apiLogInfoDTOList = apiLoggingImpl.getAPILoggerList(tenantId, logLevel);
    LoggingApiOutputListDTO loggingApiOutputListDTO = DevopsAPIUtils.getLoggingAPIList(apiLogInfoDTOList);
    return Response.ok().entity(loggingApiOutputListDTO).build();
}
Also used : APILogInfoDTO(org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO) LoggingApiOutputListDTO(org.wso2.carbon.apimgt.rest.api.devops.dto.LoggingApiOutputListDTO) APILoggingImpl(org.wso2.carbon.apimgt.devops.impl.logging.APILoggingImpl)

Aggregations

APILogInfoDTO (org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO)7 ArrayList (java.util.ArrayList)5 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 LoggingApiOutputListDTO (org.wso2.carbon.apimgt.rest.api.devops.dto.LoggingApiOutputListDTO)3 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)2 APILoggingImpl (org.wso2.carbon.apimgt.devops.impl.logging.APILoggingImpl)2 Response (javax.ws.rs.core.Response)1 APILoggingConfigDTO (org.wso2.carbon.apimgt.internal.service.dto.APILoggingConfigDTO)1 APILoggingConfigListDTO (org.wso2.carbon.apimgt.internal.service.dto.APILoggingConfigListDTO)1 ErrorDTO (org.wso2.carbon.apimgt.internal.service.dto.ErrorDTO)1 LoggingApiOutputDTO (org.wso2.carbon.apimgt.rest.api.devops.dto.LoggingApiOutputDTO)1