use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionListDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method fromListAPIRevisiontoDTO.
public static APIRevisionListDTO fromListAPIRevisiontoDTO(List<APIRevision> apiRevisionList) throws APIManagementException {
APIRevisionListDTO apiRevisionListDTO = new APIRevisionListDTO();
List<APIRevisionDTO> apiRevisionDTOS = new ArrayList<>();
for (APIRevision apiRevision : apiRevisionList) {
apiRevisionDTOS.add(fromAPIRevisiontoDTO(apiRevision));
}
apiRevisionListDTO.setCount(apiRevisionList.size());
apiRevisionListDTO.setList(apiRevisionDTOS);
return apiRevisionListDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionListDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method getAPIRevisions.
/**
* Retrieve available revisions of an API
*
* @param apiId UUID of the API
* @param query Search query string
* @param messageContext message context object
* @return response containing list of API revisions
*/
@Override
public Response getAPIRevisions(String apiId, String query, MessageContext messageContext) {
try {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
APIRevisionListDTO apiRevisionListDTO;
List<APIRevision> apiRevisions = apiProvider.getAPIRevisions(apiId);
if (StringUtils.equalsIgnoreCase(query, "deployed:true")) {
List<APIRevision> apiDeployedRevisions = new ArrayList<>();
for (APIRevision apiRevision : apiRevisions) {
if (!apiRevision.getApiRevisionDeploymentList().isEmpty()) {
apiDeployedRevisions.add(apiRevision);
}
}
apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiDeployedRevisions);
} else if (StringUtils.equalsIgnoreCase(query, "deployed:false")) {
List<APIRevision> apiNotDeployedRevisions = new ArrayList<>();
for (APIRevision apiRevision : apiRevisions) {
if (apiRevision.getApiRevisionDeploymentList().isEmpty()) {
apiNotDeployedRevisions.add(apiRevision);
}
}
apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiNotDeployedRevisions);
} else {
apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiRevisions);
}
return Response.ok().entity(apiRevisionListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while adding retrieving API Revision for api id : " + apiId + " - " + e.getMessage();
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionListDTO in project carbon-apimgt by wso2.
the class ApiProductsApiServiceImpl method deleteAPIProductRevision.
@Override
public Response deleteAPIProductRevision(String apiProductId, String revisionId, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
String organization = RestApiUtil.getValidatedOrganization(messageContext);
apiProvider.deleteAPIProductRevision(apiProductId, revisionId, organization);
List<APIRevision> apiRevisions = apiProvider.getAPIRevisions(apiProductId);
APIRevisionListDTO apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiRevisions);
return Response.ok().entity(apiRevisionListDTO).build();
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionListDTO in project carbon-apimgt by wso2.
the class ApiProductsApiServiceImpl method getAPIProductRevisions.
@Override
public Response getAPIProductRevisions(String apiProductId, String query, MessageContext messageContext) throws APIManagementException {
try {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
APIRevisionListDTO apiRevisionListDTO;
List<APIRevision> apiRevisions = apiProvider.getAPIRevisions(apiProductId);
if (StringUtils.equalsIgnoreCase(query, "deployed:true")) {
List<APIRevision> apiDeployedRevisions = new ArrayList<>();
for (APIRevision apiRevision : apiRevisions) {
if (!apiRevision.getApiRevisionDeploymentList().isEmpty()) {
apiDeployedRevisions.add(apiRevision);
}
}
apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiDeployedRevisions);
} else if (StringUtils.equalsIgnoreCase(query, "deployed:false")) {
List<APIRevision> apiProductNotDeployedRevisions = new ArrayList<>();
for (APIRevision apiRevision : apiRevisions) {
if (apiRevision.getApiRevisionDeploymentList().isEmpty()) {
apiProductNotDeployedRevisions.add(apiRevision);
}
}
apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiProductNotDeployedRevisions);
} else {
apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiRevisions);
}
return Response.ok().entity(apiRevisionListDTO).build();
} catch (APIManagementException e) {
String errorMessage = "Error while adding retrieving API Revision for API Product id : " + apiProductId + " - " + e.getMessage();
RestApiUtil.handleInternalServerError(errorMessage, e, log);
}
return null;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.APIRevisionListDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method deleteAPIRevision.
/**
* Delete a revision of an API
*
* @param apiId UUID of the API
* @param revisionId Revision ID of the API
* @param messageContext message context object
* @return response with 204 status code and no content
*/
@Override
public Response deleteAPIRevision(String apiId, String revisionId, MessageContext messageContext) throws APIManagementException {
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
String organization = RestApiUtil.getValidatedOrganization(messageContext);
// validate if api exists
APIInfo apiInfo = validateAPIExistence(apiId);
// validate API update operation permitted based on the LC state
validateAPIOperationsPerLC(apiInfo.getStatus().toString());
apiProvider.deleteAPIRevision(apiId, revisionId, organization);
List<APIRevision> apiRevisions = apiProvider.getAPIRevisions(apiId);
APIRevisionListDTO apiRevisionListDTO = APIMappingUtil.fromListAPIRevisiontoDTO(apiRevisions);
return Response.ok().entity(apiRevisionListDTO).build();
}
Aggregations