Search in sources :

Example 1 with APIProductSearchResultDTO

use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIProductSearchResultDTO in project carbon-apimgt by wso2.

the class SearchResultMappingUtil method fromAPIProductToAPIResultDTO.

/**
 * Get API result representation for content search.
 *
 * @param apiProduct APIProduct
 * @return APIProductSearchResultDTO
 */
public static APIProductSearchResultDTO fromAPIProductToAPIResultDTO(APIProduct apiProduct) {
    APIProductSearchResultDTO apiProductResultDTO = new APIProductSearchResultDTO();
    apiProductResultDTO.setId(apiProduct.getUuid());
    APIProductIdentifier apiproductId = apiProduct.getId();
    apiProductResultDTO.setName(apiproductId.getName());
    apiProductResultDTO.setVersion(apiproductId.getVersion());
    apiProductResultDTO.setProvider(APIUtil.replaceEmailDomainBack(apiproductId.getProviderName()));
    String context = apiProduct.getContextTemplate();
    if (context.endsWith("/" + RestApiConstants.API_VERSION_PARAM)) {
        context = context.replace("/" + RestApiConstants.API_VERSION_PARAM, "");
    }
    apiProductResultDTO.setContext(context);
    apiProductResultDTO.setType(SearchResultDTO.TypeEnum.APIPRODUCT);
    apiProductResultDTO.setDescription(apiProduct.getDescription());
    apiProductResultDTO.setStatus(apiProduct.getState());
    apiProductResultDTO.setThumbnailUri(apiProduct.getThumbnailUrl());
    return apiProductResultDTO;
}
Also used : APIProductIdentifier(org.wso2.carbon.apimgt.api.model.APIProductIdentifier) APIProductSearchResultDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIProductSearchResultDTO)

Aggregations

APIProductIdentifier (org.wso2.carbon.apimgt.api.model.APIProductIdentifier)1 APIProductSearchResultDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIProductSearchResultDTO)1