use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebService method setUsers.
@Override
public void setUsers(ProxyPentahoRole proxyRole, ProxyPentahoUser[] assignedUsers) throws UserRoleException {
IPentahoRole role = getDao().getRole(proxyRole.getTenant(), proxyRole.getName());
if (role == null) {
throw new UserRoleException(Messages.getInstance().getErrorString("UserRoleWebService.ERROR_0005_FAILED_TO_FIND_ROLE", // $NON-NLS-1$
proxyRole.getName()));
}
ArrayList<String> userNames = new ArrayList<String>();
for (ProxyPentahoUser proxyUser : assignedUsers) {
userNames.add(proxyUser.getName());
}
getDao().setRoleMembers(proxyRole.getTenant(), proxyRole.getName(), userNames.toArray(new String[0]));
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebService method getRoles.
@Override
public ProxyPentahoRole[] getRoles() throws UserRoleException {
List<ProxyPentahoRole> proxyRoles = new ArrayList<ProxyPentahoRole>();
List<IPentahoRole> roles = getDao().getRoles();
if (roles != null) {
for (IPentahoRole role : roles) {
proxyRoles.add(ProxyPentahoUserRoleHelper.toProxyRole(role));
}
}
return proxyRoles.toArray(new ProxyPentahoRole[0]);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebService method getRolesForUser.
@Override
public ProxyPentahoRole[] getRolesForUser(ProxyPentahoUser proxyUser) throws UserRoleException {
List<ProxyPentahoRole> proxyRoles = new ArrayList<ProxyPentahoRole>();
IPentahoUser user = getDao().getUser(proxyUser.getTenant(), proxyUser.getName());
if (user != null) {
for (IPentahoRole role : getDao().getUserRoles(proxyUser.getTenant(), proxyUser.getName())) {
proxyRoles.add(ProxyPentahoUserRoleHelper.toProxyRole(role));
}
} else {
throw new UserRoleException(Messages.getInstance().getErrorString("UserRoleWebService.ERROR_0004_FAILED_TO_FIND_USER", // $NON-NLS-1$
proxyUser.getName()));
}
return proxyRoles.toArray(new ProxyPentahoRole[0]);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebService method getUsersForRole.
@Override
public ProxyPentahoUser[] getUsersForRole(ProxyPentahoRole proxyRole) throws UserRoleException {
ArrayList<ProxyPentahoUser> users = new ArrayList<ProxyPentahoUser>();
IPentahoRole role = getDao().getRole(proxyRole.getTenant(), proxyRole.getName());
if (role != null) {
for (IPentahoUser user : getDao().getRoleMembers(proxyRole.getTenant(), proxyRole.getName())) {
users.add(ProxyPentahoUserRoleHelper.toProxyUser(user));
}
} else {
throw new UserRoleException(Messages.getInstance().getErrorString("UserRoleWebService.ERROR_0005_FAILED_TO_FIND_ROLE", // $NON-NLS-1$
proxyRole.getName()));
}
return users.toArray(new ProxyPentahoUser[0]);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoRole in project pentaho-platform by pentaho.
the class MockUserRoleDao method getRole.
public IPentahoRole getRole(ITenant tenant, String roleName) throws UncategorizedUserRoleDaoException {
if (tenant == null) {
tenant = getTenant(roleName, false);
roleName = getPrincipalName(roleName, false);
}
if (tenant == null || tenant.getId() == null) {
tenant = getCurrentTenant();
}
HashSet<IPentahoRole> roles = tenantRoles.get(tenant);
if (roles != null) {
for (IPentahoRole role : roles) {
if (role.getName().equals(roleName)) {
return role;
}
}
}
return null;
}
Aggregations