use of org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException in project carbon-apimgt by wso2.
the class SubscriptionDataLoaderImpl method loadAllSubscriptions.
@Override
public List<Subscription> loadAllSubscriptions(String tenantDomain) throws DataLoadingException {
String subscriptionsEP = APIConstants.SubscriptionValidationResources.SUBSCRIPTIONS;
List<Subscription> subscriptions = new ArrayList<>();
String responseString = null;
try {
responseString = invokeService(subscriptionsEP, tenantDomain);
} catch (IOException e) {
String msg = "Error while executing the http client " + subscriptionsEP;
log.error(msg, e);
throw new DataLoadingException(msg, e);
}
if (responseString != null && !responseString.isEmpty()) {
subscriptions = (new Gson().fromJson(responseString, SubscriptionList.class)).getList();
}
return subscriptions;
}
use of org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException in project carbon-apimgt by wso2.
the class SubscriptionDataLoaderImpl method loadAllApis.
@Override
public List<API> loadAllApis(String tenantDomain) throws DataLoadingException {
Set<String> gatewayLabels = gatewayArtifactSynchronizerProperties.getGatewayLabels();
List<API> apis = new ArrayList<>();
if (gatewayLabels != null && gatewayLabels.size() > 0) {
for (String gatewayLabel : gatewayLabels) {
String apisEP = APIConstants.SubscriptionValidationResources.APIS + "?gatewayLabel=" + getEncodedLabel(gatewayLabel);
String responseString = null;
try {
responseString = invokeService(apisEP, tenantDomain);
} catch (IOException e) {
String msg = "Error while executing the http client " + apisEP;
log.error(msg, e);
throw new DataLoadingException(msg, e);
}
if (responseString != null && !responseString.isEmpty()) {
APIList apiList = new Gson().fromJson(responseString, APIList.class);
apis.addAll(apiList.getList());
}
if (log.isDebugEnabled()) {
log.debug("apis :" + apis.get(0).toString());
}
}
}
return apis;
}
use of org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException in project carbon-apimgt by wso2.
the class SubscriptionDataLoaderImpl method getSubscriptionById.
@Override
public Subscription getSubscriptionById(String apiId, String appId) throws DataLoadingException {
String endPoint = APIConstants.SubscriptionValidationResources.SUBSCRIPTIONS + "?apiId=" + apiId + "&appId=" + appId;
Subscription subscription = null;
String responseString;
try {
responseString = invokeService(endPoint, null);
} 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()) {
SubscriptionList list = new Gson().fromJson(responseString, SubscriptionList.class);
if (list.getList() != null && !list.getList().isEmpty()) {
subscription = list.getList().get(0);
}
}
return subscription;
}
use of org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException in project carbon-apimgt by wso2.
the class SubscriptionDataLoaderImpl method loadAllApplications.
@Override
public List<Application> loadAllApplications(String tenantDomain) throws DataLoadingException {
String applicationsEP = APIConstants.SubscriptionValidationResources.APPLICATIONS;
List<Application> applications = new ArrayList<>();
String responseString = null;
try {
responseString = invokeService(applicationsEP, tenantDomain);
} catch (IOException e) {
String msg = "Error while executing the http client " + applicationsEP;
log.error(msg, e);
throw new DataLoadingException(msg, e);
}
if (responseString != null && !responseString.isEmpty()) {
applications = (new Gson().fromJson(responseString, ApplicationList.class)).getList();
}
return applications;
}
use of org.wso2.carbon.apimgt.keymgt.model.exception.DataLoadingException in project carbon-apimgt by wso2.
the class SubscriptionDataLoaderImpl method loadAllAPIPolicies.
@Override
public List<ApiPolicy> loadAllAPIPolicies(String tenantDomain) throws DataLoadingException {
String apiPoliciesEP = APIConstants.SubscriptionValidationResources.API_POLICIES;
List<ApiPolicy> apiPolicies = new ArrayList<>();
String responseString = null;
try {
responseString = invokeService(apiPoliciesEP, tenantDomain);
} catch (IOException e) {
String msg = "Error while executing the http client " + apiPoliciesEP;
log.error(msg, e);
throw new DataLoadingException(msg, e);
}
if (responseString != null && !responseString.isEmpty()) {
apiPolicies = (new Gson().fromJson(responseString, APIPolicyList.class)).getList();
}
return apiPolicies;
}
Aggregations