diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java index fd8eecb7a4e0..f89cc1504cf5 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/APIConsumerImpl.java @@ -112,6 +112,7 @@ import org.wso2.carbon.apimgt.impl.utils.APIAPIProductNameComparator; import org.wso2.carbon.apimgt.impl.utils.APIMWSDLReader; import org.wso2.carbon.apimgt.impl.utils.APINameComparator; +import org.wso2.carbon.apimgt.impl.utils.APIProductNameComparator; import org.wso2.carbon.apimgt.impl.utils.APIUtil; import org.wso2.carbon.apimgt.impl.utils.APIVersionComparator; import org.wso2.carbon.apimgt.impl.utils.ApplicationUtils; @@ -4148,6 +4149,7 @@ public Map searchPaginatedContent(String searchQuery, String org Map docMap = new HashMap(); Map result = new HashMap(); SortedSet apiSet = new TreeSet(new APINameComparator()); + SortedSet apiProductSet = new TreeSet(new APIProductNameComparator()); int totalLength = 0; String userame = (userNameWithoutChange != null) ? userNameWithoutChange : username; @@ -4175,7 +4177,7 @@ public Map searchPaginatedContent(String searchQuery, String org docItem.getApiVersion())); api.setUuid(docItem.getApiUUID()); docMap.put(doc, api); - } else { + } else if ("API".equals(item.getType())) { DevPortalSearchContent publiserAPI = (DevPortalSearchContent) item; API api = new API(new APIIdentifier(publiserAPI.getProvider(), publiserAPI.getName(), publiserAPI.getVersion())); @@ -4193,10 +4195,27 @@ public Map searchPaginatedContent(String searchQuery, String org api.setDescription(publiserAPI.getDescription()); api.setType(publiserAPI.getTransportType()); apiSet.add(api); + } else if ("APIProduct".equals(item.getType())) { + DevPortalSearchContent devAPIProduct = (DevPortalSearchContent) item; + APIProduct apiProduct = new APIProduct( + new APIProductIdentifier(devAPIProduct.getProvider(), devAPIProduct.getName(), + devAPIProduct.getVersion())); + apiProduct.setUuid(devAPIProduct.getId()); + apiProduct.setContextTemplate(devAPIProduct.getContext()); + apiProduct.setState(devAPIProduct.getStatus()); + apiProduct.setType(devAPIProduct.getTransportType()); + apiProduct.setBusinessOwner(devAPIProduct.getBusinessOwner()); + apiProduct.setBusinessOwnerEmail(devAPIProduct.getBusinessOwnerEmail()); + apiProduct.setTechnicalOwner(devAPIProduct.getTechnicalOwner()); + apiProduct.setTechnicalOwnerEmail(devAPIProduct.getTechnicalOwnerEmail()); + apiProduct.setDescription(devAPIProduct.getDescription()); + apiProduct.setRating("0");// need to retrieve from db + apiProductSet.add(apiProduct); } } compoundResult.addAll(apiSet); compoundResult.addAll(docMap.entrySet()); + compoundResult.addAll(apiProductSet); compoundResult.sort(new ContentSearchResultNameComparator()); result.put("length", sResults.getTotalCount()); } else { diff --git a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java index 7b972bd47228..b4abbe77e28e 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java +++ b/components/apimgt/org.wso2.carbon.apimgt.persistence/src/main/java/org/wso2/carbon/apimgt/persistence/RegistryPersistenceImpl.java @@ -1701,7 +1701,15 @@ public DevPortalContentSearchResult searchContentForDevPortal(Organization org, devAPI.setVisibility(apiArtifact.getAttribute(APIConstants.API_OVERVIEW_VISIBILITY)); DevPortalSearchContent content = new DevPortalSearchContent(); content.setContext(devAPI.getContext()); + String associatedType; + if (apiArtifact.getAttribute(APIConstants.API_OVERVIEW_TYPE) + .equals(APIConstants.AuditLogConstants.API_PRODUCT)) { + associatedType = APIConstants.API_PRODUCT; + } else { + associatedType = APIConstants.API; + } content.setDescription(devAPI.getDescription()); + content.setType(associatedType); content.setId(devAPI.getId()); content.setName(devAPI.getApiName()); content.setProvider( diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/devportal-api.yaml b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/devportal-api.yaml index b09c6e3af6bb..b99d43642ed8 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/devportal-api.yaml +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.common/src/main/resources/devportal-api.yaml @@ -5319,6 +5319,7 @@ components: enum: - DOC - API + - APIProduct transportType: type: string description: Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/store/v1/dto/SearchResultDTO.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/store/v1/dto/SearchResultDTO.java index 381da08a4473..5be105aa045a 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/store/v1/dto/SearchResultDTO.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/gen/java/org/wso2/carbon/apimgt/rest/api/store/v1/dto/SearchResultDTO.java @@ -29,7 +29,8 @@ public class SearchResultDTO { @XmlEnum(String.class) public enum TypeEnum { DOC("DOC"), - API("API"); + API("API"), + APIPRODUCT("APIProduct"); private String value; TypeEnum (String v) { diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/SearchResultMappingUtil.java b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/SearchResultMappingUtil.java index 2677ecef81e8..31b08f6654dd 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/SearchResultMappingUtil.java +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/java/org/wso2/carbon/apimgt/rest/api/store/v1/mappings/SearchResultMappingUtil.java @@ -110,7 +110,7 @@ public static APISearchResultDTO fromAPIToAPIResultDTO(APIProduct apiProduct) { apiBusinessInformationDTO.setTechnicalOwner(apiProduct.getTechnicalOwner()); apiBusinessInformationDTO.setTechnicalOwnerEmail(apiProduct.getTechnicalOwnerEmail()); apiResultDTO.setBusinessInformation(apiBusinessInformationDTO); - apiResultDTO.setType(SearchResultDTO.TypeEnum.API); + apiResultDTO.setType(SearchResultDTO.TypeEnum.APIPRODUCT); apiResultDTO.setTransportType(apiProduct.getType()); apiResultDTO.setDescription(apiProduct.getDescription()); apiResultDTO.setStatus(apiProduct.getState()); diff --git a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/resources/devportal-api.yaml b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/resources/devportal-api.yaml index b09c6e3af6bb..b99d43642ed8 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/resources/devportal-api.yaml +++ b/components/apimgt/org.wso2.carbon.apimgt.rest.api.store.v1/src/main/resources/devportal-api.yaml @@ -5319,6 +5319,7 @@ components: enum: - DOC - API + - APIProduct transportType: type: string description: Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL