use of org.wso2.carbon.apimgt.rest.api.service.catalog.dto.ServiceDTO in project carbon-apimgt by wso2.
the class ServicesApiServiceImpl method searchServices.
@Override
public Response searchServices(String name, String version, String definitionType, String key, Boolean shrink, String sortBy, String sortOrder, Integer limit, Integer offset, MessageContext messageContext) throws APIManagementException {
String userName = RestApiCommonUtil.getLoggedInUsername();
int tenantId = APIUtil.getTenantId(userName);
try {
List<ServiceDTO> serviceDTOList = new ArrayList<>();
ServiceFilterParams filterParams = ServiceEntryMappingUtil.getServiceFilterParams(name, version, definitionType, key, sortBy, sortOrder, limit, offset);
List<ServiceEntry> services = serviceCatalog.getServices(filterParams, tenantId, shrink);
int totalServices = serviceCatalog.getServicesCount(tenantId, filterParams);
for (ServiceEntry service : services) {
serviceDTOList.add(ServiceEntryMappingUtil.fromServiceToDTO(service, shrink));
}
ServiceListDTO serviceListDTO = new ServiceListDTO();
serviceListDTO.setList(serviceDTOList);
ServiceEntryMappingUtil.setPaginationParams(serviceListDTO, filterParams.getOffset(), filterParams.getLimit(), totalServices, filterParams);
return Response.ok().entity(serviceListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while retrieving Services";
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
Aggregations