package org.ovirt.engine.api.restapi.resource;

import org.ovirt.engine.api.model.Hook;
import org.ovirt.engine.api.model.Hooks;
import org.ovirt.engine.api.resource.HostHookResource;

public class BackendHostHookResource extends AbstractBackendSubResource<Hook, Object> implements HostHookResource {

    private BackendHostHooksResource parent;

    public BackendHostHookResource(String id, BackendHostHooksResource parent) {
        super(id, Hook.class, Object.class, new String[0]);
        this.parent = parent;
    }

    @Override
    public Hook get() {
        Hooks hooks = parent.list();
        return getHook(hooks);
    }

    public Hook getHook(Hooks hooks) {
        for (Hook hook : hooks.getHooks()) {
            if (hook.getId().equals(guid)) {
                return hook;
            }
        }
        return notFound();
    }

    public BackendHostHooksResource getParent() {
        return parent;
    }

    public void setParent(BackendHostHooksResource parent) {
        this.parent = parent;
    }

    @Override
    protected Hook doPopulate(Hook model, Object entity) {
        return model;
    }
}

@@ -667,24 +667,65 @@
 ks hooks) %7B%0A
+        String hookId = guid.toString();%0A
         for 
@@ -793,19 +793,21 @@
 .equals(
-gui
+hookI
 d)) %7B%0A  

fix incorrect compare of different object types