Eli Mesika has uploaded a new change for review.

Change subject: [WIP] core: Adding AddExternalJobCommand command
......................................................................

[WIP] core: Adding AddExternalJobCommand command

Change-Id: Id1b95a094dc586e6ebbdacd44e0a034e91604386
Signed-off-by: Eli Mesika <emes...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=872719
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalJobCommand.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/AddExternalJobParameters.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
5 files changed, 102 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/15226/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalJobCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalJobCommand.java
new file mode 100644
index 0000000..ea91562
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddExternalJobCommand.java
@@ -0,0 +1,53 @@
+package org.ovirt.engine.core.bll;
+
+import java.util.List;
+
+import org.ovirt.engine.core.bll.job.ExecutionHandler;
+import org.ovirt.engine.core.bll.job.JobRepositoryFactory;
+import org.ovirt.engine.core.bll.utils.PermissionSubject;
+import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.action.AddExternalJobParameters;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.job.Job;
+import org.ovirt.engine.core.compat.Guid;
+import org.ovirt.engine.core.dal.dbbroker.DbFacade;
+
+
+public class AddExternalJobCommand<T extends AddExternalJobParameters> extends 
CommandBase<T> {
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    public AddExternalJobCommand(T parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void executeCommand() {
+        Job job = ExecutionHandler.createJob(VdcActionType.AddExternalJob, 
this);
+        job.setDescription(getParameters().getDescription());
+        job.setAutoCleared(getParameters().isAutoCleared());
+        Guid id = job.getId();
+        job.setExternal(true);
+        JobRepositoryFactory.getJobRepository().saveJob(job);
+        if (DbFacade.getInstance().getJobDao().get(id) != null) {
+            setActionReturnValue(id);
+            setSucceeded(true);
+        }
+        else {
+            setSucceeded(false);
+        }
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        return getSucceeded() ? AuditLogType.USER_ADD_EXTERNAL_JOB : 
AuditLogType.USER_ADD_EXTERNAL_JOB_FAILED;
+    }
+
+    @Override
+    public List<PermissionSubject> getPermissionCheckSubjects() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}
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 33bbe45..9d62931 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
@@ -726,7 +726,10 @@
 
     //watchdog
     WATCHDOG_EVENT(9901),
-    ;
+
+    // External tasks
+    USER_ADD_EXTERNAL_JOB(10000),
+    USER_ADD_EXTERNAL_JOB_FAILED(10001);
 
     private int intValue;
     // indicates time interval in seconds on which identical events from same 
instance are supressed.
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalJobParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalJobParameters.java
new file mode 100644
index 0000000..5229414
--- /dev/null
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/AddExternalJobParameters.java
@@ -0,0 +1,40 @@
+package org.ovirt.engine.core.common.action;
+
+
+public class AddExternalJobParameters extends VdcActionParametersBase{
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+
+    private String description;
+    private boolean isAutoCleared = true;
+
+    public AddExternalJobParameters(String description, boolean isAutoCleared) 
{
+        super();
+        this.description = description;
+        this.isAutoCleared = isAutoCleared;
+    }
+
+    public AddExternalJobParameters(String description) {
+        super();
+        this.description = description;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public boolean isAutoCleared() {
+        return isAutoCleared;
+    }
+
+    public void setAutoCleared(boolean isAutoCleared) {
+        this.isAutoCleared = isAutoCleared;
+    }
+}
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index 1a2041d..6847e15 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -742,6 +742,9 @@
 
     private static void initCommonSeverities() {
         severities.put(AuditLogType.ENTITY_RENAMED, AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.USER_ADD_EXTERNAL_JOB, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.USER_ADD_EXTERNAL_JOB_FAILED, 
AuditLogSeverity.ERROR);
+
     }
     private static void initDwhSeverities() {
         severities.put(AuditLogType.DWH_STOPPED, AuditLogSeverity.NORMAL);
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 02e85aa..86653c1 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -549,6 +549,8 @@
 USER_ACCOUNT_DISABLED_OR_LOCKED=User ${UserName} cannot login, as it got 
disabled or locked. Please contact the system administrator.
 USER_ACCOUNT_PASSWORD_EXPIRED=User ${UserName} cannot login, as the user 
account password has expired. Please contact the system administrator.
 ENTITY_RENAMED=${EntityType} ${OldEntityName} was renamed from 
${OldEntityName} to ${NewEntityName}.
+USER_ADD_EXTERNAL_JOB=New external Job ${description} was added by user 
${UserName}
+USER_ADD_EXTERNAL_JOB_FAILED=Failed to add new external Job ${description}
 STORAGE_DOMAIN_TASKS_ERROR=Storage Domain ${StorageDomainName} is down while 
there are tasks running on it. These tasks may fail.
 IMPORTEXPORT_IMPORT_VM_INVALID_INTERFACES=While importing VM ${VmName}, the 
Network/s ${Networks} were found to be Non-VM Networks or do not exist in 
Cluster. Network Name was not set in the Interface/s ${Interfaces}.
 IMPORTEXPORT_IMPORT_TEMPLATE_INVALID_INTERFACES=While importing Template 
${VmTemplateName}, the Network/s ${Networks} were found to be Non-VM Networks 
or do not exist in Cluster. Network Name was not set in the Interface/s 
${Interfaces}.


--
To view, visit http://gerrit.ovirt.org/15226
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1b95a094dc586e6ebbdacd44e0a034e91604386
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <emes...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to