|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.eclipse.wst.common.uriresolver.internal.util.URIEncoder;
|
|
|
|
|
import org.wso2.carbon.context.CarbonContext;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
@ -41,6 +42,7 @@ import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.UserStoreCountRetriever;
|
|
|
|
|
import org.wso2.carbon.identity.user.store.count.exception.UserStoreCounterException;
|
|
|
|
|
import org.wso2.carbon.user.api.Permission;
|
|
|
|
|
import org.wso2.carbon.user.api.RealmConfiguration;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreManager;
|
|
|
|
|
import org.wso2.carbon.utils.CarbonUtils;
|
|
|
|
@ -412,6 +414,15 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
|
public Response getUserCount() {
|
|
|
|
|
try {
|
|
|
|
|
UserStoreCountRetriever userStoreCountRetrieverService = DeviceMgtAPIUtils.getUserStoreCountRetrieverService();
|
|
|
|
|
RealmConfiguration secondaryRealmConfiguration = CarbonContext.getThreadLocalCarbonContext().getUserRealm().
|
|
|
|
|
getRealmConfiguration().getSecondaryRealmConfig();
|
|
|
|
|
|
|
|
|
|
if (secondaryRealmConfiguration != null) {
|
|
|
|
|
if (!secondaryRealmConfiguration.isPrimary() && !Constants.JDBC_USERSTOREMANAGER.
|
|
|
|
|
equals(secondaryRealmConfiguration.getUserStoreClass().getClass())) {
|
|
|
|
|
return getUserCountViaUserStoreManager();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (userStoreCountRetrieverService != null) {
|
|
|
|
|
long count = userStoreCountRetrieverService.countUsers("");
|
|
|
|
|
if (count != -1) {
|
|
|
|
@ -424,6 +435,10 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
|
String msg =
|
|
|
|
|
"Error occurred while retrieving the count of users that exist within the current tenant";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
|
String msg =
|
|
|
|
|
"Error occurred while retrieving user stores.";
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
}
|
|
|
|
|
return getUserCountViaUserStoreManager();
|
|
|
|
|
}
|
|
|
|
|