use of org.wso2.carbon.apimgt.impl.utils.APIStoreNameComparator in project carbon-apimgt by wso2.
the class APIProviderImpl method getExternalAPIStores.
/**
* When enabled publishing to external APIStores support,get all the external apistore details which are
* published and stored in db and which are not unpublished
*
* @param apiId The API uuid which need to update in db
* @throws org.wso2.carbon.apimgt.api.APIManagementException If failed to update subscription status
*/
@Override
public Set<APIStore> getExternalAPIStores(String apiId) throws APIManagementException {
if (APIUtil.isAPIsPublishToExternalAPIStores(tenantId)) {
SortedSet<APIStore> sortedApiStores = new TreeSet<APIStore>(new APIStoreNameComparator());
Set<APIStore> publishedStores = apiMgtDAO.getExternalAPIStoresDetails(apiId);
sortedApiStores.addAll(publishedStores);
return APIUtil.getExternalAPIStores(sortedApiStores, tenantId);
} else {
return null;
}
}
use of org.wso2.carbon.apimgt.impl.utils.APIStoreNameComparator in project carbon-apimgt by wso2.
the class APIStoreNameComparatorTestCase method testCompareEquals.
@Test
public void testCompareEquals() {
APIStore apiStore1 = new APIStore();
apiStore1.setDisplayName("Store1");
apiStore1.setName("Store1");
APIStore apiStore2 = new APIStore();
apiStore2.setDisplayName("Store1");
apiStore2.setName("Store1");
APIStoreNameComparator apiStoreNameComparator = new APIStoreNameComparator();
int result = apiStoreNameComparator.compare(apiStore1, apiStore2);
Assert.assertEquals(0, result);
}
use of org.wso2.carbon.apimgt.impl.utils.APIStoreNameComparator in project carbon-apimgt by wso2.
the class APIStoreNameComparatorTestCase method testCompareNotEquals.
@Test
public void testCompareNotEquals() {
APIStore apiStore1 = new APIStore();
apiStore1.setDisplayName("Store1");
apiStore1.setName("Store1");
APIStore apiStore2 = new APIStore();
apiStore2.setDisplayName("Store2");
apiStore2.setName("Store2");
APIStoreNameComparator apiStoreNameComparator = new APIStoreNameComparator();
int result = apiStoreNameComparator.compare(apiStore1, apiStore2);
Assert.assertNotEquals(0, result);
}
use of org.wso2.carbon.apimgt.impl.utils.APIStoreNameComparator in project carbon-apimgt by wso2.
the class APIProviderImpl method getPublishedExternalAPIStores.
/**
* When enabled publishing to external APIStores support,get only the published external apistore details which are
* stored in db
*
* @param apiId The API uuid which need to update in db
* @throws org.wso2.carbon.apimgt.api.APIManagementException If failed to update subscription status
*/
@Override
public Set<APIStore> getPublishedExternalAPIStores(String apiId) throws APIManagementException {
Set<APIStore> storesSet;
SortedSet<APIStore> configuredAPIStores = new TreeSet<>(new APIStoreNameComparator());
configuredAPIStores.addAll(APIUtil.getExternalStores(tenantId));
if (APIUtil.isAPIsPublishToExternalAPIStores(tenantId)) {
storesSet = apiMgtDAO.getExternalAPIStoresDetails(apiId);
// Retains only the stores that contained in configuration
storesSet.retainAll(configuredAPIStores);
return storesSet;
}
return null;
}
use of org.wso2.carbon.apimgt.impl.utils.APIStoreNameComparator in project carbon-apimgt by wso2.
the class APIUtil method getExternalAPIStores.
public static Set<APIStore> getExternalAPIStores(Set<APIStore> inputStores, int tenantId) throws APIManagementException {
SortedSet<APIStore> apiStores = new TreeSet<APIStore>(new APIStoreNameComparator());
apiStores.addAll(getExternalStores(tenantId));
// Retains only the stores that contained in configuration
inputStores.retainAll(apiStores);
boolean exists = false;
if (!apiStores.isEmpty()) {
for (APIStore store : apiStores) {
for (APIStore inputStore : inputStores) {
if (inputStore.getName().equals(store.getName())) {
// If the configured apistore already stored in
// db,ignore adding it again
exists = true;
}
}
if (!exists) {
inputStores.add(store);
}
exists = false;
}
}
return inputStores;
}
Aggregations