use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO in project carbon-apimgt by wso2.
the class WorkflowMappingUtil method toWorkflowDTO.
/**
* Map Workflow to WorkflowDTO
* @param response WorkflowResponse object
* @return WorkflowResponseDTO mapped WorkflowResponseDTO
*/
public static WorkflowDTO toWorkflowDTO(Workflow response) {
WorkflowDTO workflowDTO = new WorkflowDTO();
if (response != null) {
workflowDTO.setCreatedTime(response.getCreatedTime().toString());
workflowDTO.setDescription(response.getWorkflowDescription());
workflowDTO.setType(response.getWorkflowType());
workflowDTO.setReferenceId(response.getExternalWorkflowReference());
workflowDTO.setWorkflowStatus(response.getStatus().toString());
}
return workflowDTO;
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO in project carbon-apimgt by wso2.
the class MiscMappingUtilTestCase method testFromWorkflowResponseToDTO.
@Test
public void testFromWorkflowResponseToDTO() {
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(WorkflowStatus.APPROVED);
WorkflowResponseDTO workflowResponseDTO = MiscMappingUtil.fromWorkflowResponseToDTO(workflowResponse);
assertEquals(workflowResponseDTO.getWorkflowStatus().name(), workflowResponse.getWorkflowStatus().name());
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO in project carbon-apimgt by wso2.
the class TestMappingUtilTestCase method testWorkflowResponseToWorkflowResponseDTOMapping.
@Test(description = "Workflow response to Workflow response DTO mapping ")
void testWorkflowResponseToWorkflowResponseDTOMapping() {
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(WorkflowStatus.APPROVED);
WorkflowResponseDTO workflowResponseDTO = MappingUtil.toWorkflowResponseDTO(workflowResponse);
assertEquals(workflowResponse.getWorkflowStatus().name(), workflowResponseDTO.getWorkflowStatus().name());
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO in project carbon-apimgt by wso2.
the class ApiProductsApiServiceImpl method changeAPIProductLifecycle.
@Override
public Response changeAPIProductLifecycle(String action, String apiProductId, String lifecycleChecklist, String ifMatch, MessageContext messageContext) throws APIManagementException {
String organization = RestApiUtil.getValidatedOrganization(messageContext);
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
ApiTypeWrapper productWrapper = new ApiTypeWrapper(apiProvider.getAPIProductbyUUID(apiProductId, organization));
APIStateChangeResponse stateChangeResponse = PublisherCommonUtils.changeApiOrApiProductLifecycle(action, productWrapper, lifecycleChecklist, organization);
LifecycleStateDTO stateDTO = getLifecycleState(apiProductId, organization);
WorkflowResponseDTO workflowResponseDTO = APIMappingUtil.toWorkflowResponseDTO(stateDTO, stateChangeResponse);
return Response.ok().entity(workflowResponseDTO).build();
}
use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.WorkflowResponseDTO in project carbon-apimgt by wso2.
the class ApisApiServiceImpl method changeAPILifecycle.
@Override
public Response changeAPILifecycle(String action, String apiId, String lifecycleChecklist, String ifMatch, MessageContext messageContext) {
try {
String organization = RestApiUtil.getValidatedOrganization(messageContext);
APIProvider apiProvider = RestApiCommonUtil.getLoggedInUserProvider();
ApiTypeWrapper apiWrapper = new ApiTypeWrapper(apiProvider.getAPIbyUUID(apiId, organization));
APIStateChangeResponse stateChangeResponse = PublisherCommonUtils.changeApiOrApiProductLifecycle(action, apiWrapper, lifecycleChecklist, organization);
// returns the current lifecycle state
// todo try to prevent this call
LifecycleStateDTO stateDTO = getLifecycleState(apiId, organization);
WorkflowResponseDTO workflowResponseDTO = APIMappingUtil.toWorkflowResponseDTO(stateDTO, stateChangeResponse);
return Response.ok().entity(workflowResponseDTO).build();
} catch (APIManagementException e) {
// Auth failure occurs when cross tenant accessing APIs. Sends 404, since we don't need to expose the existence of the resource
if (RestApiUtil.isDueToResourceNotFound(e) || RestApiUtil.isDueToAuthorizationFailure(e)) {
RestApiUtil.handleResourceNotFoundError(RestApiConstants.RESOURCE_API, apiId, e, log);
} else if (isAuthorizationFailure(e)) {
RestApiUtil.handleAuthorizationFailure("Authorization failure while updating the lifecycle of API " + apiId, e, log);
} else {
RestApiUtil.handleInternalServerError("Error while updating lifecycle of API " + apiId, e, log);
}
}
return null;
}
Aggregations