Search in sources :

Example 6 with APIRevisionDeploymentDTO

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();
}
Also used : APIRevision(org.wso2.carbon.apimgt.api.model.APIRevision) ArrayList(java.util.ArrayList) APIRevisionDeploymentDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment) APIProvider(org.wso2.carbon.apimgt.api.APIProvider)

Example 7 with APIRevisionDeploymentDTO

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();
}
Also used : APIRevisionDeploymentDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO) ArrayList(java.util.ArrayList) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment) APIProvider(org.wso2.carbon.apimgt.api.APIProvider)

Example 8 with APIRevisionDeploymentDTO

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();
}
Also used : HttpResponse(org.apache.http.HttpResponse) WSDLValidationResponse(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLValidationResponse) Response(javax.ws.rs.core.Response) APIDefinitionValidationResponse(org.wso2.carbon.apimgt.api.APIDefinitionValidationResponse) APIStateChangeResponse(org.wso2.carbon.apimgt.api.model.APIStateChangeResponse) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) APIInfo(org.wso2.carbon.apimgt.api.model.APIInfo) APIRevisionDeploymentDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment) APIMgtResourceNotFoundException(org.wso2.carbon.apimgt.api.APIMgtResourceNotFoundException) APIProvider(org.wso2.carbon.apimgt.api.APIProvider)

Example 9 with APIRevisionDeploymentDTO

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;
}
Also used : APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIRevisionDeploymentDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO)

Example 10 with 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;
}
Also used : APIRevisionAPIInfoDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionAPIInfoDTO) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) APIRevisionDeploymentDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO) ArrayList(java.util.ArrayList) APIRevisionDeployment(org.wso2.carbon.apimgt.api.model.APIRevisionDeployment) APIRevisionDTO(org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDTO)

Aggregations

APIRevisionDeploymentDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDeploymentDTO)10 APIRevisionDeployment (org.wso2.carbon.apimgt.api.model.APIRevisionDeployment)9 APIProvider (org.wso2.carbon.apimgt.api.APIProvider)8 ArrayList (java.util.ArrayList)7 Response (javax.ws.rs.core.Response)6 APIStateChangeResponse (org.wso2.carbon.apimgt.api.model.APIStateChangeResponse)6 Environment (org.wso2.carbon.apimgt.api.model.Environment)4 HttpResponse (org.apache.http.HttpResponse)3 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)3 APIDefinitionValidationResponse (org.wso2.carbon.apimgt.api.APIDefinitionValidationResponse)3 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)3 APIInfo (org.wso2.carbon.apimgt.api.model.APIInfo)3 WSDLValidationResponse (org.wso2.carbon.apimgt.impl.wsdl.model.WSDLValidationResponse)3 APIMgtResourceNotFoundException (org.wso2.carbon.apimgt.api.APIMgtResourceNotFoundException)2 APIRevision (org.wso2.carbon.apimgt.api.model.APIRevision)1 APIDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIDTO)1 APIRevisionAPIInfoDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionAPIInfoDTO)1 APIRevisionDTO (org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionDTO)1