Search in sources :

Example 1 with EditableVmTemplateField

use of org.ovirt.engine.core.common.businessentities.EditableVmTemplateField in project ovirt-engine by oVirt.

the class VmTemplateHandler method init.

/**
 * Initialize list containers, for identity and permission check. The initialization should be executed
 * before calling ObjectIdentityChecker.
 *
 * @see Backend#initHandlers()
 */
@PostConstruct
public void init() {
    final Class<?>[] inspectedClassNames = new Class<?>[] { VmBase.class, VmTemplate.class };
    updateVmTemplate = new ObjectIdentityChecker(VmTemplateHandler.class);
    for (Pair<EditableVmTemplateField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmTemplateField.class, inspectedClassNames)) {
        String fieldName = pair.getSecond().getName();
        updateVmTemplate.addPermittedFields(fieldName);
    }
    for (Pair<EditableVmField, Field> pair : BaseHandler.extractAnnotatedFields(EditableVmField.class, inspectedClassNames)) {
        EditableVmField annotation = pair.getFirst();
        List<VMStatus> statusList = Arrays.asList(annotation.onStatuses());
        String fieldName = pair.getSecond().getName();
        if (statusList.isEmpty()) {
            updateVmTemplate.addPermittedFields(fieldName);
        }
    }
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) EditableVmTemplateField(org.ovirt.engine.core.common.businessentities.EditableVmTemplateField) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) Field(java.lang.reflect.Field) EditableVmTemplateField(org.ovirt.engine.core.common.businessentities.EditableVmTemplateField) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) ObjectIdentityChecker(org.ovirt.engine.core.utils.ObjectIdentityChecker) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Field (java.lang.reflect.Field)1 PostConstruct (javax.annotation.PostConstruct)1 EditableVmField (org.ovirt.engine.core.common.businessentities.EditableVmField)1 EditableVmTemplateField (org.ovirt.engine.core.common.businessentities.EditableVmTemplateField)1 VMStatus (org.ovirt.engine.core.common.businessentities.VMStatus)1 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1 ObjectIdentityChecker (org.ovirt.engine.core.utils.ObjectIdentityChecker)1