use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO in project carbon-apimgt by wso2.
the class ApiProductsApiServiceImpl method getAPIProductRevisionDeployments.
@Override
public Response getAPIProductRevisionDeployments(String apiProductId, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
List<APIRevisionDeployment> apiRevisionDeploymentsList = new ArrayList<>();
List<APIRevision> apiRevisions = apiProvider.getAPIRevisions(apiProductId);
for (APIRevision apiRevision : apiRevisions) {
List<APIRevisionDeployment> apiRevisionDeploymentsResponse = apiProvider.getAPIRevisionDeploymentList(apiRevision.getRevisionUUID());
for (APIRevisionDeployment apiRevisionDeployment : apiRevisionDeploymentsResponse) {
apiRevisionDeploymentsList.add(apiRevisionDeployment);
}
}
List<APIRevisionDeploymentDTO> apiRevisionDeploymentDTOS = new ArrayList<>();
for (APIRevisionDeployment apiRevisionDeployment : apiRevisionDeploymentsList) {
apiRevisionDeploymentDTOS.add(APIMappingUtil.fromAPIRevisionDeploymenttoDTO(apiRevisionDeployment));
}
return Response.ok().entity(apiRevisionDeploymentDTOS).build();
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method getAPIRevisionDeployments.
/**
* Get revision deployment list
*
* @param apiId UUID of the API
* @param messageContext message context object
* @return response with 200 status code
*/
@Override
public Response getAPIRevisionDeployments(String apiId, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
List<APIRevisionDeployment> apiRevisionDeploymentsList = apiProvider.getAPIRevisionsDeploymentList(apiId);
List<APIRevisionDeploymentDTO> apiRevisionDeploymentDTOS = new ArrayList<>();
for (APIRevisionDeployment apiRevisionDeployment : apiRevisionDeploymentsList) {
apiRevisionDeploymentDTOS.add(APIMappingUtil.fromAPIRevisionDeploymenttoDTO(apiRevisionDeployment));
}
return Response.ok().entity(apiRevisionDeploymentDTOS).build();
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method updateAPIDeployment.
@Override
public Response updateAPIDeployment(String apiId, String deploymentId, APIRevisionDeploymentDTO apIRevisionDeploymentDTO, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
// validate if api exists
APIInfo apiInfo = validateAPIExistence(apiId);
// validate API update operation permitted based on the LC state
validateAPIOperationsPerLC(apiInfo.getStatus().toString());
String revisionId = apIRevisionDeploymentDTO.getRevisionUuid();
String decodedDeploymentName;
if (deploymentId != null) {
try {
decodedDeploymentName = new String(Base64.getUrlDecoder().decode(deploymentId), StandardCharsets.UTF_8);
} catch (IllegalArgumentException e) {
throw new APIMgtResourceNotFoundException("deployment with " + deploymentId + " not found", ExceptionCodes.from(ExceptionCodes.EXISTING_DEPLOYMENT_NOT_FOUND, deploymentId));
}
} else {
throw new APIMgtResourceNotFoundException("deployment id not found", ExceptionCodes.from(ExceptionCodes.DEPLOYMENT_ID_NOT_FOUND));
}
APIRevisionDeployment apiRevisionDeployment = new APIRevisionDeployment();
apiRevisionDeployment.setRevisionUUID(revisionId);
apiRevisionDeployment.setDeployment(decodedDeploymentName);
apiRevisionDeployment.setVhost(apIRevisionDeploymentDTO.getVhost());
apiRevisionDeployment.setDisplayOnDevportal(apIRevisionDeploymentDTO.isDisplayOnDevportal());
apiProvider.updateAPIDisplayOnDevportal(apiId, revisionId, apiRevisionDeployment);
APIRevisionDeployment apiRevisionDeploymentsResponse = apiProvider.getAPIRevisionDeployment(decodedDeploymentName, revisionId);
APIRevisionDeploymentDTO apiRevisionDeploymentDTO = APIMappingUtil.fromAPIRevisionDeploymenttoDTO(apiRevisionDeploymentsResponse);
Response.Status status = Response.Status.OK;
return Response.status(status).entity(apiRevisionDeploymentDTO).build();
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method fromAPIRevisionDeploymenttoDTO.
public static APIRevisionDeploymentDTO fromAPIRevisionDeploymenttoDTO(APIRevisionDeployment model) throws APIManagementException {
APIRevisionDeploymentDTO apiRevisionDeploymentDTO = new APIRevisionDeploymentDTO();
apiRevisionDeploymentDTO.setName(model.getDeployment());
apiRevisionDeploymentDTO.setVhost(model.getVhost());
if (model.getRevisionUUID() != null) {
apiRevisionDeploymentDTO.setRevisionUuid(model.getRevisionUUID());
}
apiRevisionDeploymentDTO.setDisplayOnDevportal(model.isDisplayOnDevportal());
if (model.getDeployedTime() != null) {
try {
apiRevisionDeploymentDTO.setDeployedTime(parseStringToDate(model.getDeployedTime()));
} catch (java.text.ParseException e) {
throw new APIManagementException("Error while parsing the deployed time:" + model.getDeployedTime(), e);
}
}
if (model.getSuccessDeployedTime() != null) {
try {
apiRevisionDeploymentDTO.setSuccessDeployedTime(parseStringToDate(model.getSuccessDeployedTime()));
} catch (java.text.ParseException e) {
throw new APIManagementException("Error while parsing the successfully deployed time:" + model.getSuccessDeployedTime(), e);
}
}
return apiRevisionDeploymentDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method fromAPIRevisiontoDTO.
public static APIRevisionDTO fromAPIRevisiontoDTO(APIRevision model) throws APIManagementException {
APIRevisionDTO apiRevisionDTO = new APIRevisionDTO();
apiRevisionDTO.setId(model.getRevisionUUID());
String key = "Revision " + model.getId();
apiRevisionDTO.setDisplayName(key);
apiRevisionDTO.setDescription(model.getDescription());
if (model.getCreatedTime() != null) {
try {
apiRevisionDTO.setCreatedTime(parseStringToDate(model.getCreatedTime()));
} catch (java.text.ParseException e) {
throw new APIManagementException("Error while parsing the created time:" + model.getCreatedTime(), e);
}
}
APIRevisionAPIInfoDTO apiRevisionAPIInfoDTO = new APIRevisionAPIInfoDTO();
apiRevisionAPIInfoDTO.setId(model.getApiUUID());
apiRevisionDTO.setApiInfo(apiRevisionAPIInfoDTO);
List<APIRevisionDeploymentDTO> apiRevisionDeploymentDTOS = new ArrayList<>();
if (model.getApiRevisionDeploymentList() != null) {
for (APIRevisionDeployment apiRevisionDeployment : model.getApiRevisionDeploymentList()) {
apiRevisionDeploymentDTOS.add(fromAPIRevisionDeploymenttoDTO(apiRevisionDeployment));
}
}
apiRevisionDTO.setDeploymentInfo(apiRevisionDeploymentDTOS);
return apiRevisionDTO;
}
Aggregations