public RoleGroupMap(ActionGroup actionGroup, Guid roleId) { this(); this.id.actionGroup = actionGroup.getId(); this.id.roleId = roleId; }
public RoleGroupMapId(Guid roleId, ActionGroup actionGroup) { this.roleId = roleId; this.actionGroup = actionGroup.getId(); }
public void setActionGroup(ActionGroup actionGroup) { this.id.actionGroup = actionGroup.getId(); }
@Mapping(from = ActionGroup.class, to = Permit.class) public static Permit map(ActionGroup entity, Permit template) { Permit model = template != null ? template : new Permit(); model.setId(Integer.toString(entity.getId())); model.setName(entity.name().toLowerCase()); model.setAdministrative(entity.getRoleType() == RoleType.ADMIN); return model; } }
@Override public RoleGroupMap getByActionGroupAndRole(ActionGroup group, Guid id) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("action_group_id", group.getId()).addValue("role_id", id); return getCallsHandler().executeRead("Get_roles_groups_By_action_group_id_And_By_role_id", roleGroupMapRowMapper, parameterSource); }
@Override public List<VM> getAllForUserAndActionGroup(Guid userID, ActionGroup actionGroup) { return getCallsHandler().executeReadList("GetAllFromVmsForUserAndActionGroup", vmRowMapper, getCustomMapSqlParameterSource().addValue("user_id", userID).addValue("action_group_id", actionGroup.getId())); }
@Override public List<Cluster> getClustersWithPermittedAction(Guid userId, ActionGroup actionGroup) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("user_id", userId).addValue("action_group_id", actionGroup.getId()); return getCallsHandler().executeReadList("fn_perms_get_clusters_with_permitted_action", clusterRowMapper, parameterSource); }
@Override public List<VmTemplate> getTemplatesWithPermittedAction(Guid userId, ActionGroup actionGroup) { return getCallsHandler().executeReadList("fn_perms_get_templates_with_permitted_action", VMTemplateRowMapper.instance, getCustomMapSqlParameterSource() .addValue("user_id", userId).addValue("action_group_id", actionGroup.getId())); }
@Override public void remove(ActionGroup group, Guid id) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("action_group_id", group.getId()).addValue("role_id", id); getCallsHandler().executeModification("Delete_roles_groups", parameterSource); } }
@Override public List<StorageDomain> getPermittedStorageDomainsByStoragePool(Guid userId, ActionGroup actionGroup, Guid storagePoolId) { return getCallsHandler().executeReadList("Getstorage_domains_by_storage_pool_id_with_permitted_action", storageDomainRowMapper, getCustomMapSqlParameterSource() .addValue("user_id", userId) .addValue("action_group_id", actionGroup.getId()) .addValue("storage_pool_id", storagePoolId)); }
@Override protected Permit postPopulate(Permit from) { ActionGroup actionGroup = ActionGroup.ACCESS_IMAGE_STORAGE; from.setId(Integer.toString(actionGroup.getId())); from.setName(actionGroup.name().toLowerCase()); from.setAdministrative(actionGroup.getRoleType() == RoleType.ADMIN); return from; }
@Override public List<StoragePool> getDataCentersWithPermittedActionOnClusters(Guid userId, ActionGroup actionGroup, boolean supportsVirtService, boolean supportsGlusterService) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("user_id", userId) .addValue("action_group_id", actionGroup.getId()) .addValue("supports_virt_service", supportsVirtService) .addValue("supports_gluster_service", supportsGlusterService); return getCallsHandler().executeReadList( "fn_perms_get_storage_pools_with_permitted_action_on_clusters", mapper, parameterSource); }
@Override public void save(RoleGroupMap map) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() .addValue("action_group_id", map.getActionGroup().getId()) .addValue("role_id", map.getRoleId()); getCallsHandler().executeModification("Insert_roles_groups", parameterSource); }
@Override public List<CpuProfile> getAllForCluster(Guid clusterId, Guid userId, boolean isFiltered, ActionGroup actionGroup) { return getCallsHandler().executeReadList("GetCpuProfilesByClusterId", createEntityRowMapper(), getCustomMapSqlParameterSource().addValue("cluster_id", clusterId) .addValue("user_id", userId) .addValue("is_filtered", isFiltered) .addValue("action_group_id", actionGroup.getId())); }
@Test public void testGet() { initResource(resource.parent); for (ActionGroup action : ActionGroup.values()) { resource.id = Integer.toString(action.getId()); verifyPermit(resource.get(), action); } resource.id = "1"; // reset id, because 'resource' is used for multiple tests. }
@Override public Guid getEntityPermissions(Guid adElementId, ActionGroup actionGroup, Guid objectId, VdcObjectType vdcObjectType) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("user_id", adElementId) .addValue("action_group_id", actionGroup.getId()).addValue("object_id", objectId).addValue( "object_type_id", vdcObjectType.getValue()); return getCallsHandler().executeRead("get_entity_permissions", createGuidMapper(), parameterSource); }
private void verifyPermit(Permit permit, ActionGroup action) { assertEquals(Integer.toString(action.getId()), permit.getId()); assertEquals(action.name().toLowerCase(), permit.getName()); assertNotNull(permit.getRole()); assertEquals(ROLE_ID.toString(), permit.getRole().getId()); }
@Override public Guid getEntityPermissionsForUserAndGroups(Guid userId, String groupIds, ActionGroup actionGroup, Guid objectId, VdcObjectType vdcObjectType, boolean ignoreEveryone) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("user_id", userId) .addValue("group_ids", groupIds) .addValue("action_group_id", actionGroup.getId()) .addValue("object_id", objectId) .addValue("object_type_id", vdcObjectType.getValue()) .addValue("ignore_everyone", ignoreEveryone); return getCallsHandler().executeRead("get_entity_permissions_for_user_and_groups", createGuidMapper(), parameterSource); }
@Test public void testAddRole() { setUriInfo(setUpBasicUriExpectations()); setUpCreationExpectations(ActionType.AddRoleWithActionGroups, RoleWithActionGroupsParameters.class, new String[] { "Role.Id", "Role.Name" }, new Object[] { GUIDS[0], NAMES[0] }, true, true, GUIDS[0], QueryType.GetRoleById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0)); Role model = new Role(); model.setName(NAMES[0]); model.setPermits(new Permits()); model.getPermits().getPermits().add(new Permit()); model.getPermits().getPermits().get(0).setId(""+ActionGroup.CREATE_VM.getId()); Response response = collection.add(model); assertEquals(201, response.getStatus()); assertTrue(response.getEntity() instanceof Role); verifyModel((Role) response.getEntity(), 0); }