refactor(manager-api): reorganise devportal methods
MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DeveloperPortalResourceImpl.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/DeveloperPortalResourceImpl.java
@@ -22,7 +22,6 @@ import io.apiman.manager.api.service.ApiService;
import io.apiman.manager.api.service.ApiService.ApiDefinitionStream;
import io.apiman.manager.api.service.DevPortalService;
import io.apiman.manager.api.service.OrganizationService;
-import io.apiman.manager.api.service.SearchService;
import java.util.List;
import java.util.stream.Collectors;
@@ -64,7 +63,7 @@ public class DeveloperPortalResourceImpl implements IDeveloperPortalResource {
@Override
public List<ApiSummaryBean> getFeaturedApis() {
- return apiService.getFeaturedApis();
+ return portalService.getFeaturedApis();
}
@Override

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ApiService.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ApiService.java
@@ -1080,17 +1080,6 @@ public class ApiService implements DataAccessUtilMixin {
tryAction(() -> storage.updateApi(api));
}
- /**
- * Get the featured APIs
- * @return list of featured ApiSummaries
- */
- public List<ApiSummaryBean> getFeaturedApis() {
- return query.getApisByTagName("featured")
- .stream()
- .map(apiMapper::toSummary)
- .collect(Collectors.toList());
- }
-
// TODO(msavy): put with rest of DTOs when get to that phase
public static final class ApiDefinitionStream {
private final ApiDefinitionType definitionType;

MODIFY
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/DevPortalService.java
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/DevPortalService.java
package io.apiman.manager.api.service;
-import io.apiman.manager.api.beans.developers.DeveloperApiPlanSummaryDto;
import io.apiman.manager.api.beans.developers.ApiVersionPolicySummaryDto;
+import io.apiman.manager.api.beans.developers.DeveloperApiPlanSummaryDto;
import io.apiman.manager.api.beans.policies.PolicyBean;
import io.apiman.manager.api.beans.policies.PolicyType;
import io.apiman.manager.api.beans.search.SearchCriteriaBean;
import io.apiman.manager.api.beans.search.SearchResultsBean;
import io.apiman.manager.api.beans.summary.ApiPlanSummaryBean;
import io.apiman.manager.api.beans.summary.ApiSummaryBean;
+import io.apiman.manager.api.beans.summary.mappers.ApiMapper;
import io.apiman.manager.api.core.IStorage;
import io.apiman.manager.api.core.IStorageQuery;
import io.apiman.manager.api.rest.impl.util.DataAccessUtilMixin;
@@ -30,6 +31,7 @@ import static io.apiman.manager.api.service.SearchService.emptySearchResults;
@Transactional
public class DevPortalService implements DataAccessUtilMixin {
+ private final ApiMapper apiMapper = ApiMapper.INSTANCE;
private IStorage storage;
private IStorageQuery query;
@@ -58,6 +60,25 @@ public class DevPortalService implements DataAccessUtilMixin {
return tryAction(() -> query.findExposedApis(criteria));
}
+ /**
+ * Get the featured APIs
+ * @return list of featured ApiSummaries
+ */
+ public List<ApiSummaryBean> getFeaturedApis() {
+ return query.getApisByTagName("featured")
+ .stream()
+ .map(apiMapper::toSummary)
+ .collect(Collectors.toList());
+ }
+
+ public List<ApiVersionPolicySummaryDto> getApiVersionPolicies(String orgId, String apiId, String apiVersion) {
+ return tryAction(() -> Lists.newArrayList(storage.getAllPolicies(orgId, apiId, apiVersion, PolicyType.Api)))
+ .stream()
+ .map(this::toDto)
+ .collect(Collectors.toList());
+ }
+
+
// TODO Use mapstruct
private DeveloperApiPlanSummaryDto toDto(String orgId, ApiPlanSummaryBean apiPsb) {
List<PolicyBean> planPolicies = tryAction(() -> Lists.newArrayList(storage.getAllPolicies(orgId, apiPsb.getPlanId(), apiPsb.getVersion(), PolicyType.Plan)));
@@ -84,10 +105,4 @@ public class DevPortalService implements DataAccessUtilMixin {
return summary;
}
- public List<ApiVersionPolicySummaryDto> getApiVersionPolicies(String orgId, String apiId, String apiVersion) {
- return tryAction(() -> Lists.newArrayList(storage.getAllPolicies(orgId, apiId, apiVersion, PolicyType.Api)))
- .stream()
- .map(this::toDto)
- .collect(Collectors.toList());
- }
}

refactor(manager-api): reorganise devportal methods