Allon Mureinik has uploaded a new change for review. Change subject: core: rv GetEntityPermissionsi[ForUserAndGroups] ......................................................................
core: rv GetEntityPermissionsi[ForUserAndGroups] Change get_entity_permissions and get_entity_permissions_for_user_and_groups to use a return value instead of an output parameter. Although the main reasoning behind this is standardisation and code cleanliness, there is an added performance bonus as this change removes an explicit conversion of the returned uuid to a varchar. Change-Id: I26d94fc765c927763af6bb0fa6775b4aaced6a28 Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/PermissionDAODbFacadeImpl.java M packaging/dbscripts/multi_level_administration_sp.sql 2 files changed, 15 insertions(+), 25 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/16387/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/PermissionDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/PermissionDAODbFacadeImpl.java index 7954a79..7780c79 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/PermissionDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/PermissionDAODbFacadeImpl.java @@ -2,9 +2,7 @@ import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.Types; import java.util.List; -import java.util.Map; import org.apache.commons.lang.NotImplementedException; import org.ovirt.engine.core.common.VdcObjectType; @@ -13,9 +11,7 @@ import org.ovirt.engine.core.common.businessentities.permissions; import org.ovirt.engine.core.compat.Guid; import org.springframework.jdbc.core.RowMapper; -import org.springframework.jdbc.core.SqlOutParameter; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -import org.springframework.jdbc.core.simple.SimpleJdbcCall; /** * <code>PermissionsDAODbFacadeImpl</code> provides a concrete implementation of {@link PermissionDAO} using code from @@ -164,13 +160,9 @@ .addValue("action_group_id", actionGroup.getId()).addValue("object_id", objectId).addValue( "object_type_id", vdcObjectType.getValue()); - String resultKey = "permission_id"; - Map<String, Object> dbResults = - new SimpleJdbcCall(jdbcTemplate).withProcedureName("get_entity_permissions") - .declareParameters(new SqlOutParameter(resultKey, Types.VARCHAR)) - .execute(parameterSource); - - return dbResults.get(resultKey) != null ? new Guid(dbResults.get(resultKey).toString()) : null; + return getCallsHandler().executeRead("get_entity_permissions", + createGuidMapper(), + parameterSource); } @Override @@ -185,17 +177,12 @@ .addValue("group_ids", groupIds) .addValue("action_group_id", actionGroup.getId()) .addValue("object_id", objectId) - .addValue( - "object_type_id", vdcObjectType.getValue()) + .addValue("object_type_id", vdcObjectType.getValue()) .addValue("ignore_everyone", ignoreEveryone); - String resultKey = "permission_id"; - Map<String, Object> dbResults = - new SimpleJdbcCall(jdbcTemplate).withProcedureName("get_entity_permissions_for_user_and_groups") - .declareParameters(new SqlOutParameter(resultKey, Types.VARCHAR)) - .execute(parameterSource); - - return dbResults.get(resultKey) != null ? new Guid(dbResults.get(resultKey).toString()) : null; + return getCallsHandler().executeRead("get_entity_permissions_for_user_and_groups", + createGuidMapper(), + parameterSource); } @Override diff --git a/packaging/dbscripts/multi_level_administration_sp.sql b/packaging/dbscripts/multi_level_administration_sp.sql index b2e2b17..4bfc4a8 100644 --- a/packaging/dbscripts/multi_level_administration_sp.sql +++ b/packaging/dbscripts/multi_level_administration_sp.sql @@ -322,15 +322,16 @@ -- gets entity permissions given the user id, action group id and the object type and id -Create or replace FUNCTION get_entity_permissions(v_user_id UUID,v_action_group_id INTEGER,v_object_id UUID,v_object_type_id INTEGER, -OUT v_permission_id UUID) +Create or replace FUNCTION get_entity_permissions(v_user_id UUID,v_action_group_id INTEGER,v_object_id UUID,v_object_type_id INTEGER) +RETURNS SETOF UUID -- Add the parameters for the stored procedure here AS $procedure$ DECLARE v_everyone_object_id UUID; BEGIN v_everyone_object_id := getGlobalIds('everyone'); -- hardcoded also in MLA Handler - select id INTO v_permission_id from permissions where + RETURN QUERY + select id from permissions where -- get all roles of action role_id in(select role_id from roles_groups where action_group_id = v_action_group_id) -- get allparents of object @@ -343,14 +344,16 @@ -- gets entity permissions given the user id, groups, action group id and the object type and object id Create or replace FUNCTION get_entity_permissions_for_user_and_groups(v_user_id UUID,v_group_ids text,v_action_group_id INTEGER,v_object_id UUID,v_object_type_id INTEGER, -v_ignore_everyone BOOLEAN, OUT v_permission_id UUID) +v_ignore_everyone BOOLEAN) +RETURNS SETOF UUID -- Add the parameters for the stored procedure here AS $procedure$ DECLARE v_everyone_object_id UUID; BEGIN v_everyone_object_id := getGlobalIds('everyone'); -- hardcoded also in MLA Handler - select id INTO v_permission_id from permissions where + RETURN QUERY + select id from permissions where -- get all roles of action role_id in(select role_id from roles_groups where action_group_id = v_action_group_id) -- get allparents of object -- To view, visit http://gerrit.ovirt.org/16387 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I26d94fc765c927763af6bb0fa6775b4aaced6a28 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
