Oved Ourfali has uploaded a new change for review. Change subject: core+userportal: get events by VM and template IDs ......................................................................
core+userportal: get events by VM and template IDs This patch changes the current get events by VM and template names, to work with IDs. These queries are used in the user portal. Change-Id: I3c179171f60b74b52cf7a0a7ca7b4b8087b5ceb2 Bug-Url: https://bugzilla.redhat.com/968961 Signed-off-by: Oved Ourfali <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQuery.java D backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQuery.java R backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQuery.java R backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQueryTest.java R backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQueryTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java M packaging/dbscripts/audit_log_sp.sql 13 files changed, 111 insertions(+), 109 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/58/23058/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQuery.java new file mode 100644 index 0000000..58ff1c2 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQuery.java @@ -0,0 +1,19 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.common.queries.IdQueryParameters; + +/** A query to return all the Audit Logs according to a given VM ID */ +public class GetAllAuditLogsByVMIdQuery<P extends IdQueryParameters> extends QueriesCommandBase<P> { + + public GetAllAuditLogsByVMIdQuery(P parameters) { + super(parameters); + } + + /** Actually executes the query, and stores the result in {@link #getQueryReturnValue()} */ + @Override + protected void executeQueryCommand() { + getQueryReturnValue().setReturnValue( + getDbFacade().getAuditLogDao() + .getAllByVMId(getParameters().getId(), getUserID(), getParameters().isFiltered())); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQuery.java deleted file mode 100644 index 12ff60d..0000000 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQuery.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.ovirt.engine.core.bll; - -import org.ovirt.engine.core.common.queries.NameQueryParameters; - -/** A query to return all the Audit Logs according to a given VM name */ -public class GetAllAuditLogsByVMNameQuery<P extends NameQueryParameters> extends QueriesCommandBase<P> { - - public GetAllAuditLogsByVMNameQuery(P parameters) { - super(parameters); - } - - /** Actually executes the query, and stores the result in {@link #getQueryReturnValue()} */ - @Override - protected void executeQueryCommand() { - getQueryReturnValue().setReturnValue( - getDbFacade().getAuditLogDao() - .getAllByVMName(getParameters().getName(), getUserID(), getParameters().isFiltered())); - } -} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateNameQuery.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQuery.java similarity index 61% rename from backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateNameQuery.java rename to backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQuery.java index a52e2f0..eadd386 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateNameQuery.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQuery.java @@ -1,11 +1,11 @@ package org.ovirt.engine.core.bll; -import org.ovirt.engine.core.common.queries.NameQueryParameters; +import org.ovirt.engine.core.common.queries.IdQueryParameters; -/** A query to return all the Audit Logs according to a given VM Template name */ -public class GetAllAuditLogsByVMTemplateNameQuery<P extends NameQueryParameters> extends QueriesCommandBase<P> { +/** A query to return all the Audit Logs according to a given VM Template ID */ +public class GetAllAuditLogsByVMTemplateIdQuery<P extends IdQueryParameters> extends QueriesCommandBase<P> { - public GetAllAuditLogsByVMTemplateNameQuery(P parameters) { + public GetAllAuditLogsByVMTemplateIdQuery(P parameters) { super(parameters); } @@ -13,8 +13,8 @@ @Override protected void executeQueryCommand() { getQueryReturnValue().setReturnValue( - getDbFacade().getAuditLogDao().getAllByVMTemplateName( - getParameters().getName(), + getDbFacade().getAuditLogDao().getAllByVMTemplateId( + getParameters().getId(), getUserID(), getParameters().isFiltered())); } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQueryTest.java similarity index 60% rename from backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQueryTest.java rename to backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQueryTest.java index 9fddb23..71ecad4 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMNameQueryTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMIdQueryTest.java @@ -9,26 +9,26 @@ import org.junit.Test; import org.ovirt.engine.core.common.businessentities.AuditLog; -import org.ovirt.engine.core.common.queries.NameQueryParameters; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dao.AuditLogDAO; -import org.ovirt.engine.core.utils.RandomUtils; -/** A test case for the {@link GetAllAuditLogsByVMNameQuery} class. */ -public class GetAllAuditLogsByVMNameQueryTest extends AbstractUserQueryTest<NameQueryParameters, GetAllAuditLogsByVMNameQuery<? extends NameQueryParameters>> { +/** A test case for the {@link GetAllAuditLogsByVMIdQuery} class. */ +public class GetAllAuditLogsByVMIdQueryTest extends AbstractUserQueryTest<IdQueryParameters, GetAllAuditLogsByVMIdQuery<? extends IdQueryParameters>> { @Test public void testExecuteQueryCommand() { // Mock the Query Parameters - String vmName = RandomUtils.instance().nextString(10, true); - when(getQueryParameters().getName()).thenReturn(vmName); + Guid vmId = Guid.newGuid(); + when(getQueryParameters().getId()).thenReturn(vmId); // Set up the expected result AuditLog expectedResult = new AuditLog(); - expectedResult.setvm_name(vmName); + expectedResult.setvm_id(vmId); // Mock the DAOs AuditLogDAO auditLogDAOMock = mock(AuditLogDAO.class); - when(auditLogDAOMock.getAllByVMName(vmName, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(Collections.singletonList(expectedResult)); + when(auditLogDAOMock.getAllByVMId(vmId, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(Collections.singletonList(expectedResult)); when(getDbFacadeMockInstance().getAuditLogDao()).thenReturn(auditLogDAOMock); getQuery().executeQueryCommand(); diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateNameQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQueryTest.java similarity index 64% rename from backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateNameQueryTest.java rename to backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQueryTest.java index 1b10c81..fe5edd5 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateNameQueryTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllAuditLogsByVMTemplateIdQueryTest.java @@ -9,27 +9,27 @@ import org.junit.Test; import org.ovirt.engine.core.common.businessentities.AuditLog; -import org.ovirt.engine.core.common.queries.NameQueryParameters; +import org.ovirt.engine.core.common.queries.IdQueryParameters; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dao.AuditLogDAO; -import org.ovirt.engine.core.utils.RandomUtils; -/** A test case for the {@link GetAllAuditLogsByVMTemplateNameQuery} class. */ -public class GetAllAuditLogsByVMTemplateNameQueryTest - extends AbstractUserQueryTest<NameQueryParameters, GetAllAuditLogsByVMTemplateNameQuery<? extends NameQueryParameters>> { +/** A test case for the {@link GetAllAuditLogsByVMTemplateIdQuery} class. */ +public class GetAllAuditLogsByVMTemplateIdQueryTest + extends AbstractUserQueryTest<IdQueryParameters, GetAllAuditLogsByVMTemplateIdQuery<? extends IdQueryParameters>> { @Test public void testExecuteQueryCommand() { // Mock the Query Parameters - String vmTemplateName = RandomUtils.instance().nextString(10, true); - when(getQueryParameters().getName()).thenReturn(vmTemplateName); + Guid vmTemplateId = Guid.newGuid(); + when(getQueryParameters().getId()).thenReturn(vmTemplateId); // Set up the expected result AuditLog expectedResult = new AuditLog(); - expectedResult.setvm_template_name(vmTemplateName); + expectedResult.setvm_template_id(vmTemplateId); // Mock the DAOs AuditLogDAO auditLogDAOMock = mock(AuditLogDAO.class); - when(auditLogDAOMock.getAllByVMTemplateName(vmTemplateName, + when(auditLogDAOMock.getAllByVMTemplateId(vmTemplateId, getUser().getId(), getQueryParameters().isFiltered())).thenReturn(Collections.singletonList(expectedResult)); when(getDbFacadeMockInstance().getAuditLogDao()).thenReturn(auditLogDAOMock); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java index 30c2f1b..a489c62 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/VdcQueryType.java @@ -165,8 +165,8 @@ // AuditLog GetAllEventMessages(VdcQueryAuthType.User), - GetAllAuditLogsByVMName(VdcQueryAuthType.User), - GetAllAuditLogsByVMTemplateName(VdcQueryAuthType.User), + GetAllAuditLogsByVMId(VdcQueryAuthType.User), + GetAllAuditLogsByVMTemplateId(VdcQueryAuthType.User), GetAuditLogById, // Search queries diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java index f279e0d..74ce183 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAO.java @@ -48,48 +48,48 @@ List<AuditLog> getAll(Guid userID, boolean isFiltered); /** - * Retrieves all audit log entries for the given VM name. + * Retrieves all audit log entries for the given VM ID. * - * @param vmName - * The name of the vm to retrieve audit logs for * @return the list of entries */ - List<AuditLog> getAllByVMName(String vmName); + List<AuditLog> getAllByVMId(Guid vmId); /** * Retrieves all audit log entries for the given VM name with optional permission filtering. * - * @param vmName - * The name of the vm to retrieve audit logs for + * @param vmId + * The ID of the vm to retrieve audit logs for * @param userID * The ID of the user requesting the information * @param isFiltered * whether the results should be filtered according to the user's permissions * @return the list of entries */ - List<AuditLog> getAllByVMName(String vmName, Guid userID, boolean isFiltered); + List<AuditLog> getAllByVMId(Guid vmId, Guid userID, boolean isFiltered); /** * Retrieves all audit log entries for the given VM Template name. * - * @param vmTemplateName - * The name of the vm template to retrieve audit logs for + * + * @param vmTemplateId + * The ID of the vm template to retrieve audit logs for * @return the list of entries */ - List<AuditLog> getAllByVMTemplateName(String vmTemplateName); + List<AuditLog> getAllByVMTemplateId(Guid vmTemplateId); /** * Retrieves all audit log entries for the given VM Template name with optional permission filtering. * - * @param vmTemplateName - * The name of the vm template to retrieve audit logs for + * + * @param vmTemplateId + * The ID of the vm template to retrieve audit logs for * @param userID * The ID of the user requesting the information * @param isFiltered * whether the results should be filtered according to the user's permissions * @return the list of entries */ - List<AuditLog> getAllByVMTemplateName(String vmTemplateName, Guid userID, boolean isFiltered); + List<AuditLog> getAllByVMTemplateId(Guid vmTemplateId, Guid userID, boolean isFiltered); /** * Saves the provided audit log diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java index 5e8afed..4b13372 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/AuditLogDAODbFacadeImpl.java @@ -65,33 +65,33 @@ } @Override - public List<AuditLog> getAllByVMName(String vmName) { - return getAllByVMName(vmName, null, false); + public List<AuditLog> getAllByVMId(Guid vmId) { + return getAllByVMId(vmId, null, false); } @Override - public List<AuditLog> getAllByVMName(String vmName, Guid userID, boolean isFiltered) { + public List<AuditLog> getAllByVMId(Guid vmId, Guid userID, boolean isFiltered) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() - .addValue("vm_name", vmName) + .addValue("vm_id", vmId) .addValue("user_id", userID) .addValue("is_filtered", isFiltered); - return getCallsHandler().executeReadList("GetAuditLogByVMName", auditLogRowMapper, parameterSource); + return getCallsHandler().executeReadList("GetAuditLogByVMId", auditLogRowMapper, parameterSource); } @Override - public List<AuditLog> getAllByVMTemplateName(String vmName) { - return getAllByVMTemplateName(vmName, null, false); + public List<AuditLog> getAllByVMTemplateId(Guid vmId) { + return getAllByVMTemplateId(vmId, null, false); } @Override - public List<AuditLog> getAllByVMTemplateName(String vmName, Guid userID, boolean isFiltered) { + public List<AuditLog> getAllByVMTemplateId(Guid vmId, Guid userID, boolean isFiltered) { MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource() - .addValue("vm_template_name", vmName) + .addValue("vm_template_id", vmId) .addValue("user_id", userID) .addValue("is_filtered", isFiltered); - return getCallsHandler().executeReadList("GetAuditLogByVMTemplateName", auditLogRowMapper, parameterSource); + return getCallsHandler().executeReadList("GetAuditLogByVMTemplateId", auditLogRowMapper, parameterSource); } @Override diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java index b2a1f8f..a7748d7 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/AuditLogDAOTest.java @@ -28,6 +28,8 @@ private static final String VM_NAME = "rhel5-pool-50"; private static final String VM_TEMPLATE_NAME = "1"; private static final Guid VDS_ID = new Guid("afce7a39-8e8c-4819-ba9c-796d316592e6"); + private static final Guid VM_ID = new Guid("77296e00-0cad-4e5a-9299-008a7b6f4354"); + private static final Guid VM_TEMPLATE_ID = new Guid("1b85420c-b84c-4f29-997e-0eb674b40b79"); private static final long EXISTING_ENTRY_ID = 44291; private static final long EXTERNAL_ENTRY_ID = 44296; private final SimpleDateFormat EXPECTED_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -50,9 +52,9 @@ newAuditLog.setaudit_log_id(44000); newAuditLog.setuser_id(new Guid("9bf7c640-b620-456f-a550-0348f366544b")); newAuditLog.setuser_name("userportal3"); - newAuditLog.setvm_id(new Guid("77296e00-0cad-4e5a-9299-008a7b6f4355")); + newAuditLog.setvm_id(VM_ID); newAuditLog.setvm_name(VM_NAME); - newAuditLog.setvm_template_id(new Guid("1b85420c-b84c-4f29-997e-0eb674b40b79")); + newAuditLog.setvm_template_id(VM_TEMPLATE_ID); newAuditLog.setvm_template_name(VM_TEMPLATE_NAME); newAuditLog.setvds_id(VDS_ID); newAuditLog.setvds_name("magenta-vdsc"); @@ -146,64 +148,64 @@ assertEquals(0, result.size()); } - /** Tests {@link AuditLogDAO#getAllByVMName(String) with a name of a VM that exists */ + /** Tests {@link AuditLogDAO#getAllByVMId(Guid) with a name of a VM that exists */ @Test - public void testGetAllByVMName() { - assertGetByNameValidResults(dao.getAllByVMName(VM_NAME)); + public void testGetAllByVMId() { + assertGetByNameValidResults(dao.getAllByVMId(VM_ID)); } - /** Tests {@link AuditLogDAO#getAllByVMName(String) with a name of a VM that doesn't exist */ + /** Tests {@link AuditLogDAO#getAllByVMId(Guid) with an ID of a VM that doesn't exist */ @Test - public void testGetAllByVMNameInvalidName() { - assertGetByNameInvalidResults(dao.getAllByVMName("There is no such VM!!!")); + public void testGetAllByVMIdInvalidId() { + assertGetByNameInvalidResults(dao.getAllByVMId(Guid.newGuid())); } - /** Tests {@link AuditLogDAO#getAllByVMName(String, Guid, boolean) with a user that has permissions on that VM */ + /** Tests {@link AuditLogDAO#getAllByVMId(Guid, Guid, boolean) with a user that has permissions on that VM */ @Test - public void testGetAllByVMNamePrivilegedUser() { - assertGetByNameValidResults(dao.getAllByVMName(VM_NAME, PRIVILEGED_USER_ID, true)); + public void testGetAllByVMIdPrivilegedUser() { + assertGetByNameValidResults(dao.getAllByVMId(VM_ID, PRIVILEGED_USER_ID, true)); } - /** Tests {@link AuditLogDAO#getAllByVMName(String, Guid, boolean) with a user that doesn't have permissions on that VM, but with the filtering mechanism disabled */ + /** Tests {@link AuditLogDAO#getAllByVMId(Guid, Guid, boolean) with a user that doesn't have permissions on that VM, but with the filtering mechanism disabled */ @Test public void testGetAllByVMNameUnprivilegedUserNoFiltering() { - assertGetByNameValidResults(dao.getAllByVMName(VM_NAME, UNPRIVILEGED_USER_ID, false)); + assertGetByNameValidResults(dao.getAllByVMId(VM_ID, UNPRIVILEGED_USER_ID, false)); } - /** Tests {@link AuditLogDAO#getAllByVMName(String, Guid, boolean) with a user that doesn't have permissions on that VM */ + /** Tests {@link AuditLogDAO#getAllByVMId(Guid, Guid, boolean) with a user that doesn't have permissions on that VM */ @Test public void testGetAllByVMNameUnprivilegedUserFiltering() { - assertGetByNameInvalidResults(dao.getAllByVMName(VM_NAME, UNPRIVILEGED_USER_ID, true)); + assertGetByNameInvalidResults(dao.getAllByVMId(VM_ID, UNPRIVILEGED_USER_ID, true)); } - /** Tests {@link AuditLogDAO#getAllByVMTemplateName(String) with a name of a VM Template that exists */ + /** Tests {@link AuditLogDAO#getAllByVMTemplateId(org.ovirt.engine.core.compat.Guid) with an ID of a VM Template that exists */ @Test public void testGetAllByVMTemplateName() { - assertGetByNameValidResults(dao.getAllByVMTemplateName(VM_TEMPLATE_NAME)); + assertGetByNameValidResults(dao.getAllByVMTemplateId(VM_TEMPLATE_ID)); } - /** Tests {@link AuditLogDAO#getAllByVMTemplateName(String) with a name of a VM Template that doesn't exist */ + /** Tests {@link AuditLogDAO#getAllByVMTemplateId(org.ovirt.engine.core.compat.Guid) with a an ID of a VM Template that doesn't exist */ @Test - public void testGetAllByVMTemplateNameInvalidName() { - assertGetByNameInvalidResults(dao.getAllByVMTemplateName("There is no such VM!!!")); + public void testGetAllByVMTemplateIdInvalidId() { + assertGetByNameInvalidResults(dao.getAllByVMTemplateId(Guid.newGuid())); } - /** Tests {@link AuditLogDAO#getAllByVMTemplateName(String, Guid, boolean) with a user that has permissions on that VM Template */ + /** Tests {@link AuditLogDAO#getAllByVMTemplateId(org.ovirt.engine.core.compat.Guid, org.ovirt.engine.core.compat.Guid, boolean) with a user that has permissions on that VM Template */ @Test - public void testGetAllByVMTemplateNamePrivilegedUser() { - assertGetByNameValidResults(dao.getAllByVMTemplateName(VM_TEMPLATE_NAME, PRIVILEGED_USER_ID, true)); + public void testGetAllByVMTemplateIdPrivilegedUser() { + assertGetByNameValidResults(dao.getAllByVMTemplateId(VM_TEMPLATE_ID, PRIVILEGED_USER_ID, true)); } - /** Tests {@link AuditLogDAO#getAllByVMTemplateName(String, Guid, boolean) with a user that doesn't have permissions on that VM Template, but with the filtering mechanism disabled */ + /** Tests {@link AuditLogDAO#getAllByVMTemplateId(org.ovirt.engine.core.compat.Guid, org.ovirt.engine.core.compat.Guid, boolean) with a user that doesn't have permissions on that VM Template, but with the filtering mechanism disabled */ @Test - public void testGetAllByVMTemplateNameUnprivilegedUserNoFiltering() { - assertGetByNameValidResults(dao.getAllByVMTemplateName(VM_TEMPLATE_NAME, UNPRIVILEGED_USER_ID, false)); + public void testGetAllByVMTemplateIdUnprivilegedUserNoFiltering() { + assertGetByNameValidResults(dao.getAllByVMTemplateId(VM_TEMPLATE_ID, UNPRIVILEGED_USER_ID, false)); } - /** Tests {@link AuditLogDAO#getAllByVMTemplateName(String, Guid, boolean) with a user that doesn't have permissions on that VM Template */ + /** Tests {@link AuditLogDAO#getAllByVMTemplateId(org.ovirt.engine.core.compat.Guid, org.ovirt.engine.core.compat.Guid, boolean) with a user that doesn't have permissions on that VM Template */ @Test - public void testGetAllByVMTemplateNameUnprivilegedUserFiltering() { - assertGetByNameInvalidResults(dao.getAllByVMTemplateName(VM_TEMPLATE_NAME, UNPRIVILEGED_USER_ID, true)); + public void testGetAllByVMTemplateIdUnprivilegedUserFiltering() { + assertGetByNameInvalidResults(dao.getAllByVMTemplateId(VM_TEMPLATE_ID, UNPRIVILEGED_USER_ID, true)); } private static void assertGetByNameValidResults(List<AuditLog> results) { diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java index 9777bca..4be44bc 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java @@ -35,25 +35,25 @@ } @Override - public List<AuditLog> getAllByVMName(String vmName) { + public List<AuditLog> getAllByVMId(Guid vmId) { // TODO Auto-generated method stub return null; } @Override - public List<AuditLog> getAllByVMName(String vmName, Guid userID, boolean isFiltered) { + public List<AuditLog> getAllByVMId(Guid vmId, Guid userID, boolean isFiltered) { // TODO Auto-generated method stub return null; } @Override - public List<AuditLog> getAllByVMTemplateName(String vmTemplateName) { + public List<AuditLog> getAllByVMTemplateId(Guid vmTemplateId) { // TODO Auto-generated method stub return null; } @Override - public List<AuditLog> getAllByVMTemplateName(String vmTemplateName, Guid userID, boolean isFiltered) { + public List<AuditLog> getAllByVMTemplateId(Guid vmTemplateId, Guid userID, boolean isFiltered) { // TODO Auto-generated method stub return null; } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java index 14d93b4..feca3c9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/UserPortalTemplateEventListModel.java @@ -5,7 +5,7 @@ import org.ovirt.engine.core.common.businessentities.AuditLog; import org.ovirt.engine.core.common.businessentities.VmTemplate; -import org.ovirt.engine.core.common.queries.NameQueryParameters; +import org.ovirt.engine.core.common.queries.IdQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.ui.uicommonweb.Linq; @@ -17,8 +17,8 @@ return; } - super.syncSearch(VdcQueryType.GetAllAuditLogsByVMTemplateName, - new NameQueryParameters(getEntity().getName())); + super.syncSearch(VdcQueryType.GetAllAuditLogsByVMTemplateId, + new IdQueryParameters(getEntity().getId())); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java index 201be6c..aeceaaa 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UserPortalVmEventListModel.java @@ -5,7 +5,7 @@ import org.ovirt.engine.core.common.businessentities.AuditLog; import org.ovirt.engine.core.common.businessentities.VM; -import org.ovirt.engine.core.common.queries.NameQueryParameters; +import org.ovirt.engine.core.common.queries.IdQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.ui.uicommonweb.Linq; @@ -19,7 +19,7 @@ VM vm = (VM) getEntity(); - super.syncSearch(VdcQueryType.GetAllAuditLogsByVMName, new NameQueryParameters(vm.getName())); + super.syncSearch(VdcQueryType.GetAllAuditLogsByVMId, new IdQueryParameters(vm.getId())); } @Override diff --git a/packaging/dbscripts/audit_log_sp.sql b/packaging/dbscripts/audit_log_sp.sql index 323c624..d372ef4 100644 --- a/packaging/dbscripts/audit_log_sp.sql +++ b/packaging/dbscripts/audit_log_sp.sql @@ -159,12 +159,12 @@ END; $procedure$ LANGUAGE plpgsql; -Create or replace FUNCTION GetAuditLogByVMName(v_vm_name VARCHAR, v_user_id UUID, v_is_filtered BOOLEAN) RETURNS SETOF audit_log STABLE +Create or replace FUNCTION GetAuditLogByVMId(v_vm_id UUID, v_user_id UUID, v_is_filtered BOOLEAN) RETURNS SETOF audit_log STABLE AS $procedure$ BEGIN RETURN QUERY SELECT * FROM audit_log - WHERE not deleted and vm_name = v_vm_name + WHERE not deleted and vm_id = v_vm_id AND (NOT v_is_filtered OR EXISTS (SELECT 1 FROM user_vm_permissions_view WHERE user_id = v_user_id AND entity_id = vm_id)); @@ -173,12 +173,12 @@ END; $procedure$ LANGUAGE plpgsql; -Create or replace FUNCTION GetAuditLogByVMTemplateName(v_vm_template_name VARCHAR, v_user_id UUID, v_is_filtered BOOLEAN) RETURNS SETOF audit_log STABLE +Create or replace FUNCTION GetAuditLogByVMTemplateId(v_vm_template_id UUID, v_user_id UUID, v_is_filtered BOOLEAN) RETURNS SETOF audit_log STABLE AS $procedure$ BEGIN RETURN QUERY SELECT * FROM audit_log - WHERE not deleted and vm_template_name = v_vm_template_name + WHERE not deleted and vm_template_id = v_vm_template_id AND (NOT v_is_filtered OR EXISTS (SELECT 1 FROM user_vm_template_permissions_view WHERE user_id = v_user_id AND entity_id = vm_template_id)); -- To view, visit http://gerrit.ovirt.org/23058 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3c179171f60b74b52cf7a0a7ca7b4b8087b5ceb2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Oved Ourfali <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
