use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ErrorListItemDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getErrorListItemsDTOsFromErrorHandler.
public static List<ErrorListItemDTO> getErrorListItemsDTOsFromErrorHandler(ErrorHandler error) {
List<ErrorListItemDTO> errorListItemDTOs = new ArrayList<>();
ErrorListItemDTO dto = new ErrorListItemDTO();
dto.setCode(error.getErrorCode() + "");
dto.setMessage(error.getErrorMessage());
dto.setDescription(error.getErrorDescription());
errorListItemDTOs.add(dto);
return errorListItemDTOs;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ErrorListItemDTO in project carbon-apimgt by wso2.
the class ErrorListItemDTOTestCase method testToString.
@Test
public void testToString() throws Exception {
ErrorListItemDTO errorListItemDTO = new ErrorListItemDTO();
errorListItemDTO.setCode("900311");
errorListItemDTO.setMessage("Couldn't Update as API have changes can't be done");
String result = errorListItemDTO.toString();
Assert.assertEquals(result, expectedString);
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ErrorListItemDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getErrorDTOFromErrorListItems.
/**
* Get the ErrorDTO from a list of ErrorListItemDTOs. The first item in the list is set as the main error.
*
* @param errorListItemDTOs A list of ErrorListItemDTO objects
* @return ErrorDTO from a list of ErrorListItemDTOs
*/
public static ErrorDTO getErrorDTOFromErrorListItems(List<ErrorListItemDTO> errorListItemDTOs) {
ErrorDTO errorDTO = new ErrorDTO();
for (int i = 0; i < errorListItemDTOs.size(); i++) {
if (i == 0) {
ErrorListItemDTO elementAt0 = errorListItemDTOs.get(0);
errorDTO.setCode(Long.parseLong(elementAt0.getCode()));
errorDTO.setMoreInfo("");
errorDTO.setMessage(elementAt0.getMessage());
errorDTO.setDescription(elementAt0.getDescription());
} else {
org.wso2.carbon.apimgt.rest.api.common.dto.ErrorListItemDTO errorListItemDTO = new org.wso2.carbon.apimgt.rest.api.common.dto.ErrorListItemDTO();
errorListItemDTO.setCode(errorListItemDTOs.get(i).getCode() + "");
errorListItemDTO.setMessage(errorListItemDTOs.get(i).getMessage());
errorListItemDTO.setDescription(errorListItemDTOs.get(i).getDescription());
errorDTO.getError().add(errorListItemDTO);
}
}
return errorDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ErrorListItemDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getErrorListItemsDTOsFromErrorHandlers.
public static List<ErrorListItemDTO> getErrorListItemsDTOsFromErrorHandlers(List<ErrorHandler> errorHandlers) {
List<ErrorListItemDTO> errorListItemDTOs = new ArrayList<>();
for (ErrorHandler handler : errorHandlers) {
ErrorListItemDTO dto = new ErrorListItemDTO();
dto.setCode(handler.getErrorCode() + "");
dto.setMessage(handler.getErrorMessage());
dto.setDescription(handler.getErrorDescription());
errorListItemDTOs.add(dto);
}
return errorListItemDTOs;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.ErrorListItemDTO in project carbon-apimgt by wso2.
the class RestApiUtil method getErrorDTO.
/**
* Returns a generic errorDTO from a list of Error Handlers
*
* @param errorHandlers A List of error handler objects containing the error information
* @return A generic errorDTO with the specified details
*/
public static ErrorDTO getErrorDTO(List<ErrorHandler> errorHandlers) {
ErrorDTO errorDTO = new ErrorDTO();
for (int i = 0; i < errorHandlers.size(); i++) {
if (i == 0) {
ErrorHandler elementAt0 = errorHandlers.get(0);
errorDTO.setCode(elementAt0.getErrorCode());
errorDTO.setMoreInfo("");
errorDTO.setMessage(elementAt0.getErrorMessage());
errorDTO.setDescription(elementAt0.getErrorDescription());
} else {
ErrorListItemDTO errorListItemDTO = new ErrorListItemDTO();
errorListItemDTO.setCode(errorHandlers.get(i).getErrorCode() + "");
errorListItemDTO.setMessage(errorHandlers.get(i).getErrorMessage());
errorListItemDTO.setDescription(errorHandlers.get(i).getErrorDescription());
errorDTO.getError().add(errorListItemDTO);
}
}
return errorDTO;
}
Aggregations