Search in sources :

Example 56 with StorableKey

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()));
}
Also used : UserRole(com.hortonworks.streamline.streams.security.catalog.UserRole) Role(com.hortonworks.streamline.streams.security.catalog.Role) QueryParam(com.hortonworks.registries.common.QueryParam) UserRole(com.hortonworks.streamline.streams.security.catalog.UserRole) StorableKey(com.hortonworks.registries.storage.StorableKey) RoleHierarchy(com.hortonworks.streamline.streams.security.catalog.RoleHierarchy)

Example 57 with StorableKey

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()));
}
Also used : Datasource(com.hortonworks.streamline.registries.dashboard.entites.Datasource) StorableKey(com.hortonworks.registries.storage.StorableKey)

Example 58 with StorableKey

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()));
}
Also used : Datasource(com.hortonworks.streamline.registries.dashboard.entites.Datasource) StorableKey(com.hortonworks.registries.storage.StorableKey)

Example 59 with StorableKey

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()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) Dashboard(com.hortonworks.streamline.registries.dashboard.entites.Dashboard)

Example 60 with StorableKey

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()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) Dashboard(com.hortonworks.streamline.registries.dashboard.entites.Dashboard)

Aggregations

StorableKey (com.hortonworks.registries.storage.StorableKey)72 Schema (com.hortonworks.registries.common.Schema)6 OrderByField (com.hortonworks.registries.storage.OrderByField)6 PrimaryKey (com.hortonworks.registries.storage.PrimaryKey)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)5 QueryParam (com.hortonworks.registries.common.QueryParam)4 StorageManager (com.hortonworks.registries.storage.StorageManager)4 SchemaNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaNotFoundException)3 Storable (com.hortonworks.registries.storage.Storable)3 StorageException (com.hortonworks.registries.storage.exception.StorageException)3 Role (com.hortonworks.streamline.streams.security.catalog.Role)3 UserRole (com.hortonworks.streamline.streams.security.catalog.UserRole)3 CacheBuilder (com.google.common.cache.CacheBuilder)2 SchemaVersionInfoCache (com.hortonworks.registries.schemaregistry.cache.SchemaVersionInfoCache)2 CacheBackedStorageManager (com.hortonworks.registries.storage.CacheBackedStorageManager)2 StorageWriter (com.hortonworks.registries.storage.cache.writer.StorageWriter)2 AlreadyExistsException (com.hortonworks.registries.storage.exception.AlreadyExistsException)2 IllegalQueryParameterException (com.hortonworks.registries.storage.exception.IllegalQueryParameterException)2 MySqlSelectQuery (com.hortonworks.registries.storage.impl.jdbc.provider.mysql.query.MySqlSelectQuery)2