Eli Mesika has uploaded a new change for review.

Change subject: [WIP] core: RFE-Adding External Tasks Support
......................................................................

[WIP] core: RFE-Adding External Tasks Support

Enable plug-in to inject tasks to the engine application using the REST
API, change their statuses and track them from the UI.
A task may have other nesting sub-tasks under it.

more info :
http://www.ovirt.org/Features/ExternalTasks
http://www.ovirt.org/Features/Design/DetailedExternalTasks

This series of patches includes only backend changes, API changes will
follow.

This patch fix NPE problems

Change-Id: I622e2a92b0433edbbf45fc4ed4f352cb2d09872d
Signed-off-by: Eli Mesika <emes...@redhat.com>
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=872719
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
2 files changed, 40 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/15219/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
index f8aa861..7562a89 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
@@ -1726,19 +1726,21 @@
         if (jobProperties == null) {
             jobProperties = new HashMap<String, String>();
             List<PermissionSubject> subjects = getPermissionCheckSubjects();
-            if (!subjects.isEmpty()) {
-                VdcObjectType entityType;
-                Guid entityId;
-                String value;
-                for (PermissionSubject permSubject : subjects) {
-                    entityType = permSubject.getObjectType();
-                    entityId = permSubject.getObjectId();
-                    if (entityType != null && entityId != null) {
-                        value = 
DbFacade.getInstance().getEntityNameByIdAndType(entityId, entityType);
-                        if (value == null) {
-                            value = entityId.toString();
+            if (subjects != null) {
+                if (!subjects.isEmpty()) {
+                    VdcObjectType entityType;
+                    Guid entityId;
+                    String value;
+                    for (PermissionSubject permSubject : subjects) {
+                        entityType = permSubject.getObjectType();
+                        entityId = permSubject.getObjectId();
+                        if (entityType != null && entityId != null) {
+                            value = 
DbFacade.getInstance().getEntityNameByIdAndType(entityId, entityType);
+                            if (value == null) {
+                                value = entityId.toString();
+                            }
+                            jobProperties.put(entityType.name().toLowerCase(), 
value);
                         }
-                        jobProperties.put(entityType.name().toLowerCase(), 
value);
                     }
                 }
             }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
index 756a047..794fba3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/job/ExecutionHandler.java
@@ -76,9 +76,11 @@
 
     private static Map<Guid, VdcObjectType> 
getSubjectEntities(List<PermissionSubject> permSubjectList) {
         Map<Guid, VdcObjectType> entities = new HashMap<Guid, VdcObjectType>();
-        for (PermissionSubject permSubj : permSubjectList) {
-            if (permSubj.getObjectId() != null && permSubj.getObjectType() != 
null) {
-                entities.put(permSubj.getObjectId(), permSubj.getObjectType());
+        if (permSubjectList != null) {
+            for (PermissionSubject permSubj : permSubjectList) {
+                if (permSubj.getObjectId() != null && permSubj.getObjectType() 
!= null) {
+                    entities.put(permSubj.getObjectId(), 
permSubj.getObjectType());
+                }
             }
         }
         return entities;
@@ -238,6 +240,26 @@
      * @return The created instance of the step or {@code null}.
      */
     public static Step addStep(ExecutionContext context, StepEnum stepName, 
String description) {
+        return addStep(context, stepName, description, false);
+
+    }
+
+    /**
+     * Adds a {@link Step} entity by the provided context. A {@link Step} will 
not be created if
+     * {@code ExecutionContext.isMonitored()} returns false.
+     *
+     * @param context
+     *            The context of the execution which defines visibility and 
execution method.
+     * @param stepName
+     *            The name of the step.
+     * @param description
+     *            A presentation name for the step. If not provided, the 
presentation name is resolved by the
+     *            {@code stepName}.
+     * @param isExternal
+     *        Indicates if the step is invoked by a plug-in
+     * @return
+     */
+    public static Step addStep(ExecutionContext context, StepEnum stepName, 
String description, boolean isExternal) {
         if (context == null) {
             return null;
         }
@@ -271,6 +293,7 @@
                 log.error(e);
             }
         }
+        step.setExternal(isExternal);
         return step;
     }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I622e2a92b0433edbbf45fc4ed4f352cb2d09872d
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