Search in sources :

Example 1 with GroupEntity

use of org.activiti.engine.impl.persistence.entity.GroupEntity in project carbon-business-process by wso2.

the class BPSGroupIdentityManager method findGroupsByUser.

@Override
public List<Group> findGroupsByUser(String userId) {
    List<Group> groups = new ArrayList<Group>();
    try {
        String[] roles = userStoreManager.getRoleListOfUser(userId);
        for (String role : roles) {
            Group group = new GroupEntity(role);
            groups.add(group);
        }
    } catch (UserStoreException e) {
        String msg = "Failed to get roles of the user: " + userId + ". Returning an empty roles list.";
        log.error(msg, e);
    }
    return groups;
}
Also used : Group(org.activiti.engine.identity.Group) GroupEntity(org.activiti.engine.impl.persistence.entity.GroupEntity) ArrayList(java.util.ArrayList) UserStoreException(org.wso2.carbon.user.api.UserStoreException)

Example 2 with GroupEntity

use of org.activiti.engine.impl.persistence.entity.GroupEntity in project carbon-business-process by wso2.

the class BPSUserIdentityManager method findGroupsByUser.

@Override
public List<Group> findGroupsByUser(String userId) {
    List<Group> groups = new ArrayList<Group>();
    try {
        String[] userNameTokens = userId.split("@");
        int tenantId = BPMNConstants.SUPER_TENANT_ID;
        if (userNameTokens.length > 1) {
            TenantInfoBean tenantInfoBean = tenantMgtAdminService.getTenant(userNameTokens[userNameTokens.length - 1]);
            if (tenantInfoBean != null) {
                tenantId = tenantInfoBean.getTenantId();
            } else {
                log.error("Could not retrieve tenant ID for tenant domain : " + userNameTokens[userNameTokens.length - 1]);
                return new ArrayList<Group>();
            }
        }
        String[] roles = registryService.getUserRealm(tenantId).getUserStoreManager().getRoleListOfUser(userId);
        for (String role : roles) {
            Group group = new GroupEntity(role);
            groups.add(group);
        }
    } catch (UserStoreException e) {
        String msg = "Failed to get roles of the user: " + userId + ". Returning an empty roles list.";
        log.error(msg, e);
    } catch (Exception e) {
        log.error("error retrieving user tenant info", e);
    }
    return groups;
}
Also used : Group(org.activiti.engine.identity.Group) GroupEntity(org.activiti.engine.impl.persistence.entity.GroupEntity) ArrayList(java.util.ArrayList) UserStoreException(org.wso2.carbon.user.api.UserStoreException) TenantInfoBean(org.wso2.carbon.stratos.common.beans.TenantInfoBean) UserStoreException(org.wso2.carbon.user.api.UserStoreException) RegistryException(org.wso2.carbon.registry.core.exceptions.RegistryException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) BPMNAuthenticationException(org.wso2.carbon.bpmn.core.exception.BPMNAuthenticationException)

Aggregations

ArrayList (java.util.ArrayList)2 Group (org.activiti.engine.identity.Group)2 GroupEntity (org.activiti.engine.impl.persistence.entity.GroupEntity)2 UserStoreException (org.wso2.carbon.user.api.UserStoreException)2 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 BPMNAuthenticationException (org.wso2.carbon.bpmn.core.exception.BPMNAuthenticationException)1 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)1 TenantInfoBean (org.wso2.carbon.stratos.common.beans.TenantInfoBean)1