Merge pull request #808 from hasuniea/master

Fixing issue wso2/product-iot#527
revert-70aa11f8
Harshan Liyanage 8 years ago committed by GitHub
commit 188c80f52a

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

@ -29,6 +29,7 @@ public class Constants {
public static final String PRIMARY_USER_STORE = "PRIMARY"; public static final String PRIMARY_USER_STORE = "PRIMARY";
public static final String DEFAULT_STREAM_VERSION = "1.0.0"; public static final String DEFAULT_STREAM_VERSION = "1.0.0";
public static final String SCOPE = "scope"; public static final String SCOPE = "scope";
public static final String JDBC_USERSTOREMANAGER = "org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager";
public final class ErrorMessages { public final class ErrorMessages {

Loading…
Cancel
Save