Search in sources :

Example 51 with StorableKey

use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.

the class CatalogService method getFile.

public File getFile(Long jarId) {
    File file = new File();
    file.setId(jarId);
    return dao.get(new StorableKey(FILE_NAMESPACE, file.getPrimaryKey()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) File(com.hortonworks.streamline.streams.catalog.File)

Example 52 with StorableKey

use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.

the class SecurityCatalogService method removeChildRole.

public RoleHierarchy removeChildRole(Long parentRoleId, Long childRoleId) {
    validateRoleIds(parentRoleId);
    RoleHierarchy roleHierarchy = new RoleHierarchy();
    roleHierarchy.setParentId(parentRoleId);
    roleHierarchy.setChildId(childRoleId);
    return this.dao.remove(new StorableKey(RoleHierarchy.NAMESPACE, roleHierarchy.getPrimaryKey()));
}
Also used : StorableKey(com.hortonworks.registries.storage.StorableKey) RoleHierarchy(com.hortonworks.streamline.streams.security.catalog.RoleHierarchy)

Example 53 with StorableKey

use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.

the class SecurityCatalogService method getRole.

public Role getRole(Long roleId) {
    Role role = new Role();
    role.setId(roleId);
    return this.dao.get(new StorableKey(Role.NAMESPACE, role.getPrimaryKey()));
}
Also used : UserRole(com.hortonworks.streamline.streams.security.catalog.UserRole) Role(com.hortonworks.streamline.streams.security.catalog.Role) StorableKey(com.hortonworks.registries.storage.StorableKey)

Example 54 with StorableKey

use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.

the class SecurityCatalogService method getUser.

public User getUser(Long userId) {
    User user = new User();
    user.setId(userId);
    return fillRoles(this.dao.<User>get(new StorableKey(User.NAMESPACE, user.getPrimaryKey())));
}
Also used : User(com.hortonworks.streamline.streams.security.catalog.User) StorableKey(com.hortonworks.registries.storage.StorableKey)

Example 55 with StorableKey

use of com.hortonworks.registries.storage.StorableKey in project streamline by hortonworks.

the class SecurityCatalogService method removeUser.

public User removeUser(Long userId) {
    User userToRemove = getUser(userId);
    if (userToRemove != null) {
        if (userToRemove.getRoles() != null) {
            userToRemove.getRoles().forEach(roleName -> {
                Optional<Role> r = getRole(roleName);
                if (r.isPresent()) {
                    removeUserRole(userId, r.get().getId());
                }
            });
        }
        // remove permissions assigned to user
        LOG.debug("Removing ACL entries for user {}", userToRemove);
        List<QueryParam> qps = QueryParam.params(AclEntry.SID_ID, String.valueOf(userId), AclEntry.SID_TYPE, AclEntry.SidType.USER.toString());
        listAcls(qps).forEach(aclEntry -> removeAcl(aclEntry.getId()));
        return dao.remove(new StorableKey(User.NAMESPACE, userToRemove.getPrimaryKey()));
    }
    throw new IllegalArgumentException("No user with id: " + userId);
}
Also used : UserRole(com.hortonworks.streamline.streams.security.catalog.UserRole) Role(com.hortonworks.streamline.streams.security.catalog.Role) User(com.hortonworks.streamline.streams.security.catalog.User) QueryParam(com.hortonworks.registries.common.QueryParam) StorableKey(com.hortonworks.registries.storage.StorableKey)

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