use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.
the class SecurityCatalogService method removeRole.
public Role removeRole(Long roleId) {
// check if role is part of any parent roles, if so parent role should be deleted first.
Set<Role> parentRoles = getParentRoles(roleId);
if (!parentRoles.isEmpty()) {
throw new IllegalStateException("Role is a child role of the following parent role(s): " + parentRoles + ". Parent roles must be deleted first.");
}
// check if role has any users
List<QueryParam> qps = QueryParam.params(UserRole.ROLE_ID, String.valueOf(roleId));
Collection<UserRole> userRoles = listUserRoles(qps);
if (!userRoles.isEmpty()) {
throw new IllegalStateException("Role has users");
}
// remove child role associations
qps = QueryParam.params(RoleHierarchy.PARENT_ID, String.valueOf(roleId));
Collection<RoleHierarchy> roleHierarchies = dao.find(RoleHierarchy.NAMESPACE, qps);
LOG.info("Removing child role association for role id {}", roleId);
roleHierarchies.forEach(rh -> removeChildRole(roleId, rh.getChildId()));
// remove permissions assigned to role
qps = QueryParam.params(AclEntry.SID_ID, String.valueOf(roleId), AclEntry.SID_TYPE, AclEntry.SidType.ROLE.toString());
LOG.info("Removing ACL entries for role id {}", roleId);
listAcls(qps).forEach(aclEntry -> removeAcl(aclEntry.getId()));
Role role = new Role();
role.setId(roleId);
return dao.remove(new StorableKey(Role.NAMESPACE, role.getPrimaryKey()));
}
use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.
the class DashboardCatalogService method getDatasource.
public Datasource getDatasource(Long dashboardId, Long datasourceId) {
Datasource datasource = new Datasource();
datasource.setDashboardId(dashboardId);
datasource.setId(datasourceId);
ensureDashboardExists(dashboardId);
return dao.get(new StorableKey(DATASOURCE_NAMESPACE, datasource.getPrimaryKey()));
}
use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.
the class DashboardCatalogService method removeDatasource.
public Datasource removeDatasource(Long dashboardId, Long datasourceId) {
ensureDashboardExists(dashboardId);
Datasource datasource = new Datasource();
datasource.setDashboardId(dashboardId);
datasource.setId(datasourceId);
return dao.remove(new StorableKey(DATASOURCE_NAMESPACE, datasource.getPrimaryKey()));
}
use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.
the class DashboardCatalogService method removeDashboard.
public Dashboard removeDashboard(Long dashboardId) {
Dashboard dashboard = new Dashboard();
dashboard.setId(dashboardId);
return dao.remove(new StorableKey(DASHBOARD_NAMESPACE, dashboard.getPrimaryKey()));
}
use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.
the class DashboardCatalogService method getDashboard.
public Dashboard getDashboard(Long dashboardId) {
Dashboard dashboard = new Dashboard();
dashboard.setId(dashboardId);
return dao.get(new StorableKey(DASHBOARD_NAMESPACE, dashboard.getPrimaryKey()));
}
Aggregations