use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.GatewayEnvironmentProtocolURIDTO in project carbon-apimgt by wso2.
the class EnvironmentMappingUtil method fromEnvironmentToDTO.
/**
* Converts an Environment object into EnvironmentDTO.
*
* @param environment Environment object
* @return EnvironmentDTO object corresponding to the given Environment object
*/
public static EnvironmentDTO fromEnvironmentToDTO(Environment environment) {
EnvironmentDTO environmentDTO = new EnvironmentDTO();
environmentDTO.setId(environment.getUuid());
environmentDTO.setName(environment.getName());
environmentDTO.setDisplayName(environment.getDisplayName());
environmentDTO.setType(environment.getType());
environmentDTO.setServerUrl(environment.getServerURL());
environmentDTO.setShowInApiConsole(environment.isShowInConsole());
environmentDTO.setProvider(environment.getProvider());
environmentDTO.setVhosts(environment.getVhosts().stream().map(EnvironmentMappingUtil::fromVHostToVHostDTO).collect(Collectors.toList()));
environmentDTO.setAdditionalProperties(fromAdditionalPropertiesToAdditionalPropertiesDTO(environment.getAdditionalProperties()));
ExternalEnvironment parser = APIUtil.getExternalEnvironment(environment.getProvider());
if (parser != null) {
List<GatewayEnvironmentProtocolURIDTO> endpointsList = new ArrayList<>();
List<AsyncProtocolEndpoint> endpointUrlsList = parser.getExternalEndpointURLs(environment);
if (endpointUrlsList != null || endpointUrlsList.size() > 0) {
for (AsyncProtocolEndpoint asyncProtocolEndpoint : endpointUrlsList) {
GatewayEnvironmentProtocolURIDTO gatewayEnvironmentProtocolURIDTO = new GatewayEnvironmentProtocolURIDTO();
gatewayEnvironmentProtocolURIDTO.setProtocol(asyncProtocolEndpoint.getProtocol());
gatewayEnvironmentProtocolURIDTO.setEndpointURI(asyncProtocolEndpoint.getProtocolUrl());
endpointsList.add(gatewayEnvironmentProtocolURIDTO);
}
environmentDTO.setEndpointURIs(endpointsList);
}
}
return environmentDTO;
}
Aggregations