use of com.hortonworks.registries.common.QueryParam 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);
}
use of com.hortonworks.registries.common.QueryParam 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.common.QueryParam in project streamline by hortonworks.
the class DashboardCatalogResource method listWidgets.
@GET
@Path("/{dashboardId}/widgets")
@Timed
public Response listWidgets(@PathParam("dashboardId") Long dashboardId, @Context UriInfo uriInfo) {
List<QueryParam> queryParams = buildDashboardIdAwareQueryParams(dashboardId, uriInfo);
Collection<Widget> widgets = dashboardCatalogService.listWidgets(queryParams);
if (widgets != null) {
List<WidgetDto> dtos = new ArrayList<>();
widgets.forEach(widget -> {
WidgetDto dto = WidgetDto.fromWidget(widget);
dto.setDatasourceIds(dashboardCatalogService.getWidgetDatasourceMapping(widget));
dtos.add(dto);
});
return WSUtils.respondEntities(dtos, OK);
}
throw EntityNotFoundException.byFilter(queryParams.toString());
}
use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.
the class DashboardCatalogResource method buildDashboardIdAwareQueryParams.
public static List<QueryParam> buildDashboardIdAwareQueryParams(Long dashboardId, UriInfo uriInfo) {
List<QueryParam> queryParams = new ArrayList<>();
queryParams.add(new QueryParam(Dashboard.DASHBOARD_ID, dashboardId.toString()));
if (uriInfo != null) {
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
if (!params.isEmpty()) {
queryParams.addAll(WSUtils.buildQueryParameters(params));
}
}
return queryParams;
}
use of com.hortonworks.registries.common.QueryParam in project streamline by hortonworks.
the class StormTopologyDependenciesHandler method visit.
@Override
public void visit(RulesProcessor rulesProcessor) {
Set<UDF> udfsToShip = new HashSet<>();
for (Rule rule : rulesProcessor.getRules()) {
for (Udf udf : rule.getReferredUdfs()) {
List<QueryParam> qps = QueryParam.params(UDF.NAME, udf.getName());
// The null check for backward compatibility
if (udf.getClassName() != null) {
qps.add(new QueryParam(UDF.CLASSNAME, udf.getClassName()));
}
// The null check for backward compatibility
if (udf.getType() != null) {
qps.add(new QueryParam(UDF.TYPE, udf.getType().toString()));
}
Collection<UDF> udfs = catalogService.listUDFs(qps);
if (udfs.size() > 1) {
throw new IllegalStateException("Multiple UDF definitions for :" + udf);
} else if (udfs.size() == 1) {
udfsToShip.add(udfs.iterator().next());
} else {
throw new IllegalStateException("No catalog entity for udf: '" + udf + "'. " + "May be the UDF information is not bootstrapped or got deleted.");
}
}
for (UDF udf : udfsToShip) {
extraJars.add(udf.getJarStoragePath());
}
}
resourceNames.addAll(rulesProcessor.getExtraResources());
handleBundleForStreamlineComponent(rulesProcessor);
}
Aggregations