use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.EnvironmentListDTO in project carbon-apimgt by wso2.
the class EnvironmentsApiServiceImpl method environmentsGet.
/**
* Get list of gateway environments from config api-manager.xml and dynamic environments (from DB)
*
* @param messageContext message context
* @return created environment
* @throws APIManagementException if failed to get list
*/
public Response environmentsGet(MessageContext messageContext) throws APIManagementException {
APIAdmin apiAdmin = new APIAdminImpl();
String organization = RestApiUtil.getValidatedOrganization(messageContext);
List<Environment> envList = apiAdmin.getAllEnvironments(organization);
EnvironmentListDTO envListDTO = EnvironmentMappingUtil.fromEnvListToEnvListDTO(envList);
return Response.ok().entity(envListDTO).build();
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.EnvironmentListDTO in project carbon-apimgt by wso2.
the class EnvironmentMappingUtil method fromEnvironmentCollectionToDTO.
/**
* Converts a List object of SubscribedAPIs into a DTO.
*
* @param environmentCollection a collection of Environment objects
* @return EnvironmentListDTO object containing EnvironmentDTOs
*/
public static EnvironmentListDTO fromEnvironmentCollectionToDTO(Collection<Environment> environmentCollection) {
EnvironmentListDTO environmentListDTO = new EnvironmentListDTO();
List<EnvironmentDTO> environmentDTOs = environmentListDTO.getList();
if (environmentDTOs == null) {
environmentDTOs = new ArrayList<>();
environmentListDTO.setList(environmentDTOs);
}
for (Environment environment : environmentCollection) {
environmentDTOs.add(fromEnvironmentToDTO(environment));
}
environmentListDTO.setCount(environmentDTOs.size());
return environmentListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.EnvironmentListDTO in project carbon-apimgt by wso2.
the class SettingsMappingUtil method fromSettingstoDTO.
/**
* This method feeds data into the settingsDTO.
*
* @param isUserAvailable check if user is logged in
* @return SettingsDTO
* @throws APIManagementException,IOException
*/
public SettingsDTO fromSettingstoDTO(Boolean isUserAvailable, String organization) throws APIManagementException, IOException {
SettingsDTO settingsDTO = new SettingsDTO();
EnvironmentListDTO environmentListDTO = new EnvironmentListDTO();
if (isUserAvailable) {
Map<String, Environment> environments = APIUtil.getEnvironments(organization);
if (environments != null) {
environmentListDTO = EnvironmentMappingUtil.fromEnvironmentCollectionToDTO(environments.values());
}
settingsDTO.setEnvironment(environmentListDTO.getList());
String storeUrl = APIUtil.getStoreUrl();
String loggedInUserTenantDomain = RestApiCommonUtil.getLoggedInUserTenantDomain();
Map<String, String> domainMappings = APIUtil.getDomainMappings(loggedInUserTenantDomain, APIConstants.API_DOMAIN_MAPPINGS_STORE);
if (domainMappings.size() != 0) {
Iterator entries = domainMappings.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry thisEntry = (Map.Entry) entries.next();
storeUrl = "https://" + thisEntry.getValue();
break;
}
}
settingsDTO.setDevportalUrl(storeUrl);
settingsDTO.setMonetizationAttributes(getMonetizationAttributes());
settingsDTO.setSecurityAuditProperties(getSecurityAuditProperties());
settingsDTO.setExternalStoresEnabled(APIUtil.isExternalStoresEnabled(RestApiCommonUtil.getLoggedInUserTenantDomain()));
settingsDTO.setDocVisibilityEnabled(APIUtil.isDocVisibilityLevelsEnabled());
settingsDTO.setCrossTenantSubscriptionEnabled(APIUtil.isCrossTenantSubscriptionsEnabled());
Map<String, Environment> gatewayEnvironments = APIUtil.getReadOnlyGatewayEnvironments();
String authorizationHeader = APIUtil.getOAuthConfiguration(loggedInUserTenantDomain, APIConstants.AUTHORIZATION_HEADER);
if (authorizationHeader == null) {
authorizationHeader = APIConstants.AUTHORIZATION_HEADER_DEFAULT;
}
settingsDTO.setAuthorizationHeader(authorizationHeader);
}
return settingsDTO;
}
use of org.wso2.carbon.apimgt.rest.api.admin.v1.dto.EnvironmentListDTO in project carbon-apimgt by wso2.
the class EnvironmentMappingUtil method fromEnvListToEnvListDTO.
/**
* Convert list of Environment to EnvironmentListDTO
*
* @param envList List of Environment
* @return EnvironmentListDTO containing Environment list
*/
public static EnvironmentListDTO fromEnvListToEnvListDTO(List<Environment> envList) {
EnvironmentListDTO envListDTO = new EnvironmentListDTO();
envListDTO.setCount(envList.size());
envListDTO.setList(envList.stream().map(EnvironmentMappingUtil::fromEnvToEnvDTO).collect(Collectors.toList()));
return envListDTO;
}
Aggregations