Search in sources :

Example 11 with SubscriptionList

use of org.wso2.carbon.apimgt.keymgt.model.entity.SubscriptionList in project carbon-apimgt by wso2.

the class APISubscriptionDAOImpl method createSubscriptionValidationDataFromResultSet.

private List<SubscriptionValidationData> createSubscriptionValidationDataFromResultSet(ResultSet rs) throws APIMgtDAOException {
    List<SubscriptionValidationData> subscriptionList = new ArrayList<>();
    if (rs == null) {
        return new ArrayList<>();
    }
    try {
        while (rs.next()) {
            SubscriptionValidationData subValidationData = new SubscriptionValidationData(rs.getString("API_CONTEXT"), rs.getString("API_VERSION"), rs.getString("CLIENT_ID"));
            subValidationData.setSubscriptionPolicy(rs.getString("SUBS_POLICY"));
            subValidationData.setApiName(rs.getString("API_NAME"));
            subValidationData.setApiProvider(rs.getString("API_PROVIDER"));
            subValidationData.setKeyEnvType(rs.getString("KEY_ENV_TYPE"));
            subValidationData.setApplicationId(rs.getString("APP_ID"));
            subValidationData.setStatus(rs.getString("SUB_STATUS"));
            subscriptionList.add(subValidationData);
        }
    } catch (SQLException e) {
        throw new APIMgtDAOException(DAOUtil.DAO_ERROR_PREFIX + "creating subscription validation data", e);
    }
    return subscriptionList;
}
Also used : APIMgtDAOException(org.wso2.carbon.apimgt.core.exception.APIMgtDAOException) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) SubscriptionValidationData(org.wso2.carbon.apimgt.core.models.SubscriptionValidationData)

Example 12 with SubscriptionList

use of org.wso2.carbon.apimgt.keymgt.model.entity.SubscriptionList in project carbon-apimgt by wso2.

the class APIPublisherImpl method getSubscribersByAPIId.

@Override
public Set<String> getSubscribersByAPIId(String apiId) throws APIManagementException {
    List<Subscription> subscriptionList = new ArrayList();
    Set<String> subscriberList = new HashSet<>();
    if (StringUtils.isNotEmpty(apiId)) {
        subscriptionList = getSubscriptionsByAPI(apiId);
    }
    for (Subscription listItem : subscriptionList) {
        subscriberList.add(listItem.getApplication().getCreatedUser());
    }
    return subscriberList;
}
Also used : ArrayList(java.util.ArrayList) Subscription(org.wso2.carbon.apimgt.core.models.Subscription) HashSet(java.util.HashSet)

Example 13 with SubscriptionList

use of org.wso2.carbon.apimgt.keymgt.model.entity.SubscriptionList in project carbon-apimgt by wso2.

the class MappingUtil method fromSubscriptionListToDTO.

/**
 * Converts Subscription model into SubscriptionListDTO object
 *
 * @param subscriptionList list of subscriptions
 * @param limit            no of items to return
 * @param offset value to offset
 * @return SubscriptionListDTO containing subscriptions
 */
public static SubscriptionListDTO fromSubscriptionListToDTO(List<Subscription> subscriptionList, Integer limit, Integer offset) {
    SubscriptionListDTO subscriptionListDTO = new SubscriptionListDTO();
    for (Subscription subscription : subscriptionList) {
        subscriptionListDTO.addListItem(fromSubscription(subscription));
    }
    // TODO need to change when pagination implementation goes on
    subscriptionListDTO.count(subscriptionList.size());
    return subscriptionListDTO;
}
Also used : Subscription(org.wso2.carbon.apimgt.core.models.Subscription) SubscriptionListDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.SubscriptionListDTO)

Aggregations

ArrayList (java.util.ArrayList)10 Subscription (org.wso2.carbon.apimgt.core.models.Subscription)10 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)4 SQLException (java.sql.SQLException)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)2 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)2 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)2 API (org.wso2.carbon.apimgt.core.models.API)2 Application (org.wso2.carbon.apimgt.core.models.Application)2 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)2 GeneralWorkflowResponse (org.wso2.carbon.apimgt.core.workflow.GeneralWorkflowResponse)2 SubscriptionListDTO (org.wso2.carbon.apimgt.rest.api.publisher.dto.SubscriptionListDTO)2 Request (org.wso2.msf4j.Request)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1