Search in sources :

Example 66 with LifecycleException

use of org.wso2.carbon.lcm.core.exception.LifecycleException in project carbon-apimgt by wso2.

the class APIPublisherImpl method updateCheckListItem.

/**
 * This method used to Update the lifecycle checklist of API
 *
 * @param apiId            UUID of the API
 * @param status           Current API lifecycle status.
 * @param checkListItemMap Check list item values.
 * @throws APIManagementException If failed to update checklist item values.
 */
@Override
public void updateCheckListItem(String apiId, String status, Map<String, Boolean> checkListItemMap) throws APIManagementException {
    API api = getApiDAO().getAPI(apiId);
    try {
        API.APIBuilder apiBuilder = new API.APIBuilder(api);
        apiBuilder.lastUpdatedTime(LocalDateTime.now());
        apiBuilder.updatedBy(getUsername());
        apiBuilder.lifecycleState(getApiLifecycleManager().getLifecycleDataForState(apiBuilder.getLifecycleInstanceId(), apiBuilder.getLifeCycleStatus()));
        for (Map.Entry<String, Boolean> checkListItem : checkListItemMap.entrySet()) {
            getApiLifecycleManager().checkListItemEvent(api.getLifecycleInstanceId(), api.getLifeCycleStatus(), checkListItem.getKey(), checkListItem.getValue());
        }
    } catch (LifecycleException e) {
        String errorMsg = "Couldn't get the lifecycle status of api ID " + apiId;
        log.error(errorMsg, e);
        throw new APIManagementException(errorMsg, e, ExceptionCodes.APIMGT_LIFECYCLE_EXCEPTION);
    }
}
Also used : LifecycleException(org.wso2.carbon.lcm.core.exception.LifecycleException) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) API(org.wso2.carbon.apimgt.core.models.API) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)59 Test (org.testng.annotations.Test)58 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)56 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)55 API (org.wso2.carbon.apimgt.core.models.API)54 LifecycleState (org.wso2.carbon.lcm.core.impl.LifecycleState)32 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)31 LabelDAO (org.wso2.carbon.apimgt.core.dao.LabelDAO)21 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)20 HashMap (java.util.HashMap)17 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)15 Endpoint (org.wso2.carbon.apimgt.core.models.Endpoint)14 LifecycleException (org.wso2.carbon.lcm.core.exception.LifecycleException)14 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)13 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)13 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)11 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)11 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)11 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)10 IdentityProvider (org.wso2.carbon.apimgt.core.api.IdentityProvider)8