Search in sources :

Example 1 with ObjectIdentityChecker

use of org.ovirt.engine.core.utils.ObjectIdentityChecker in project ovirt-engine by oVirt.

the class VmHandler 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() {
    Class<?>[] inspectedClassNames = new Class<?>[] { VmBase.class, VM.class, VmStatic.class, VmDynamic.class, VmManagementParametersBase.class };
    updateVmsStatic = new ObjectIdentityChecker(VmHandler.class, Arrays.asList(inspectedClassNames));
    for (Pair<EditableDeviceOnVmStatusField, Field> pair : BaseHandler.extractAnnotatedFields(EditableDeviceOnVmStatusField.class, inspectedClassNames)) {
        updateVmsStatic.addField(Arrays.asList(pair.getFirst().statuses()), pair.getSecond().getName());
    }
    for (Pair<TransientField, Field> pair : BaseHandler.extractAnnotatedFields(TransientField.class, inspectedClassNames)) {
        updateVmsStatic.addTransientFields(pair.getSecond().getName());
    }
    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()) {
            updateVmsStatic.addPermittedFields(fieldName);
        } else {
            updateVmsStatic.addField(statusList, fieldName);
            if (!annotation.hotSettableOnStatus().getStates().isEmpty()) {
                updateVmsStatic.addHotsetField(fieldName, annotation.hotSettableOnStatus().getStates());
            }
        }
        if (annotation.onHostedEngine()) {
            updateVmsStatic.addHostedEngineFields(fieldName);
        }
    }
}
Also used : VmBase(org.ovirt.engine.core.common.businessentities.VmBase) EditableDeviceOnVmStatusField(org.ovirt.engine.core.common.businessentities.EditableDeviceOnVmStatusField) Field(java.lang.reflect.Field) TransientField(org.ovirt.engine.core.common.businessentities.TransientField) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) VmDynamic(org.ovirt.engine.core.common.businessentities.VmDynamic) TransientField(org.ovirt.engine.core.common.businessentities.TransientField) ObjectIdentityChecker(org.ovirt.engine.core.utils.ObjectIdentityChecker) VM(org.ovirt.engine.core.common.businessentities.VM) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) VmManagementParametersBase(org.ovirt.engine.core.common.action.VmManagementParametersBase) EditableDeviceOnVmStatusField(org.ovirt.engine.core.common.businessentities.EditableDeviceOnVmStatusField) EditableVmField(org.ovirt.engine.core.common.businessentities.EditableVmField) VMStatus(org.ovirt.engine.core.common.businessentities.VMStatus) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ObjectIdentityChecker

use of org.ovirt.engine.core.utils.ObjectIdentityChecker 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)

Example 3 with ObjectIdentityChecker

use of org.ovirt.engine.core.utils.ObjectIdentityChecker in project ovirt-engine by oVirt.

the class VdsHandler 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() {
    Class<?>[] inspectedClasses = new Class<?>[] { VDS.class, VdsStatic.class, VdsDynamic.class };
    updateVdsStatic = new ObjectIdentityChecker(VdsHandler.class, Arrays.asList(inspectedClasses));
    updateVdsStatic.setContainer(this);
    for (Pair<EditableVdsField, Field> pair : extractAnnotatedFields(EditableVdsField.class, inspectedClasses)) {
        List<VDSStatus> statusList = Arrays.asList(pair.getFirst().onStatuses());
        String fieldName = pair.getSecond().getName();
        if (statusList.isEmpty()) {
            updateVdsStatic.addPermittedFields(fieldName);
        } else {
            updateVdsStatic.addField(statusList, fieldName);
        }
    }
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) VDS(org.ovirt.engine.core.common.businessentities.VDS) EditableVdsField(org.ovirt.engine.core.common.businessentities.EditableVdsField) Field(java.lang.reflect.Field) EditableVdsField(org.ovirt.engine.core.common.businessentities.EditableVdsField) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) VdsDynamic(org.ovirt.engine.core.common.businessentities.VdsDynamic) ObjectIdentityChecker(org.ovirt.engine.core.utils.ObjectIdentityChecker) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Field (java.lang.reflect.Field)3 PostConstruct (javax.annotation.PostConstruct)3 ObjectIdentityChecker (org.ovirt.engine.core.utils.ObjectIdentityChecker)3 EditableVmField (org.ovirt.engine.core.common.businessentities.EditableVmField)2 VMStatus (org.ovirt.engine.core.common.businessentities.VMStatus)2 VmBase (org.ovirt.engine.core.common.businessentities.VmBase)2 VmManagementParametersBase (org.ovirt.engine.core.common.action.VmManagementParametersBase)1 EditableDeviceOnVmStatusField (org.ovirt.engine.core.common.businessentities.EditableDeviceOnVmStatusField)1 EditableVdsField (org.ovirt.engine.core.common.businessentities.EditableVdsField)1 EditableVmTemplateField (org.ovirt.engine.core.common.businessentities.EditableVmTemplateField)1 TransientField (org.ovirt.engine.core.common.businessentities.TransientField)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VDSStatus (org.ovirt.engine.core.common.businessentities.VDSStatus)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VdsDynamic (org.ovirt.engine.core.common.businessentities.VdsDynamic)1 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)1 VmDynamic (org.ovirt.engine.core.common.businessentities.VmDynamic)1 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)1 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)1