Ravi Nori has uploaded a new change for review. Change subject: engine ,webadmin: Ability to dismiss alerts and events from web-admin portal ......................................................................
engine ,webadmin: Ability to dismiss alerts and events from web-admin portal >From the webadmin portal, the user should have the ability to dismiss the unwanted/undesired Alerts. A x is provided besides the alert to remove it from the alerts table in the footer. A right click option clear all is available to clear all dismissed alerts and show all alerts. Two backend commands have been added RemoveAuditLogById and ClearAllDismissedAuditLog to support the actions from webadmin. A new action group AUDIT_LOG_MANAGEMENT has been added and all Admin users are given access to this action. When creating a new role the role can be assigned the new permit. Change-Id: I3873226b64049170743d4bf0add531d0fda2a0cb Bug-Url: https://bugzilla.redhat.com/988392 Signed-off-by: Ravi Nori <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java A backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RemoveAuditLogByIdParameters.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.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/main/resources/bundles/AppErrors.properties M backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/AuditLogDaoMocker.java M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java A frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageButtonCell.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/roles_ui/RoleTreeView.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M packaging/dbscripts/audit_log_sp.sql A packaging/dbscripts/upgrade/03_05_0290_add_audit_log_operation_action_group_and_roles.sql 24 files changed, 438 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/26722/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java new file mode 100644 index 0000000..f3752dc --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ClearAllDismissedAuditLogsCommand.java @@ -0,0 +1,41 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.VdcActionParametersBase; +import org.ovirt.engine.core.common.businessentities.ActionGroup; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; + +import java.util.Collections; +import java.util.List; + +public class ClearAllDismissedAuditLogsCommand<T extends VdcActionParametersBase> extends CommandBase<T> { + public ClearAllDismissedAuditLogsCommand(T parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + return true; + } + + @Override + protected void executeCommand() { + DbFacade.getInstance().getAuditLogDao().clearAllDismissed(); + setSucceeded(true); + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + return Collections.singletonList(new PermissionSubject(Guid.SYSTEM, + VdcObjectType.System, + ActionGroup.AUDIT_LOG_MANAGEMENT)); + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return getSucceeded() ? AuditLogType.USER_CLEAR_ALL_DISMISSED_AUDIT_LOG : AuditLogType.USER_CLEAR_ALL_DISMISSED_AUDIT_LOG_FAILED; + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java new file mode 100644 index 0000000..32c0af8 --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveAuditLogByIdCommand.java @@ -0,0 +1,48 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.VdcObjectType; +import org.ovirt.engine.core.common.action.RemoveAuditLogByIdParameters; +import org.ovirt.engine.core.common.businessentities.ActionGroup; +import org.ovirt.engine.core.common.errors.VdcBllMessages; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; + +import java.util.Collections; +import java.util.List; + +public class RemoveAuditLogByIdCommand<T extends RemoveAuditLogByIdParameters> extends CommandBase<T> { + public RemoveAuditLogByIdCommand(T parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + if (getParameters().getAuditLogId() == -1 || DbFacade.getInstance().getAuditLogDao().get(getParameters().getAuditLogId()) == null) { + addCanDoActionMessage(VdcBllMessages.AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST); + return false; + } + + return true; + } + + @Override + protected void executeCommand() { + DbFacade.getInstance().getAuditLogDao() + .remove(getParameters().getAuditLogId()); + setSucceeded(true); + } + + @Override + public List<PermissionSubject> getPermissionCheckSubjects() { + return Collections.singletonList(new PermissionSubject(Guid.SYSTEM, + VdcObjectType.System, + ActionGroup.AUDIT_LOG_MANAGEMENT)); + } + + @Override + public AuditLogType getAuditLogTypeValue() { + return getSucceeded() ? AuditLogType.USER_REMOVE_AUDIT_LOG : AuditLogType.USER_REMOVE_AUDIT_LOG_FAILED; + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index e61fbe4..bd6009f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -983,7 +983,13 @@ // External scheduler EXTERNAL_SCHEDULER_PLUGIN_ERROR(10500, AuditLogSeverity.ERROR), - EXTERNAL_SCHEDULER_ERROR(10501, AuditLogSeverity.ERROR); + EXTERNAL_SCHEDULER_ERROR(10501, AuditLogSeverity.ERROR), + + // Audit Log + USER_REMOVE_AUDIT_LOG(10600), + USER_REMOVE_AUDIT_LOG_FAILED(10601, AuditLogSeverity.ERROR), + USER_CLEAR_ALL_DISMISSED_AUDIT_LOG(10602), + USER_CLEAR_ALL_DISMISSED_AUDIT_LOG_FAILED(10603, AuditLogSeverity.ERROR); private int intValue; // indicates time interval in seconds on which identical events from same instance are suppressed. diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RemoveAuditLogByIdParameters.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RemoveAuditLogByIdParameters.java new file mode 100644 index 0000000..7308d74 --- /dev/null +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RemoveAuditLogByIdParameters.java @@ -0,0 +1,22 @@ +package org.ovirt.engine.core.common.action; + +import java.io.Serializable; + +public class RemoveAuditLogByIdParameters extends VdcActionParametersBase implements Serializable { + private static final long serialVersionUID = 7211692656127711421L; + private long auditLogId; + + public RemoveAuditLogByIdParameters() {} + + public RemoveAuditLogByIdParameters(long auditLogId) { + this.auditLogId = auditLogId; + } + + public void setAuditLogId(long auditLogId) { + this.auditLogId = auditLogId; + } + + public long getAuditLogId() { + return auditLogId; + } +} diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index 872b6c5..5b49509 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -344,7 +344,11 @@ EditIscsiBond(2001, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), RemoveIscsiBond(2002, ActionGroup.EDIT_STORAGE_POOL_CONFIGURATION, false, QuotaDependency.NONE), - SetHaMaintenance(2050, ActionGroup.MANIPULATE_HOST, false, QuotaDependency.NONE); + SetHaMaintenance(2050, ActionGroup.MANIPULATE_HOST, false, QuotaDependency.NONE), + + // Audit Log + RemoveAuditLogById(2100, false, QuotaDependency.NONE), + ClearAllDismissedAuditLogs(2101, false, QuotaDependency.NONE); private int intValue; private ActionGroup actionGroup; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java index 15aee11..5aeec1e 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionGroup.java @@ -127,6 +127,10 @@ // Event notification management action group EVENT_NOTIFICATION_MANAGEMENT(1303, RoleType.ADMIN, false), + + // audit log management action group + AUDIT_LOG_MANAGEMENT(1304, RoleType.ADMIN, false), + // affinity group CRUD commands MANIPULATE_AFFINITY_GROUPS(1550, RoleType.ADMIN, true, ApplicationMode.VirtOnly); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 602778b..3ba3502 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -620,6 +620,7 @@ TAGS_SPECIFY_TAG_IS_NOT_EXISTS(ErrorType.BAD_PARAMETERS), TAGS_SPECIFY_TAG_IS_IN_USE(ErrorType.CONFLICT), TAGS_SPECIFIED_TAG_CANNOT_BE_THE_PARENT_OF_ITSELF(ErrorType.CONFLICT), + AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST(ErrorType.BAD_PARAMETERS), TAGS_CANNOT_REMOVE_TAG_NOT_EXIST(ErrorType.BAD_PARAMETERS), NETWORK_CANNOT_CONTAIN_BOND_NAME(ErrorType.BAD_PARAMETERS), VMPAYLOAD_INVALID_PAYLOAD_TYPE(ErrorType.CONFLICT), 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 74ce183..b42c23d 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 @@ -150,4 +150,10 @@ * @return number of seconds (0 or negative value if we can perform operation immediately) */ public int getTimeToWaitForNextPmOp(String vdsName, String event); + + /** + * Clears all previously dismissed audit log entries. All audit logs + * delete flag will be set back to false. + */ + void clearAllDismissed(); } 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 4b13372..b7934f0 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 @@ -196,6 +196,11 @@ return dbResults.get(resultKey) != null ? ((Integer) dbResults.get(resultKey)).intValue() : 0; } + @Override + public void clearAllDismissed() { + getCallsHandler().executeModification("ClearAllDismissedAuditLogs", getCustomMapSqlParameterSource()); + } + private static class AuditLogRowMapper implements RowMapper<AuditLog> { @Override diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 3bd2728..25e66d9 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -833,6 +833,7 @@ CANNOT_REMOVE_STORAGE_DOMAIN_INVALID_HOST_ID=Can not Remove Storage Domain - the underlying Host ID is invalid. ERROR_CANNOT_DEACTIVATE_MASTER_WITH_LOCKED_DOMAINS=You are trying to deactivate a Master storage domain while there are locked domains in the Data Center. Please wait for the operations on those domains to finish first. TAGS_CANNOT_REMOVE_TAG_NOT_EXIST=Cannot remove tag. Tag does not exist. +AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST=Cannot remove audit log. Audit Log does not exist. VAR__TYPE__VM__CLUSTER=$type VM Cluster VDS_FENCE_OPERATION_FAILED=Cannot ${action} ${type}. Fence operation failed. VM_CANNOT_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO=Cannot ${action} without active ISO domain. diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java index b0b9a99..439ae0f 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/model/PermitType.java @@ -113,6 +113,7 @@ TAG_MANAGEMENT, BOOKMARK_MANAGEMENT, EVENT_NOTIFICATION_MANAGEMENT, + AUDIT_LOG_MANAGEMENT, // affinity groups CRUD commands MANIPULATE_AFFINITY_GROUPS; diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java index fea2859..ff9d19f 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/PermitMapper.java @@ -182,6 +182,8 @@ return PermitType.ACCESS_IMAGE_STORAGE; case TAG_MANAGEMENT: return PermitType.TAG_MANAGEMENT; + case AUDIT_LOG_MANAGEMENT: + return PermitType.AUDIT_LOG_MANAGEMENT; case BOOKMARK_MANAGEMENT: return PermitType.BOOKMARK_MANAGEMENT; case EVENT_NOTIFICATION_MANAGEMENT: @@ -336,6 +338,8 @@ return ActionGroup.ACCESS_IMAGE_STORAGE; case TAG_MANAGEMENT: return ActionGroup.TAG_MANAGEMENT; + case AUDIT_LOG_MANAGEMENT: + return ActionGroup.AUDIT_LOG_MANAGEMENT; case BOOKMARK_MANAGEMENT: return ActionGroup.BOOKMARK_MANAGEMENT; case EVENT_NOTIFICATION_MANAGEMENT: 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 4be44bc..7f0d723 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 @@ -104,4 +104,8 @@ return null; } + @Override + public void clearAllDismissed() { + } + } diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 3e85693..4212797 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -2260,6 +2260,9 @@ @DefaultStringValue("Cannot remove tag. Tag does not exist.") String TAGS_CANNOT_REMOVE_TAG_NOT_EXIST(); + @DefaultStringValue("Cannot remove audit log. Audit Log does not exist.") + String AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST(); + @DefaultStringValue("${type} VM Cluster.") String VAR__TYPE__VM__CLUSTER(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageButtonCell.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageButtonCell.java new file mode 100644 index 0000000..9b5ff7a --- /dev/null +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/table/column/ImageButtonCell.java @@ -0,0 +1,94 @@ +package org.ovirt.engine.ui.common.widget.table.column; + +import com.google.gwt.cell.client.AbstractCell; +import com.google.gwt.cell.client.ValueUpdater; +import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.EventTarget; +import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.resources.client.ImageResource; +import com.google.gwt.safehtml.shared.SafeHtml; +import com.google.gwt.safehtml.shared.SafeHtmlBuilder; +import com.google.gwt.safehtml.shared.SafeHtmlUtils; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.AbstractImagePrototype; +import org.ovirt.engine.ui.common.utils.ElementIdUtils; +import org.ovirt.engine.ui.uicommonweb.UICommand; + +/** + * Cell that renders ActionButtonDefinition-like image buttons. + * + * @param <T> + * The data type of the cell (the model) + */ +public abstract class ImageButtonCell<T> extends AbstractCell<T> { + + private final SafeHtml imageHtml; + + // DOM element ID settings for the text container element + private String elementIdPrefix = DOM.createUniqueId(); + private String columnId; + + public ImageButtonCell(ImageResource image) { + super("click"); //$NON-NLS-1$ + this.imageHtml = SafeHtmlUtils.fromTrustedString(AbstractImagePrototype.create(image).getHTML()); + } + + public void setElementIdPrefix(String elementIdPrefix) { + this.elementIdPrefix = elementIdPrefix; + } + + public void setColumnId(String columnId) { + this.columnId = columnId; + } + + @Override + public void onBrowserEvent(Context context, Element parent, T value, NativeEvent event, ValueUpdater<T> valueUpdater) { + super.onBrowserEvent(context, parent, value, event, valueUpdater); + + EventTarget eventTarget = event.getEventTarget(); + if (!Element.is(eventTarget)) { + return; + } + + if ("click".equals(event.getType())) { //$NON-NLS-1$ + onClick(value); + } + } + + @Override + public void render(Context context, T value, SafeHtmlBuilder sb) { + sb.appendHtmlConstant("<span id=\"" //$NON-NLS-1$ + + ElementIdUtils.createTableCellElementId(elementIdPrefix, columnId, context) + + "\" style=\"vertical-align: middle;\" title=\"" //$NON-NLS-1$ + + SafeHtmlUtils.htmlEscape(getTitle(value)) + + "\">"); //$NON-NLS-1$ + sb.append(imageHtml); + sb.appendHtmlConstant("</span>"); //$NON-NLS-1$ + } + + /** + * + * @param value + * @return + */ + protected abstract String getTitle(T value); + + /** + * Get the UICommand associated with the button. + * @param value + * @return + */ + protected abstract UICommand resolveCommand(T value); + + /** + * Execute the click command. + * @param value + */ + protected void onClick(T value) { + UICommand command = resolveCommand(value); + if (command != null) { + command.execute(); + } + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/roles_ui/RoleTreeView.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/roles_ui/RoleTreeView.java index d8a566b..9cc7bde 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/roles_ui/RoleTreeView.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/roles_ui/RoleTreeView.java @@ -294,6 +294,7 @@ new RoleNode(ActionGroup.TAG_MANAGEMENT, getConstants().allowToManageTags()), new RoleNode(ActionGroup.BOOKMARK_MANAGEMENT, getConstants().allowToManageBookmarks()), new RoleNode(ActionGroup.EVENT_NOTIFICATION_MANAGEMENT, getConstants().allowToManageEventNotifications()), + new RoleNode(ActionGroup.AUDIT_LOG_MANAGEMENT, getConstants().allowToManageAuditLogs()), new RoleNode(ActionGroup.CONFIGURE_ENGINE, getConstants().allowToGetOrSetSystemConfigurationRoleTreeTooltip()) })); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java index 93876c3..a53d7c9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/events/AlertListModel.java @@ -2,6 +2,9 @@ import java.util.ArrayList; +import org.ovirt.engine.core.common.action.RemoveAuditLogByIdParameters; +import org.ovirt.engine.core.common.action.VdcActionParametersBase; +import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.AuditLog; import org.ovirt.engine.core.common.interfaces.SearchType; import org.ovirt.engine.core.common.queries.SearchParameters; @@ -10,16 +13,51 @@ import org.ovirt.engine.ui.frontend.AsyncQuery; import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; @SuppressWarnings("unused") public class AlertListModel extends SearchableListModel { + private UICommand dismissCommand; + + public UICommand getDismissCommand() { + return dismissCommand; + } + + public void setDismissCommand(UICommand value) { + dismissCommand = value; + } + + private UICommand clearAllCommand; + + public UICommand getClearAllCommand() { + return clearAllCommand; + } + + public void setClearAllCommand(UICommand value) { + clearAllCommand = value; + } + public AlertListModel() { setTitle(ConstantsManager.getInstance().getConstants().alertsTitle()); setIsTimerDisabled(false); + setDismissCommand(new UICommand("Dismiss Alert", this)); //$NON-NLS-1$ + setClearAllCommand(new UICommand("Clear All", this)); //$NON-NLS-1$ + } + + @Override + public void executeCommand(UICommand command) { + if (command == getDismissCommand()) + { + dismissAlert(); + } + else if (command == getClearAllCommand()) + { + clearAllDismissedAlerts(); + } } @Override @@ -46,6 +84,17 @@ Frontend.getInstance().runQuery(VdcQueryType.Search, searchParameters, _asyncQuery); } + public void dismissAlert() { + AuditLog auditLog = (AuditLog) getSelectedItem(); + RemoveAuditLogByIdParameters params = new RemoveAuditLogByIdParameters(auditLog.getaudit_log_id()); + Frontend.getInstance().runAction(VdcActionType.RemoveAuditLogById, params); + } + + public void clearAllDismissedAlerts() { + VdcActionParametersBase params = new VdcActionParametersBase(); + Frontend.getInstance().runAction(VdcActionType.ClearAllDismissedAuditLogs, params); + } + @Override protected String getListName() { return "AlertListModel"; //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 121babc..89a9047 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -1107,6 +1107,9 @@ @DefaultStringValue("Allow to manage Event Notifications") String allowToManageEventNotifications(); + @DefaultStringValue("Allow to manage Audit Logs") + String allowToManageAuditLogs(); + @DefaultStringValue("Allow to define/configure roles in the System") String allowToDefineConfigureRolesInTheSystemRoleTreeTooltip(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 7fc910f..e2487b0 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -807,6 +807,7 @@ CANNOT_REMOVE_STORAGE_DOMAIN_INVALID_HOST_ID=Can not Remove Storage Domain - the underlying Host ID is invalid. ERROR_CANNOT_DEACTIVATE_MASTER_WITH_LOCKED_DOMAINS=You are trying to deactivate a Master storage domain while there are locked domains in the Data Center. Please wait for the operations on those domains to finish first. TAGS_CANNOT_REMOVE_TAG_NOT_EXIST=Cannot remove tag. Tag does not exist. +AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST=Cannot remove audit log. Audit Log does not exist. VAR__TYPE__VM__CLUSTER=$type VM Cluster VDS_FENCE_OPERATION_FAILED=Cannot ${action} ${type}. Fence operation failed. VM_CANNOT_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO=Cannot ${action} without active ISO domain. diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index 87a3e6f..28dcae2 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -2346,6 +2346,12 @@ @DefaultStringValue("Last Task:") String lastTaskEventFooter(); + @DefaultStringValue("Clear All") + String clearAllDismissedAlerts(); + + @DefaultStringValue("Dismiss Alert") + String dismissAlert(); + // Network popup // Header diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java index f9cec6a..34b4beb 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/footer/AlertsEventsFooterView.java @@ -1,16 +1,22 @@ package org.ovirt.engine.ui.webadmin.widget.footer; import java.util.Date; +import java.util.List; +import com.google.gwt.user.cellview.client.Column; +import com.google.gwt.view.client.SelectionChangeEvent; import org.ovirt.engine.core.common.businessentities.AuditLog; import org.ovirt.engine.core.common.job.Job; import org.ovirt.engine.ui.common.system.ClientStorage; import org.ovirt.engine.ui.common.uicommon.model.SearchableTabModelProvider; +import org.ovirt.engine.ui.common.widget.action.CommandLocation; import org.ovirt.engine.ui.common.widget.table.SimpleActionTable; import org.ovirt.engine.ui.common.widget.table.column.AuditLogSeverityColumn; import org.ovirt.engine.ui.common.widget.table.column.FullDateTimeColumn; +import org.ovirt.engine.ui.common.widget.table.column.ImageButtonCell; import org.ovirt.engine.ui.common.widget.table.column.ImageResourceColumn; import org.ovirt.engine.ui.common.widget.table.column.TextColumnWithTooltip; +import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.webadmin.ApplicationConstants; import org.ovirt.engine.ui.webadmin.ApplicationResources; @@ -24,6 +30,7 @@ import org.ovirt.engine.ui.webadmin.uicommon.model.TaskFirstRowModelProvider; import org.ovirt.engine.ui.webadmin.uicommon.model.TaskModelProvider; import org.ovirt.engine.ui.webadmin.uicommon.model.TaskModelProvider.TaskHandler; +import org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition; import org.ovirt.engine.ui.webadmin.widget.table.column.TaskStatusColumn; import com.google.gwt.core.client.GWT; @@ -131,7 +138,7 @@ alertsTable = createActionTable(alertModelProvider); alertsTable.setBarStyle(style.barStyle()); - initTable(alertsTable); + initAlertTable(alertsTable, alertModelProvider); _alertsTable = createActionTable(alertFirstRowModelProvider); _alertsTable.setBarStyle(style.barStyle()); @@ -374,6 +381,54 @@ table.addColumn(messageColumn, constants.messageEvent()); } + void initAlertTable(final SimpleActionTable<AuditLog> table, final AlertModelProvider alertModelProvider) { + table.addColumn(new AuditLogSeverityColumn(), constants.empty(), "30px"); //$NON-NLS-1$ + + TextColumnWithTooltip<AuditLog> logTimeColumn = new FullDateTimeColumn<AuditLog>() { + @Override + protected Date getRawValue(AuditLog object) { + return object.getlog_time(); + } + }; + table.addColumn(logTimeColumn, constants.timeEvent(), "160px"); //$NON-NLS-1$ + + table.addColumn(new DismissColumn(alertModelProvider), constants.empty(), "30px"); //$NON-NLS-1$ + + TextColumnWithTooltip<AuditLog> messageColumn = new TextColumnWithTooltip<AuditLog>() { + @Override + public String getValue(AuditLog object) { + return object.getmessage(); + } + }; + table.addColumn(messageColumn, constants.messageEvent()); + + + table.getSelectionModel().setMultiSelectEnabled(false); + + table.addActionButton(new WebAdminButtonDefinition<AuditLog>(constants.dismissAlert(), CommandLocation.OnlyFromContext) { + @Override + protected UICommand resolveCommand() { + return alertModelProvider.getModel().getDismissCommand(); + } + }); + + table.addActionButton(new WebAdminButtonDefinition<AuditLog>(constants.clearAllDismissedAlerts(), CommandLocation.OnlyFromContext) { + @Override + protected UICommand resolveCommand() { + return alertModelProvider.getModel().getClearAllCommand(); + } + }); + + table.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() { + @Override + public void onSelectionChange(SelectionChangeEvent event) { + List<AuditLog> selectedItems = table.getSelectionModel().getSelectedList(); + AuditLog selectedItem = selectedItems != null && selectedItems.size() > 0 ? selectedItems.get(0) : null; + alertModelProvider.getModel().setSelectedItem(selectedItem); + } + }); + } + void initTaskTable(SimpleActionTable<Job> taskTable) { ImageResourceColumn<Job> taskStatusColumn = new ImageResourceColumn<Job>() { @Override @@ -438,4 +493,38 @@ public void updateTree() { tasksTree.updateTree(taskModelProvider.getModel()); } + + class DismissColumn extends Column<AuditLog, AuditLog> { + + DismissColumn(AlertModelProvider alertModelProvider) { + super(new DismissAuditLogImageButtonCell(alertModelProvider)); + } + + @Override + public AuditLog getValue(AuditLog object) { + return object; + } + } + + class DismissAuditLogImageButtonCell extends ImageButtonCell<AuditLog> { + + AlertModelProvider alertModelProvider; + + public DismissAuditLogImageButtonCell(AlertModelProvider alertModelProvider) { + super(resources.dialogIconClose()); + this.alertModelProvider = alertModelProvider; + } + + @Override + protected String getTitle(AuditLog value) { + return constants.dismissAlert(); + } + + @Override + protected UICommand resolveCommand(AuditLog value) { + alertModelProvider.getModel().setSelectedItem(value); + return alertModelProvider.getModel().getDismissCommand(); + } + } + } diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 85ae876..2e3d91c 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -829,6 +829,7 @@ CANNOT_REMOVE_STORAGE_DOMAIN_INVALID_HOST_ID=Can not Remove Storage Domain - the underlying Host ID is invalid. ERROR_CANNOT_DEACTIVATE_MASTER_WITH_LOCKED_DOMAINS=You are trying to deactivate a Master storage domain while there are locked domains in the Data Center. Please wait for the operations on those domains to finish first. TAGS_CANNOT_REMOVE_TAG_NOT_EXIST=Cannot remove tag. Tag does not exist. +AUDIT_LOG_CANNOT_REMOVE_AUDIT_LOG_NOT_EXIST=Cannot remove audit log. Audit Log does not exist. VAR__TYPE__VM__CLUSTER=$type VM Cluster VDS_FENCE_OPERATION_FAILED=Cannot ${action} ${type}. Fence operation failed. VM_CANNOT_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO=Cannot ${action} without active ISO domain. diff --git a/packaging/dbscripts/audit_log_sp.sql b/packaging/dbscripts/audit_log_sp.sql index d372ef4..714c053 100644 --- a/packaging/dbscripts/audit_log_sp.sql +++ b/packaging/dbscripts/audit_log_sp.sql @@ -117,6 +117,14 @@ END; $procedure$ LANGUAGE plpgsql; +Create or replace FUNCTION ClearAllDismissedAuditLogs() +RETURNS VOID + AS $procedure$ +BEGIN + UPDATE audit_log SET deleted = false; +END; $procedure$ +LANGUAGE plpgsql; + -- Returns the events for which the user has direct permissions on -- If the user has permissions only on a VM, the user will see only events for this VM -- If the user has permissions on a cluster, he will see events from the cluster, the hosts and the VMS in the cluster diff --git a/packaging/dbscripts/upgrade/03_05_0290_add_audit_log_operation_action_group_and_roles.sql b/packaging/dbscripts/upgrade/03_05_0290_add_audit_log_operation_action_group_and_roles.sql new file mode 100644 index 0000000..6598a2d --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_0290_add_audit_log_operation_action_group_and_roles.sql @@ -0,0 +1,33 @@ +CREATE OR REPLACE FUNCTION __temp_add_audit_log_operation_action_groups() + RETURNS void AS +$BODY$ + DECLARE + v_roles_to_filter_out uuid[]; + v_AUDIT_LOG_MANAGER_ROLE_ID uuid; +BEGIN + v_AUDIT_LOG_MANAGER_ROLE_ID := 'DEF00011-0000-0000-0000-DEF000000016'; + + -- We only add these action groups to ADMIN roles that have an action group that isn't the login permissions one + v_roles_to_filter_out := array(select id from roles where role_type = 2 or (exists (select * from roles_groups where role_id = id) and not exists (select * from roles_groups where role_id = id and action_group_id != 1300))); + + -- Adding the TAG_MANAGEMENT action group + perform fn_db_grant_action_group_to_all_roles_filter(1304, v_roles_to_filter_out); + + -- Adding the TagManager role + DELETE FROM roles_groups WHERE role_id = v_AUDIT_LOG_MANAGER_ROLE_ID; + + INSERT INTO roles(id, name, description, is_readonly, role_type, allows_viewing_children, app_mode) SELECT v_AUDIT_LOG_MANAGER_ROLE_ID, 'AuditLogManager', 'Audit Log Manager', true, 1, false, 255 + WHERE NOT EXISTS (SELECT id + FROM roles + WHERE id = v_AUDIT_LOG_MANAGER_ROLE_ID); + + INSERT INTO roles_groups values(v_AUDIT_LOG_MANAGER_ROLE_ID, 1304); + INSERT INTO roles_groups values(v_AUDIT_LOG_MANAGER_ROLE_ID, 1300); + +END; $BODY$ + +LANGUAGE plpgsql; + +select __temp_add_audit_log_operation_action_groups(); +drop function __temp_add_audit_log_operation_action_groups(); + -- To view, visit http://gerrit.ovirt.org/26722 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3873226b64049170743d4bf0add531d0fda2a0cb Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
