|
|
@ -854,6 +854,28 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
return groupResult;
|
|
|
|
return groupResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int getHierarchicalGroupCount() throws GroupManagementException {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Get groups count");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
return groupDAO.getGroupCount(tenantId, null);
|
|
|
|
|
|
|
|
} catch (GroupManagementDAOException | SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int getGroupCount() throws GroupManagementException {
|
|
|
|
public int getGroupCount() throws GroupManagementException {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -962,6 +984,53 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int getHierarchicalGroupCount(String username, String parentPath) throws GroupManagementException {
|
|
|
|
|
|
|
|
if (username == null || username.isEmpty()) {
|
|
|
|
|
|
|
|
String msg = "Received empty user name for getHierarchicalGroupCount";
|
|
|
|
|
|
|
|
log.error(msg);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
|
|
|
|
log.debug("Get groups count of '" + username + "'");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
UserStoreManager userStoreManager;
|
|
|
|
|
|
|
|
int count;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
|
|
|
userStoreManager = DeviceManagementDataHolder.getInstance().getRealmService().getTenantUserRealm(tenantId)
|
|
|
|
|
|
|
|
.getUserStoreManager();
|
|
|
|
|
|
|
|
if (isAdminUser(username, userStoreManager)) {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
count = groupDAO.getGroupCount(tenantId, null);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
String[] roleList = userStoreManager.getRoleListOfUser(username);
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
|
|
|
|
count = groupDAO.getOwnGroupsCount(username, tenantId, parentPath);
|
|
|
|
|
|
|
|
count += groupDAO.getGroupsCount(roleList, tenantId, parentPath);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while retrieving role list of user '" + username + "'";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while opening db connection to get group count.";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while retrieving group count of user '" + username + "'";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new GroupManagementException(msg, e);
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
GroupManagementDAOFactory.closeConnection();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|