Search in sources :

Example 1 with ApplicationKeyMappingList

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

the class SubscriptionDataLoaderImpl method getKeyMapping.

@Override
public ApplicationKeyMapping getKeyMapping(String consumerKey, String keymanager, String tenantDomain) throws DataLoadingException {
    ApplicationKeyMapping application = null;
    String responseString;
    String endPoint = null;
    try {
        keymanager = URLEncoder.encode(keymanager, APIConstants.DigestAuthConstants.CHARSET);
        keymanager = keymanager.replace("\\+", "%20");
        endPoint = APIConstants.SubscriptionValidationResources.APPLICATION_KEY_MAPPINGS + "?consumerKey=" + consumerKey + "&keymanager=" + keymanager;
        responseString = invokeService(endPoint, tenantDomain);
    } catch (IOException e) {
        String msg = "Error while executing the http client " + endPoint;
        log.error(msg, e);
        throw new DataLoadingException(msg, e);
    }
    if (responseString != null && !responseString.isEmpty()) {
        ApplicationKeyMappingList list = new Gson().fromJson(responseString, ApplicationKeyMappingList.class);
        if (list.getList() != null && !list.getList().isEmpty()) {
            application = list.getList().get(0);
        }
    }
    return application;
}
Also used : DataLoadingException(org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException) Gson(com.google.gson.Gson) IOException(java.io.IOException) ApplicationKeyMappingList(org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMappingList) ApplicationKeyMapping(org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMapping)

Aggregations

Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 ApplicationKeyMapping (org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMapping)1 ApplicationKeyMappingList (org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMappingList)1 DataLoadingException (org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException)1