use of org.wso2.carbon.apimgt.internal.service.dto.DeployedAPIRevisionDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method deployedAPIRevision.
public Response deployedAPIRevision(List<DeployedAPIRevisionDTO> deployedAPIRevisionDTOList, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
List<String> revisionUUIDs = new ArrayList<>();
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
for (DeployedAPIRevisionDTO deployedAPIRevisionDTO : deployedAPIRevisionDTOList) {
// get revision uuid
String revisionUUID = apiProvider.getAPIRevisionUUID(Integer.toString(deployedAPIRevisionDTO.getRevisionId()), deployedAPIRevisionDTO.getApiId());
if (revisionUUID == null) {
return Response.status(Response.Status.BAD_REQUEST).entity(null).build();
}
if (!revisionUUIDs.contains(revisionUUID)) {
revisionUUIDs.add(revisionUUID);
Map<String, Environment> environments = APIUtil.getEnvironments(tenantDomain);
List<DeployedAPIRevision> deployedAPIRevisions = new ArrayList<>();
for (DeployedEnvInfoDTO deployedEnvInfoDTO : deployedAPIRevisionDTO.getEnvInfo()) {
DeployedAPIRevision deployedAPIRevision = new DeployedAPIRevision();
deployedAPIRevision.setRevisionUUID(revisionUUID);
String environment = deployedEnvInfoDTO.getName();
if (environments.get(environment) == null) {
RestApiUtil.handleBadRequest("Gateway environment not found: " + environment, log);
}
deployedAPIRevision.setDeployment(environment);
deployedAPIRevision.setVhost(deployedEnvInfoDTO.getVhost());
if (StringUtils.isEmpty(deployedEnvInfoDTO.getVhost())) {
RestApiUtil.handleBadRequest("Required field 'vhost' not found in deployment", log);
}
deployedAPIRevisions.add(deployedAPIRevision);
}
apiProvider.addDeployedAPIRevision(deployedAPIRevisionDTO.getApiId(), revisionUUID, deployedAPIRevisions);
}
}
return Response.ok().build();
}
Aggregations