use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.
the class ApiLoggingConfigsApiServiceImpl method apiLoggingConfigsGet.
public Response apiLoggingConfigsGet(MessageContext messageContext) {
ErrorDTO errorObject = new ErrorDTO();
Response.Status status = Response.Status.NOT_IMPLEMENTED;
errorObject.setCode(200);
errorObject.setMessage(status.toString());
List<APILoggingConfigDTO> loggingAPIDTOList = new ArrayList<>();
try {
List<APILogInfoDTO> apiLoggerList = LoggingMgtDAO.getInstance().retrieveAllAPILoggerList();
for (APILogInfoDTO apiLogInfo : apiLoggerList) {
APILoggingConfigDTO apiLoggingConfigDTO = new APILoggingConfigDTO();
apiLoggingConfigDTO.setContext(apiLogInfo.getContext());
apiLoggingConfigDTO.setLogLevel(apiLogInfo.getLogLevel());
loggingAPIDTOList.add(apiLoggingConfigDTO);
}
} catch (APIManagementException e) {
log.error("Error while retrieving api logger list");
}
APILoggingConfigListDTO apiLoggingConfigListDTO = new APILoggingConfigListDTO();
apiLoggingConfigListDTO.apis(loggingAPIDTOList);
return Response.ok().entity(apiLoggingConfigListDTO).build();
}
use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.
the class TenantLogsApiServiceImpl method tenantLogsTenantIdApisApiIdGet.
public Response tenantLogsTenantIdApisApiIdGet(String tenantId, String apiId, MessageContext messageContext) throws APIManagementException {
APILoggingImpl apiLoggingImpl = new APILoggingImpl();
List<APILogInfoDTO> apiLogInfoDTOList = apiLoggingImpl.getAPILoggerListByApiId(tenantId, apiId);
LoggingApiOutputListDTO loggingApiOutputListDT = DevopsAPIUtils.getLoggingAPIList(apiLogInfoDTOList);
return Response.ok().entity(loggingApiOutputListDT).build();
}
use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.
the class DevopsAPIUtils method getLoggingAPIList.
public static LoggingApiOutputListDTO getLoggingAPIList(List<APILogInfoDTO> apiLogInfoDTOList) {
LoggingApiOutputListDTO loggingApiOutputListDTO = new LoggingApiOutputListDTO();
List<LoggingApiOutputDTO> loggingApiOutputDTOList = new ArrayList<>();
for (APILogInfoDTO apiLogInfoDTO : apiLogInfoDTOList) {
LoggingApiOutputDTO loggingApiOutputDTO = new LoggingApiOutputDTO();
loggingApiOutputDTO.setContext(apiLogInfoDTO.getContext());
loggingApiOutputDTO.setLogLevel(apiLogInfoDTO.getLogLevel());
loggingApiOutputDTO.setApiId(apiLogInfoDTO.getApiId());
loggingApiOutputDTOList.add(loggingApiOutputDTO);
}
loggingApiOutputListDTO.apis(loggingApiOutputDTOList);
return loggingApiOutputListDTO;
}
use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.
the class LoggingMgtDAO method retrieveAPILoggerList.
public List<APILogInfoDTO> retrieveAPILoggerList(String organization, String logLevel) throws APIManagementException {
List<APILogInfoDTO> apiLogInfoDTOList = new ArrayList<>();
String query;
if (logLevel == null) {
query = SQLConstants.RETRIEVE_PER_API_LOGGING_ALL_SQL;
} else {
switch(logLevel.toUpperCase()) {
case APIConstants.LOG_LEVEL_OFF:
query = SQLConstants.RETRIEVE_PER_API_LOGGING_OFF_SQL;
break;
case APIConstants.LOG_LEVEL_BASIC:
query = SQLConstants.RETRIEVE_PER_API_LOGGING_BASIC_SQL;
break;
case APIConstants.LOG_LEVEL_STANDARD:
query = SQLConstants.RETRIEVE_PER_API_LOGGING_STANDARD_SQL;
break;
case APIConstants.LOG_LEVEL_FULL:
query = SQLConstants.RETRIEVE_PER_API_LOGGING_FULL_SQL;
break;
default:
throw new APIManagementException("Invalid log level", ExceptionCodes.from(ExceptionCodes.LOGGING_API_INCORRECT_LOG_LEVEL));
}
}
try (Connection connection = APIMgtDBUtil.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(query)) {
preparedStatement.setString(1, organization);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
String retrievedLogLevel = APIConstants.LOG_LEVEL_OFF;
if (resultSet.getString(APIConstants.LOG_LEVEL) != null) {
retrievedLogLevel = resultSet.getString(APIConstants.LOG_LEVEL);
}
APILogInfoDTO apiLogInfoDTO = new APILogInfoDTO(resultSet.getString(API_UUID), resultSet.getString(CONTEXT), retrievedLogLevel);
apiLogInfoDTOList.add(apiLogInfoDTO);
}
}
} catch (SQLException e) {
handleException("Failed to retrieve API logging for organization" + organization, e);
}
return apiLogInfoDTOList;
}
use of org.wso2.carbon.apimgt.impl.dto.APILogInfoDTO in project carbon-apimgt by wso2.
the class LoggingMgtDAO method retrieveAllAPILoggerList.
public List<APILogInfoDTO> retrieveAllAPILoggerList() throws APIManagementException {
List<APILogInfoDTO> apiLogInfoDTOList = new ArrayList<>();
String query = SQLConstants.RETRIEVE_ALL_PER_API_LOGGING_SQL;
try (Connection connection = APIMgtDBUtil.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(query)) {
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;
}
Aggregations