Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Jun 5, 2024
1 parent bf66c58 commit 3ea3d93
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -4148,6 +4149,7 @@ public Map<String, Object> searchPaginatedContent(String searchQuery, String org
Map<Documentation, API> docMap = new HashMap<Documentation, API>();
Map<String, Object> result = new HashMap<String, Object>();
SortedSet<API> apiSet = new TreeSet<API>(new APINameComparator());
SortedSet<APIProduct> apiProductSet = new TreeSet<APIProduct>(new APIProductNameComparator());
int totalLength = 0;

String userame = (userNameWithoutChange != null) ? userNameWithoutChange : username;
Expand Down Expand Up @@ -4175,7 +4177,7 @@ public Map<String, Object> 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()));
Expand All @@ -4193,10 +4195,27 @@ public Map<String, Object> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5319,6 +5319,7 @@ components:
enum:
- DOC
- API
- APIProduct
transportType:
type: string
description: Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5319,6 +5319,7 @@ components:
enum:
- DOC
- API
- APIProduct
transportType:
type: string
description: Accepted values are HTTP, WS, SOAPTOREST, GRAPHQL
Expand Down

0 comments on commit 3ea3d93

Please sign in to comment.